react-better-html 1.1.150 → 1.1.152
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 +6 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +52 -36
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +65 -49
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -2951,13 +2951,17 @@ function useForm(options) {
|
|
|
2951
2951
|
const focusField = useCallback4((field) => {
|
|
2952
2952
|
inputFieldRefs.current[field]?.focus();
|
|
2953
2953
|
}, []);
|
|
2954
|
+
const validateForm = useCallback4(() => {
|
|
2955
|
+
const validationErrors = validate?.(values) || {};
|
|
2956
|
+
setErrors(validationErrors);
|
|
2957
|
+
return validationErrors;
|
|
2958
|
+
}, [validate, values]);
|
|
2954
2959
|
const onSubmitFunction = useCallback4(
|
|
2955
2960
|
async (event) => {
|
|
2956
2961
|
event.preventDefault();
|
|
2957
2962
|
setIsSubmitting.setTrue();
|
|
2958
2963
|
try {
|
|
2959
|
-
const validationErrors =
|
|
2960
|
-
setErrors(validationErrors);
|
|
2964
|
+
const validationErrors = validateForm();
|
|
2961
2965
|
if (Object.keys(validationErrors).length === 0) {
|
|
2962
2966
|
await onSubmit?.(values);
|
|
2963
2967
|
} else {
|
|
@@ -2968,7 +2972,7 @@ function useForm(options) {
|
|
|
2968
2972
|
setIsSubmitting.setFalse();
|
|
2969
2973
|
}
|
|
2970
2974
|
},
|
|
2971
|
-
[values,
|
|
2975
|
+
[values, validateForm, onSubmit, focusField]
|
|
2972
2976
|
);
|
|
2973
2977
|
const reset = useCallback4(() => {
|
|
2974
2978
|
setValues(defaultValues);
|
|
@@ -2999,6 +3003,7 @@ function useForm(options) {
|
|
|
2999
3003
|
getRadioButtonProps,
|
|
3000
3004
|
getSwitchProps,
|
|
3001
3005
|
focusField,
|
|
3006
|
+
validate: validateForm,
|
|
3002
3007
|
onSubmit: onSubmitFunction,
|
|
3003
3008
|
reset,
|
|
3004
3009
|
requiredFields,
|
|
@@ -3611,7 +3616,7 @@ var PageHeaderComponent = forwardRef8(function PageHeader({
|
|
|
3611
3616
|
{
|
|
3612
3617
|
alignItems: "center",
|
|
3613
3618
|
gap: theme2.styles.space,
|
|
3614
|
-
marginBottom: marginBottom
|
|
3619
|
+
marginBottom: marginBottom || theme2.styles.space * 2,
|
|
3615
3620
|
ref,
|
|
3616
3621
|
children: [
|
|
3617
3622
|
imageUrl && /* @__PURE__ */ jsx13(Image_default.profileImage, { src: imageUrl, size: imageSize ?? (mediaQuery.size600 ? 46 : 60) }),
|
|
@@ -5396,8 +5401,8 @@ function Label({ text, required, isError, color, htmlFor }) {
|
|
|
5396
5401
|
var Label_default = memo15(Label);
|
|
5397
5402
|
|
|
5398
5403
|
// src/components/Dropdown.tsx
|
|
5399
|
-
import { forwardRef as forwardRef10, memo as memo16, useCallback as useCallback7, useEffect as useEffect6, useMemo as useMemo4, useRef as useRef4, useState as useState5 } from "react";
|
|
5400
|
-
import { Fragment as
|
|
5404
|
+
import { forwardRef as forwardRef10, Fragment as Fragment3, memo as memo16, useCallback as useCallback7, useEffect as useEffect6, useMemo as useMemo4, useRef as useRef4, useState as useState5 } from "react";
|
|
5405
|
+
import { Fragment as Fragment4, jsx as jsx15, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
5401
5406
|
var DropdownComponent = forwardRef10(function Dropdown({
|
|
5402
5407
|
label,
|
|
5403
5408
|
labelColor,
|
|
@@ -5422,6 +5427,7 @@ var DropdownComponent = forwardRef10(function Dropdown({
|
|
|
5422
5427
|
onChange,
|
|
5423
5428
|
onChangeSearch,
|
|
5424
5429
|
renderOption,
|
|
5430
|
+
renderOptionDivider,
|
|
5425
5431
|
id,
|
|
5426
5432
|
...props
|
|
5427
5433
|
}, ref) {
|
|
@@ -5523,31 +5529,41 @@ var DropdownComponent = forwardRef10(function Dropdown({
|
|
|
5523
5529
|
);
|
|
5524
5530
|
const selectedOption = useMemo4(() => options.find((option) => option.value === value), [options, value]);
|
|
5525
5531
|
const renderedOptions = useMemo4(
|
|
5526
|
-
() =>
|
|
5527
|
-
|
|
5528
|
-
|
|
5529
|
-
|
|
5530
|
-
|
|
5531
|
-
|
|
5532
|
-
{
|
|
5533
|
-
|
|
5534
|
-
|
|
5535
|
-
|
|
5536
|
-
|
|
5537
|
-
|
|
5538
|
-
|
|
5539
|
-
|
|
5540
|
-
|
|
5541
|
-
|
|
5542
|
-
|
|
5543
|
-
|
|
5544
|
-
|
|
5545
|
-
|
|
5546
|
-
|
|
5547
|
-
|
|
5548
|
-
|
|
5549
|
-
|
|
5550
|
-
|
|
5532
|
+
() => /* @__PURE__ */ jsxs10(Fragment4, { children: [
|
|
5533
|
+
renderOptionDivider ? renderOptionDivider(void 0, filteredOptions[0], -1, 0) : void 0,
|
|
5534
|
+
filteredOptions.map((option, index) => {
|
|
5535
|
+
const isSelected = option.value === value;
|
|
5536
|
+
const isDisabled = option.disabled;
|
|
5537
|
+
const isFocused2 = index === focusedOptionIndex;
|
|
5538
|
+
return /* @__PURE__ */ jsxs10(Fragment3, { children: [
|
|
5539
|
+
/* @__PURE__ */ jsx15(
|
|
5540
|
+
Div_default,
|
|
5541
|
+
{
|
|
5542
|
+
color: isDisabled ? theme2.colors.textSecondary + "80" : isSelected ? theme2.colors.base : theme2.colors.textPrimary,
|
|
5543
|
+
backgroundColor: isSelected ? theme2.colors.primary : theme2.colors.backgroundContent,
|
|
5544
|
+
filter: isFocused2 ? isDisabled ? "brightness(0.95)" : "brightness(0.9)" : void 0,
|
|
5545
|
+
filterHover: focusedOptionIndex === void 0 && !isDisabled ? "brightness(0.9)" : void 0,
|
|
5546
|
+
cursor: isDisabled ? "not-allowed" : "pointer",
|
|
5547
|
+
padding: `${theme2.styles.space / 2}px ${theme2.styles.space + theme2.styles.gap}px`,
|
|
5548
|
+
value: option,
|
|
5549
|
+
onClickWithValue: onClickOption,
|
|
5550
|
+
onMouseMove: () => setFocusedOptionIndex(void 0),
|
|
5551
|
+
role: "option",
|
|
5552
|
+
"aria-selected": isSelected,
|
|
5553
|
+
"aria-disabled": isDisabled,
|
|
5554
|
+
children: renderOption ? renderOption(option, index, isSelected) : /* @__PURE__ */ jsx15(Text_default, { children: option.label })
|
|
5555
|
+
}
|
|
5556
|
+
),
|
|
5557
|
+
renderOptionDivider ? renderOptionDivider(
|
|
5558
|
+
option,
|
|
5559
|
+
filteredOptions[index + 1],
|
|
5560
|
+
index,
|
|
5561
|
+
filteredOptions[index + 1] ? index + 1 : -1
|
|
5562
|
+
) : void 0
|
|
5563
|
+
] }, JSON.stringify(option));
|
|
5564
|
+
})
|
|
5565
|
+
] }),
|
|
5566
|
+
[filteredOptions, value, focusedOptionIndex, theme2.colors, onClickOption, renderOption, renderOptionDivider]
|
|
5551
5567
|
);
|
|
5552
5568
|
useEffect6(() => {
|
|
5553
5569
|
if (isOpen) {
|
|
@@ -5631,7 +5647,7 @@ var DropdownComponent = forwardRef10(function Dropdown({
|
|
|
5631
5647
|
transition: theme2.styles.transition,
|
|
5632
5648
|
role: "listbox",
|
|
5633
5649
|
"aria-label": label,
|
|
5634
|
-
children: isLoadingDebouncedSearchQuery || debounceIsLoading ? /* @__PURE__ */ jsx15(Div_default, { padding: `${theme2.styles.space / 2}px ${theme2.styles.space + theme2.styles.gap}px`, children: /* @__PURE__ */ jsx15(Loader_default.text, {}) }) : filteredOptions.length ? /* @__PURE__ */ jsx15(
|
|
5650
|
+
children: isLoadingDebouncedSearchQuery || debounceIsLoading ? /* @__PURE__ */ jsx15(Div_default, { padding: `${theme2.styles.space / 2}px ${theme2.styles.space + theme2.styles.gap}px`, children: /* @__PURE__ */ jsx15(Loader_default.text, {}) }) : filteredOptions.length ? /* @__PURE__ */ jsx15(Fragment4, { children: (withoutRenderingOptionsWhenClosed ? isOpen || isOpenLate : true) ? renderedOptions : void 0 }) : /* @__PURE__ */ jsx15(Div_default, { padding: `${theme2.styles.space / 2}px ${theme2.styles.space + theme2.styles.gap}px`, children: /* @__PURE__ */ jsx15(Text_default.unknown, { textAlign: "left", children: debounceMinimumSymbolsRequired !== void 0 && searchQuery.length < debounceMinimumSymbolsRequired ? `Enter at least ${debounceMinimumSymbolsRequired} characters` : "No options" }) })
|
|
5635
5651
|
}
|
|
5636
5652
|
),
|
|
5637
5653
|
role: "combobox",
|
|
@@ -6495,7 +6511,7 @@ InputFieldComponent.date = forwardRef11(function Date2({ minDate, maxDate, ...pr
|
|
|
6495
6511
|
}
|
|
6496
6512
|
);
|
|
6497
6513
|
});
|
|
6498
|
-
InputFieldComponent.dateTime = forwardRef11(function DateTime({ minDate, maxDate, ...props }, ref) {
|
|
6514
|
+
InputFieldComponent.dateTime = forwardRef11(function DateTime({ minDate, maxDate, defaultDateAfterTimePick, defaultTimeAfterDatePick = "00:00", ...props }, ref) {
|
|
6499
6515
|
const theme2 = useTheme();
|
|
6500
6516
|
const holderRef = useRef5(null);
|
|
6501
6517
|
const selectedHourRef = useRef5(null);
|
|
@@ -6504,31 +6520,31 @@ InputFieldComponent.dateTime = forwardRef11(function DateTime({ minDate, maxDate
|
|
|
6504
6520
|
const { internalValue, setInternalValue, inputFieldProps, insideInputFieldComponentProps, isOpen } = useComponentInputFieldDateProps(props, holderRef, isMobileIOS);
|
|
6505
6521
|
const onChange = useCallback9(
|
|
6506
6522
|
(date) => {
|
|
6507
|
-
const newValue = date ? `${date}T${internalValue?.toString().split("T")[1] ??
|
|
6523
|
+
const newValue = date ? `${date}T${internalValue?.toString().split("T")[1] ?? defaultTimeAfterDatePick}` : "";
|
|
6508
6524
|
inputFieldProps.onChangeValue?.(newValue);
|
|
6509
6525
|
setInternalValue(newValue);
|
|
6510
6526
|
},
|
|
6511
|
-
[internalValue, inputFieldProps.onChangeValue]
|
|
6527
|
+
[internalValue, defaultTimeAfterDatePick, inputFieldProps.onChangeValue]
|
|
6512
6528
|
);
|
|
6513
6529
|
const onClickHour = useCallback9(
|
|
6514
6530
|
(hour) => {
|
|
6515
6531
|
const newTime = `${hour.toString().padStart(2, "0")}:${internalValue?.toString().split(":")[1] || "00"}`;
|
|
6516
|
-
const today = `${(/* @__PURE__ */ new Date()).getFullYear()}-${((/* @__PURE__ */ new Date()).getMonth() + 1).toString().padStart(2, "0")}-${(/* @__PURE__ */ new Date()).getDate().toString().padStart(2, "0")}`;
|
|
6532
|
+
const today = defaultDateAfterTimePick ?? `${(/* @__PURE__ */ new Date()).getFullYear()}-${((/* @__PURE__ */ new Date()).getMonth() + 1).toString().padStart(2, "0")}-${(/* @__PURE__ */ new Date()).getDate().toString().padStart(2, "0")}`;
|
|
6517
6533
|
const newValue = `${(internalValue.trim() || today)?.toString().split("T")[0]}T${newTime}`;
|
|
6518
6534
|
inputFieldProps.onChangeValue?.(newValue);
|
|
6519
6535
|
setInternalValue(newValue);
|
|
6520
6536
|
},
|
|
6521
|
-
[internalValue, inputFieldProps.onChangeValue]
|
|
6537
|
+
[defaultDateAfterTimePick, internalValue, inputFieldProps.onChangeValue]
|
|
6522
6538
|
);
|
|
6523
6539
|
const onClickMinute = useCallback9(
|
|
6524
6540
|
(minute) => {
|
|
6525
6541
|
const newTime = `${internalValue?.toString().split("T")?.[1]?.split(":")[0] || "00"}:${minute.toString().padStart(2, "0")}`;
|
|
6526
|
-
const today = `${(/* @__PURE__ */ new Date()).getFullYear()}-${((/* @__PURE__ */ new Date()).getMonth() + 1).toString().padStart(2, "0")}-${(/* @__PURE__ */ new Date()).getDate().toString().padStart(2, "0")}`;
|
|
6542
|
+
const today = defaultDateAfterTimePick ?? `${(/* @__PURE__ */ new Date()).getFullYear()}-${((/* @__PURE__ */ new Date()).getMonth() + 1).toString().padStart(2, "0")}-${(/* @__PURE__ */ new Date()).getDate().toString().padStart(2, "0")}`;
|
|
6527
6543
|
const newValue = `${(internalValue.trim() || today)?.toString().split("T")[0]}T${newTime}`;
|
|
6528
6544
|
inputFieldProps.onChangeValue?.(newValue);
|
|
6529
6545
|
setInternalValue(newValue);
|
|
6530
6546
|
},
|
|
6531
|
-
[internalValue, inputFieldProps.onChangeValue]
|
|
6547
|
+
[defaultDateAfterTimePick, internalValue, inputFieldProps.onChangeValue]
|
|
6532
6548
|
);
|
|
6533
6549
|
useEffect8(() => {
|
|
6534
6550
|
if (isOpen && selectedHourRef.current)
|
|
@@ -7094,7 +7110,7 @@ var ToggleInput_default = {
|
|
|
7094
7110
|
};
|
|
7095
7111
|
|
|
7096
7112
|
// src/components/Form.tsx
|
|
7097
|
-
import { Children, forwardRef as forwardRef13, Fragment as
|
|
7113
|
+
import { Children, forwardRef as forwardRef13, Fragment as Fragment5, memo as memo19, useMemo as useMemo7 } from "react";
|
|
7098
7114
|
import { jsx as jsx19, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
7099
7115
|
var FormComponent = forwardRef13(function Form({
|
|
7100
7116
|
form,
|
|
@@ -7124,7 +7140,7 @@ var FormComponent = forwardRef13(function Form({
|
|
|
7124
7140
|
const SubmitButtonTag = isDestructive ? Button_default.destructive : Button_default;
|
|
7125
7141
|
const submitButtonIsDisabledFinal = submitButtonIsDisabled || submitButtonIsDisabledInternal;
|
|
7126
7142
|
return /* @__PURE__ */ jsx19(Div_default, { width: "100%", ...props, children: /* @__PURE__ */ jsxs14("form", { onSubmit: onSubmit ?? form?.onSubmit, ref, children: [
|
|
7127
|
-
gap !== void 0 || withDividers ? /* @__PURE__ */ jsx19(Div_default.column, { gap: gap ?? (withDividers ? theme2.styles.space : theme2.styles.gap), children: withDividers ? Children.toArray(children).map((child, index) => /* @__PURE__ */ jsxs14(
|
|
7143
|
+
gap !== void 0 || withDividers ? /* @__PURE__ */ jsx19(Div_default.column, { gap: gap ?? (withDividers ? theme2.styles.space : theme2.styles.gap), children: withDividers ? Children.toArray(children).map((child, index) => /* @__PURE__ */ jsxs14(Fragment5, { children: [
|
|
7128
7144
|
child,
|
|
7129
7145
|
index < Children.toArray(children).length - 1 && /* @__PURE__ */ jsx19(Divider_default.horizontal, {})
|
|
7130
7146
|
] }, index)) : children }) : children,
|
|
@@ -7348,10 +7364,10 @@ import {
|
|
|
7348
7364
|
useImperativeHandle as useImperativeHandle2,
|
|
7349
7365
|
useRef as useRef6,
|
|
7350
7366
|
useEffect as useEffect10,
|
|
7351
|
-
Fragment as
|
|
7367
|
+
Fragment as Fragment6
|
|
7352
7368
|
} from "react";
|
|
7353
7369
|
import styled12, { css as css2 } from "styled-components";
|
|
7354
|
-
import { Fragment as
|
|
7370
|
+
import { Fragment as Fragment7, jsx as jsx22, jsxs as jsxs17 } from "react/jsx-runtime";
|
|
7355
7371
|
var defaultImageWidth = 160;
|
|
7356
7372
|
var maximumVisiblePages = 11;
|
|
7357
7373
|
var TableStyledComponent = styled12.table.withConfig({
|
|
@@ -7567,7 +7583,7 @@ var TableComponent = forwardRef15(function Table({
|
|
|
7567
7583
|
return /* @__PURE__ */ jsx22(Text_default, { ...textProps, children: column.format?.(item, itemIndex) ?? String(value ?? "") });
|
|
7568
7584
|
}
|
|
7569
7585
|
case "element": {
|
|
7570
|
-
return column.render?.(item, itemIndex) ?? /* @__PURE__ */ jsx22(
|
|
7586
|
+
return column.render?.(item, itemIndex) ?? /* @__PURE__ */ jsx22(Fragment7, {});
|
|
7571
7587
|
}
|
|
7572
7588
|
case "image": {
|
|
7573
7589
|
const imageProps = (typeof column.getImageProps === "function" ? column.getImageProps?.(item, itemIndex) : column.getImageProps) ?? {};
|
|
@@ -7607,7 +7623,7 @@ var TableComponent = forwardRef15(function Table({
|
|
|
7607
7623
|
) });
|
|
7608
7624
|
}
|
|
7609
7625
|
default: {
|
|
7610
|
-
return /* @__PURE__ */ jsx22(
|
|
7626
|
+
return /* @__PURE__ */ jsx22(Fragment7, {});
|
|
7611
7627
|
}
|
|
7612
7628
|
}
|
|
7613
7629
|
},
|
|
@@ -7880,7 +7896,7 @@ var TableComponent = forwardRef15(function Table({
|
|
|
7880
7896
|
);
|
|
7881
7897
|
const withFooter = pageSize !== void 0 && pageCountInternal > 1;
|
|
7882
7898
|
const mobileFooterBreakingPoint = mediaQuery.size700 && pageCountInternal > maximumVisiblePages / 1.4;
|
|
7883
|
-
return /* @__PURE__ */ jsxs17(
|
|
7899
|
+
return /* @__PURE__ */ jsxs17(Fragment7, { children: [
|
|
7884
7900
|
/* @__PURE__ */ jsx22(
|
|
7885
7901
|
Div_default,
|
|
7886
7902
|
{
|
|
@@ -7938,7 +7954,7 @@ var TableComponent = forwardRef15(function Table({
|
|
|
7938
7954
|
},
|
|
7939
7955
|
column.type + column.label + index
|
|
7940
7956
|
)) }) }),
|
|
7941
|
-
/* @__PURE__ */ jsx22("tbody", { children: isLoading ? /* @__PURE__ */ jsx22("tr", { className: "withoutHover", children: /* @__PURE__ */ jsx22("td", { className: "noData", colSpan: columns.length, children: /* @__PURE__ */ jsx22(Loader_default.box, {}) }) }) : dataAfterPagination.length > 0 ? dataAfterPagination.map((item, rowIndex) => /* @__PURE__ */ jsxs17(
|
|
7957
|
+
/* @__PURE__ */ jsx22("tbody", { children: isLoading ? /* @__PURE__ */ jsx22("tr", { className: "withoutHover", children: /* @__PURE__ */ jsx22("td", { className: "noData", colSpan: columns.length, children: /* @__PURE__ */ jsx22(Loader_default.box, {}) }) }) : dataAfterPagination.length > 0 ? dataAfterPagination.map((item, rowIndex) => /* @__PURE__ */ jsxs17(Fragment6, { children: [
|
|
7942
7958
|
/* @__PURE__ */ jsx22(
|
|
7943
7959
|
"tr",
|
|
7944
7960
|
{
|
|
@@ -8087,10 +8103,10 @@ var TableComponent = forwardRef15(function Table({
|
|
|
8087
8103
|
cancelButtonText: "Clear",
|
|
8088
8104
|
onClickCancel: openedFilterData ? onClickCancelFormFilter : void 0,
|
|
8089
8105
|
children: [
|
|
8090
|
-
/* @__PURE__ */ jsx22(FormRow_default, { children: openedFilterColumn.filter === "date" ? /* @__PURE__ */ jsxs17(
|
|
8106
|
+
/* @__PURE__ */ jsx22(FormRow_default, { children: openedFilterColumn.filter === "date" ? /* @__PURE__ */ jsxs17(Fragment7, { children: [
|
|
8091
8107
|
/* @__PURE__ */ jsx22(InputField_default.date, { label: "Min", ...filterForm.getInputFieldProps("min") }),
|
|
8092
8108
|
/* @__PURE__ */ jsx22(InputField_default.date, { label: "Max", ...filterForm.getInputFieldProps("max") })
|
|
8093
|
-
] }) : /* @__PURE__ */ jsxs17(
|
|
8109
|
+
] }) : /* @__PURE__ */ jsxs17(Fragment7, { children: [
|
|
8094
8110
|
/* @__PURE__ */ jsx22(InputField_default.dateTime, { label: "Min", ...filterForm.getInputFieldProps("min") }),
|
|
8095
8111
|
/* @__PURE__ */ jsx22(InputField_default.dateTime, { label: "Max", ...filterForm.getInputFieldProps("max") })
|
|
8096
8112
|
] }) }),
|