react-better-html 1.1.28 → 1.1.30
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.
|
@@ -23,10 +23,10 @@ export type DropdownProps<Value, Data> = {
|
|
|
23
23
|
withDebounce?: boolean;
|
|
24
24
|
/** @default 0.5s */
|
|
25
25
|
debounceDelay?: number;
|
|
26
|
-
debounceIsLoading?:
|
|
26
|
+
debounceIsLoading?: boolean;
|
|
27
27
|
onChange?: (value: Value | undefined) => void;
|
|
28
28
|
onChangeSearch?: (query: string) => void;
|
|
29
|
-
renderOption?: (option: DropdownOption<Value, Data>, index: number) => React.ReactNode;
|
|
29
|
+
renderOption?: (option: DropdownOption<Value, Data>, index: number, isSelected: boolean) => React.ReactNode;
|
|
30
30
|
} & OmitProps<DivProps<unknown>, "onChange">;
|
|
31
31
|
type DropdownComponentType = {
|
|
32
32
|
<Value, Data>(props: ComponentPropWithRef<HTMLDivElement, DropdownProps<Value, Data>>): React.ReactElement;
|
|
@@ -149,7 +149,7 @@ const DropdownComponent = (0, react_1.forwardRef)(function Dropdown({ label, err
|
|
|
149
149
|
? theme.colors.textSecondary + "80"
|
|
150
150
|
: isSelected
|
|
151
151
|
? theme.colors.base
|
|
152
|
-
: theme.colors.textPrimary, backgroundColor: isSelected ? theme.colors.primary : theme.colors.backgroundContent, filter: isFocused ? (isDisabled ? "brightness(0.95)" : "brightness(0.9)") : undefined, filterHover: focusedOptionIndex === undefined && !isDisabled ? "brightness(0.9)" : undefined, cursor: isDisabled ? "not-allowed" : "pointer", padding: `${theme.styles.space / 2}px ${theme.styles.space + theme.styles.gap}px`, value: option, onClickWithValue: onClickOption, onMouseMove: () => setFocusedOptionIndex(undefined), role: "option", "aria-selected": isSelected, "aria-disabled": isDisabled, children: renderOption ? renderOption(option, index) : (0, jsx_runtime_1.jsx)(Text_1.default, { children: option.label }) }, JSON.stringify(option)));
|
|
152
|
+
: theme.colors.textPrimary, backgroundColor: isSelected ? theme.colors.primary : theme.colors.backgroundContent, filter: isFocused ? (isDisabled ? "brightness(0.95)" : "brightness(0.9)") : undefined, filterHover: focusedOptionIndex === undefined && !isDisabled ? "brightness(0.9)" : undefined, cursor: isDisabled ? "not-allowed" : "pointer", padding: `${theme.styles.space / 2}px ${theme.styles.space + theme.styles.gap}px`, value: option, onClickWithValue: onClickOption, onMouseMove: () => setFocusedOptionIndex(undefined), role: "option", "aria-selected": isSelected, "aria-disabled": isDisabled, children: renderOption ? renderOption(option, index, isSelected) : (0, jsx_runtime_1.jsx)(Text_1.default, { children: option.label }) }, JSON.stringify(option)));
|
|
153
153
|
})) : ((0, jsx_runtime_1.jsx)(Div_1.default, { padding: `${theme.styles.space / 2}px ${theme.styles.space + theme.styles.gap}px`, children: (0, jsx_runtime_1.jsx)(Text_1.default.unknown, { textAlign: "left", children: "No options" }) })) }), role: "combobox", "aria-expanded": isOpen, "aria-controls": "dropdown-list", "aria-haspopup": "listbox", "aria-label": label, ref: inputRef }), (0, jsx_runtime_1.jsxs)(Div_1.default.row, { position: "absolute", top: 46 / 2 + (label ? 16 + theme.styles.gap / 2 : 0), right: theme.styles.space + 1, alignItems: "center", gap: theme.styles.gap, transform: "translateY(-50%)", pointerEvents: "none", filter: disabled ? "brightness(0.9)" : undefined, opacity: disabled ? 0.6 : undefined, zIndex: isOpen || isOpenLate ? 1001 : undefined, children: [(0, jsx_runtime_1.jsx)(Button_1.default.icon, { icon: "XMark", position: "relative", size: 10, iconSize: 14, opacity: !withClearButton ? 0 : undefined, pointerEvents: withClearButton ? "all" : undefined, onClick: onClickClearButton, disabled: !withClearButton }), (0, jsx_runtime_1.jsx)(Icon_1.default, { name: "chevronDown", position: "relative", size: 16, color: theme.colors.textSecondary, transform: `rotate(${isOpen ? 180 : 0}deg)`, transition: theme.styles.transition, pointerEvents: "none" })] })] }) }));
|
|
154
154
|
});
|
|
155
155
|
const Dropdown = (0, react_1.memo)(DropdownComponent);
|
|
@@ -23,7 +23,7 @@ type InputFieldComponentType = {
|
|
|
23
23
|
search: (props: ComponentPropWithRef<HTMLInputElement, InputFieldProps>) => React.ReactElement;
|
|
24
24
|
};
|
|
25
25
|
declare const InputFieldComponent: InputFieldComponentType;
|
|
26
|
-
type TextareaFieldProps = OmitProps<InputFieldProps, "type"> & OmitProps<React.ComponentProps<"textarea">, "style">;
|
|
26
|
+
export type TextareaFieldProps = OmitProps<InputFieldProps, "type"> & OmitProps<React.ComponentProps<"textarea">, "style" | "ref">;
|
|
27
27
|
declare const InputField: typeof InputFieldComponent & {
|
|
28
28
|
multiline: typeof InputFieldComponent.multiline;
|
|
29
29
|
email: typeof InputFieldComponent.email;
|
package/dist/utils/hooks.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ComponentHoverStyle, ComponentPropWithRef, ComponentStyle } from "../types/components";
|
|
2
2
|
import { Theme } from "../types/theme";
|
|
3
3
|
import { OmitProps, PartialRecord } from "../types/app";
|
|
4
|
-
import { InputFieldProps } from "../components/InputField";
|
|
4
|
+
import { InputFieldProps, TextareaFieldProps } from "../components/InputField";
|
|
5
5
|
import { DropdownProps } from "../components/Dropdown";
|
|
6
6
|
import { ToggleInputProps, ToggleInputRef } from "../components/ToggleInput";
|
|
7
7
|
export declare function useStyledComponentStyles(props: ComponentStyle & ComponentHoverStyle, theme?: Theme,
|
|
@@ -54,6 +54,7 @@ export declare function useForm<FormFields extends Record<string, string | numbe
|
|
|
54
54
|
setFieldValue: <FieldName extends keyof FormFields>(field: FieldName, value: FormFields[FieldName] | undefined) => void;
|
|
55
55
|
setFieldsValue: (values: Partial<FormFields>) => void;
|
|
56
56
|
getInputFieldProps: <FieldName extends keyof FormFields>(field: FieldName) => ComponentPropWithRef<HTMLInputElement, InputFieldProps>;
|
|
57
|
+
getTextAreaProps: <FieldName extends keyof FormFields>(field: FieldName) => ComponentPropWithRef<HTMLTextAreaElement, TextareaFieldProps>;
|
|
57
58
|
getDropdownFieldProps: <FieldName extends keyof FormFields>(field: FieldName) => OmitProps<ComponentPropWithRef<HTMLDivElement, DropdownProps<FormFields[FieldName], unknown>>, "options">;
|
|
58
59
|
getCheckboxProps: <FieldName extends keyof FormFields>(field: FieldName) => ComponentPropWithRef<ToggleInputRef, ToggleInputProps<FormFields[FieldName]>>;
|
|
59
60
|
focusField: (field: keyof FormFields) => void;
|
package/dist/utils/hooks.js
CHANGED
|
@@ -205,6 +205,16 @@ function useForm({ defaultValues, onSubmit, validate, }) {
|
|
|
205
205
|
errorText: errors[field],
|
|
206
206
|
};
|
|
207
207
|
}, [values, setFieldValue, inputTypes, errors]);
|
|
208
|
+
const getTextAreaProps = (0, react_1.useCallback)((field) => {
|
|
209
|
+
const type = inputTypes[field] ?? "text";
|
|
210
|
+
return {
|
|
211
|
+
value: values[field]?.toString() ?? "",
|
|
212
|
+
onChangeValue: (newValue) => {
|
|
213
|
+
setFieldValue(field, newValue);
|
|
214
|
+
},
|
|
215
|
+
errorText: errors[field],
|
|
216
|
+
};
|
|
217
|
+
}, [values, setFieldValue, inputTypes, errors]);
|
|
208
218
|
const getDropdownFieldProps = (0, react_1.useCallback)((field) => {
|
|
209
219
|
return {
|
|
210
220
|
value: values[field],
|
|
@@ -255,6 +265,7 @@ function useForm({ defaultValues, onSubmit, validate, }) {
|
|
|
255
265
|
setFieldValue,
|
|
256
266
|
setFieldsValue,
|
|
257
267
|
getInputFieldProps,
|
|
268
|
+
getTextAreaProps,
|
|
258
269
|
getDropdownFieldProps,
|
|
259
270
|
getCheckboxProps,
|
|
260
271
|
focusField,
|