react-better-html 1.1.93 → 1.1.95
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 +5 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js +40 -27
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +45 -32
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -4866,7 +4866,7 @@ var Label_default = memo13(Label);
|
|
|
4866
4866
|
|
|
4867
4867
|
// src/components/Dropdown.tsx
|
|
4868
4868
|
import { forwardRef as forwardRef7, memo as memo14, useCallback as useCallback6, useEffect as useEffect5, useMemo as useMemo3, useRef as useRef3, useState as useState4 } from "react";
|
|
4869
|
-
import { jsx as jsx13, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
4869
|
+
import { Fragment as Fragment3, jsx as jsx13, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
4870
4870
|
var DropdownComponent = forwardRef7(function Dropdown({
|
|
4871
4871
|
label,
|
|
4872
4872
|
labelColor,
|
|
@@ -4887,6 +4887,7 @@ var DropdownComponent = forwardRef7(function Dropdown({
|
|
|
4887
4887
|
debounceIsLoading,
|
|
4888
4888
|
debounceMinimumSymbolsRequired,
|
|
4889
4889
|
withoutClearButton,
|
|
4890
|
+
withoutRenderingOptionsWhenClosed,
|
|
4890
4891
|
onChange,
|
|
4891
4892
|
onChangeSearch,
|
|
4892
4893
|
renderOption,
|
|
@@ -4895,6 +4896,7 @@ var DropdownComponent = forwardRef7(function Dropdown({
|
|
|
4895
4896
|
}, ref) {
|
|
4896
4897
|
const theme2 = useTheme();
|
|
4897
4898
|
const inputFieldHolderRef = useRef3(null);
|
|
4899
|
+
const buttonsRef = useRef3(null);
|
|
4898
4900
|
const inputRef = useRef3(null);
|
|
4899
4901
|
const [isOpen, setIsOpen] = useBooleanState();
|
|
4900
4902
|
const [isOpenLate, setIsOpenLate] = useBooleanState();
|
|
@@ -4989,6 +4991,33 @@ var DropdownComponent = forwardRef7(function Dropdown({
|
|
|
4989
4991
|
[withDebounce, onChangeSearch]
|
|
4990
4992
|
);
|
|
4991
4993
|
const selectedOption = useMemo3(() => options.find((option) => option.value === value), [options, value]);
|
|
4994
|
+
const renderedOptions = useMemo3(
|
|
4995
|
+
() => filteredOptions.map((option, index) => {
|
|
4996
|
+
const isSelected = option.value === value;
|
|
4997
|
+
const isDisabled = option.disabled;
|
|
4998
|
+
const isFocused2 = index === focusedOptionIndex;
|
|
4999
|
+
return /* @__PURE__ */ jsx13(
|
|
5000
|
+
Div_default,
|
|
5001
|
+
{
|
|
5002
|
+
color: isDisabled ? theme2.colors.textSecondary + "80" : isSelected ? theme2.colors.base : theme2.colors.textPrimary,
|
|
5003
|
+
backgroundColor: isSelected ? theme2.colors.primary : theme2.colors.backgroundContent,
|
|
5004
|
+
filter: isFocused2 ? isDisabled ? "brightness(0.95)" : "brightness(0.9)" : void 0,
|
|
5005
|
+
filterHover: focusedOptionIndex === void 0 && !isDisabled ? "brightness(0.9)" : void 0,
|
|
5006
|
+
cursor: isDisabled ? "not-allowed" : "pointer",
|
|
5007
|
+
padding: `${theme2.styles.space / 2}px ${theme2.styles.space + theme2.styles.gap}px`,
|
|
5008
|
+
value: option,
|
|
5009
|
+
onClickWithValue: onClickOption,
|
|
5010
|
+
onMouseMove: () => setFocusedOptionIndex(void 0),
|
|
5011
|
+
role: "option",
|
|
5012
|
+
"aria-selected": isSelected,
|
|
5013
|
+
"aria-disabled": isDisabled,
|
|
5014
|
+
children: renderOption ? renderOption(option, index, isSelected) : /* @__PURE__ */ jsx13(Text_default, { children: option.label })
|
|
5015
|
+
},
|
|
5016
|
+
JSON.stringify(option)
|
|
5017
|
+
);
|
|
5018
|
+
}),
|
|
5019
|
+
[filteredOptions, value, focusedOptionIndex, theme2.colors, onClickOption, renderOption]
|
|
5020
|
+
);
|
|
4992
5021
|
useEffect5(() => {
|
|
4993
5022
|
if (isOpen) {
|
|
4994
5023
|
setIsOpenLate.setTrue();
|
|
@@ -5005,7 +5034,7 @@ var DropdownComponent = forwardRef7(function Dropdown({
|
|
|
5005
5034
|
}, [filteredOptions]);
|
|
5006
5035
|
useEffect5(() => {
|
|
5007
5036
|
const handleClickOutside = (event) => {
|
|
5008
|
-
if (inputFieldHolderRef.current && !inputFieldHolderRef.current.contains(event.target)) {
|
|
5037
|
+
if (inputFieldHolderRef.current && buttonsRef.current && !inputFieldHolderRef.current.contains(event.target) && !buttonsRef.current.contains(event.target)) {
|
|
5009
5038
|
setIsOpen.setFalse();
|
|
5010
5039
|
setSearchQuery("");
|
|
5011
5040
|
setFocusedOptionIndex(void 0);
|
|
@@ -5025,7 +5054,7 @@ var DropdownComponent = forwardRef7(function Dropdown({
|
|
|
5025
5054
|
const displayValue = withSearch && isFocused ? searchQuery : selectedOption?.label ?? "";
|
|
5026
5055
|
const withClearButton = isOpen && selectedOption;
|
|
5027
5056
|
const readyPlaceholder = placeholder ? placeholder : `Select an ${label?.toLowerCase() ?? "option"}`;
|
|
5028
|
-
return /* @__PURE__ */ jsx13(Div_default.column, { width: "100%", position: "relative", userSelect: "none", ...props, children: /* @__PURE__ */ jsxs8(Div_default.row, { position: "relative", width: "100%",
|
|
5057
|
+
return /* @__PURE__ */ jsx13(Div_default.column, { width: "100%", position: "relative", userSelect: "none", ...props, children: /* @__PURE__ */ jsxs8(Div_default.row, { position: "relative", width: "100%", children: [
|
|
5029
5058
|
/* @__PURE__ */ jsx13(
|
|
5030
5059
|
InputField_default,
|
|
5031
5060
|
{
|
|
@@ -5070,30 +5099,7 @@ var DropdownComponent = forwardRef7(function Dropdown({
|
|
|
5070
5099
|
transition: theme2.styles.transition,
|
|
5071
5100
|
role: "listbox",
|
|
5072
5101
|
"aria-label": label,
|
|
5073
|
-
children: isLoadingDebouncedSearchQuery || debounceIsLoading ? /* @__PURE__ */ jsx13(Div_default, { padding: `${theme2.styles.space / 2}px ${theme2.styles.space + theme2.styles.gap}px`, children: /* @__PURE__ */ jsx13(Loader_default.text, {}) }) : filteredOptions.length ?
|
|
5074
|
-
const isSelected = option.value === value;
|
|
5075
|
-
const isDisabled = option.disabled;
|
|
5076
|
-
const isFocused2 = index === focusedOptionIndex;
|
|
5077
|
-
return /* @__PURE__ */ jsx13(
|
|
5078
|
-
Div_default,
|
|
5079
|
-
{
|
|
5080
|
-
color: isDisabled ? theme2.colors.textSecondary + "80" : isSelected ? theme2.colors.base : theme2.colors.textPrimary,
|
|
5081
|
-
backgroundColor: isSelected ? theme2.colors.primary : theme2.colors.backgroundContent,
|
|
5082
|
-
filter: isFocused2 ? isDisabled ? "brightness(0.95)" : "brightness(0.9)" : void 0,
|
|
5083
|
-
filterHover: focusedOptionIndex === void 0 && !isDisabled ? "brightness(0.9)" : void 0,
|
|
5084
|
-
cursor: isDisabled ? "not-allowed" : "pointer",
|
|
5085
|
-
padding: `${theme2.styles.space / 2}px ${theme2.styles.space + theme2.styles.gap}px`,
|
|
5086
|
-
value: option,
|
|
5087
|
-
onClickWithValue: onClickOption,
|
|
5088
|
-
onMouseMove: () => setFocusedOptionIndex(void 0),
|
|
5089
|
-
role: "option",
|
|
5090
|
-
"aria-selected": isSelected,
|
|
5091
|
-
"aria-disabled": isDisabled,
|
|
5092
|
-
children: renderOption ? renderOption(option, index, isSelected) : /* @__PURE__ */ jsx13(Text_default, { children: option.label })
|
|
5093
|
-
},
|
|
5094
|
-
JSON.stringify(option)
|
|
5095
|
-
);
|
|
5096
|
-
}) : /* @__PURE__ */ jsx13(Div_default, { padding: `${theme2.styles.space / 2}px ${theme2.styles.space + theme2.styles.gap}px`, children: /* @__PURE__ */ jsx13(Text_default.unknown, { textAlign: "left", children: debounceMinimumSymbolsRequired !== void 0 && searchQuery.length < debounceMinimumSymbolsRequired ? `Enter at least ${debounceMinimumSymbolsRequired} characters` : "No options" }) })
|
|
5102
|
+
children: isLoadingDebouncedSearchQuery || debounceIsLoading ? /* @__PURE__ */ jsx13(Div_default, { padding: `${theme2.styles.space / 2}px ${theme2.styles.space + theme2.styles.gap}px`, children: /* @__PURE__ */ jsx13(Loader_default.text, {}) }) : filteredOptions.length ? /* @__PURE__ */ jsx13(Fragment3, { children: (withoutRenderingOptionsWhenClosed ? isOpen || isOpenLate : true) ? renderedOptions : void 0 }) : /* @__PURE__ */ jsx13(Div_default, { padding: `${theme2.styles.space / 2}px ${theme2.styles.space + theme2.styles.gap}px`, children: /* @__PURE__ */ jsx13(Text_default.unknown, { textAlign: "left", children: debounceMinimumSymbolsRequired !== void 0 && searchQuery.length < debounceMinimumSymbolsRequired ? `Enter at least ${debounceMinimumSymbolsRequired} characters` : "No options" }) })
|
|
5097
5103
|
}
|
|
5098
5104
|
),
|
|
5099
5105
|
role: "combobox",
|
|
@@ -5101,6 +5107,7 @@ var DropdownComponent = forwardRef7(function Dropdown({
|
|
|
5101
5107
|
"aria-controls": "dropdown-list",
|
|
5102
5108
|
"aria-haspopup": "listbox",
|
|
5103
5109
|
"aria-label": label,
|
|
5110
|
+
holderRef: inputFieldHolderRef,
|
|
5104
5111
|
ref: inputRef
|
|
5105
5112
|
}
|
|
5106
5113
|
),
|
|
@@ -5117,6 +5124,7 @@ var DropdownComponent = forwardRef7(function Dropdown({
|
|
|
5117
5124
|
filter: disabled ? "brightness(0.9)" : void 0,
|
|
5118
5125
|
opacity: disabled ? 0.6 : void 0,
|
|
5119
5126
|
zIndex: isOpen || isOpenLate ? 1001 : void 0,
|
|
5127
|
+
ref: buttonsRef,
|
|
5120
5128
|
children: [
|
|
5121
5129
|
!withoutClearButton && /* @__PURE__ */ jsx13(
|
|
5122
5130
|
Button_default.icon,
|
|
@@ -5175,6 +5183,7 @@ DropdownComponent.countries = forwardRef7(function Countries({ ...props }, ref)
|
|
|
5175
5183
|
placeholder: "Select a country",
|
|
5176
5184
|
options,
|
|
5177
5185
|
renderOption,
|
|
5186
|
+
withoutRenderingOptionsWhenClosed: true,
|
|
5178
5187
|
ref,
|
|
5179
5188
|
...props
|
|
5180
5189
|
}
|
|
@@ -6473,7 +6482,7 @@ var ToggleInput_default = {
|
|
|
6473
6482
|
};
|
|
6474
6483
|
|
|
6475
6484
|
// src/components/Form.tsx
|
|
6476
|
-
import { memo as memo17, useMemo as useMemo6 } from "react";
|
|
6485
|
+
import { Children, Fragment as Fragment4, memo as memo17, useMemo as useMemo6 } from "react";
|
|
6477
6486
|
import { jsx as jsx17, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
6478
6487
|
function Form({
|
|
6479
6488
|
form,
|
|
@@ -6485,6 +6494,7 @@ function Form({
|
|
|
6485
6494
|
gap,
|
|
6486
6495
|
isSubmitting,
|
|
6487
6496
|
isDestructive,
|
|
6497
|
+
withDividers,
|
|
6488
6498
|
onClickCancel,
|
|
6489
6499
|
onSubmit,
|
|
6490
6500
|
children,
|
|
@@ -6500,7 +6510,10 @@ function Form({
|
|
|
6500
6510
|
const SubmitButtonTag = isDestructive ? Button_default.destructive : Button_default;
|
|
6501
6511
|
const submitButtonIsDisabledFinal = submitButtonIsDisabled || submitButtonIsDisabledInternal;
|
|
6502
6512
|
return /* @__PURE__ */ jsx17(Div_default, { width: "100%", ...props, children: /* @__PURE__ */ jsxs12("form", { onSubmit: onSubmit ?? form?.onSubmit, children: [
|
|
6503
|
-
gap !== void 0 ? /* @__PURE__ */ jsx17(Div_default.column, { gap, children
|
|
6513
|
+
gap !== void 0 || withDividers ? /* @__PURE__ */ jsx17(Div_default.column, { gap: gap ?? (withDividers ? theme2.styles.space : theme2.styles.gap), children: withDividers ? Children.toArray(children).map((child, index) => /* @__PURE__ */ jsxs12(Fragment4, { children: [
|
|
6514
|
+
child,
|
|
6515
|
+
index < Children.toArray(children).length - 1 && /* @__PURE__ */ jsx17(Divider_default.horizontal, {})
|
|
6516
|
+
] }, index)) : children }) : children,
|
|
6504
6517
|
submitButtonText && /* @__PURE__ */ jsxs12(
|
|
6505
6518
|
Div_default.row,
|
|
6506
6519
|
{
|
|
@@ -6647,7 +6660,7 @@ var ColorThemeSwitch_default = ColorThemeSwitch2;
|
|
|
6647
6660
|
// src/components/Table.tsx
|
|
6648
6661
|
import { forwardRef as forwardRef11, memo as memo20, useCallback as useCallback10, useMemo as useMemo7, useState as useState8 } from "react";
|
|
6649
6662
|
import styled10, { css as css2 } from "styled-components";
|
|
6650
|
-
import { Fragment as
|
|
6663
|
+
import { Fragment as Fragment5, jsx as jsx20, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
6651
6664
|
var defaultImageWidth = 120;
|
|
6652
6665
|
var TableStyledComponent = styled10.table.withConfig({
|
|
6653
6666
|
shouldForwardProp: (prop) => !["isStriped", "withHover", "withStickyHeader", "colorTheme", "theme"].includes(prop)
|
|
@@ -6734,7 +6747,7 @@ var TableComponent = forwardRef11(function Table({
|
|
|
6734
6747
|
return column.format ? column.format(item, index) : String(value ?? "");
|
|
6735
6748
|
}
|
|
6736
6749
|
case "element": {
|
|
6737
|
-
return column.render?.(item, index) ?? /* @__PURE__ */ jsx20(
|
|
6750
|
+
return column.render?.(item, index) ?? /* @__PURE__ */ jsx20(Fragment5, {});
|
|
6738
6751
|
}
|
|
6739
6752
|
case "image": {
|
|
6740
6753
|
const { type, keyName, ...props2 } = column;
|
|
@@ -6759,7 +6772,7 @@ var TableComponent = forwardRef11(function Table({
|
|
|
6759
6772
|
);
|
|
6760
6773
|
}
|
|
6761
6774
|
default: {
|
|
6762
|
-
return /* @__PURE__ */ jsx20(
|
|
6775
|
+
return /* @__PURE__ */ jsx20(Fragment5, {});
|
|
6763
6776
|
}
|
|
6764
6777
|
}
|
|
6765
6778
|
},
|