react-better-html 1.1.214 → 1.1.216
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 +16 -4
- package/dist/index.d.ts +16 -4
- package/dist/index.js +238 -231
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +39 -32
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -4136,6 +4136,7 @@ var filterHover = () => {
|
|
|
4136
4136
|
|
|
4137
4137
|
// src/components/Chip.tsx
|
|
4138
4138
|
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
4139
|
+
var borderRadiusOffset = 1.3;
|
|
4139
4140
|
var ChipComponent = (0, import_react16.forwardRef)(function Chip({
|
|
4140
4141
|
text,
|
|
4141
4142
|
color,
|
|
@@ -4160,7 +4161,7 @@ var ChipComponent = (0, import_react16.forwardRef)(function Chip({
|
|
|
4160
4161
|
{
|
|
4161
4162
|
width: "fit-content",
|
|
4162
4163
|
backgroundColor: backgroundColor ?? theme2.colors.backgroundSecondary,
|
|
4163
|
-
borderRadius: isCircle ? 999 : borderRadius ?? theme2.styles.borderRadius /
|
|
4164
|
+
borderRadius: isCircle ? 999 : borderRadius ?? theme2.styles.borderRadius / borderRadiusOffset,
|
|
4164
4165
|
paddingBlock: theme2.styles.gap / 2,
|
|
4165
4166
|
paddingInline: theme2.styles.space / 1.5,
|
|
4166
4167
|
filterHover: onClick || onClickWithValue ? filterHover().z1 : void 0,
|
|
@@ -4172,11 +4173,11 @@ var ChipComponent = (0, import_react16.forwardRef)(function Chip({
|
|
|
4172
4173
|
}
|
|
4173
4174
|
);
|
|
4174
4175
|
});
|
|
4175
|
-
ChipComponent.colored = (0, import_react16.forwardRef)(function Colored({ color, ...props }, ref) {
|
|
4176
|
+
ChipComponent.colored = (0, import_react16.forwardRef)(function Colored({ color, withWhiteBackground, ...props }, ref) {
|
|
4176
4177
|
const theme2 = useTheme();
|
|
4177
4178
|
const { colorTheme } = useBetterHtmlContextInternal();
|
|
4178
4179
|
const readyColor = color ?? theme2.colors.textSecondary;
|
|
4179
|
-
|
|
4180
|
+
const chip = /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
4180
4181
|
ChipComponent,
|
|
4181
4182
|
{
|
|
4182
4183
|
color: colorTheme === "light" ? darkenColor(readyColor, 0.7) : lightenColor(readyColor, 0.7),
|
|
@@ -4186,13 +4187,22 @@ ChipComponent.colored = (0, import_react16.forwardRef)(function Colored({ color,
|
|
|
4186
4187
|
...props
|
|
4187
4188
|
}
|
|
4188
4189
|
);
|
|
4190
|
+
return withWhiteBackground ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
4191
|
+
Div_default,
|
|
4192
|
+
{
|
|
4193
|
+
width: "fit-content",
|
|
4194
|
+
backgroundColor: withWhiteBackground ? colorTheme === "light" ? "#ffffff" : "#000000" : void 0,
|
|
4195
|
+
borderRadius: withWhiteBackground ? props.borderRadius ?? theme2.styles.borderRadius / borderRadiusOffset + 0.3 : void 0,
|
|
4196
|
+
children: chip
|
|
4197
|
+
}
|
|
4198
|
+
) : chip;
|
|
4189
4199
|
});
|
|
4190
4200
|
var Chip2 = (0, import_react16.memo)(ChipComponent);
|
|
4191
4201
|
Chip2.colored = ChipComponent.colored;
|
|
4192
4202
|
var Chip_default = Chip2;
|
|
4193
4203
|
|
|
4194
4204
|
// src/components/InputField.tsx
|
|
4195
|
-
var
|
|
4205
|
+
var import_react21 = require("react");
|
|
4196
4206
|
var import_styled_components11 = __toESM(require("styled-components"));
|
|
4197
4207
|
|
|
4198
4208
|
// src/constants/countries.ts
|
|
@@ -5821,6 +5831,7 @@ var Label_default = (0, import_react17.memo)(Label);
|
|
|
5821
5831
|
// src/components/Dropdown.tsx
|
|
5822
5832
|
var import_react18 = require("react");
|
|
5823
5833
|
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
5834
|
+
var import_react19 = require("react");
|
|
5824
5835
|
var DropdownComponent = (0, import_react18.forwardRef)(function Dropdown({
|
|
5825
5836
|
label,
|
|
5826
5837
|
labelColor,
|
|
@@ -5992,7 +6003,7 @@ var DropdownComponent = (0, import_react18.forwardRef)(function Dropdown({
|
|
|
5992
6003
|
role: "option",
|
|
5993
6004
|
"aria-selected": isSelected,
|
|
5994
6005
|
"aria-disabled": isDisabled,
|
|
5995
|
-
children: renderOption ? renderOption(option, index, isSelected) : /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Text_default, { children: option.label })
|
|
6006
|
+
children: renderOption ? renderOption(option, index, isSelected) : /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_jsx_runtime16.Fragment, { children: !option.renderType || option.renderType === "default" ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Text_default, { children: option.label }) : option.renderType === "chip" ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Chip_default, { text: option.label, ...option.chipProps }) : option.renderType === "chip.colored" ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Chip_default.colored, { text: option.label, withWhiteBackground: true, ...option.chipProps }) : void 0 })
|
|
5996
6007
|
}
|
|
5997
6008
|
),
|
|
5998
6009
|
renderOptionDivider ? renderOptionDivider(
|
|
@@ -6090,7 +6101,18 @@ var DropdownComponent = (0, import_react18.forwardRef)(function Dropdown({
|
|
|
6090
6101
|
paddingBlock: theme2.styles.gap,
|
|
6091
6102
|
paddingInline: (theme2.styles.space + theme2.styles.gap) / 2,
|
|
6092
6103
|
transition: theme2.styles.transition,
|
|
6093
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Div_default.row, { width: "100%", flexWrap: "wrap", gap: theme2.styles.gap, children: selectedOption.map((option) =>
|
|
6104
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Div_default.row, { width: "100%", flexWrap: "wrap", gap: theme2.styles.gap, children: selectedOption.map((option) => {
|
|
6105
|
+
const ChipComponentTag = !option.renderType || option.renderType === "default" || option.renderType === "chip" ? Chip_default : option.renderType === "chip.colored" ? Chip_default.colored : Chip_default;
|
|
6106
|
+
return /* @__PURE__ */ (0, import_react19.createElement)(
|
|
6107
|
+
ChipComponentTag,
|
|
6108
|
+
{
|
|
6109
|
+
text: option.label,
|
|
6110
|
+
...option.renderType === "chip" || option.renderType === "chip.colored" ? option.chipProps : [],
|
|
6111
|
+
withWhiteBackground: option.renderType === "chip.colored",
|
|
6112
|
+
key: JSON.stringify(option)
|
|
6113
|
+
}
|
|
6114
|
+
);
|
|
6115
|
+
}) })
|
|
6094
6116
|
}
|
|
6095
6117
|
) : void 0,
|
|
6096
6118
|
insideInputFieldAfterComponent: /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(import_jsx_runtime16.Fragment, { children: [
|
|
@@ -6212,7 +6234,7 @@ Dropdown2.countries = DropdownComponent.countries;
|
|
|
6212
6234
|
var Dropdown_default = Dropdown2;
|
|
6213
6235
|
|
|
6214
6236
|
// src/components/Calendar.tsx
|
|
6215
|
-
var
|
|
6237
|
+
var import_react20 = require("react");
|
|
6216
6238
|
var import_styled_components10 = __toESM(require("styled-components"));
|
|
6217
6239
|
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
6218
6240
|
var getMonthName = (month, short = false) => {
|
|
@@ -6265,24 +6287,24 @@ var SelectComponent = import_styled_components10.default.select.withConfig({
|
|
|
6265
6287
|
`;
|
|
6266
6288
|
function Calendar({ value, minDate, maxDate, onChange }) {
|
|
6267
6289
|
const theme2 = useTheme();
|
|
6268
|
-
const internalYearSelectId = (0,
|
|
6269
|
-
const [currentDate, setCurrentDate] = (0,
|
|
6270
|
-
const [currentMonth, setCurrentMonth] = (0,
|
|
6271
|
-
const [currentYear, setCurrentYear] = (0,
|
|
6272
|
-
const daysInMonth = (0,
|
|
6273
|
-
const onClickPreviousMonthButton = (0,
|
|
6290
|
+
const internalYearSelectId = (0, import_react20.useId)();
|
|
6291
|
+
const [currentDate, setCurrentDate] = (0, import_react20.useState)(value ? new Date(value) : void 0);
|
|
6292
|
+
const [currentMonth, setCurrentMonth] = (0, import_react20.useState)(currentDate?.getMonth() ?? (/* @__PURE__ */ new Date()).getMonth());
|
|
6293
|
+
const [currentYear, setCurrentYear] = (0, import_react20.useState)(currentDate?.getFullYear() ?? (/* @__PURE__ */ new Date()).getFullYear());
|
|
6294
|
+
const daysInMonth = (0, import_react20.useMemo)(() => new Date(currentYear, currentMonth + 1, 0).getDate(), [currentMonth, currentYear]);
|
|
6295
|
+
const onClickPreviousMonthButton = (0, import_react20.useCallback)(() => {
|
|
6274
6296
|
const newMonth = currentMonth === 0 ? 11 : currentMonth - 1;
|
|
6275
6297
|
const newYear = currentMonth === 0 ? currentYear - 1 : currentYear;
|
|
6276
6298
|
setCurrentMonth(newMonth);
|
|
6277
6299
|
setCurrentYear(newYear);
|
|
6278
6300
|
}, [currentMonth, currentYear]);
|
|
6279
|
-
const onClickNextMonthButton = (0,
|
|
6301
|
+
const onClickNextMonthButton = (0, import_react20.useCallback)(() => {
|
|
6280
6302
|
const newMonth = currentMonth === 11 ? 0 : currentMonth + 1;
|
|
6281
6303
|
const newYear = currentMonth === 11 ? currentYear + 1 : currentYear;
|
|
6282
6304
|
setCurrentMonth(newMonth);
|
|
6283
6305
|
setCurrentYear(newYear);
|
|
6284
6306
|
}, [currentMonth, currentYear]);
|
|
6285
|
-
const onClickDay = (0,
|
|
6307
|
+
const onClickDay = (0, import_react20.useCallback)(
|
|
6286
6308
|
(day) => {
|
|
6287
6309
|
if (!day) return;
|
|
6288
6310
|
const newDate = new Date(currentYear, currentMonth, day);
|
|
@@ -6293,25 +6315,25 @@ function Calendar({ value, minDate, maxDate, onChange }) {
|
|
|
6293
6315
|
},
|
|
6294
6316
|
[currentMonth, currentYear, onChange]
|
|
6295
6317
|
);
|
|
6296
|
-
const onClickClear = (0,
|
|
6318
|
+
const onClickClear = (0, import_react20.useCallback)(() => {
|
|
6297
6319
|
setCurrentDate(void 0);
|
|
6298
6320
|
onChange?.(void 0);
|
|
6299
6321
|
}, []);
|
|
6300
|
-
const onClickToday = (0,
|
|
6322
|
+
const onClickToday = (0, import_react20.useCallback)(() => {
|
|
6301
6323
|
const today = /* @__PURE__ */ new Date();
|
|
6302
6324
|
setCurrentDate(today);
|
|
6303
6325
|
onChange?.(
|
|
6304
6326
|
`${today.getFullYear()}-${(today.getMonth() + 1).toString().padStart(2, "0")}-${today.getDate().toString().padStart(2, "0")}`
|
|
6305
6327
|
);
|
|
6306
6328
|
}, [onChange]);
|
|
6307
|
-
const onChangeYearSelect = (0,
|
|
6329
|
+
const onChangeYearSelect = (0, import_react20.useCallback)((event) => {
|
|
6308
6330
|
setCurrentYear(parseInt(event.target.value));
|
|
6309
6331
|
}, []);
|
|
6310
|
-
const firstDayOfMonth = (0,
|
|
6332
|
+
const firstDayOfMonth = (0, import_react20.useMemo)(() => {
|
|
6311
6333
|
const day = new Date(currentYear, currentMonth, 1).getDay();
|
|
6312
6334
|
return day === 0 ? 6 : day - 1;
|
|
6313
6335
|
}, [currentMonth, currentYear]);
|
|
6314
|
-
const days = (0,
|
|
6336
|
+
const days = (0, import_react20.useMemo)(() => {
|
|
6315
6337
|
const result = [];
|
|
6316
6338
|
for (let index = 0; index < firstDayOfMonth; index++) {
|
|
6317
6339
|
result.push(void 0);
|
|
@@ -6321,7 +6343,7 @@ function Calendar({ value, minDate, maxDate, onChange }) {
|
|
|
6321
6343
|
}
|
|
6322
6344
|
return result;
|
|
6323
6345
|
}, [daysInMonth, firstDayOfMonth]);
|
|
6324
|
-
(0,
|
|
6346
|
+
(0, import_react20.useEffect)(() => {
|
|
6325
6347
|
if (!value) return;
|
|
6326
6348
|
const date = new Date(value);
|
|
6327
6349
|
setCurrentDate(date);
|
|
@@ -6427,7 +6449,7 @@ function Calendar({ value, minDate, maxDate, onChange }) {
|
|
|
6427
6449
|
] })
|
|
6428
6450
|
] });
|
|
6429
6451
|
}
|
|
6430
|
-
var Calendar_default = (0,
|
|
6452
|
+
var Calendar_default = (0, import_react20.memo)(Calendar);
|
|
6431
6453
|
|
|
6432
6454
|
// src/components/InputField.tsx
|
|
6433
6455
|
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
@@ -6595,7 +6617,7 @@ var TextareaElement = import_styled_components11.default.textarea.withConfig({
|
|
|
6595
6617
|
`;
|
|
6596
6618
|
var hours = Array.from({ length: 24 }, (_, index) => index);
|
|
6597
6619
|
var minutes = Array.from({ length: 60 }, (_, index) => index);
|
|
6598
|
-
var InputFieldComponent = (0,
|
|
6620
|
+
var InputFieldComponent = (0, import_react21.forwardRef)(function InputField({
|
|
6599
6621
|
label,
|
|
6600
6622
|
labelColor,
|
|
6601
6623
|
errorText,
|
|
@@ -6620,7 +6642,7 @@ var InputFieldComponent = (0, import_react20.forwardRef)(function InputField({
|
|
|
6620
6642
|
...props
|
|
6621
6643
|
}, ref) {
|
|
6622
6644
|
const theme2 = useTheme();
|
|
6623
|
-
const internalId = (0,
|
|
6645
|
+
const internalId = (0, import_react21.useId)();
|
|
6624
6646
|
const { colorTheme } = useBetterHtmlContextInternal();
|
|
6625
6647
|
const [_, debouncedValue, setDebouncedValue] = useDebounceState(
|
|
6626
6648
|
props.value?.toString() ?? "",
|
|
@@ -6631,7 +6653,7 @@ var InputFieldComponent = (0, import_react20.forwardRef)(function InputField({
|
|
|
6631
6653
|
const dataProps = useComponentPropsWithPrefix(props, "data");
|
|
6632
6654
|
const ariaProps = useComponentPropsWithPrefix(props, "aria");
|
|
6633
6655
|
const restProps = useComponentPropsWithoutStyle(props);
|
|
6634
|
-
const onChangeElement = (0,
|
|
6656
|
+
const onChangeElement = (0, import_react21.useCallback)(
|
|
6635
6657
|
(event) => {
|
|
6636
6658
|
const newValue = event.target.value;
|
|
6637
6659
|
if (withDebounce) {
|
|
@@ -6644,13 +6666,13 @@ var InputFieldComponent = (0, import_react20.forwardRef)(function InputField({
|
|
|
6644
6666
|
},
|
|
6645
6667
|
[onChange, onChangeValue, withDebounce]
|
|
6646
6668
|
);
|
|
6647
|
-
const leftIconZIndex = (0,
|
|
6669
|
+
const leftIconZIndex = (0, import_react21.useMemo)(
|
|
6648
6670
|
() => ["react-better-html-dropdown-open-late", "react-better-html-inputField-dateTime-opened-late"].some(
|
|
6649
6671
|
(classNameItem) => props.className?.includes(classNameItem)
|
|
6650
6672
|
) ? 1002 : 1,
|
|
6651
6673
|
[props.className]
|
|
6652
6674
|
);
|
|
6653
|
-
(0,
|
|
6675
|
+
(0, import_react21.useEffect)(() => {
|
|
6654
6676
|
if (!withDebounce) return;
|
|
6655
6677
|
onChangeValue?.(debouncedValue);
|
|
6656
6678
|
}, [withDebounce, onChangeValue, debouncedValue]);
|
|
@@ -6757,7 +6779,7 @@ var InputFieldComponent = (0, import_react20.forwardRef)(function InputField({
|
|
|
6757
6779
|
)
|
|
6758
6780
|
] });
|
|
6759
6781
|
});
|
|
6760
|
-
InputFieldComponent.multiline = (0,
|
|
6782
|
+
InputFieldComponent.multiline = (0, import_react21.forwardRef)(function Multiline({
|
|
6761
6783
|
label,
|
|
6762
6784
|
placeholder,
|
|
6763
6785
|
errorText,
|
|
@@ -6772,12 +6794,12 @@ InputFieldComponent.multiline = (0, import_react20.forwardRef)(function Multilin
|
|
|
6772
6794
|
...props
|
|
6773
6795
|
}, ref) {
|
|
6774
6796
|
const theme2 = useTheme();
|
|
6775
|
-
const internalId = (0,
|
|
6797
|
+
const internalId = (0, import_react21.useId)();
|
|
6776
6798
|
const styledComponentStyles = useStyledComponentStyles(props, theme2);
|
|
6777
6799
|
const dataProps = useComponentPropsWithPrefix(props, "data");
|
|
6778
6800
|
const ariaProps = useComponentPropsWithPrefix(props, "aria");
|
|
6779
6801
|
const restProps = useComponentPropsWithoutStyle(props);
|
|
6780
|
-
const onChangeElement = (0,
|
|
6802
|
+
const onChangeElement = (0, import_react21.useCallback)(
|
|
6781
6803
|
(event) => {
|
|
6782
6804
|
onChange?.(event);
|
|
6783
6805
|
onChangeValue?.(event.target.value);
|
|
@@ -6851,7 +6873,7 @@ InputFieldComponent.multiline = (0, import_react20.forwardRef)(function Multilin
|
|
|
6851
6873
|
)
|
|
6852
6874
|
] });
|
|
6853
6875
|
});
|
|
6854
|
-
InputFieldComponent.email = (0,
|
|
6876
|
+
InputFieldComponent.email = (0, import_react21.forwardRef)(function Email({ ...props }, ref) {
|
|
6855
6877
|
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
6856
6878
|
InputFieldComponent,
|
|
6857
6879
|
{
|
|
@@ -6865,7 +6887,7 @@ InputFieldComponent.email = (0, import_react20.forwardRef)(function Email({ ...p
|
|
|
6865
6887
|
}
|
|
6866
6888
|
);
|
|
6867
6889
|
});
|
|
6868
|
-
InputFieldComponent.password = (0,
|
|
6890
|
+
InputFieldComponent.password = (0, import_react21.forwardRef)(function Password({ ...props }, ref) {
|
|
6869
6891
|
const [isPassword, setIsPassword] = useBooleanState(true);
|
|
6870
6892
|
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
6871
6893
|
InputFieldComponent,
|
|
@@ -6882,31 +6904,31 @@ InputFieldComponent.password = (0, import_react20.forwardRef)(function Password(
|
|
|
6882
6904
|
}
|
|
6883
6905
|
);
|
|
6884
6906
|
});
|
|
6885
|
-
InputFieldComponent.search = (0,
|
|
6886
|
-
const [inputFieldValue, setInputFieldValue] = (0,
|
|
6907
|
+
InputFieldComponent.search = (0, import_react21.forwardRef)(function Search({ value, onChangeValue, onFocus, onBlur, ...props }, ref) {
|
|
6908
|
+
const [inputFieldValue, setInputFieldValue] = (0, import_react21.useState)(value?.toString() ?? "");
|
|
6887
6909
|
const [inputFieldFocused, setInputFieldFocused] = useBooleanState();
|
|
6888
|
-
const onChangeValueElement = (0,
|
|
6910
|
+
const onChangeValueElement = (0, import_react21.useCallback)(
|
|
6889
6911
|
(value2) => {
|
|
6890
6912
|
setInputFieldValue(value2);
|
|
6891
6913
|
onChangeValue?.(value2);
|
|
6892
6914
|
},
|
|
6893
6915
|
[onChangeValue]
|
|
6894
6916
|
);
|
|
6895
|
-
const onFocusElement = (0,
|
|
6917
|
+
const onFocusElement = (0, import_react21.useCallback)(
|
|
6896
6918
|
(event) => {
|
|
6897
6919
|
setInputFieldFocused.setTrue();
|
|
6898
6920
|
onFocus?.(event);
|
|
6899
6921
|
},
|
|
6900
6922
|
[onFocus]
|
|
6901
6923
|
);
|
|
6902
|
-
const onBlurElement = (0,
|
|
6924
|
+
const onBlurElement = (0, import_react21.useCallback)(
|
|
6903
6925
|
(event) => {
|
|
6904
6926
|
setTimeout(() => setInputFieldFocused.setFalse(), 0.1 * 1e3);
|
|
6905
6927
|
onBlur?.(event);
|
|
6906
6928
|
},
|
|
6907
6929
|
[onBlur]
|
|
6908
6930
|
);
|
|
6909
|
-
const onClickRightIcon = (0,
|
|
6931
|
+
const onClickRightIcon = (0, import_react21.useCallback)(() => {
|
|
6910
6932
|
onChangeValueElement("");
|
|
6911
6933
|
}, [onChangeValueElement]);
|
|
6912
6934
|
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
@@ -6925,26 +6947,26 @@ InputFieldComponent.search = (0, import_react20.forwardRef)(function Search({ va
|
|
|
6925
6947
|
}
|
|
6926
6948
|
);
|
|
6927
6949
|
});
|
|
6928
|
-
InputFieldComponent.phoneNumber = (0,
|
|
6950
|
+
InputFieldComponent.phoneNumber = (0, import_react21.forwardRef)(function PhoneNumber({ label, value, onChangeValue, labelColor, id, ...props }, ref) {
|
|
6929
6951
|
const theme2 = useTheme();
|
|
6930
|
-
const internalId = (0,
|
|
6931
|
-
const [dropdownValue, setDropdownValue] = (0,
|
|
6932
|
-
const [inputFieldValue, setInputFieldValue] = (0,
|
|
6933
|
-
const renderOption = (0,
|
|
6952
|
+
const internalId = (0, import_react21.useId)();
|
|
6953
|
+
const [dropdownValue, setDropdownValue] = (0, import_react21.useState)();
|
|
6954
|
+
const [inputFieldValue, setInputFieldValue] = (0, import_react21.useState)(value?.toString() ?? "");
|
|
6955
|
+
const renderOption = (0, import_react21.useCallback)(
|
|
6934
6956
|
(option, index, isSelected) => /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(Div_default.row, { alignItems: "center", gap: theme2.styles.gap, children: [
|
|
6935
6957
|
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Image_default, { src: `https://flagcdn.com/w80/${option.data?.code.toString().toLowerCase()}.webp`, width: 20 }),
|
|
6936
6958
|
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Text_default, { children: option.label })
|
|
6937
6959
|
] }),
|
|
6938
6960
|
[]
|
|
6939
6961
|
);
|
|
6940
|
-
const onChangeDropdown = (0,
|
|
6962
|
+
const onChangeDropdown = (0, import_react21.useCallback)(
|
|
6941
6963
|
(value2) => {
|
|
6942
6964
|
setDropdownValue(value2);
|
|
6943
6965
|
onChangeValue?.(value2 ? `+${value2}${inputFieldValue}` : inputFieldValue);
|
|
6944
6966
|
},
|
|
6945
6967
|
[onChangeValue, inputFieldValue]
|
|
6946
6968
|
);
|
|
6947
|
-
const onChangeValueElement = (0,
|
|
6969
|
+
const onChangeValueElement = (0, import_react21.useCallback)(
|
|
6948
6970
|
(value2) => {
|
|
6949
6971
|
const readyValue = value2.replace(/\D/g, "");
|
|
6950
6972
|
setInputFieldValue(readyValue);
|
|
@@ -6952,7 +6974,7 @@ InputFieldComponent.phoneNumber = (0, import_react20.forwardRef)(function PhoneN
|
|
|
6952
6974
|
},
|
|
6953
6975
|
[onChangeValue, dropdownValue]
|
|
6954
6976
|
);
|
|
6955
|
-
const options = (0,
|
|
6977
|
+
const options = (0, import_react21.useMemo)(
|
|
6956
6978
|
() => countries.map((country) => ({
|
|
6957
6979
|
value: country.phoneNumberExtension,
|
|
6958
6980
|
label: `+${country.phoneNumberExtension}`,
|
|
@@ -6960,13 +6982,13 @@ InputFieldComponent.phoneNumber = (0, import_react20.forwardRef)(function PhoneN
|
|
|
6960
6982
|
})),
|
|
6961
6983
|
[]
|
|
6962
6984
|
);
|
|
6963
|
-
const defaultValue = (0,
|
|
6985
|
+
const defaultValue = (0, import_react21.useMemo)(() => {
|
|
6964
6986
|
const thisTimeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
6965
6987
|
const initialDefaultValue = options.find((option) => option.data?.timeZone === thisTimeZone)?.value ?? "";
|
|
6966
6988
|
setDropdownValue(initialDefaultValue);
|
|
6967
6989
|
return initialDefaultValue;
|
|
6968
6990
|
}, [options]);
|
|
6969
|
-
(0,
|
|
6991
|
+
(0, import_react21.useEffect)(() => {
|
|
6970
6992
|
if (value === void 0 || value === null) return;
|
|
6971
6993
|
const newValue = value.toString();
|
|
6972
6994
|
const country = countries.find(
|
|
@@ -7028,12 +7050,12 @@ InputFieldComponent.phoneNumber = (0, import_react20.forwardRef)(function PhoneN
|
|
|
7028
7050
|
] })
|
|
7029
7051
|
] });
|
|
7030
7052
|
});
|
|
7031
|
-
InputFieldComponent.date = (0,
|
|
7053
|
+
InputFieldComponent.date = (0, import_react21.forwardRef)(function Date2({ minDate, maxDate, ...props }, ref) {
|
|
7032
7054
|
const theme2 = useTheme();
|
|
7033
|
-
const holderRef = (0,
|
|
7055
|
+
const holderRef = (0, import_react21.useRef)(null);
|
|
7034
7056
|
const isMobileIOS = isMobileDevice && getBrowser() === "safari";
|
|
7035
7057
|
const { internalValue, setInternalValue, inputFieldProps, insideInputFieldComponentProps } = useComponentInputFieldDateProps(props, holderRef, isMobileIOS);
|
|
7036
|
-
const onChange = (0,
|
|
7058
|
+
const onChange = (0, import_react21.useCallback)(
|
|
7037
7059
|
(date) => {
|
|
7038
7060
|
inputFieldProps.onChangeValue?.(date ?? "");
|
|
7039
7061
|
setInternalValue(date ?? "");
|
|
@@ -7067,14 +7089,14 @@ InputFieldComponent.date = (0, import_react20.forwardRef)(function Date2({ minDa
|
|
|
7067
7089
|
}
|
|
7068
7090
|
);
|
|
7069
7091
|
});
|
|
7070
|
-
InputFieldComponent.dateTime = (0,
|
|
7092
|
+
InputFieldComponent.dateTime = (0, import_react21.forwardRef)(function DateTime({ minDate, maxDate, defaultDateAfterTimePick, defaultTimeAfterDatePick = "00:00", ...props }, ref) {
|
|
7071
7093
|
const theme2 = useTheme();
|
|
7072
|
-
const holderRef = (0,
|
|
7073
|
-
const selectedHourRef = (0,
|
|
7074
|
-
const selectedMinuteRef = (0,
|
|
7094
|
+
const holderRef = (0, import_react21.useRef)(null);
|
|
7095
|
+
const selectedHourRef = (0, import_react21.useRef)(null);
|
|
7096
|
+
const selectedMinuteRef = (0, import_react21.useRef)(null);
|
|
7075
7097
|
const isMobileIOS = isMobileDevice && getBrowser() === "safari";
|
|
7076
7098
|
const { internalValue, setInternalValue, inputFieldProps, insideInputFieldComponentProps, isOpen } = useComponentInputFieldDateProps(props, holderRef, isMobileIOS);
|
|
7077
|
-
const onChange = (0,
|
|
7099
|
+
const onChange = (0, import_react21.useCallback)(
|
|
7078
7100
|
(date) => {
|
|
7079
7101
|
const newValue = date ? `${date}T${internalValue?.toString().split("T")[1] ?? defaultTimeAfterDatePick}` : "";
|
|
7080
7102
|
inputFieldProps.onChangeValue?.(newValue);
|
|
@@ -7082,7 +7104,7 @@ InputFieldComponent.dateTime = (0, import_react20.forwardRef)(function DateTime(
|
|
|
7082
7104
|
},
|
|
7083
7105
|
[internalValue, defaultTimeAfterDatePick, inputFieldProps.onChangeValue]
|
|
7084
7106
|
);
|
|
7085
|
-
const onClickHour = (0,
|
|
7107
|
+
const onClickHour = (0, import_react21.useCallback)(
|
|
7086
7108
|
(hour) => {
|
|
7087
7109
|
const newTime = `${hour.toString().padStart(2, "0")}:${internalValue?.toString().split(":")[1] || "00"}`;
|
|
7088
7110
|
const today = defaultDateAfterTimePick ?? `${(/* @__PURE__ */ new Date()).getFullYear()}-${((/* @__PURE__ */ new Date()).getMonth() + 1).toString().padStart(2, "0")}-${(/* @__PURE__ */ new Date()).getDate().toString().padStart(2, "0")}`;
|
|
@@ -7092,7 +7114,7 @@ InputFieldComponent.dateTime = (0, import_react20.forwardRef)(function DateTime(
|
|
|
7092
7114
|
},
|
|
7093
7115
|
[defaultDateAfterTimePick, internalValue, inputFieldProps.onChangeValue]
|
|
7094
7116
|
);
|
|
7095
|
-
const onClickMinute = (0,
|
|
7117
|
+
const onClickMinute = (0, import_react21.useCallback)(
|
|
7096
7118
|
(minute) => {
|
|
7097
7119
|
const newTime = `${internalValue?.toString().split("T")?.[1]?.split(":")[0] || "00"}:${minute.toString().padStart(2, "0")}`;
|
|
7098
7120
|
const today = defaultDateAfterTimePick ?? `${(/* @__PURE__ */ new Date()).getFullYear()}-${((/* @__PURE__ */ new Date()).getMonth() + 1).toString().padStart(2, "0")}-${(/* @__PURE__ */ new Date()).getDate().toString().padStart(2, "0")}`;
|
|
@@ -7102,7 +7124,7 @@ InputFieldComponent.dateTime = (0, import_react20.forwardRef)(function DateTime(
|
|
|
7102
7124
|
},
|
|
7103
7125
|
[defaultDateAfterTimePick, internalValue, inputFieldProps.onChangeValue]
|
|
7104
7126
|
);
|
|
7105
|
-
(0,
|
|
7127
|
+
(0, import_react21.useEffect)(() => {
|
|
7106
7128
|
if (isOpen && selectedHourRef.current)
|
|
7107
7129
|
selectedHourRef.current.scrollIntoView({ block: "nearest", behavior: "instant" });
|
|
7108
7130
|
if (isOpen && selectedMinuteRef.current)
|
|
@@ -7221,14 +7243,14 @@ InputFieldComponent.dateTime = (0, import_react20.forwardRef)(function DateTime(
|
|
|
7221
7243
|
}
|
|
7222
7244
|
);
|
|
7223
7245
|
});
|
|
7224
|
-
InputFieldComponent.time = (0,
|
|
7246
|
+
InputFieldComponent.time = (0, import_react21.forwardRef)(function Time({ ...props }, ref) {
|
|
7225
7247
|
const theme2 = useTheme();
|
|
7226
|
-
const holderRef = (0,
|
|
7227
|
-
const selectedHourRef = (0,
|
|
7228
|
-
const selectedMinuteRef = (0,
|
|
7248
|
+
const holderRef = (0, import_react21.useRef)(null);
|
|
7249
|
+
const selectedHourRef = (0, import_react21.useRef)(null);
|
|
7250
|
+
const selectedMinuteRef = (0, import_react21.useRef)(null);
|
|
7229
7251
|
const isMobileIOS = isMobileDevice && getBrowser() === "safari";
|
|
7230
7252
|
const { internalValue, setInternalValue, inputFieldProps, insideInputFieldComponentProps, isOpen } = useComponentInputFieldDateProps(props, holderRef, isMobileIOS);
|
|
7231
|
-
const onClickHour = (0,
|
|
7253
|
+
const onClickHour = (0, import_react21.useCallback)(
|
|
7232
7254
|
(hour) => {
|
|
7233
7255
|
const value = `${hour.toString().padStart(2, "0")}:${internalValue?.toString().split(":")[1] || "00"}`;
|
|
7234
7256
|
inputFieldProps.onChangeValue?.(value);
|
|
@@ -7236,7 +7258,7 @@ InputFieldComponent.time = (0, import_react20.forwardRef)(function Time({ ...pro
|
|
|
7236
7258
|
},
|
|
7237
7259
|
[internalValue, inputFieldProps.onChangeValue]
|
|
7238
7260
|
);
|
|
7239
|
-
const onClickMinute = (0,
|
|
7261
|
+
const onClickMinute = (0, import_react21.useCallback)(
|
|
7240
7262
|
(minute) => {
|
|
7241
7263
|
const value = `${internalValue?.toString().split(":")[0] || "00"}:${minute.toString().padStart(2, "0")}`;
|
|
7242
7264
|
inputFieldProps.onChangeValue?.(value);
|
|
@@ -7244,7 +7266,7 @@ InputFieldComponent.time = (0, import_react20.forwardRef)(function Time({ ...pro
|
|
|
7244
7266
|
},
|
|
7245
7267
|
[internalValue, inputFieldProps.onChangeValue]
|
|
7246
7268
|
);
|
|
7247
|
-
(0,
|
|
7269
|
+
(0, import_react21.useEffect)(() => {
|
|
7248
7270
|
if (isOpen && selectedHourRef.current)
|
|
7249
7271
|
selectedHourRef.current.scrollIntoView({ block: "nearest", behavior: "instant" });
|
|
7250
7272
|
if (isOpen && selectedMinuteRef.current)
|
|
@@ -7343,16 +7365,16 @@ InputFieldComponent.time = (0, import_react20.forwardRef)(function Time({ ...pro
|
|
|
7343
7365
|
}
|
|
7344
7366
|
);
|
|
7345
7367
|
});
|
|
7346
|
-
InputFieldComponent.color = (0,
|
|
7347
|
-
const [inputFieldValue, setInputFieldValue] = (0,
|
|
7348
|
-
const onChangeValueElement = (0,
|
|
7368
|
+
InputFieldComponent.color = (0, import_react21.forwardRef)(function Color2({ value, onChangeValue, ...props }, ref) {
|
|
7369
|
+
const [inputFieldValue, setInputFieldValue] = (0, import_react21.useState)(value ?? "#000000");
|
|
7370
|
+
const onChangeValueElement = (0, import_react21.useCallback)(
|
|
7349
7371
|
(value2) => {
|
|
7350
7372
|
setInputFieldValue(value2);
|
|
7351
7373
|
onChangeValue?.(value2);
|
|
7352
7374
|
},
|
|
7353
7375
|
[onChangeValue]
|
|
7354
7376
|
);
|
|
7355
|
-
(0,
|
|
7377
|
+
(0, import_react21.useEffect)(() => {
|
|
7356
7378
|
setInputFieldValue(value);
|
|
7357
7379
|
}, [value]);
|
|
7358
7380
|
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
@@ -7381,7 +7403,7 @@ InputFieldComponent.color = (0, import_react20.forwardRef)(function Color2({ val
|
|
|
7381
7403
|
}
|
|
7382
7404
|
);
|
|
7383
7405
|
});
|
|
7384
|
-
var InputField2 = (0,
|
|
7406
|
+
var InputField2 = (0, import_react21.memo)(InputFieldComponent);
|
|
7385
7407
|
InputField2.multiline = InputFieldComponent.multiline;
|
|
7386
7408
|
InputField2.email = InputFieldComponent.email;
|
|
7387
7409
|
InputField2.password = InputFieldComponent.password;
|
|
@@ -7394,7 +7416,7 @@ InputField2.color = InputFieldComponent.color;
|
|
|
7394
7416
|
var InputField_default = InputField2;
|
|
7395
7417
|
|
|
7396
7418
|
// src/components/ToggleInput.tsx
|
|
7397
|
-
var
|
|
7419
|
+
var import_react22 = require("react");
|
|
7398
7420
|
var import_styled_components12 = __toESM(require("styled-components"));
|
|
7399
7421
|
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
7400
7422
|
var componentSize = 26;
|
|
@@ -7489,7 +7511,7 @@ var SwitchElement = import_styled_components12.default.div.withConfig({
|
|
|
7489
7511
|
${(props) => props.hoverStyle}
|
|
7490
7512
|
}
|
|
7491
7513
|
`;
|
|
7492
|
-
var ToggleInputComponent = (0,
|
|
7514
|
+
var ToggleInputComponent = (0, import_react22.forwardRef)(function ToggleInput({
|
|
7493
7515
|
label,
|
|
7494
7516
|
labelColor,
|
|
7495
7517
|
text,
|
|
@@ -7505,14 +7527,14 @@ var ToggleInputComponent = (0, import_react21.forwardRef)(function ToggleInput({
|
|
|
7505
7527
|
...props
|
|
7506
7528
|
}, ref) {
|
|
7507
7529
|
const theme2 = useTheme();
|
|
7508
|
-
const internalId = (0,
|
|
7530
|
+
const internalId = (0, import_react22.useId)();
|
|
7509
7531
|
const styledComponentStyles = useStyledComponentStyles(props, theme2, true);
|
|
7510
7532
|
const styledComponentStylesWithExcluded = useComponentPropsWithExcludedStyle(props);
|
|
7511
7533
|
const dataProps = useComponentPropsWithPrefix(props, "data");
|
|
7512
7534
|
const ariaProps = useComponentPropsWithPrefix(props, "aria");
|
|
7513
7535
|
const restProps = useComponentPropsWithoutStyle(props);
|
|
7514
|
-
const [internalChecked, setInternalChecked] = (0,
|
|
7515
|
-
const onChangeElement = (0,
|
|
7536
|
+
const [internalChecked, setInternalChecked] = (0, import_react22.useState)(false);
|
|
7537
|
+
const onChangeElement = (0, import_react22.useCallback)(
|
|
7516
7538
|
(event) => {
|
|
7517
7539
|
const newIsChecked = event.target.checked;
|
|
7518
7540
|
if (controlledChecked === void 0) setInternalChecked(newIsChecked);
|
|
@@ -7521,7 +7543,7 @@ var ToggleInputComponent = (0, import_react21.forwardRef)(function ToggleInput({
|
|
|
7521
7543
|
[onChange, controlledChecked, value]
|
|
7522
7544
|
);
|
|
7523
7545
|
const checked = controlledChecked ?? internalChecked;
|
|
7524
|
-
const onClickText = (0,
|
|
7546
|
+
const onClickText = (0, import_react22.useCallback)(() => {
|
|
7525
7547
|
const newIsChecked = !checked;
|
|
7526
7548
|
if (controlledChecked === void 0) setInternalChecked(newIsChecked);
|
|
7527
7549
|
onChange?.(newIsChecked, value);
|
|
@@ -7602,13 +7624,13 @@ var ToggleInputComponent = (0, import_react21.forwardRef)(function ToggleInput({
|
|
|
7602
7624
|
] });
|
|
7603
7625
|
});
|
|
7604
7626
|
var ToggleInput_default = {
|
|
7605
|
-
checkbox: (0,
|
|
7627
|
+
checkbox: (0, import_react22.forwardRef)(function Checkbox(props, ref) {
|
|
7606
7628
|
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(ToggleInputComponent, { type: "checkbox", ref, ...props });
|
|
7607
7629
|
}),
|
|
7608
|
-
radiobutton: (0,
|
|
7630
|
+
radiobutton: (0, import_react22.forwardRef)(function RadioButton(props, ref) {
|
|
7609
7631
|
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(ToggleInputComponent, { type: "radio", ref, ...props });
|
|
7610
7632
|
}),
|
|
7611
|
-
switch: (0,
|
|
7633
|
+
switch: (0, import_react22.forwardRef)(function Switch({
|
|
7612
7634
|
label,
|
|
7613
7635
|
labelColor,
|
|
7614
7636
|
errorText,
|
|
@@ -7622,7 +7644,7 @@ var ToggleInput_default = {
|
|
|
7622
7644
|
...props
|
|
7623
7645
|
}, ref) {
|
|
7624
7646
|
const theme2 = useTheme();
|
|
7625
|
-
const internalId = (0,
|
|
7647
|
+
const internalId = (0, import_react22.useId)();
|
|
7626
7648
|
const styledComponentStyles = useStyledComponentStyles(props, theme2, true);
|
|
7627
7649
|
const styledComponentStylesWithExcluded = useComponentPropsWithExcludedStyle(props);
|
|
7628
7650
|
const dataProps = useComponentPropsWithPrefix(props, "data");
|
|
@@ -7631,7 +7653,7 @@ var ToggleInput_default = {
|
|
|
7631
7653
|
const [internalChecked, setInternalChecked] = useBooleanState();
|
|
7632
7654
|
const [isMouseDown, setIsMouseDown] = useBooleanState();
|
|
7633
7655
|
const checked = controlledChecked ?? internalChecked;
|
|
7634
|
-
const onClickElement = (0,
|
|
7656
|
+
const onClickElement = (0, import_react22.useCallback)(() => {
|
|
7635
7657
|
if (disabled) return;
|
|
7636
7658
|
const newIsChecked = !checked;
|
|
7637
7659
|
if (controlledChecked === void 0) setInternalChecked.setState(newIsChecked);
|
|
@@ -7688,9 +7710,9 @@ var ToggleInput_default = {
|
|
|
7688
7710
|
};
|
|
7689
7711
|
|
|
7690
7712
|
// src/components/Form.tsx
|
|
7691
|
-
var
|
|
7713
|
+
var import_react23 = require("react");
|
|
7692
7714
|
var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
7693
|
-
var FormComponent = (0,
|
|
7715
|
+
var FormComponent = (0, import_react23.forwardRef)(function Form({
|
|
7694
7716
|
form,
|
|
7695
7717
|
name,
|
|
7696
7718
|
submitButtonText,
|
|
@@ -7714,7 +7736,7 @@ var FormComponent = (0, import_react22.forwardRef)(function Form({
|
|
|
7714
7736
|
...props
|
|
7715
7737
|
}, ref) {
|
|
7716
7738
|
const theme2 = useTheme();
|
|
7717
|
-
const submitButtonIsDisabledInternal = (0,
|
|
7739
|
+
const submitButtonIsDisabledInternal = (0, import_react23.useMemo)(() => {
|
|
7718
7740
|
if (!form || !form.requiredFields) return false;
|
|
7719
7741
|
return Object.entries(form.values).some(
|
|
7720
7742
|
([key, value]) => form.requiredFields?.includes(key) && (value === void 0 || value === null || value?.toString().trim() === "")
|
|
@@ -7723,9 +7745,9 @@ var FormComponent = (0, import_react22.forwardRef)(function Form({
|
|
|
7723
7745
|
const SubmitButtonTag = isDestructive ? Button_default.destructive : Button_default;
|
|
7724
7746
|
const submitButtonIsDisabledFinal = submitButtonIsDisabled || submitButtonIsDisabledInternal;
|
|
7725
7747
|
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Div_default, { width: "100%", ...props, children: /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("form", { name, onSubmit: onSubmit ?? form?.onSubmit, ref, children: [
|
|
7726
|
-
gap !== void 0 || withDividers ? /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Div_default.column, { gap: gap ?? (withDividers ? theme2.styles.space : theme2.styles.gap), children: withDividers ?
|
|
7748
|
+
gap !== void 0 || withDividers ? /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Div_default.column, { gap: gap ?? (withDividers ? theme2.styles.space : theme2.styles.gap), children: withDividers ? import_react23.Children.toArray(children).map((child, index) => /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(import_react23.Fragment, { children: [
|
|
7727
7749
|
child,
|
|
7728
|
-
index <
|
|
7750
|
+
index < import_react23.Children.toArray(children).length - 1 && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Divider_default.horizontal, {})
|
|
7729
7751
|
] }, index)) : children }) : children,
|
|
7730
7752
|
submitButtonText && /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
|
|
7731
7753
|
Div_default.row,
|
|
@@ -7763,13 +7785,13 @@ var FormComponent = (0, import_react22.forwardRef)(function Form({
|
|
|
7763
7785
|
)
|
|
7764
7786
|
] }) });
|
|
7765
7787
|
});
|
|
7766
|
-
var Form2 = (0,
|
|
7788
|
+
var Form2 = (0, import_react23.memo)(FormComponent);
|
|
7767
7789
|
var Form_default = Form2;
|
|
7768
7790
|
|
|
7769
7791
|
// src/components/FormRow.tsx
|
|
7770
|
-
var
|
|
7792
|
+
var import_react24 = require("react");
|
|
7771
7793
|
var import_jsx_runtime21 = require("react/jsx-runtime");
|
|
7772
|
-
var FormRowComponent = (0,
|
|
7794
|
+
var FormRowComponent = (0, import_react24.forwardRef)(function FormRow({ oneItemOnly, noBreakingPoint, asColumn, gap, children, ...props }, ref) {
|
|
7773
7795
|
const theme2 = useTheme();
|
|
7774
7796
|
const mediaQuery = useMediaQuery();
|
|
7775
7797
|
const breakingPoint = asColumn ?? (!noBreakingPoint ? mediaQuery.size900 : false);
|
|
@@ -7779,7 +7801,7 @@ var FormRowComponent = (0, import_react23.forwardRef)(function FormRow({ oneItem
|
|
|
7779
7801
|
oneItemOnly && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Div_default, { width: "100%" })
|
|
7780
7802
|
] });
|
|
7781
7803
|
});
|
|
7782
|
-
FormRowComponent.withTitle = (0,
|
|
7804
|
+
FormRowComponent.withTitle = (0, import_react24.forwardRef)(function WithTitle({
|
|
7783
7805
|
icon,
|
|
7784
7806
|
title,
|
|
7785
7807
|
titleAs = "h3",
|
|
@@ -7846,12 +7868,12 @@ FormRowComponent.withTitle = (0, import_react23.forwardRef)(function WithTitle({
|
|
|
7846
7868
|
)
|
|
7847
7869
|
] });
|
|
7848
7870
|
});
|
|
7849
|
-
var FormRow2 = (0,
|
|
7871
|
+
var FormRow2 = (0, import_react24.memo)(FormRowComponent);
|
|
7850
7872
|
FormRow2.withTitle = FormRowComponent.withTitle;
|
|
7851
7873
|
var FormRow_default = FormRow2;
|
|
7852
7874
|
|
|
7853
7875
|
// src/components/ColorThemeSwitch.tsx
|
|
7854
|
-
var
|
|
7876
|
+
var import_react25 = require("react");
|
|
7855
7877
|
var import_jsx_runtime22 = require("react/jsx-runtime");
|
|
7856
7878
|
var ColorThemeSwitchComponent = function ColorThemeSwitch({
|
|
7857
7879
|
withMoon,
|
|
@@ -7863,10 +7885,10 @@ var ColorThemeSwitchComponent = function ColorThemeSwitch({
|
|
|
7863
7885
|
darkMode: localStorage.getItem("theme") === "dark"
|
|
7864
7886
|
}
|
|
7865
7887
|
});
|
|
7866
|
-
(0,
|
|
7888
|
+
(0, import_react25.useEffect)(() => {
|
|
7867
7889
|
colorThemeControls.toggleTheme(form.values.darkMode ? "dark" : "light");
|
|
7868
7890
|
}, [form.values.darkMode]);
|
|
7869
|
-
(0,
|
|
7891
|
+
(0, import_react25.useEffect)(() => {
|
|
7870
7892
|
const html = document.querySelector("html");
|
|
7871
7893
|
if (!html) return;
|
|
7872
7894
|
const observer = new MutationObserver((mutations) => {
|
|
@@ -7900,16 +7922,16 @@ ColorThemeSwitchComponent.withText = function WithText({ withMoon, className, ..
|
|
|
7900
7922
|
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)(Text_default, { children: "Dark" })
|
|
7901
7923
|
] });
|
|
7902
7924
|
};
|
|
7903
|
-
var ColorThemeSwitch2 = (0,
|
|
7925
|
+
var ColorThemeSwitch2 = (0, import_react25.memo)(ColorThemeSwitchComponent);
|
|
7904
7926
|
ColorThemeSwitch2.withText = ColorThemeSwitchComponent.withText;
|
|
7905
7927
|
var ColorThemeSwitch_default = ColorThemeSwitch2;
|
|
7906
7928
|
|
|
7907
7929
|
// src/components/Table.tsx
|
|
7908
|
-
var
|
|
7930
|
+
var import_react27 = require("react");
|
|
7909
7931
|
var import_styled_components13 = __toESM(require("styled-components"));
|
|
7910
7932
|
|
|
7911
7933
|
// src/components/Pagination.tsx
|
|
7912
|
-
var
|
|
7934
|
+
var import_react26 = require("react");
|
|
7913
7935
|
var import_jsx_runtime23 = require("react/jsx-runtime");
|
|
7914
7936
|
var PaginationComponent = function Pagination({
|
|
7915
7937
|
currentPage = 1,
|
|
@@ -7923,19 +7945,19 @@ var PaginationComponent = function Pagination({
|
|
|
7923
7945
|
}) {
|
|
7924
7946
|
const theme2 = useTheme();
|
|
7925
7947
|
const mediaQuery = useMediaQuery();
|
|
7926
|
-
const [currentPageInternal, setCurrentPage] = (0,
|
|
7948
|
+
const [currentPageInternal, setCurrentPage] = (0, import_react26.useState)(currentPage);
|
|
7927
7949
|
const pageCountInternal = pageCount ?? (itemsPerPage !== void 0 ? Math.ceil(itemsLength / itemsPerPage) : 1);
|
|
7928
|
-
const onClickPreviousPageElement = (0,
|
|
7950
|
+
const onClickPreviousPageElement = (0, import_react26.useCallback)(() => {
|
|
7929
7951
|
const newPage = currentPageInternal <= 1 ? 1 : currentPageInternal - 1;
|
|
7930
7952
|
setCurrentPage(newPage);
|
|
7931
7953
|
onClickPreviousPage?.(newPage);
|
|
7932
7954
|
}, [currentPageInternal, onClickPreviousPage]);
|
|
7933
|
-
const onClickNextPageElement = (0,
|
|
7955
|
+
const onClickNextPageElement = (0, import_react26.useCallback)(() => {
|
|
7934
7956
|
const newPage = currentPageInternal >= pageCountInternal ? pageCountInternal : currentPageInternal + 1;
|
|
7935
7957
|
setCurrentPage(newPage);
|
|
7936
7958
|
onClickNextPage?.(newPage);
|
|
7937
7959
|
}, [currentPageInternal, pageCountInternal, onClickNextPage]);
|
|
7938
|
-
const paginationItems = (0,
|
|
7960
|
+
const paginationItems = (0, import_react26.useMemo)(() => {
|
|
7939
7961
|
const halfRange = Math.floor(maximumVisiblePages2 / 2);
|
|
7940
7962
|
let startPage = Math.max(1, currentPageInternal - halfRange);
|
|
7941
7963
|
let endPage = Math.min(pageCountInternal, currentPageInternal + halfRange);
|
|
@@ -7950,10 +7972,10 @@ var PaginationComponent = function Pagination({
|
|
|
7950
7972
|
(_, index) => startPage + index
|
|
7951
7973
|
);
|
|
7952
7974
|
}, [pageCountInternal, currentPageInternal]);
|
|
7953
|
-
(0,
|
|
7975
|
+
(0, import_react26.useEffect)(() => {
|
|
7954
7976
|
onChangePage?.(currentPageInternal);
|
|
7955
7977
|
}, [currentPageInternal, onChangePage]);
|
|
7956
|
-
(0,
|
|
7978
|
+
(0, import_react26.useEffect)(() => {
|
|
7957
7979
|
setCurrentPage(currentPage);
|
|
7958
7980
|
}, [currentPage]);
|
|
7959
7981
|
const mobileFooterBreakingPoint = mediaQuery.size700 && pageCountInternal > maximumVisiblePages2 / 1.4;
|
|
@@ -8018,7 +8040,7 @@ var PaginationComponent = function Pagination({
|
|
|
8018
8040
|
)
|
|
8019
8041
|
] });
|
|
8020
8042
|
};
|
|
8021
|
-
var Pagination2 = (0,
|
|
8043
|
+
var Pagination2 = (0, import_react26.memo)(PaginationComponent);
|
|
8022
8044
|
var Pagination_default = Pagination2;
|
|
8023
8045
|
|
|
8024
8046
|
// src/components/Table.tsx
|
|
@@ -8167,7 +8189,7 @@ var filterPresetsText = {
|
|
|
8167
8189
|
nextMonth: "Next month",
|
|
8168
8190
|
nextYear: "Next year"
|
|
8169
8191
|
};
|
|
8170
|
-
var TableComponent = (0,
|
|
8192
|
+
var TableComponent = (0, import_react27.forwardRef)(function Table({
|
|
8171
8193
|
name,
|
|
8172
8194
|
columns,
|
|
8173
8195
|
data,
|
|
@@ -8194,14 +8216,14 @@ var TableComponent = (0, import_react26.forwardRef)(function Table({
|
|
|
8194
8216
|
const theme2 = useTheme();
|
|
8195
8217
|
const mediaQuery = useMediaQuery();
|
|
8196
8218
|
const { colorTheme } = useBetterHtmlContextInternal();
|
|
8197
|
-
const filterModalRef = (0,
|
|
8198
|
-
const readyColumns = (0,
|
|
8199
|
-
const columnsRef = (0,
|
|
8219
|
+
const filterModalRef = (0, import_react27.useRef)(null);
|
|
8220
|
+
const readyColumns = (0, import_react27.useMemo)(() => columns.filter((column) => !column.hidden), [columns]);
|
|
8221
|
+
const columnsRef = (0, import_react27.useRef)(readyColumns);
|
|
8200
8222
|
columnsRef.current = readyColumns;
|
|
8201
|
-
const [checkedItems, setCheckedItems] = (0,
|
|
8202
|
-
const [expandedRows, setExpandedRows] = (0,
|
|
8203
|
-
const [currentPage, setCurrentPage] = (0,
|
|
8204
|
-
const [filterData, setFilterData] = (0,
|
|
8223
|
+
const [checkedItems, setCheckedItems] = (0, import_react27.useState)([]);
|
|
8224
|
+
const [expandedRows, setExpandedRows] = (0, import_react27.useState)([]);
|
|
8225
|
+
const [currentPage, setCurrentPage] = (0, import_react27.useState)(1);
|
|
8226
|
+
const [filterData, setFilterData] = (0, import_react27.useState)(() => {
|
|
8205
8227
|
if (!memoizeFilters || !name) return defaultFilterData ?? {};
|
|
8206
8228
|
const localStorageData = JSON.parse(localStorage.getItem(`react-better-html-table-filters-${name}`) || "{}");
|
|
8207
8229
|
const timestamp = localStorageData.timestamp;
|
|
@@ -8210,8 +8232,8 @@ var TableComponent = (0, import_react26.forwardRef)(function Table({
|
|
|
8210
8232
|
if (timeDiff > memoizeFiltersLifespan) return defaultFilterData ?? {};
|
|
8211
8233
|
return data2;
|
|
8212
8234
|
});
|
|
8213
|
-
const [openedFilterColumnIndex, setOpenedFilterColumnIndex] = (0,
|
|
8214
|
-
const [filterListSelectedItems, setFilterListSelectedItems] = (0,
|
|
8235
|
+
const [openedFilterColumnIndex, setOpenedFilterColumnIndex] = (0, import_react27.useState)();
|
|
8236
|
+
const [filterListSelectedItems, setFilterListSelectedItems] = (0, import_react27.useState)();
|
|
8215
8237
|
const openedFilterData = openedFilterColumnIndex !== void 0 ? filterData[openedFilterColumnIndex] : void 0;
|
|
8216
8238
|
const openedFilterColumn = openedFilterColumnIndex !== void 0 ? readyColumns[openedFilterColumnIndex] : void 0;
|
|
8217
8239
|
const filterForm = useForm({
|
|
@@ -8241,8 +8263,8 @@ var TableComponent = (0, import_react26.forwardRef)(function Table({
|
|
|
8241
8263
|
filterModalRef.current?.close();
|
|
8242
8264
|
}
|
|
8243
8265
|
});
|
|
8244
|
-
const expandColumn = (0,
|
|
8245
|
-
const renderCellContent = (0,
|
|
8266
|
+
const expandColumn = (0, import_react27.useMemo)(() => readyColumns.find((column) => column.type === "expand"), [readyColumns]);
|
|
8267
|
+
const renderCellContent = (0, import_react27.useCallback)(
|
|
8246
8268
|
(column, item, itemIndex) => {
|
|
8247
8269
|
switch (column.type) {
|
|
8248
8270
|
case "text": {
|
|
@@ -8297,7 +8319,7 @@ var TableComponent = (0, import_react26.forwardRef)(function Table({
|
|
|
8297
8319
|
},
|
|
8298
8320
|
[theme2, checkedItems, expandedRows]
|
|
8299
8321
|
);
|
|
8300
|
-
const onClickRowElement = (0,
|
|
8322
|
+
const onClickRowElement = (0, import_react27.useCallback)(
|
|
8301
8323
|
(item, index) => {
|
|
8302
8324
|
if (expandColumn) {
|
|
8303
8325
|
setExpandedRows((oldValue) => {
|
|
@@ -8314,14 +8336,14 @@ var TableComponent = (0, import_react26.forwardRef)(function Table({
|
|
|
8314
8336
|
},
|
|
8315
8337
|
[onClickRow, expandColumn]
|
|
8316
8338
|
);
|
|
8317
|
-
const onClickAllCheckboxesElement = (0,
|
|
8339
|
+
const onClickAllCheckboxesElement = (0, import_react27.useCallback)(
|
|
8318
8340
|
(checked) => {
|
|
8319
8341
|
onClickAllCheckboxes?.(checked);
|
|
8320
8342
|
setCheckedItems(data.map(() => checked));
|
|
8321
8343
|
},
|
|
8322
8344
|
[onClickAllCheckboxes, data]
|
|
8323
8345
|
);
|
|
8324
|
-
const onClickFilterButton = (0,
|
|
8346
|
+
const onClickFilterButton = (0, import_react27.useCallback)(
|
|
8325
8347
|
(columnIndex) => {
|
|
8326
8348
|
const thisFilterData = filterData[columnIndex];
|
|
8327
8349
|
if (thisFilterData?.type === "number" || thisFilterData?.type === "date" || thisFilterData?.type === "date-time") {
|
|
@@ -8337,12 +8359,12 @@ var TableComponent = (0, import_react26.forwardRef)(function Table({
|
|
|
8337
8359
|
},
|
|
8338
8360
|
[filterData]
|
|
8339
8361
|
);
|
|
8340
|
-
const onCloseFilterModal = (0,
|
|
8362
|
+
const onCloseFilterModal = (0, import_react27.useCallback)(() => {
|
|
8341
8363
|
setTimeout(() => setOpenedFilterColumnIndex(void 0), 0.2 * 1e3);
|
|
8342
8364
|
setFilterListSelectedItems(void 0);
|
|
8343
8365
|
filterForm.reset();
|
|
8344
8366
|
}, []);
|
|
8345
|
-
const onClickCancelFormFilter = (0,
|
|
8367
|
+
const onClickCancelFormFilter = (0, import_react27.useCallback)(() => {
|
|
8346
8368
|
if (openedFilterColumnIndex === void 0) return;
|
|
8347
8369
|
setFilterData(
|
|
8348
8370
|
(oldValue) => Object.entries({
|
|
@@ -8355,7 +8377,7 @@ var TableComponent = (0, import_react26.forwardRef)(function Table({
|
|
|
8355
8377
|
);
|
|
8356
8378
|
filterModalRef.current?.close();
|
|
8357
8379
|
}, [openedFilterColumnIndex]);
|
|
8358
|
-
const onClickFilterListItem = (0,
|
|
8380
|
+
const onClickFilterListItem = (0, import_react27.useCallback)(
|
|
8359
8381
|
(value) => setFilterListSelectedItems((oldValue) => {
|
|
8360
8382
|
if (!oldValue) return [value];
|
|
8361
8383
|
if (oldValue.includes(value)) return oldValue.filter((item) => item !== value);
|
|
@@ -8363,7 +8385,7 @@ var TableComponent = (0, import_react26.forwardRef)(function Table({
|
|
|
8363
8385
|
}),
|
|
8364
8386
|
[]
|
|
8365
8387
|
);
|
|
8366
|
-
const onClickFilterPreset = (0,
|
|
8388
|
+
const onClickFilterPreset = (0, import_react27.useCallback)(
|
|
8367
8389
|
(preset) => {
|
|
8368
8390
|
const getValueForDate = (date) => {
|
|
8369
8391
|
if (openedFilterColumn?.filter === "date") return date.toISOString().split("T")[0];
|
|
@@ -8448,7 +8470,7 @@ var TableComponent = (0, import_react26.forwardRef)(function Table({
|
|
|
8448
8470
|
},
|
|
8449
8471
|
[openedFilterColumn]
|
|
8450
8472
|
);
|
|
8451
|
-
const renderExpandedRow = (0,
|
|
8473
|
+
const renderExpandedRow = (0, import_react27.useCallback)(
|
|
8452
8474
|
(...props2) => {
|
|
8453
8475
|
const expandColumn2 = readyColumns.find((column) => column.type === "expand");
|
|
8454
8476
|
if (!expandColumn2) return;
|
|
@@ -8456,7 +8478,7 @@ var TableComponent = (0, import_react26.forwardRef)(function Table({
|
|
|
8456
8478
|
},
|
|
8457
8479
|
[readyColumns]
|
|
8458
8480
|
);
|
|
8459
|
-
const dataAfterFilter = (0,
|
|
8481
|
+
const dataAfterFilter = (0, import_react27.useMemo)(
|
|
8460
8482
|
() => data.filter(
|
|
8461
8483
|
(item) => Object.entries(filterData).every(([columnIndex, filter]) => {
|
|
8462
8484
|
if (!filter) return true;
|
|
@@ -8477,7 +8499,7 @@ var TableComponent = (0, import_react26.forwardRef)(function Table({
|
|
|
8477
8499
|
if (filter.min !== void 0 && minDate && itemValue < minDate) return false;
|
|
8478
8500
|
if (filter.max !== void 0 && maxDate && itemValue > maxDate) return false;
|
|
8479
8501
|
} else if (column.filter === "list" && filter.type === "list") {
|
|
8480
|
-
const itemValue = column.
|
|
8502
|
+
const itemValue = column.getItemValue?.(item) ?? (column.type === "text" && column.keyName ? String(item[column.keyName]) : "");
|
|
8481
8503
|
if (!filter.list?.includes(itemValue)) return false;
|
|
8482
8504
|
}
|
|
8483
8505
|
return true;
|
|
@@ -8485,57 +8507,42 @@ var TableComponent = (0, import_react26.forwardRef)(function Table({
|
|
|
8485
8507
|
),
|
|
8486
8508
|
[data, filterData]
|
|
8487
8509
|
);
|
|
8488
|
-
const dataAfterPagination = (0,
|
|
8510
|
+
const dataAfterPagination = (0, import_react27.useMemo)(() => {
|
|
8489
8511
|
if (pageSize === void 0) return dataAfterFilter;
|
|
8490
8512
|
if (pageCount !== void 0) return dataAfterFilter;
|
|
8491
8513
|
const pageStartItemIndex = (currentPage - 1) * (pageSize ?? 0);
|
|
8492
8514
|
const pageEndItemIndex = pageStartItemIndex + (pageSize ?? 0);
|
|
8493
8515
|
return dataAfterFilter.slice(pageStartItemIndex, pageEndItemIndex);
|
|
8494
8516
|
}, [dataAfterFilter, pageSize, currentPage, pageCount]);
|
|
8495
|
-
const everythingIsChecked = (0,
|
|
8517
|
+
const everythingIsChecked = (0, import_react27.useMemo)(() => {
|
|
8496
8518
|
return data.length > 0 && checkedItems.every((checked) => checked) && checkedItems.length === data.length;
|
|
8497
8519
|
}, [data, checkedItems]);
|
|
8498
|
-
const possibleFilterListValues = (0,
|
|
8499
|
-
if (!openedFilterColumn) return [];
|
|
8500
|
-
return
|
|
8501
|
-
|
|
8502
|
-
|
|
8503
|
-
|
|
8504
|
-
|
|
8505
|
-
|
|
8506
|
-
|
|
8507
|
-
|
|
8508
|
-
|
|
8509
|
-
|
|
8510
|
-
previousValue = previousValue.map(
|
|
8511
|
-
(item) => item.value === value ? {
|
|
8512
|
-
...item,
|
|
8513
|
-
count: item.count + 1
|
|
8514
|
-
} : item
|
|
8515
|
-
);
|
|
8516
|
-
} else
|
|
8517
|
-
previousValue.push({
|
|
8518
|
-
label: label?.toString() ?? "",
|
|
8519
|
-
value,
|
|
8520
|
-
count: 1
|
|
8521
|
-
});
|
|
8522
|
-
}
|
|
8523
|
-
return previousValue;
|
|
8524
|
-
}, []);
|
|
8520
|
+
const possibleFilterListValues = (0, import_react27.useMemo)(() => {
|
|
8521
|
+
if (!openedFilterColumn || openedFilterColumn.filter !== "list") return [];
|
|
8522
|
+
return openedFilterColumn.list.filter((item) => item !== void 0).map((item) => ({
|
|
8523
|
+
...item,
|
|
8524
|
+
count: data.reduce((previousValue, currentValue) => {
|
|
8525
|
+
const value = openedFilterColumn.getItemValue?.(currentValue) ?? (openedFilterColumn.type === "text" && openedFilterColumn.keyName ? String(currentValue[openedFilterColumn.keyName]) : "");
|
|
8526
|
+
return previousValue + (item.value === value ? 1 : 0);
|
|
8527
|
+
}, 0)
|
|
8528
|
+
})).reduce(
|
|
8529
|
+
(previousValue, currentValue) => !previousValue.some((item) => item.value === currentValue.value) ? [...previousValue, currentValue] : previousValue,
|
|
8530
|
+
[]
|
|
8531
|
+
);
|
|
8525
8532
|
}, [data, openedFilterColumn, filterForm.values.search]);
|
|
8526
8533
|
const pageCountInternal = pageCount ?? (pageSize !== void 0 ? Math.ceil(dataAfterFilter.length / pageSize) : 1);
|
|
8527
|
-
const onClickSelectAllFilterListItems = (0,
|
|
8534
|
+
const onClickSelectAllFilterListItems = (0, import_react27.useCallback)(
|
|
8528
8535
|
() => setFilterListSelectedItems(possibleFilterListValues.map((item) => item.value)),
|
|
8529
8536
|
[possibleFilterListValues]
|
|
8530
8537
|
);
|
|
8531
|
-
const onClickDeselectAllFilterListItems = (0,
|
|
8532
|
-
(0,
|
|
8538
|
+
const onClickDeselectAllFilterListItems = (0, import_react27.useCallback)(() => setFilterListSelectedItems([]), []);
|
|
8539
|
+
(0, import_react27.useEffect)(() => {
|
|
8533
8540
|
onChangePage?.(currentPage);
|
|
8534
8541
|
}, [onChangePage, currentPage]);
|
|
8535
|
-
(0,
|
|
8542
|
+
(0, import_react27.useEffect)(() => {
|
|
8536
8543
|
onChangeFilter?.(filterData);
|
|
8537
8544
|
}, [onChangeFilter, filterData]);
|
|
8538
|
-
(0,
|
|
8545
|
+
(0, import_react27.useEffect)(() => {
|
|
8539
8546
|
if (!memoizeFilters) return;
|
|
8540
8547
|
if (!name) return;
|
|
8541
8548
|
localStorage.setItem(
|
|
@@ -8546,10 +8553,10 @@ var TableComponent = (0, import_react26.forwardRef)(function Table({
|
|
|
8546
8553
|
})
|
|
8547
8554
|
);
|
|
8548
8555
|
}, [memoizeFilters, name, filterData]);
|
|
8549
|
-
(0,
|
|
8556
|
+
(0, import_react27.useEffect)(() => {
|
|
8550
8557
|
onChangeFilterDataValue?.(dataAfterFilter);
|
|
8551
8558
|
}, [onChangeFilterDataValue, dataAfterFilter]);
|
|
8552
|
-
(0,
|
|
8559
|
+
(0, import_react27.useImperativeHandle)(
|
|
8553
8560
|
ref,
|
|
8554
8561
|
() => {
|
|
8555
8562
|
return {
|
|
@@ -8623,7 +8630,7 @@ var TableComponent = (0, import_react26.forwardRef)(function Table({
|
|
|
8623
8630
|
)) }) }),
|
|
8624
8631
|
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)("tbody", { children: isLoading ? /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("tr", { className: "withoutHover", children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("td", { className: "noData", colSpan: readyColumns.length, children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(Loader_default.box, {}) }) }) : dataAfterPagination.length > 0 ? dataAfterPagination.map((item, rowIndex) => {
|
|
8625
8632
|
const realRowIndex = rowIndex + (pageSize ? (currentPage - 1) * pageSize : 0);
|
|
8626
|
-
return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(
|
|
8633
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(import_react27.Fragment, { children: [
|
|
8627
8634
|
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
8628
8635
|
"tr",
|
|
8629
8636
|
{
|
|
@@ -8814,11 +8821,11 @@ var TableComponent = (0, import_react26.forwardRef)(function Table({
|
|
|
8814
8821
|
)
|
|
8815
8822
|
] });
|
|
8816
8823
|
});
|
|
8817
|
-
var Table2 = (0,
|
|
8824
|
+
var Table2 = (0, import_react27.memo)(TableComponent);
|
|
8818
8825
|
var Table_default = Table2;
|
|
8819
8826
|
|
|
8820
8827
|
// src/components/Tooltip.tsx
|
|
8821
|
-
var
|
|
8828
|
+
var import_react28 = require("react");
|
|
8822
8829
|
var import_styled_components14 = __toESM(require("styled-components"));
|
|
8823
8830
|
var import_jsx_runtime25 = require("react/jsx-runtime");
|
|
8824
8831
|
var tooltipContainerStyle = (props) => ({
|
|
@@ -8922,10 +8929,10 @@ var arrowStyle = (props, borderWidth) => ({
|
|
|
8922
8929
|
transform: !borderWidth && props.align === "center" ? "translateY(-50%);" : void 0
|
|
8923
8930
|
}
|
|
8924
8931
|
});
|
|
8925
|
-
var Arrow = (0,
|
|
8932
|
+
var Arrow = (0, import_react28.memo)(function Arrow2(props) {
|
|
8926
8933
|
const theme2 = useTheme();
|
|
8927
8934
|
const { position, size } = props;
|
|
8928
|
-
const outerProps = (0,
|
|
8935
|
+
const outerProps = (0, import_react28.useMemo)(
|
|
8929
8936
|
() => ({
|
|
8930
8937
|
...props,
|
|
8931
8938
|
color: theme2.colors.border
|
|
@@ -8954,7 +8961,7 @@ var Arrow = (0, import_react27.memo)(function Arrow2(props) {
|
|
|
8954
8961
|
}
|
|
8955
8962
|
);
|
|
8956
8963
|
});
|
|
8957
|
-
var TooltipComponent = (0,
|
|
8964
|
+
var TooltipComponent = (0, import_react28.forwardRef)(function Tooltip({
|
|
8958
8965
|
position = "bottom",
|
|
8959
8966
|
trigger = "hover",
|
|
8960
8967
|
align = "center",
|
|
@@ -8975,17 +8982,17 @@ var TooltipComponent = (0, import_react27.forwardRef)(function Tooltip({
|
|
|
8975
8982
|
children
|
|
8976
8983
|
}, ref) {
|
|
8977
8984
|
const theme2 = useTheme();
|
|
8978
|
-
const triggerHolderRef = (0,
|
|
8979
|
-
const contentRef = (0,
|
|
8980
|
-
const tooltipContainerRef = (0,
|
|
8981
|
-
const closeTimerRef = (0,
|
|
8982
|
-
const [isOpen, setIsOpen] = (0,
|
|
8983
|
-
const [isOpenLate, setIsOpenLate] = (0,
|
|
8985
|
+
const triggerHolderRef = (0, import_react28.useRef)(null);
|
|
8986
|
+
const contentRef = (0, import_react28.useRef)(null);
|
|
8987
|
+
const tooltipContainerRef = (0, import_react28.useRef)(null);
|
|
8988
|
+
const closeTimerRef = (0, import_react28.useRef)(void 0);
|
|
8989
|
+
const [isOpen, setIsOpen] = (0, import_react28.useState)(false);
|
|
8990
|
+
const [isOpenLate, setIsOpenLate] = (0, import_react28.useState)(false);
|
|
8984
8991
|
const arrowSize = withArrow ? theme2.styles.gap : 0;
|
|
8985
8992
|
const gap = theme2.styles.gap / 2;
|
|
8986
8993
|
const outsideScreenGap = theme2.styles.gap / 2;
|
|
8987
8994
|
const totalGap = arrowSize + gap;
|
|
8988
|
-
const openTooltip = (0,
|
|
8995
|
+
const openTooltip = (0, import_react28.useCallback)(() => {
|
|
8989
8996
|
if (disabled) return;
|
|
8990
8997
|
if (closeTimerRef.current) clearTimeout(closeTimerRef.current);
|
|
8991
8998
|
setIsOpen(true);
|
|
@@ -9010,18 +9017,18 @@ var TooltipComponent = (0, import_react27.forwardRef)(function Tooltip({
|
|
|
9010
9017
|
}, 1);
|
|
9011
9018
|
onOpen?.();
|
|
9012
9019
|
}, [disabled, onOpen, outsideScreenGap, totalGap]);
|
|
9013
|
-
const closeTooltip = (0,
|
|
9020
|
+
const closeTooltip = (0, import_react28.useCallback)(() => {
|
|
9014
9021
|
setIsOpen(false);
|
|
9015
9022
|
closeTimerRef.current = setTimeout(() => setIsOpenLate(false), 300);
|
|
9016
9023
|
onClose?.();
|
|
9017
9024
|
}, [onClose]);
|
|
9018
|
-
const onMouseEnter = (0,
|
|
9025
|
+
const onMouseEnter = (0, import_react28.useCallback)(() => {
|
|
9019
9026
|
if (trigger === "hover") openTooltip();
|
|
9020
9027
|
}, [trigger, openTooltip]);
|
|
9021
|
-
const onMouseLeave = (0,
|
|
9028
|
+
const onMouseLeave = (0, import_react28.useCallback)(() => {
|
|
9022
9029
|
if (trigger === "hover") closeTooltip();
|
|
9023
9030
|
}, [trigger, closeTooltip]);
|
|
9024
|
-
const onClickHolder = (0,
|
|
9031
|
+
const onClickHolder = (0, import_react28.useCallback)(
|
|
9025
9032
|
(event) => {
|
|
9026
9033
|
if (trigger === "click") {
|
|
9027
9034
|
if (!isOpen) openTooltip();
|
|
@@ -9030,7 +9037,7 @@ var TooltipComponent = (0, import_react27.forwardRef)(function Tooltip({
|
|
|
9030
9037
|
},
|
|
9031
9038
|
[trigger, openTooltip, isOpen, closeTooltip]
|
|
9032
9039
|
);
|
|
9033
|
-
const onClickOutside = (0,
|
|
9040
|
+
const onClickOutside = (0, import_react28.useCallback)(
|
|
9034
9041
|
(event) => {
|
|
9035
9042
|
if (!isOpen) return;
|
|
9036
9043
|
if (trigger !== "click") return;
|
|
@@ -9040,7 +9047,7 @@ var TooltipComponent = (0, import_react27.forwardRef)(function Tooltip({
|
|
|
9040
9047
|
},
|
|
9041
9048
|
[trigger, isOpen, closeTooltip]
|
|
9042
9049
|
);
|
|
9043
|
-
(0,
|
|
9050
|
+
(0, import_react28.useEffect)(() => {
|
|
9044
9051
|
if (trigger === "click") {
|
|
9045
9052
|
document.addEventListener("mousedown", onClickOutside);
|
|
9046
9053
|
return () => {
|
|
@@ -9048,11 +9055,11 @@ var TooltipComponent = (0, import_react27.forwardRef)(function Tooltip({
|
|
|
9048
9055
|
};
|
|
9049
9056
|
}
|
|
9050
9057
|
}, [trigger, onClickOutside]);
|
|
9051
|
-
(0,
|
|
9058
|
+
(0, import_react28.useEffect)(() => {
|
|
9052
9059
|
if (!disabled) return;
|
|
9053
9060
|
closeTooltip();
|
|
9054
9061
|
}, [disabled]);
|
|
9055
|
-
(0,
|
|
9062
|
+
(0, import_react28.useImperativeHandle)(
|
|
9056
9063
|
ref,
|
|
9057
9064
|
() => {
|
|
9058
9065
|
return {
|
|
@@ -9143,7 +9150,7 @@ var TooltipComponent = (0, import_react27.forwardRef)(function Tooltip({
|
|
|
9143
9150
|
}
|
|
9144
9151
|
);
|
|
9145
9152
|
});
|
|
9146
|
-
TooltipComponent.item = (0,
|
|
9153
|
+
TooltipComponent.item = (0, import_react28.forwardRef)(function Item({
|
|
9147
9154
|
icon,
|
|
9148
9155
|
iconColor,
|
|
9149
9156
|
text,
|
|
@@ -9184,11 +9191,11 @@ TooltipComponent.item = (0, import_react27.forwardRef)(function Item({
|
|
|
9184
9191
|
}
|
|
9185
9192
|
);
|
|
9186
9193
|
});
|
|
9187
|
-
TooltipComponent.divider = (0,
|
|
9194
|
+
TooltipComponent.divider = (0, import_react28.forwardRef)(function DividerComponent(props, ref) {
|
|
9188
9195
|
const theme2 = useTheme();
|
|
9189
9196
|
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Divider_default.horizontal, { marginBlock: theme2.styles.gap, ...props, ref });
|
|
9190
9197
|
});
|
|
9191
|
-
TooltipComponent.sectionTitle = (0,
|
|
9198
|
+
TooltipComponent.sectionTitle = (0, import_react28.forwardRef)(function SectionTitle({ text, ...props }, ref) {
|
|
9192
9199
|
const theme2 = useTheme();
|
|
9193
9200
|
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
9194
9201
|
Text_default,
|
|
@@ -9204,26 +9211,26 @@ TooltipComponent.sectionTitle = (0, import_react27.forwardRef)(function SectionT
|
|
|
9204
9211
|
}
|
|
9205
9212
|
);
|
|
9206
9213
|
});
|
|
9207
|
-
var Tooltip2 = (0,
|
|
9214
|
+
var Tooltip2 = (0, import_react28.memo)(TooltipComponent);
|
|
9208
9215
|
Tooltip2.item = TooltipComponent.item;
|
|
9209
9216
|
Tooltip2.divider = TooltipComponent.divider;
|
|
9210
9217
|
Tooltip2.sectionTitle = TooltipComponent.sectionTitle;
|
|
9211
9218
|
var Tooltip_default = Tooltip2;
|
|
9212
9219
|
|
|
9213
9220
|
// src/components/Tabs.tsx
|
|
9214
|
-
var
|
|
9221
|
+
var import_react29 = require("react");
|
|
9215
9222
|
var import_jsx_runtime26 = require("react/jsx-runtime");
|
|
9216
9223
|
var tabBottomLineWidth = 2;
|
|
9217
9224
|
var tabDotSize = 6;
|
|
9218
9225
|
var defaultTabName = "tab";
|
|
9219
|
-
var TabsComponent = (0,
|
|
9226
|
+
var TabsComponent = (0, import_react29.forwardRef)(function Tabs({ tabs, name, accentColor, style = "default", onChange, children, ...props }, ref) {
|
|
9220
9227
|
const reactRouterDomPlugin2 = usePlugin("react-router-dom");
|
|
9221
9228
|
const theme2 = useTheme();
|
|
9222
9229
|
const urlQuery = reactRouterDomPlugin2 ? useUrlQuery() : void 0;
|
|
9223
9230
|
const { colorTheme, componentsState } = useBetterHtmlContextInternal();
|
|
9224
|
-
const firstRenderPassedRef = (0,
|
|
9225
|
-
const tabsRef = (0,
|
|
9226
|
-
const [selectedTab, setSelectedTab] = (0,
|
|
9231
|
+
const firstRenderPassedRef = (0, import_react29.useRef)(false);
|
|
9232
|
+
const tabsRef = (0, import_react29.useRef)({});
|
|
9233
|
+
const [selectedTab, setSelectedTab] = (0, import_react29.useState)(() => {
|
|
9227
9234
|
const selectedTabValue = tabs[0] ?? "";
|
|
9228
9235
|
if (urlQuery) {
|
|
9229
9236
|
const tabQueryValue = urlQuery.getQuery(name ?? defaultTabName);
|
|
@@ -9232,9 +9239,9 @@ var TabsComponent = (0, import_react28.forwardRef)(function Tabs({ tabs, name, a
|
|
|
9232
9239
|
}
|
|
9233
9240
|
return selectedTabValue;
|
|
9234
9241
|
});
|
|
9235
|
-
const [rerenderState, setRerenderState] = (0,
|
|
9242
|
+
const [rerenderState, setRerenderState] = (0, import_react29.useState)(0);
|
|
9236
9243
|
const tabsGap = style === "box" ? theme2.styles.gap / 2 : 0;
|
|
9237
|
-
const onClickTab = (0,
|
|
9244
|
+
const onClickTab = (0, import_react29.useCallback)(
|
|
9238
9245
|
(tab) => {
|
|
9239
9246
|
setSelectedTab(tab);
|
|
9240
9247
|
onChange?.(tab);
|
|
@@ -9246,11 +9253,11 @@ var TabsComponent = (0, import_react28.forwardRef)(function Tabs({ tabs, name, a
|
|
|
9246
9253
|
},
|
|
9247
9254
|
[onChange, name, urlQuery]
|
|
9248
9255
|
);
|
|
9249
|
-
const width = (0,
|
|
9256
|
+
const width = (0, import_react29.useMemo)(
|
|
9250
9257
|
() => tabsRef.current[selectedTab]?.getBoundingClientRect().width ?? 0,
|
|
9251
9258
|
[rerenderState, selectedTab]
|
|
9252
9259
|
);
|
|
9253
|
-
const leftSpacing = (0,
|
|
9260
|
+
const leftSpacing = (0, import_react29.useMemo)(() => {
|
|
9254
9261
|
const selectedTabIndex = tabs.findIndex((tab) => tab === selectedTab);
|
|
9255
9262
|
let spacing = 0;
|
|
9256
9263
|
Object.values(tabsRef.current).forEach((tab, index) => {
|
|
@@ -9258,7 +9265,7 @@ var TabsComponent = (0, import_react28.forwardRef)(function Tabs({ tabs, name, a
|
|
|
9258
9265
|
});
|
|
9259
9266
|
return spacing;
|
|
9260
9267
|
}, [selectedTab, tabs, tabsGap]);
|
|
9261
|
-
(0,
|
|
9268
|
+
(0, import_react29.useEffect)(() => {
|
|
9262
9269
|
const timeout = setTimeout(() => {
|
|
9263
9270
|
setRerenderState(Math.random());
|
|
9264
9271
|
firstRenderPassedRef.current = true;
|
|
@@ -9267,7 +9274,7 @@ var TabsComponent = (0, import_react28.forwardRef)(function Tabs({ tabs, name, a
|
|
|
9267
9274
|
clearTimeout(timeout);
|
|
9268
9275
|
};
|
|
9269
9276
|
}, []);
|
|
9270
|
-
(0,
|
|
9277
|
+
(0, import_react29.useEffect)(() => {
|
|
9271
9278
|
componentsState.tabs.setTabGroups((oldValue) => {
|
|
9272
9279
|
const thisTabGroup = oldValue.find((item) => item.name === (name ?? defaultTabName));
|
|
9273
9280
|
if (thisTabGroup) {
|
|
@@ -9288,20 +9295,20 @@ var TabsComponent = (0, import_react28.forwardRef)(function Tabs({ tabs, name, a
|
|
|
9288
9295
|
}
|
|
9289
9296
|
});
|
|
9290
9297
|
}, [selectedTab, name]);
|
|
9291
|
-
(0,
|
|
9298
|
+
(0, import_react29.useEffect)(() => {
|
|
9292
9299
|
tabsRef.current[selectedTab]?.scrollIntoView({
|
|
9293
9300
|
behavior: firstRenderPassedRef.current ? "smooth" : void 0,
|
|
9294
9301
|
block: "nearest"
|
|
9295
9302
|
});
|
|
9296
9303
|
}, [selectedTab]);
|
|
9297
|
-
(0,
|
|
9304
|
+
(0, import_react29.useEffect)(() => {
|
|
9298
9305
|
return () => {
|
|
9299
9306
|
componentsState.tabs.setTabGroups(
|
|
9300
9307
|
(oldValue) => oldValue.filter((item) => item.name !== (name ?? defaultTabName))
|
|
9301
9308
|
);
|
|
9302
9309
|
};
|
|
9303
9310
|
}, []);
|
|
9304
|
-
(0,
|
|
9311
|
+
(0, import_react29.useImperativeHandle)(
|
|
9305
9312
|
ref,
|
|
9306
9313
|
() => {
|
|
9307
9314
|
return {
|
|
@@ -9382,11 +9389,11 @@ var TabsComponent = (0, import_react28.forwardRef)(function Tabs({ tabs, name, a
|
|
|
9382
9389
|
});
|
|
9383
9390
|
TabsComponent.content = function Content({ tab, tabWithDot, tabsGroupName, isInitialTab, children }) {
|
|
9384
9391
|
const { componentsState } = useBetterHtmlContextInternal();
|
|
9385
|
-
const thisTabGroupData = (0,
|
|
9392
|
+
const thisTabGroupData = (0, import_react29.useMemo)(
|
|
9386
9393
|
() => componentsState.tabs.tabGroups.find((item) => item.name === (tabsGroupName ?? defaultTabName)),
|
|
9387
9394
|
[componentsState.tabs, tabsGroupName]
|
|
9388
9395
|
);
|
|
9389
|
-
(0,
|
|
9396
|
+
(0, import_react29.useEffect)(() => {
|
|
9390
9397
|
if (tabWithDot) {
|
|
9391
9398
|
componentsState.tabs.setTabsWithDots?.((oldValue) => oldValue.includes(tab) ? oldValue : [...oldValue, tab]);
|
|
9392
9399
|
} else {
|
|
@@ -9397,16 +9404,16 @@ TabsComponent.content = function Content({ tab, tabWithDot, tabsGroupName, isIni
|
|
|
9397
9404
|
}, [tabWithDot]);
|
|
9398
9405
|
return (thisTabGroupData ? thisTabGroupData.selectedTab === tab : isInitialTab) ? /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(Div_default, { width: "100%", children }) : void 0;
|
|
9399
9406
|
};
|
|
9400
|
-
var Tabs2 = (0,
|
|
9407
|
+
var Tabs2 = (0, import_react29.memo)(TabsComponent);
|
|
9401
9408
|
Tabs2.content = TabsComponent.content;
|
|
9402
9409
|
var Tabs_default = Tabs2;
|
|
9403
9410
|
|
|
9404
9411
|
// src/components/Foldable.tsx
|
|
9405
|
-
var
|
|
9412
|
+
var import_react30 = require("react");
|
|
9406
9413
|
var import_jsx_runtime27 = require("react/jsx-runtime");
|
|
9407
9414
|
var animationDurationClose = 0.15;
|
|
9408
9415
|
var animationDurationOpen = animationDurationClose * 2;
|
|
9409
|
-
var FoldableComponent = (0,
|
|
9416
|
+
var FoldableComponent = (0, import_react30.forwardRef)(function Foldable({
|
|
9410
9417
|
isOpen: controlledIsOpen,
|
|
9411
9418
|
defaultOpen = false,
|
|
9412
9419
|
title,
|
|
@@ -9426,23 +9433,23 @@ var FoldableComponent = (0, import_react29.forwardRef)(function Foldable({
|
|
|
9426
9433
|
...props
|
|
9427
9434
|
}, ref) {
|
|
9428
9435
|
const theme2 = useTheme();
|
|
9429
|
-
const bodyRef = (0,
|
|
9436
|
+
const bodyRef = (0, import_react30.useRef)(null);
|
|
9430
9437
|
const [internalIsOpen, setInternalIsOpen] = useBooleanState(defaultOpen);
|
|
9431
|
-
const [bodyVirtualHeight, setBodyVirtualHeight] = (0,
|
|
9438
|
+
const [bodyVirtualHeight, setBodyVirtualHeight] = (0, import_react30.useState)();
|
|
9432
9439
|
const isOpen = controlledIsOpen !== void 0 ? controlledIsOpen : internalIsOpen;
|
|
9433
|
-
const open = (0,
|
|
9440
|
+
const open = (0, import_react30.useCallback)(() => {
|
|
9434
9441
|
if (controlledIsOpen === void 0) setInternalIsOpen.setTrue();
|
|
9435
9442
|
onOpenChange?.(true);
|
|
9436
9443
|
}, [controlledIsOpen, onOpenChange]);
|
|
9437
|
-
const close = (0,
|
|
9444
|
+
const close = (0, import_react30.useCallback)(() => {
|
|
9438
9445
|
if (controlledIsOpen === void 0) setInternalIsOpen.setFalse();
|
|
9439
9446
|
onOpenChange?.(false);
|
|
9440
9447
|
}, [controlledIsOpen, onOpenChange]);
|
|
9441
|
-
const toggleOpen = (0,
|
|
9448
|
+
const toggleOpen = (0, import_react30.useCallback)(() => {
|
|
9442
9449
|
if (controlledIsOpen === void 0) setInternalIsOpen.toggle();
|
|
9443
9450
|
onOpenChange?.(!isOpen);
|
|
9444
9451
|
}, [controlledIsOpen, isOpen, onOpenChange]);
|
|
9445
|
-
(0,
|
|
9452
|
+
(0, import_react30.useEffect)(() => {
|
|
9446
9453
|
if (!bodyRef.current) return;
|
|
9447
9454
|
const body = bodyRef.current;
|
|
9448
9455
|
setBodyVirtualHeight(body.scrollHeight * 2);
|
|
@@ -9453,7 +9460,7 @@ var FoldableComponent = (0, import_react29.forwardRef)(function Foldable({
|
|
|
9453
9460
|
clearTimeout(timeout);
|
|
9454
9461
|
};
|
|
9455
9462
|
}, [isOpen]);
|
|
9456
|
-
(0,
|
|
9463
|
+
(0, import_react30.useEffect)(() => {
|
|
9457
9464
|
if (!isOpen) return;
|
|
9458
9465
|
if (!bodyRef.current) return;
|
|
9459
9466
|
const observer = new ResizeObserver(() => {
|
|
@@ -9465,7 +9472,7 @@ var FoldableComponent = (0, import_react29.forwardRef)(function Foldable({
|
|
|
9465
9472
|
observer.disconnect();
|
|
9466
9473
|
};
|
|
9467
9474
|
}, [isOpen]);
|
|
9468
|
-
(0,
|
|
9475
|
+
(0, import_react30.useImperativeHandle)(
|
|
9469
9476
|
ref,
|
|
9470
9477
|
() => {
|
|
9471
9478
|
return {
|
|
@@ -9537,7 +9544,7 @@ var FoldableComponent = (0, import_react29.forwardRef)(function Foldable({
|
|
|
9537
9544
|
)
|
|
9538
9545
|
] });
|
|
9539
9546
|
});
|
|
9540
|
-
FoldableComponent.box = (0,
|
|
9547
|
+
FoldableComponent.box = (0, import_react30.forwardRef)(function Box3({ ...props }, ref) {
|
|
9541
9548
|
const theme2 = useTheme();
|
|
9542
9549
|
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
9543
9550
|
FoldableComponent,
|
|
@@ -9552,23 +9559,23 @@ FoldableComponent.box = (0, import_react29.forwardRef)(function Box3({ ...props
|
|
|
9552
9559
|
}
|
|
9553
9560
|
);
|
|
9554
9561
|
});
|
|
9555
|
-
var Foldable2 = (0,
|
|
9562
|
+
var Foldable2 = (0, import_react30.memo)(FoldableComponent);
|
|
9556
9563
|
Foldable2.box = FoldableComponent.box;
|
|
9557
9564
|
var Foldable_default = Foldable2;
|
|
9558
9565
|
|
|
9559
9566
|
// src/components/SideMenu.tsx
|
|
9560
|
-
var
|
|
9567
|
+
var import_react31 = require("react");
|
|
9561
9568
|
var import_jsx_runtime28 = require("react/jsx-runtime");
|
|
9562
|
-
var sideMenuContext = (0,
|
|
9569
|
+
var sideMenuContext = (0, import_react31.createContext)(void 0);
|
|
9563
9570
|
var SideMenuContextProvider = sideMenuContext.Provider;
|
|
9564
9571
|
var useSideMenuContext = () => {
|
|
9565
|
-
const context = (0,
|
|
9572
|
+
const context = (0, import_react31.useContext)(sideMenuContext);
|
|
9566
9573
|
if (!context) {
|
|
9567
9574
|
throw new Error("`useSideMenuContext` must be used within a `<SideMenuContextProvider>` component");
|
|
9568
9575
|
}
|
|
9569
9576
|
return context;
|
|
9570
9577
|
};
|
|
9571
|
-
var MenuItemComponent = (0,
|
|
9578
|
+
var MenuItemComponent = (0, import_react31.memo)(function MenuItemComponent2({ item, backgroundColor, onClick }) {
|
|
9572
9579
|
const reactRouterDomPlugin2 = usePlugin("react-router-dom");
|
|
9573
9580
|
if (!reactRouterDomPlugin2) {
|
|
9574
9581
|
throw new Error(
|
|
@@ -9583,7 +9590,7 @@ var MenuItemComponent = (0, import_react30.memo)(function MenuItemComponent2({ i
|
|
|
9583
9590
|
const { activeItem, setActiveItem } = useSideMenuContext();
|
|
9584
9591
|
const [isOpened, setIsOpened] = useBooleanState();
|
|
9585
9592
|
const isCollapsed = sideMenuIsCollapsed && !mediaQuery.size1000;
|
|
9586
|
-
const onClickElement = (0,
|
|
9593
|
+
const onClickElement = (0, import_react31.useCallback)(() => {
|
|
9587
9594
|
if (item.disabled) return;
|
|
9588
9595
|
if (!item.children) setActiveItem((oldValue) => oldValue?.href === item.href ? oldValue : void 0);
|
|
9589
9596
|
if (item.children) {
|
|
@@ -9660,7 +9667,7 @@ var MenuItemComponent = (0, import_react30.memo)(function MenuItemComponent2({ i
|
|
|
9660
9667
|
)
|
|
9661
9668
|
}
|
|
9662
9669
|
);
|
|
9663
|
-
(0,
|
|
9670
|
+
(0, import_react31.useEffect)(() => {
|
|
9664
9671
|
if (!item.href) return;
|
|
9665
9672
|
const isActive2 = location.pathname === "/" ? location.pathname === item.href : location.pathname.startsWith(item.href) && item.href !== "/";
|
|
9666
9673
|
if (!isActive2) return;
|
|
@@ -9671,14 +9678,14 @@ var MenuItemComponent = (0, import_react30.memo)(function MenuItemComponent2({ i
|
|
|
9671
9678
|
} : void 0
|
|
9672
9679
|
);
|
|
9673
9680
|
}, [location.pathname]);
|
|
9674
|
-
(0,
|
|
9681
|
+
(0, import_react31.useEffect)(() => {
|
|
9675
9682
|
if (!item.children) return;
|
|
9676
9683
|
const toBeOpened = item.children.some(
|
|
9677
9684
|
(child) => child.href ? location.pathname === "/" ? location.pathname === child.href : location.pathname.startsWith(child.href) && child.href !== "/" : false
|
|
9678
9685
|
);
|
|
9679
9686
|
setIsOpened.setState(toBeOpened);
|
|
9680
9687
|
}, [item]);
|
|
9681
|
-
(0,
|
|
9688
|
+
(0, import_react31.useEffect)(() => {
|
|
9682
9689
|
if (!isCollapsed) return;
|
|
9683
9690
|
setIsOpened.setFalse();
|
|
9684
9691
|
}, [isCollapsed]);
|
|
@@ -9768,13 +9775,13 @@ var SideMenuComponent = function SideMenu({
|
|
|
9768
9775
|
const theme2 = useTheme();
|
|
9769
9776
|
const mediaQuery = useMediaQuery();
|
|
9770
9777
|
const { components, sideMenuIsCollapsed, setSideMenuIsCollapsed, sideMenuIsOpenMobile, setSideMenuIsOpenMobile } = useBetterHtmlContextInternal();
|
|
9771
|
-
const [activeItem, setActiveItem] = (0,
|
|
9772
|
-
const onClickXButton = (0,
|
|
9778
|
+
const [activeItem, setActiveItem] = (0, import_react31.useState)();
|
|
9779
|
+
const onClickXButton = (0, import_react31.useCallback)(() => {
|
|
9773
9780
|
setSideMenuIsOpenMobile.setFalse();
|
|
9774
9781
|
}, []);
|
|
9775
|
-
const readyItems = (0,
|
|
9776
|
-
const readyBottomItems = (0,
|
|
9777
|
-
const contextValue = (0,
|
|
9782
|
+
const readyItems = (0, import_react31.useMemo)(() => items.filter((item) => !item.hidden), [items]);
|
|
9783
|
+
const readyBottomItems = (0, import_react31.useMemo)(() => bottomItems?.filter((item) => !item.hidden), [bottomItems]);
|
|
9784
|
+
const contextValue = (0, import_react31.useMemo)(
|
|
9778
9785
|
() => ({
|
|
9779
9786
|
activeItem,
|
|
9780
9787
|
setActiveItem
|
|
@@ -10039,7 +10046,7 @@ SideMenuComponent.burgerButton = function BurgerButton() {
|
|
|
10039
10046
|
}
|
|
10040
10047
|
);
|
|
10041
10048
|
};
|
|
10042
|
-
var SideMenu2 = (0,
|
|
10049
|
+
var SideMenu2 = (0, import_react31.memo)(SideMenuComponent);
|
|
10043
10050
|
SideMenu2.pageHolder = SideMenuComponent.pageHolder;
|
|
10044
10051
|
SideMenu2.burgerButton = SideMenuComponent.burgerButton;
|
|
10045
10052
|
var SideMenu_default = SideMenu2;
|