react-better-html 1.1.92 → 1.1.94
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 +4 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +87 -27
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +91 -31
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -381,6 +381,7 @@ type InputFieldComponentType = {
|
|
|
381
381
|
maxDate?: Date;
|
|
382
382
|
}>) => React.ReactElement;
|
|
383
383
|
time: (props: ComponentPropWithRef<HTMLInputElement, InputFieldProps>) => React.ReactElement;
|
|
384
|
+
color: (props: ComponentPropWithRef<HTMLInputElement, InputFieldProps>) => React.ReactElement;
|
|
384
385
|
};
|
|
385
386
|
declare const InputFieldComponent: InputFieldComponentType;
|
|
386
387
|
declare const InputField: typeof InputFieldComponent & {
|
|
@@ -392,6 +393,7 @@ declare const InputField: typeof InputFieldComponent & {
|
|
|
392
393
|
date: typeof InputFieldComponent.date;
|
|
393
394
|
dateTime: typeof InputFieldComponent.dateTime;
|
|
394
395
|
time: typeof InputFieldComponent.time;
|
|
396
|
+
color: typeof InputFieldComponent.color;
|
|
395
397
|
};
|
|
396
398
|
|
|
397
399
|
type Country = {
|
|
@@ -437,6 +439,8 @@ type DropdownProps<Value, Data = unknown> = {
|
|
|
437
439
|
debounceMinimumSymbolsRequired?: number;
|
|
438
440
|
/** @default false */
|
|
439
441
|
withoutClearButton?: boolean;
|
|
442
|
+
/** @default false */
|
|
443
|
+
withoutRenderingOptionsWhenClosed?: boolean;
|
|
440
444
|
onChange?: (value: Value | undefined) => void;
|
|
441
445
|
onChangeSearch?: (query: string) => void;
|
|
442
446
|
renderOption?: (option: DropdownOption<Value, Data>, index: number, isSelected: boolean) => React.ReactNode;
|
package/dist/index.d.ts
CHANGED
|
@@ -381,6 +381,7 @@ type InputFieldComponentType = {
|
|
|
381
381
|
maxDate?: Date;
|
|
382
382
|
}>) => React.ReactElement;
|
|
383
383
|
time: (props: ComponentPropWithRef<HTMLInputElement, InputFieldProps>) => React.ReactElement;
|
|
384
|
+
color: (props: ComponentPropWithRef<HTMLInputElement, InputFieldProps>) => React.ReactElement;
|
|
384
385
|
};
|
|
385
386
|
declare const InputFieldComponent: InputFieldComponentType;
|
|
386
387
|
declare const InputField: typeof InputFieldComponent & {
|
|
@@ -392,6 +393,7 @@ declare const InputField: typeof InputFieldComponent & {
|
|
|
392
393
|
date: typeof InputFieldComponent.date;
|
|
393
394
|
dateTime: typeof InputFieldComponent.dateTime;
|
|
394
395
|
time: typeof InputFieldComponent.time;
|
|
396
|
+
color: typeof InputFieldComponent.color;
|
|
395
397
|
};
|
|
396
398
|
|
|
397
399
|
type Country = {
|
|
@@ -437,6 +439,8 @@ type DropdownProps<Value, Data = unknown> = {
|
|
|
437
439
|
debounceMinimumSymbolsRequired?: number;
|
|
438
440
|
/** @default false */
|
|
439
441
|
withoutClearButton?: boolean;
|
|
442
|
+
/** @default false */
|
|
443
|
+
withoutRenderingOptionsWhenClosed?: boolean;
|
|
440
444
|
onChange?: (value: Value | undefined) => void;
|
|
441
445
|
onChangeSearch?: (query: string) => void;
|
|
442
446
|
renderOption?: (option: DropdownOption<Value, Data>, index: number, isSelected: boolean) => React.ReactNode;
|
package/dist/index.js
CHANGED
|
@@ -1882,7 +1882,7 @@ function useComponentInputFieldDateProps(props, holderRef, disabled) {
|
|
|
1882
1882
|
}, [isOpen]);
|
|
1883
1883
|
(0, import_react2.useEffect)(() => {
|
|
1884
1884
|
const handleClickOutside = (event) => {
|
|
1885
|
-
if (holderRef.current && !holderRef.current.contains(event.target)) {
|
|
1885
|
+
if (holderRef && holderRef.current && !holderRef.current.contains(event.target)) {
|
|
1886
1886
|
setIsOpen.setFalse();
|
|
1887
1887
|
}
|
|
1888
1888
|
};
|
|
@@ -4925,6 +4925,7 @@ function Label({ text, required, isError, color, htmlFor }) {
|
|
|
4925
4925
|
Text_default,
|
|
4926
4926
|
{
|
|
4927
4927
|
as: "label",
|
|
4928
|
+
width: "fit-content",
|
|
4928
4929
|
height: 16,
|
|
4929
4930
|
fontSize: 14,
|
|
4930
4931
|
color: isError ? theme2.colors.error : color ?? theme2.colors.textSecondary,
|
|
@@ -4965,6 +4966,7 @@ var DropdownComponent = (0, import_react16.forwardRef)(function Dropdown({
|
|
|
4965
4966
|
debounceIsLoading,
|
|
4966
4967
|
debounceMinimumSymbolsRequired,
|
|
4967
4968
|
withoutClearButton,
|
|
4969
|
+
withoutRenderingOptionsWhenClosed,
|
|
4968
4970
|
onChange,
|
|
4969
4971
|
onChangeSearch,
|
|
4970
4972
|
renderOption,
|
|
@@ -4973,6 +4975,7 @@ var DropdownComponent = (0, import_react16.forwardRef)(function Dropdown({
|
|
|
4973
4975
|
}, ref) {
|
|
4974
4976
|
const theme2 = useTheme();
|
|
4975
4977
|
const inputFieldHolderRef = (0, import_react16.useRef)(null);
|
|
4978
|
+
const buttonsRef = (0, import_react16.useRef)(null);
|
|
4976
4979
|
const inputRef = (0, import_react16.useRef)(null);
|
|
4977
4980
|
const [isOpen, setIsOpen] = useBooleanState();
|
|
4978
4981
|
const [isOpenLate, setIsOpenLate] = useBooleanState();
|
|
@@ -5067,6 +5070,33 @@ var DropdownComponent = (0, import_react16.forwardRef)(function Dropdown({
|
|
|
5067
5070
|
[withDebounce, onChangeSearch]
|
|
5068
5071
|
);
|
|
5069
5072
|
const selectedOption = (0, import_react16.useMemo)(() => options.find((option) => option.value === value), [options, value]);
|
|
5073
|
+
const renderedOptions = (0, import_react16.useMemo)(
|
|
5074
|
+
() => filteredOptions.map((option, index) => {
|
|
5075
|
+
const isSelected = option.value === value;
|
|
5076
|
+
const isDisabled = option.disabled;
|
|
5077
|
+
const isFocused2 = index === focusedOptionIndex;
|
|
5078
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
5079
|
+
Div_default,
|
|
5080
|
+
{
|
|
5081
|
+
color: isDisabled ? theme2.colors.textSecondary + "80" : isSelected ? theme2.colors.base : theme2.colors.textPrimary,
|
|
5082
|
+
backgroundColor: isSelected ? theme2.colors.primary : theme2.colors.backgroundContent,
|
|
5083
|
+
filter: isFocused2 ? isDisabled ? "brightness(0.95)" : "brightness(0.9)" : void 0,
|
|
5084
|
+
filterHover: focusedOptionIndex === void 0 && !isDisabled ? "brightness(0.9)" : void 0,
|
|
5085
|
+
cursor: isDisabled ? "not-allowed" : "pointer",
|
|
5086
|
+
padding: `${theme2.styles.space / 2}px ${theme2.styles.space + theme2.styles.gap}px`,
|
|
5087
|
+
value: option,
|
|
5088
|
+
onClickWithValue: onClickOption,
|
|
5089
|
+
onMouseMove: () => setFocusedOptionIndex(void 0),
|
|
5090
|
+
role: "option",
|
|
5091
|
+
"aria-selected": isSelected,
|
|
5092
|
+
"aria-disabled": isDisabled,
|
|
5093
|
+
children: renderOption ? renderOption(option, index, isSelected) : /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Text_default, { children: option.label })
|
|
5094
|
+
},
|
|
5095
|
+
JSON.stringify(option)
|
|
5096
|
+
);
|
|
5097
|
+
}),
|
|
5098
|
+
[filteredOptions, value, focusedOptionIndex, theme2.colors, onClickOption, renderOption]
|
|
5099
|
+
);
|
|
5070
5100
|
(0, import_react16.useEffect)(() => {
|
|
5071
5101
|
if (isOpen) {
|
|
5072
5102
|
setIsOpenLate.setTrue();
|
|
@@ -5083,7 +5113,7 @@ var DropdownComponent = (0, import_react16.forwardRef)(function Dropdown({
|
|
|
5083
5113
|
}, [filteredOptions]);
|
|
5084
5114
|
(0, import_react16.useEffect)(() => {
|
|
5085
5115
|
const handleClickOutside = (event) => {
|
|
5086
|
-
if (inputFieldHolderRef.current && !inputFieldHolderRef.current.contains(event.target)) {
|
|
5116
|
+
if (inputFieldHolderRef.current && buttonsRef.current && !inputFieldHolderRef.current.contains(event.target) && !buttonsRef.current.contains(event.target)) {
|
|
5087
5117
|
setIsOpen.setFalse();
|
|
5088
5118
|
setSearchQuery("");
|
|
5089
5119
|
setFocusedOptionIndex(void 0);
|
|
@@ -5103,7 +5133,7 @@ var DropdownComponent = (0, import_react16.forwardRef)(function Dropdown({
|
|
|
5103
5133
|
const displayValue = withSearch && isFocused ? searchQuery : selectedOption?.label ?? "";
|
|
5104
5134
|
const withClearButton = isOpen && selectedOption;
|
|
5105
5135
|
const readyPlaceholder = placeholder ? placeholder : `Select an ${label?.toLowerCase() ?? "option"}`;
|
|
5106
|
-
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Div_default.column, { width: "100%", position: "relative", userSelect: "none", ...props, children: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(Div_default.row, { position: "relative", width: "100%",
|
|
5136
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Div_default.column, { width: "100%", position: "relative", userSelect: "none", ...props, children: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(Div_default.row, { position: "relative", width: "100%", children: [
|
|
5107
5137
|
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
5108
5138
|
InputField_default,
|
|
5109
5139
|
{
|
|
@@ -5148,30 +5178,7 @@ var DropdownComponent = (0, import_react16.forwardRef)(function Dropdown({
|
|
|
5148
5178
|
transition: theme2.styles.transition,
|
|
5149
5179
|
role: "listbox",
|
|
5150
5180
|
"aria-label": label,
|
|
5151
|
-
children: isLoadingDebouncedSearchQuery || debounceIsLoading ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Div_default, { padding: `${theme2.styles.space / 2}px ${theme2.styles.space + theme2.styles.gap}px`, children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Loader_default.text, {}) }) : filteredOptions.length ?
|
|
5152
|
-
const isSelected = option.value === value;
|
|
5153
|
-
const isDisabled = option.disabled;
|
|
5154
|
-
const isFocused2 = index === focusedOptionIndex;
|
|
5155
|
-
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
5156
|
-
Div_default,
|
|
5157
|
-
{
|
|
5158
|
-
color: isDisabled ? theme2.colors.textSecondary + "80" : isSelected ? theme2.colors.base : theme2.colors.textPrimary,
|
|
5159
|
-
backgroundColor: isSelected ? theme2.colors.primary : theme2.colors.backgroundContent,
|
|
5160
|
-
filter: isFocused2 ? isDisabled ? "brightness(0.95)" : "brightness(0.9)" : void 0,
|
|
5161
|
-
filterHover: focusedOptionIndex === void 0 && !isDisabled ? "brightness(0.9)" : void 0,
|
|
5162
|
-
cursor: isDisabled ? "not-allowed" : "pointer",
|
|
5163
|
-
padding: `${theme2.styles.space / 2}px ${theme2.styles.space + theme2.styles.gap}px`,
|
|
5164
|
-
value: option,
|
|
5165
|
-
onClickWithValue: onClickOption,
|
|
5166
|
-
onMouseMove: () => setFocusedOptionIndex(void 0),
|
|
5167
|
-
role: "option",
|
|
5168
|
-
"aria-selected": isSelected,
|
|
5169
|
-
"aria-disabled": isDisabled,
|
|
5170
|
-
children: renderOption ? renderOption(option, index, isSelected) : /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Text_default, { children: option.label })
|
|
5171
|
-
},
|
|
5172
|
-
JSON.stringify(option)
|
|
5173
|
-
);
|
|
5174
|
-
}) : /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Div_default, { padding: `${theme2.styles.space / 2}px ${theme2.styles.space + theme2.styles.gap}px`, children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Text_default.unknown, { textAlign: "left", children: debounceMinimumSymbolsRequired !== void 0 && searchQuery.length < debounceMinimumSymbolsRequired ? `Enter at least ${debounceMinimumSymbolsRequired} characters` : "No options" }) })
|
|
5181
|
+
children: isLoadingDebouncedSearchQuery || debounceIsLoading ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Div_default, { padding: `${theme2.styles.space / 2}px ${theme2.styles.space + theme2.styles.gap}px`, children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Loader_default.text, {}) }) : filteredOptions.length ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_jsx_runtime14.Fragment, { children: (withoutRenderingOptionsWhenClosed ? isOpen || isOpenLate : true) ? renderedOptions : void 0 }) : /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Div_default, { padding: `${theme2.styles.space / 2}px ${theme2.styles.space + theme2.styles.gap}px`, children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Text_default.unknown, { textAlign: "left", children: debounceMinimumSymbolsRequired !== void 0 && searchQuery.length < debounceMinimumSymbolsRequired ? `Enter at least ${debounceMinimumSymbolsRequired} characters` : "No options" }) })
|
|
5175
5182
|
}
|
|
5176
5183
|
),
|
|
5177
5184
|
role: "combobox",
|
|
@@ -5179,6 +5186,7 @@ var DropdownComponent = (0, import_react16.forwardRef)(function Dropdown({
|
|
|
5179
5186
|
"aria-controls": "dropdown-list",
|
|
5180
5187
|
"aria-haspopup": "listbox",
|
|
5181
5188
|
"aria-label": label,
|
|
5189
|
+
holderRef: inputFieldHolderRef,
|
|
5182
5190
|
ref: inputRef
|
|
5183
5191
|
}
|
|
5184
5192
|
),
|
|
@@ -5195,6 +5203,7 @@ var DropdownComponent = (0, import_react16.forwardRef)(function Dropdown({
|
|
|
5195
5203
|
filter: disabled ? "brightness(0.9)" : void 0,
|
|
5196
5204
|
opacity: disabled ? 0.6 : void 0,
|
|
5197
5205
|
zIndex: isOpen || isOpenLate ? 1001 : void 0,
|
|
5206
|
+
ref: buttonsRef,
|
|
5198
5207
|
children: [
|
|
5199
5208
|
!withoutClearButton && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
5200
5209
|
Button_default.icon,
|
|
@@ -5253,6 +5262,7 @@ DropdownComponent.countries = (0, import_react16.forwardRef)(function Countries(
|
|
|
5253
5262
|
placeholder: "Select a country",
|
|
5254
5263
|
options,
|
|
5255
5264
|
renderOption,
|
|
5265
|
+
withoutRenderingOptionsWhenClosed: true,
|
|
5256
5266
|
ref,
|
|
5257
5267
|
...props
|
|
5258
5268
|
}
|
|
@@ -5444,6 +5454,9 @@ var Calendar_default = (0, import_react17.memo)(Calendar);
|
|
|
5444
5454
|
// src/components/InputField.tsx
|
|
5445
5455
|
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
5446
5456
|
var buttonWidth = 50;
|
|
5457
|
+
var colorPickerSpacing = 4;
|
|
5458
|
+
var colorPickerColorWidth = 12 + 27 + colorPickerSpacing;
|
|
5459
|
+
var colorPickerValueWidth = 12 + 74 + colorPickerSpacing;
|
|
5447
5460
|
var InputElement = import_styled_components9.default.input.withConfig({
|
|
5448
5461
|
shouldForwardProp: (prop) => !["theme", "withLeftIcon", "withRightIcon", "normalStyle", "hoverStyle"].includes(prop)
|
|
5449
5462
|
})`
|
|
@@ -5492,6 +5505,17 @@ var InputElement = import_styled_components9.default.input.withConfig({
|
|
|
5492
5505
|
}
|
|
5493
5506
|
}
|
|
5494
5507
|
|
|
5508
|
+
&[type="color"] {
|
|
5509
|
+
--color-spacing: ${(props) => (props.theme.styles.space + props.theme.styles.gap) / 2}px;
|
|
5510
|
+
|
|
5511
|
+
width: calc(var(--color-spacing) + 27px + ${colorPickerValueWidth}px);
|
|
5512
|
+
height: 48px;
|
|
5513
|
+
padding: 0px;
|
|
5514
|
+
padding-block: calc(var(--color-spacing) - 3px);
|
|
5515
|
+
padding-left: var(--color-spacing);
|
|
5516
|
+
padding-right: ${colorPickerValueWidth}px;
|
|
5517
|
+
}
|
|
5518
|
+
|
|
5495
5519
|
&.react-better-html-phone-number-holder {
|
|
5496
5520
|
border-right: none;
|
|
5497
5521
|
border-top-right-radius: 0px;
|
|
@@ -6204,6 +6228,41 @@ InputFieldComponent.time = (0, import_react18.forwardRef)(function Time({ ...pro
|
|
|
6204
6228
|
}
|
|
6205
6229
|
);
|
|
6206
6230
|
});
|
|
6231
|
+
InputFieldComponent.color = (0, import_react18.forwardRef)(function Color2({ value, onChangeValue, ...props }, ref) {
|
|
6232
|
+
const [inputFieldValue, setInputFieldValue] = (0, import_react18.useState)(value ?? "#000000");
|
|
6233
|
+
const onChangeValueElement = (0, import_react18.useCallback)(
|
|
6234
|
+
(value2) => {
|
|
6235
|
+
setInputFieldValue(value2);
|
|
6236
|
+
onChangeValue?.(value2);
|
|
6237
|
+
},
|
|
6238
|
+
[onChangeValue]
|
|
6239
|
+
);
|
|
6240
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
6241
|
+
InputFieldComponent,
|
|
6242
|
+
{
|
|
6243
|
+
type: "color",
|
|
6244
|
+
insideInputFieldComponent: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
6245
|
+
Div_default.row,
|
|
6246
|
+
{
|
|
6247
|
+
position: "absolute",
|
|
6248
|
+
width: "100%",
|
|
6249
|
+
height: "100%",
|
|
6250
|
+
top: 0,
|
|
6251
|
+
left: colorPickerSpacing,
|
|
6252
|
+
alignItems: "center",
|
|
6253
|
+
pointerEvents: "none",
|
|
6254
|
+
userSelect: "none",
|
|
6255
|
+
paddingLeft: colorPickerColorWidth,
|
|
6256
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Text_default, { children: inputFieldValue })
|
|
6257
|
+
}
|
|
6258
|
+
),
|
|
6259
|
+
value: inputFieldValue,
|
|
6260
|
+
onChangeValue: onChangeValueElement,
|
|
6261
|
+
ref,
|
|
6262
|
+
...props
|
|
6263
|
+
}
|
|
6264
|
+
);
|
|
6265
|
+
});
|
|
6207
6266
|
var InputField2 = (0, import_react18.memo)(InputFieldComponent);
|
|
6208
6267
|
InputField2.multiline = InputFieldComponent.multiline;
|
|
6209
6268
|
InputField2.email = InputFieldComponent.email;
|
|
@@ -6213,6 +6272,7 @@ InputField2.phoneNumber = InputFieldComponent.phoneNumber;
|
|
|
6213
6272
|
InputField2.date = InputFieldComponent.date;
|
|
6214
6273
|
InputField2.dateTime = InputFieldComponent.dateTime;
|
|
6215
6274
|
InputField2.time = InputFieldComponent.time;
|
|
6275
|
+
InputField2.color = InputFieldComponent.color;
|
|
6216
6276
|
var InputField_default = InputField2;
|
|
6217
6277
|
|
|
6218
6278
|
// src/components/ToggleInput.tsx
|