react-better-html 1.1.203 → 1.1.205

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 CHANGED
@@ -406,7 +406,8 @@ type InputFieldProps = {
406
406
  prefixBackgroundColor?: string;
407
407
  suffix?: React.ReactNode;
408
408
  suffixBackgroundColor?: string;
409
- insideInputFieldComponent?: React.ReactNode;
409
+ insideInputFieldBeforeComponent?: React.ReactNode;
410
+ insideInputFieldAfterComponent?: React.ReactNode;
410
411
  /** @default false */
411
412
  withDebounce?: boolean;
412
413
  /** @default 0.5s */
@@ -481,8 +482,6 @@ type DropdownProps<Value, Data = unknown> = {
481
482
  /** @default false */
482
483
  disabled?: boolean;
483
484
  options: DropdownOption<Value, Data>[];
484
- value?: Value;
485
- defaultValue?: Value;
486
485
  placeholder?: string;
487
486
  leftIcon?: IconName | AnyOtherString;
488
487
  inputFieldClassName?: string;
@@ -499,11 +498,20 @@ type DropdownProps<Value, Data = unknown> = {
499
498
  withoutClearButton?: boolean;
500
499
  /** @default false */
501
500
  withoutRenderingOptionsWhenClosed?: boolean;
502
- onChange?: (value: Value | undefined) => void;
503
501
  onChangeSearch?: (query: string) => void;
504
502
  renderOption?: (option: DropdownOption<Value, Data>, index: number, isSelected: boolean) => React.ReactNode;
505
503
  renderOptionDivider?: (previousOption: DropdownOption<Value, Data> | undefined, nextOption: DropdownOption<Value, Data> | undefined, previousOptionIndex: number, nextOptionIndex: number) => React.ReactNode;
506
- } & OmitProps<DivProps, "onChange" | "defaultChecked">;
504
+ } & OmitProps<DivProps, "onChange" | "defaultChecked"> & ({
505
+ withMultiselect?: false;
506
+ value?: Value;
507
+ defaultValue?: Value;
508
+ onChange?: (value: Value | undefined) => void;
509
+ } | {
510
+ withMultiselect?: true;
511
+ value?: Value[];
512
+ defaultValue?: Value[];
513
+ onChange?: (value: Value[] | undefined) => void;
514
+ });
507
515
  type DropdownComponentType = {
508
516
  <Value, Data>(props: ComponentPropWithRef<HTMLDivElement, DropdownProps<Value, Data>>): React.ReactElement;
509
517
  countries: (props: ComponentPropWithRef<HTMLDivElement, OmitProps<DropdownProps<string, Country>, "options">>) => React.ReactElement;
@@ -567,7 +575,8 @@ declare function useBooleanState(initialValue?: boolean): [
567
575
  }
568
576
  ];
569
577
  declare function useDebounceState<Value>(initialValue: Value, delay?: number): [value: Value, debouncedValue: Value, setValue: React.Dispatch<React.SetStateAction<Value>>, isLoading: boolean];
570
- declare function useForm<FormFields extends Record<string | number, string | number | boolean | undefined>>(options: {
578
+ type FormFieldValue = string | number | boolean;
579
+ declare function useForm<FormFields extends Record<string | number, FormFieldValue | FormFieldValue[] | undefined>>(options: {
571
580
  defaultValues: FormFields;
572
581
  requiredFields?: (keyof FormFields)[];
573
582
  onSubmit?: (values: FormFields) => void | Promise<void>;
@@ -580,7 +589,7 @@ declare function useForm<FormFields extends Record<string | number, string | num
580
589
  setFieldsValue: (values: Partial<FormFields>) => void;
581
590
  getInputFieldProps: <FieldName extends keyof FormFields>(field: FieldName) => ComponentPropWithRef<HTMLInputElement, InputFieldProps>;
582
591
  getTextAreaProps: <FieldName extends keyof FormFields>(field: FieldName) => ComponentPropWithRef<HTMLTextAreaElement, TextareaFieldProps>;
583
- getDropdownFieldProps: <FieldName extends keyof FormFields>(field: FieldName) => OmitProps<ComponentPropWithRef<HTMLDivElement, DropdownProps<FormFields[FieldName]>>, "options">;
592
+ getDropdownFieldProps: <FieldName extends keyof FormFields>(field: FieldName) => any;
584
593
  getCheckboxProps: <FieldName extends keyof FormFields>(field: FieldName) => ComponentPropWithRef<ToggleInputRef, ToggleInputProps<FormFields[FieldName]>>;
585
594
  getRadioButtonProps: <FieldName extends keyof FormFields>(field: FieldName, value: FormFields[FieldName]) => ComponentPropWithRef<ToggleInputRef, ToggleInputProps<FormFields[FieldName]>>;
586
595
  getSwitchProps: <FieldName extends keyof FormFields>(field: FieldName) => ComponentPropWithRef<ToggleInputRef, ToggleInputProps<FormFields[FieldName]>>;
@@ -1087,6 +1096,7 @@ declare const getFormErrorObject: <FormFields extends ReturnType<typeof useForm>
1087
1096
  declare const eventPreventDefault: (event: React.MouseEvent) => void;
1088
1097
  declare const eventStopPropagation: (event: React.MouseEvent) => void;
1089
1098
  declare const eventPreventStop: (event: React.MouseEvent) => void;
1099
+ declare const getPluralWord: (word: string, count: number) => string;
1090
1100
 
1091
1101
  declare const lightenColor: (hexColor: string, amount: number) => string;
1092
1102
  declare const darkenColor: (hexColor: string, amount: number) => string;
@@ -1166,4 +1176,4 @@ type LocalStoragePluginOptions = {
1166
1176
  declare const defaultLocalStoragePluginOptions: Required<LocalStoragePluginOptions>;
1167
1177
  declare const localStoragePlugin: BetterHtmlPluginConstructor<LocalStoragePluginOptions>;
1168
1178
 
1169
- export { type Alert, type AlertType, type AlertsPluginOptions, type AppConfig, type AssetName, type AssetsConfig, type BetterHtmlConfig, type BetterHtmlPlugin, _default as BetterHtmlProvider, type BetterHtmlProviderConfig, type BrowserName, Button, type ButtonProps, Chip, type ChipProps, type Color, type ColorName, type ColorTheme, ColorThemeSwitch, type ColorThemeSwitchProps, type Colors, type ComponentHoverStyle, type ComponentMarginProps, type ComponentPaddingProps, type DeepPartialRecord, Div, type DivProps, _default$3 as Divider, Dropdown, type DropdownOption, type DropdownProps, type ExcludeOptions, Foldable, type FoldableProps, type FoldableRef, Form, type FormProps, FormRow, type FormRowProps, type HorizontalDividerProps, _default$5 as Icon, type IconName, type IconProps, type IconsConfig, _default$4 as Image, type ImageProps, InputField, type InputFieldProps, _default$1 as Label, type LabelProps, Loader, type LoaderConfig, type LoaderName, type LoaderProps, type LocalStoragePluginOptions, Modal, type ModalProps, type ModalRef, type OmitProps, PageHeader, type PageHeaderProps, PageHolder, type PageHolderProps, Pagination, type PartialRecord, type PickAllRequired, type PickValue, type PluginName, type ReactRouterDomPluginOptions, SideMenu, type SideMenuItem, type Styles, type TabGroup, Table, type TableColumn, type TableFilterData, type TableProps, type TableRef, Tabs, type TabsProps, type TabsRef, Text, type TextAs, type TextProps, type TextareaFieldProps, type Theme, type ThemeConfig, _default$2 as ToggleInput, type ToggleInputProps, type ToggleInputRef, Tooltip, type TooltipProps, type TooltipRef, type VerticalDividerProps, alertControls, alertsPlugin, colorThemeControls, countries, darkenColor, defaultAlertsPluginOptions, defaultLocalStoragePluginOptions, defaultReactRouterDomPluginOptions, desaturateColor, eventPreventDefault, eventPreventStop, eventStopPropagation, filterHover, formatPhoneNumber, generateLocalStorage, generateRandomString, getBrowser, getFormErrorObject, isMobileDevice, lightenColor, loaderControls, localStoragePlugin, reactRouterDomPlugin, saturateColor, sideMenuControls, useAlertControls, useBetterHtmlContext, useBooleanState, useDebounceState, useForm, useLoader, useLoaderControls, useMediaQuery, usePageResize, usePageScroll, useTheme, useUrlQuery };
1179
+ export { type Alert, type AlertType, type AlertsPluginOptions, type AppConfig, type AssetName, type AssetsConfig, type BetterHtmlConfig, type BetterHtmlPlugin, _default as BetterHtmlProvider, type BetterHtmlProviderConfig, type BrowserName, Button, type ButtonProps, Chip, type ChipProps, type Color, type ColorName, type ColorTheme, ColorThemeSwitch, type ColorThemeSwitchProps, type Colors, type ComponentHoverStyle, type ComponentMarginProps, type ComponentPaddingProps, type DeepPartialRecord, Div, type DivProps, _default$3 as Divider, Dropdown, type DropdownOption, type DropdownProps, type ExcludeOptions, Foldable, type FoldableProps, type FoldableRef, Form, type FormProps, FormRow, type FormRowProps, type HorizontalDividerProps, _default$5 as Icon, type IconName, type IconProps, type IconsConfig, _default$4 as Image, type ImageProps, InputField, type InputFieldProps, _default$1 as Label, type LabelProps, Loader, type LoaderConfig, type LoaderName, type LoaderProps, type LocalStoragePluginOptions, Modal, type ModalProps, type ModalRef, type OmitProps, PageHeader, type PageHeaderProps, PageHolder, type PageHolderProps, Pagination, type PartialRecord, type PickAllRequired, type PickValue, type PluginName, type ReactRouterDomPluginOptions, SideMenu, type SideMenuItem, type Styles, type TabGroup, Table, type TableColumn, type TableFilterData, type TableProps, type TableRef, Tabs, type TabsProps, type TabsRef, Text, type TextAs, type TextProps, type TextareaFieldProps, type Theme, type ThemeConfig, _default$2 as ToggleInput, type ToggleInputProps, type ToggleInputRef, Tooltip, type TooltipProps, type TooltipRef, type VerticalDividerProps, alertControls, alertsPlugin, colorThemeControls, countries, darkenColor, defaultAlertsPluginOptions, defaultLocalStoragePluginOptions, defaultReactRouterDomPluginOptions, desaturateColor, eventPreventDefault, eventPreventStop, eventStopPropagation, filterHover, formatPhoneNumber, generateLocalStorage, generateRandomString, getBrowser, getFormErrorObject, getPluralWord, isMobileDevice, lightenColor, loaderControls, localStoragePlugin, reactRouterDomPlugin, saturateColor, sideMenuControls, useAlertControls, useBetterHtmlContext, useBooleanState, useDebounceState, useForm, useLoader, useLoaderControls, useMediaQuery, usePageResize, usePageScroll, useTheme, useUrlQuery };
package/dist/index.d.ts CHANGED
@@ -406,7 +406,8 @@ type InputFieldProps = {
406
406
  prefixBackgroundColor?: string;
407
407
  suffix?: React.ReactNode;
408
408
  suffixBackgroundColor?: string;
409
- insideInputFieldComponent?: React.ReactNode;
409
+ insideInputFieldBeforeComponent?: React.ReactNode;
410
+ insideInputFieldAfterComponent?: React.ReactNode;
410
411
  /** @default false */
411
412
  withDebounce?: boolean;
412
413
  /** @default 0.5s */
@@ -481,8 +482,6 @@ type DropdownProps<Value, Data = unknown> = {
481
482
  /** @default false */
482
483
  disabled?: boolean;
483
484
  options: DropdownOption<Value, Data>[];
484
- value?: Value;
485
- defaultValue?: Value;
486
485
  placeholder?: string;
487
486
  leftIcon?: IconName | AnyOtherString;
488
487
  inputFieldClassName?: string;
@@ -499,11 +498,20 @@ type DropdownProps<Value, Data = unknown> = {
499
498
  withoutClearButton?: boolean;
500
499
  /** @default false */
501
500
  withoutRenderingOptionsWhenClosed?: boolean;
502
- onChange?: (value: Value | undefined) => void;
503
501
  onChangeSearch?: (query: string) => void;
504
502
  renderOption?: (option: DropdownOption<Value, Data>, index: number, isSelected: boolean) => React.ReactNode;
505
503
  renderOptionDivider?: (previousOption: DropdownOption<Value, Data> | undefined, nextOption: DropdownOption<Value, Data> | undefined, previousOptionIndex: number, nextOptionIndex: number) => React.ReactNode;
506
- } & OmitProps<DivProps, "onChange" | "defaultChecked">;
504
+ } & OmitProps<DivProps, "onChange" | "defaultChecked"> & ({
505
+ withMultiselect?: false;
506
+ value?: Value;
507
+ defaultValue?: Value;
508
+ onChange?: (value: Value | undefined) => void;
509
+ } | {
510
+ withMultiselect?: true;
511
+ value?: Value[];
512
+ defaultValue?: Value[];
513
+ onChange?: (value: Value[] | undefined) => void;
514
+ });
507
515
  type DropdownComponentType = {
508
516
  <Value, Data>(props: ComponentPropWithRef<HTMLDivElement, DropdownProps<Value, Data>>): React.ReactElement;
509
517
  countries: (props: ComponentPropWithRef<HTMLDivElement, OmitProps<DropdownProps<string, Country>, "options">>) => React.ReactElement;
@@ -567,7 +575,8 @@ declare function useBooleanState(initialValue?: boolean): [
567
575
  }
568
576
  ];
569
577
  declare function useDebounceState<Value>(initialValue: Value, delay?: number): [value: Value, debouncedValue: Value, setValue: React.Dispatch<React.SetStateAction<Value>>, isLoading: boolean];
570
- declare function useForm<FormFields extends Record<string | number, string | number | boolean | undefined>>(options: {
578
+ type FormFieldValue = string | number | boolean;
579
+ declare function useForm<FormFields extends Record<string | number, FormFieldValue | FormFieldValue[] | undefined>>(options: {
571
580
  defaultValues: FormFields;
572
581
  requiredFields?: (keyof FormFields)[];
573
582
  onSubmit?: (values: FormFields) => void | Promise<void>;
@@ -580,7 +589,7 @@ declare function useForm<FormFields extends Record<string | number, string | num
580
589
  setFieldsValue: (values: Partial<FormFields>) => void;
581
590
  getInputFieldProps: <FieldName extends keyof FormFields>(field: FieldName) => ComponentPropWithRef<HTMLInputElement, InputFieldProps>;
582
591
  getTextAreaProps: <FieldName extends keyof FormFields>(field: FieldName) => ComponentPropWithRef<HTMLTextAreaElement, TextareaFieldProps>;
583
- getDropdownFieldProps: <FieldName extends keyof FormFields>(field: FieldName) => OmitProps<ComponentPropWithRef<HTMLDivElement, DropdownProps<FormFields[FieldName]>>, "options">;
592
+ getDropdownFieldProps: <FieldName extends keyof FormFields>(field: FieldName) => any;
584
593
  getCheckboxProps: <FieldName extends keyof FormFields>(field: FieldName) => ComponentPropWithRef<ToggleInputRef, ToggleInputProps<FormFields[FieldName]>>;
585
594
  getRadioButtonProps: <FieldName extends keyof FormFields>(field: FieldName, value: FormFields[FieldName]) => ComponentPropWithRef<ToggleInputRef, ToggleInputProps<FormFields[FieldName]>>;
586
595
  getSwitchProps: <FieldName extends keyof FormFields>(field: FieldName) => ComponentPropWithRef<ToggleInputRef, ToggleInputProps<FormFields[FieldName]>>;
@@ -1087,6 +1096,7 @@ declare const getFormErrorObject: <FormFields extends ReturnType<typeof useForm>
1087
1096
  declare const eventPreventDefault: (event: React.MouseEvent) => void;
1088
1097
  declare const eventStopPropagation: (event: React.MouseEvent) => void;
1089
1098
  declare const eventPreventStop: (event: React.MouseEvent) => void;
1099
+ declare const getPluralWord: (word: string, count: number) => string;
1090
1100
 
1091
1101
  declare const lightenColor: (hexColor: string, amount: number) => string;
1092
1102
  declare const darkenColor: (hexColor: string, amount: number) => string;
@@ -1166,4 +1176,4 @@ type LocalStoragePluginOptions = {
1166
1176
  declare const defaultLocalStoragePluginOptions: Required<LocalStoragePluginOptions>;
1167
1177
  declare const localStoragePlugin: BetterHtmlPluginConstructor<LocalStoragePluginOptions>;
1168
1178
 
1169
- export { type Alert, type AlertType, type AlertsPluginOptions, type AppConfig, type AssetName, type AssetsConfig, type BetterHtmlConfig, type BetterHtmlPlugin, _default as BetterHtmlProvider, type BetterHtmlProviderConfig, type BrowserName, Button, type ButtonProps, Chip, type ChipProps, type Color, type ColorName, type ColorTheme, ColorThemeSwitch, type ColorThemeSwitchProps, type Colors, type ComponentHoverStyle, type ComponentMarginProps, type ComponentPaddingProps, type DeepPartialRecord, Div, type DivProps, _default$3 as Divider, Dropdown, type DropdownOption, type DropdownProps, type ExcludeOptions, Foldable, type FoldableProps, type FoldableRef, Form, type FormProps, FormRow, type FormRowProps, type HorizontalDividerProps, _default$5 as Icon, type IconName, type IconProps, type IconsConfig, _default$4 as Image, type ImageProps, InputField, type InputFieldProps, _default$1 as Label, type LabelProps, Loader, type LoaderConfig, type LoaderName, type LoaderProps, type LocalStoragePluginOptions, Modal, type ModalProps, type ModalRef, type OmitProps, PageHeader, type PageHeaderProps, PageHolder, type PageHolderProps, Pagination, type PartialRecord, type PickAllRequired, type PickValue, type PluginName, type ReactRouterDomPluginOptions, SideMenu, type SideMenuItem, type Styles, type TabGroup, Table, type TableColumn, type TableFilterData, type TableProps, type TableRef, Tabs, type TabsProps, type TabsRef, Text, type TextAs, type TextProps, type TextareaFieldProps, type Theme, type ThemeConfig, _default$2 as ToggleInput, type ToggleInputProps, type ToggleInputRef, Tooltip, type TooltipProps, type TooltipRef, type VerticalDividerProps, alertControls, alertsPlugin, colorThemeControls, countries, darkenColor, defaultAlertsPluginOptions, defaultLocalStoragePluginOptions, defaultReactRouterDomPluginOptions, desaturateColor, eventPreventDefault, eventPreventStop, eventStopPropagation, filterHover, formatPhoneNumber, generateLocalStorage, generateRandomString, getBrowser, getFormErrorObject, isMobileDevice, lightenColor, loaderControls, localStoragePlugin, reactRouterDomPlugin, saturateColor, sideMenuControls, useAlertControls, useBetterHtmlContext, useBooleanState, useDebounceState, useForm, useLoader, useLoaderControls, useMediaQuery, usePageResize, usePageScroll, useTheme, useUrlQuery };
1179
+ export { type Alert, type AlertType, type AlertsPluginOptions, type AppConfig, type AssetName, type AssetsConfig, type BetterHtmlConfig, type BetterHtmlPlugin, _default as BetterHtmlProvider, type BetterHtmlProviderConfig, type BrowserName, Button, type ButtonProps, Chip, type ChipProps, type Color, type ColorName, type ColorTheme, ColorThemeSwitch, type ColorThemeSwitchProps, type Colors, type ComponentHoverStyle, type ComponentMarginProps, type ComponentPaddingProps, type DeepPartialRecord, Div, type DivProps, _default$3 as Divider, Dropdown, type DropdownOption, type DropdownProps, type ExcludeOptions, Foldable, type FoldableProps, type FoldableRef, Form, type FormProps, FormRow, type FormRowProps, type HorizontalDividerProps, _default$5 as Icon, type IconName, type IconProps, type IconsConfig, _default$4 as Image, type ImageProps, InputField, type InputFieldProps, _default$1 as Label, type LabelProps, Loader, type LoaderConfig, type LoaderName, type LoaderProps, type LocalStoragePluginOptions, Modal, type ModalProps, type ModalRef, type OmitProps, PageHeader, type PageHeaderProps, PageHolder, type PageHolderProps, Pagination, type PartialRecord, type PickAllRequired, type PickValue, type PluginName, type ReactRouterDomPluginOptions, SideMenu, type SideMenuItem, type Styles, type TabGroup, Table, type TableColumn, type TableFilterData, type TableProps, type TableRef, Tabs, type TabsProps, type TabsRef, Text, type TextAs, type TextProps, type TextareaFieldProps, type Theme, type ThemeConfig, _default$2 as ToggleInput, type ToggleInputProps, type ToggleInputRef, Tooltip, type TooltipProps, type TooltipRef, type VerticalDividerProps, alertControls, alertsPlugin, colorThemeControls, countries, darkenColor, defaultAlertsPluginOptions, defaultLocalStoragePluginOptions, defaultReactRouterDomPluginOptions, desaturateColor, eventPreventDefault, eventPreventStop, eventStopPropagation, filterHover, formatPhoneNumber, generateLocalStorage, generateRandomString, getBrowser, getFormErrorObject, getPluralWord, isMobileDevice, lightenColor, loaderControls, localStoragePlugin, reactRouterDomPlugin, saturateColor, sideMenuControls, useAlertControls, useBetterHtmlContext, useBooleanState, useDebounceState, useForm, useLoader, useLoaderControls, useMediaQuery, usePageResize, usePageScroll, useTheme, useUrlQuery };