@stenajs-webui/forms 17.5.0 → 17.8.0

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.
Files changed (45) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/dist/components/ui/checkbox/Checkbox.d.ts +10 -10
  3. package/dist/components/ui/checkbox/CheckboxWithLabel.d.ts +10 -10
  4. package/dist/components/ui/numeric-stepper/NumericStepper.d.ts +6 -6
  5. package/dist/components/ui/numeric-text-input/NumericTextInput.d.ts +10 -10
  6. package/dist/components/ui/numeric-text-input/hooks/UseNumericInputValue.d.ts +4 -4
  7. package/dist/components/ui/password-input/PasswordInput.d.ts +8 -8
  8. package/dist/components/ui/radio/RadioButton.d.ts +8 -8
  9. package/dist/components/ui/radio/RadioButtonWithLabel.d.ts +10 -10
  10. package/dist/components/ui/switch/Switch.d.ts +8 -8
  11. package/dist/components/ui/switch/SwitchWithLabel.d.ts +7 -7
  12. package/dist/components/ui/text-area/TextArea.d.ts +12 -12
  13. package/dist/components/ui/text-input/TextInput.d.ts +43 -43
  14. package/dist/components/ui/text-input/TextInputBox.d.ts +7 -7
  15. package/dist/components/ui/text-input/TextInputIcon.d.ts +14 -14
  16. package/dist/components/ui/text-input/__tests__/TextInput.test.d.ts +1 -1
  17. package/dist/components/ui/types.d.ts +17 -17
  18. package/dist/hooks/UseKeyboardNavigation.d.ts +8 -8
  19. package/dist/hooks/UseSelectAllOnMount.d.ts +4 -4
  20. package/dist/hooks/UseTextInput.d.ts +30 -30
  21. package/dist/index.d.ts +18 -18
  22. package/dist/index.es.js +665 -466
  23. package/dist/index.es.js.map +1 -1
  24. package/dist/index.js +1 -529
  25. package/dist/index.js.map +1 -1
  26. package/dist/storybook-helpers/storybook-controls.d.ts +46 -46
  27. package/dist/utils/NumberComparator.d.ts +2 -2
  28. package/dist/utils/NumericHelpers.d.ts +13 -13
  29. package/package.json +7 -8
  30. package/dist/components/ui/Form.stories.d.ts +0 -6
  31. package/dist/components/ui/checkbox/Checkbox.stories.d.ts +0 -24
  32. package/dist/components/ui/checkbox/CheckboxWithLabel.stories.d.ts +0 -27
  33. package/dist/components/ui/numeric-stepper/NumericStepper.stories.d.ts +0 -40
  34. package/dist/components/ui/numeric-text-input/NumericTextInput.stories.d.ts +0 -57
  35. package/dist/components/ui/password-input/PasswordInput.stories.d.ts +0 -9
  36. package/dist/components/ui/radio/RadioButton.stories.d.ts +0 -25
  37. package/dist/components/ui/radio/RadioButtonWithLabel.stories.d.ts +0 -7
  38. package/dist/components/ui/switch/Switch.stories.d.ts +0 -13
  39. package/dist/components/ui/switch/SwitchWithLabel.stories.d.ts +0 -12
  40. package/dist/components/ui/text-area/TextArea.stories.d.ts +0 -21
  41. package/dist/components/ui/text-input/TextInput.stories.d.ts +0 -62
  42. package/dist/components/ui/text-input/TextInputBox.stories.d.ts +0 -7
  43. package/dist/hooks/__tests__/useSelectAllOnMount.test.d.ts +0 -1
  44. package/dist/utils/__tests__/NumberComparator.test.d.ts +0 -1
  45. package/dist/utils/__tests__/NumericHelpers.test.d.ts +0 -1
package/CHANGELOG.md CHANGED
@@ -1,3 +1,29 @@
1
+ # v17.7.0 (Fri Jul 01 2022)
2
+
3
+ #### 🚀 Enhancement
4
+
5
+ - Build packages with vite [#475](https://github.com/StenaIT/stenajs-webui/pull/475) ([@lindskogen](https://github.com/lindskogen))
6
+
7
+ #### Authors: 1
8
+
9
+ - Johan Lindskogen ([@lindskogen](https://github.com/lindskogen))
10
+
11
+ ---
12
+
13
+ # v17.6.0 (Fri Jul 01 2022)
14
+
15
+ #### 🚀 Enhancement
16
+
17
+ - Use Stena icons instead of Font Awesome icons [#471](https://github.com/StenaIT/stenajs-webui/pull/471) (david.zetterdahl@stenaline.com [@LordDz](https://github.com/LordDz) [@lindskogen](https://github.com/lindskogen))
18
+
19
+ #### Authors: 3
20
+
21
+ - David ([@LordDz](https://github.com/LordDz))
22
+ - David Zetterdahl (david.zetterdahl@stenaline.com)
23
+ - Johan Lindskogen ([@lindskogen](https://github.com/lindskogen))
24
+
25
+ ---
26
+
1
27
  # v17.0.0 (Fri Jun 17 2022)
2
28
 
3
29
  #### 💥 Breaking Change
@@ -1,10 +1,10 @@
1
- import * as React from "react";
2
- import { ChangeEvent, ComponentPropsWithoutRef } from "react";
3
- import { FullOnChangeProps } from "../types";
4
- export declare type CheckboxSize = "standard" | "small";
5
- export interface CheckboxProps extends FullOnChangeProps<boolean, ChangeEvent<HTMLInputElement>>, Omit<ComponentPropsWithoutRef<"input">, "size" | "value"> {
6
- indeterminate?: boolean;
7
- size?: CheckboxSize;
8
- disabled?: boolean;
9
- }
10
- export declare const Checkbox: React.ForwardRefExoticComponent<CheckboxProps & React.RefAttributes<HTMLInputElement>>;
1
+ import * as React from "react";
2
+ import { ChangeEvent, ComponentPropsWithoutRef } from "react";
3
+ import { FullOnChangeProps } from "../types";
4
+ export declare type CheckboxSize = "standard" | "small";
5
+ export interface CheckboxProps extends FullOnChangeProps<boolean, ChangeEvent<HTMLInputElement>>, Omit<ComponentPropsWithoutRef<"input">, "size" | "value"> {
6
+ indeterminate?: boolean;
7
+ size?: CheckboxSize;
8
+ disabled?: boolean;
9
+ }
10
+ export declare const Checkbox: React.ForwardRefExoticComponent<CheckboxProps & React.RefAttributes<HTMLInputElement>>;
@@ -1,10 +1,10 @@
1
- import * as React from "react";
2
- import { Ref } from "react";
3
- import { CheckboxProps } from "./Checkbox";
4
- export interface CheckboxWithLabelProps extends CheckboxProps {
5
- label?: string;
6
- textColor?: string;
7
- wrapperRef?: Ref<HTMLDivElement>;
8
- inputRef?: Ref<HTMLInputElement>;
9
- }
10
- export declare const CheckboxWithLabel: React.FC<CheckboxWithLabelProps>;
1
+ import * as React from "react";
2
+ import { Ref } from "react";
3
+ import { CheckboxProps } from "./Checkbox";
4
+ export interface CheckboxWithLabelProps extends CheckboxProps {
5
+ label?: string;
6
+ textColor?: string;
7
+ wrapperRef?: Ref<HTMLDivElement>;
8
+ inputRef?: Ref<HTMLInputElement>;
9
+ }
10
+ export declare const CheckboxWithLabel: React.FC<CheckboxWithLabelProps>;
@@ -1,6 +1,6 @@
1
- import { Omit } from "@stenajs-webui/core";
2
- import * as React from "react";
3
- import { NumericTextInputProps } from "../numeric-text-input/NumericTextInput";
4
- export interface NumericStepperProps extends Omit<NumericTextInputProps, "hideButtons"> {
5
- }
6
- export declare const NumericStepper: React.FC<NumericStepperProps>;
1
+ import { Omit } from "@stenajs-webui/core";
2
+ import * as React from "react";
3
+ import { NumericTextInputProps } from "../numeric-text-input/NumericTextInput";
4
+ export interface NumericStepperProps extends Omit<NumericTextInputProps, "hideButtons"> {
5
+ }
6
+ export declare const NumericStepper: React.FC<NumericStepperProps>;
@@ -1,10 +1,10 @@
1
- import { Omit } from "@stenajs-webui/core";
2
- import * as React from "react";
3
- import { TextInputProps } from "../text-input/TextInput";
4
- export interface NumericTextInputProps extends Omit<TextInputProps, "onChange" | "selectAllOnMount" | "moveCursorToEndOnMount"> {
5
- max?: number;
6
- min?: number;
7
- step?: number;
8
- hideButtons?: boolean;
9
- }
10
- export declare const NumericTextInput: React.FC<NumericTextInputProps>;
1
+ import { Omit } from "@stenajs-webui/core";
2
+ import * as React from "react";
3
+ import { TextInputProps } from "../text-input/TextInput";
4
+ export interface NumericTextInputProps extends Omit<TextInputProps, "onChange" | "selectAllOnMount" | "moveCursorToEndOnMount"> {
5
+ max?: number;
6
+ min?: number;
7
+ step?: number;
8
+ hideButtons?: boolean;
9
+ }
10
+ export declare const NumericTextInput: React.FC<NumericTextInputProps>;
@@ -1,4 +1,4 @@
1
- import { ValueAndOnValueChangeProps } from "../../types";
2
- import { NumericTextInputProps } from "../NumericTextInput";
3
- export declare type NumericInputValueProps = ValueAndOnValueChangeProps<number | undefined>;
4
- export declare const useNumericInputValue: (value: number | undefined, onValueChange?: ((value: number | undefined) => void) | undefined) => Partial<NumericTextInputProps>;
1
+ import { ValueAndOnValueChangeProps } from "../../types";
2
+ import { NumericTextInputProps } from "../NumericTextInput";
3
+ export declare type NumericInputValueProps = ValueAndOnValueChangeProps<number | undefined>;
4
+ export declare const useNumericInputValue: (value: number | undefined, onValueChange?: ((value: number | undefined) => void) | undefined) => Partial<NumericTextInputProps>;
@@ -1,8 +1,8 @@
1
- import * as React from "react";
2
- import { IconDefinition } from "@fortawesome/fontawesome-svg-core";
3
- import { TextInputProps } from "../text-input/TextInput";
4
- export interface PasswordInputProps extends TextInputProps {
5
- visibleIcon?: IconDefinition;
6
- hiddenIcon?: IconDefinition;
7
- }
8
- export declare const PasswordInput: React.FC<PasswordInputProps>;
1
+ import * as React from "react";
2
+ import { IconDefinition } from "@fortawesome/fontawesome-svg-core";
3
+ import { TextInputProps } from "../text-input/TextInput";
4
+ export interface PasswordInputProps extends TextInputProps {
5
+ visibleIcon?: IconDefinition;
6
+ hiddenIcon?: IconDefinition;
7
+ }
8
+ export declare const PasswordInput: React.FC<PasswordInputProps>;
@@ -1,8 +1,8 @@
1
- import * as React from "react";
2
- import { ChangeEvent, ComponentPropsWithoutRef } from "react";
3
- import { FullOnChangeProps } from "../types";
4
- export declare type RadioButtonSize = "standard" | "small";
5
- export interface RadioButtonProps extends FullOnChangeProps<string, ChangeEvent<HTMLInputElement>>, Omit<ComponentPropsWithoutRef<"input">, "size" | "value"> {
6
- size?: RadioButtonSize;
7
- }
8
- export declare const RadioButton: React.ForwardRefExoticComponent<RadioButtonProps & React.RefAttributes<HTMLInputElement>>;
1
+ import * as React from "react";
2
+ import { ChangeEvent, ComponentPropsWithoutRef } from "react";
3
+ import { FullOnChangeProps } from "../types";
4
+ export declare type RadioButtonSize = "standard" | "small";
5
+ export interface RadioButtonProps extends FullOnChangeProps<string, ChangeEvent<HTMLInputElement>>, Omit<ComponentPropsWithoutRef<"input">, "size" | "value"> {
6
+ size?: RadioButtonSize;
7
+ }
8
+ export declare const RadioButton: React.ForwardRefExoticComponent<RadioButtonProps & React.RefAttributes<HTMLInputElement>>;
@@ -1,10 +1,10 @@
1
- import * as React from "react";
2
- import { Ref } from "react";
3
- import { RadioButtonProps } from "./RadioButton";
4
- export interface RadioButtonWithLabelProps extends RadioButtonProps {
5
- label: string;
6
- textColor?: string;
7
- wrapperRef?: Ref<HTMLDivElement>;
8
- inputRef?: Ref<HTMLInputElement>;
9
- }
10
- export declare const RadioButtonWithLabel: React.FC<RadioButtonWithLabelProps>;
1
+ import * as React from "react";
2
+ import { Ref } from "react";
3
+ import { RadioButtonProps } from "./RadioButton";
4
+ export interface RadioButtonWithLabelProps extends RadioButtonProps {
5
+ label: string;
6
+ textColor?: string;
7
+ wrapperRef?: Ref<HTMLDivElement>;
8
+ inputRef?: Ref<HTMLInputElement>;
9
+ }
10
+ export declare const RadioButtonWithLabel: React.FC<RadioButtonWithLabelProps>;
@@ -1,8 +1,8 @@
1
- import { Ref } from "react";
2
- import * as React from "react";
3
- import { ButtonElementProps } from "@stenajs-webui/core";
4
- import { ValueAndOnValueChangeProps } from "../types";
5
- export interface SwitchProps extends Omit<ButtonElementProps, "value">, ValueAndOnValueChangeProps<boolean> {
6
- wrapperRef?: Ref<HTMLDivElement>;
7
- }
8
- export declare const Switch: React.FC<SwitchProps>;
1
+ import { Ref } from "react";
2
+ import * as React from "react";
3
+ import { ButtonElementProps } from "@stenajs-webui/core";
4
+ import { ValueAndOnValueChangeProps } from "../types";
5
+ export interface SwitchProps extends Omit<ButtonElementProps, "value">, ValueAndOnValueChangeProps<boolean> {
6
+ wrapperRef?: Ref<HTMLDivElement>;
7
+ }
8
+ export declare const Switch: React.FC<SwitchProps>;
@@ -1,7 +1,7 @@
1
- import * as React from "react";
2
- import { SwitchProps } from "./Switch";
3
- export interface SwitchWithLabelProps extends SwitchProps {
4
- label: string;
5
- textColor?: string;
6
- }
7
- export declare const SwitchWithLabel: React.FC<SwitchWithLabelProps>;
1
+ import * as React from "react";
2
+ import { SwitchProps } from "./Switch";
3
+ export interface SwitchWithLabelProps extends SwitchProps {
4
+ label: string;
5
+ textColor?: string;
6
+ }
7
+ export declare const SwitchWithLabel: React.FC<SwitchWithLabelProps>;
@@ -1,12 +1,12 @@
1
- import * as React from "react";
2
- import { ChangeEvent, ComponentPropsWithoutRef } from "react";
3
- import { FullOnChangeProps } from "../types";
4
- declare type Resize = "none" | "both" | "horizontal" | "vertical" | "inherit" | "initial" | "revert" | "unset";
5
- export interface TextAreaProps extends Omit<ComponentPropsWithoutRef<"textarea">, "value">, FullOnChangeProps<string, ChangeEvent<HTMLTextAreaElement>> {
6
- resize?: Resize;
7
- readOnly?: boolean;
8
- rows?: number;
9
- disabled?: boolean;
10
- }
11
- export declare const TextArea: React.ForwardRefExoticComponent<TextAreaProps & React.RefAttributes<HTMLTextAreaElement>>;
12
- export {};
1
+ import * as React from "react";
2
+ import { ChangeEvent, ComponentPropsWithoutRef } from "react";
3
+ import { FullOnChangeProps } from "../types";
4
+ declare type Resize = "none" | "both" | "horizontal" | "vertical" | "inherit" | "initial" | "revert" | "unset";
5
+ export interface TextAreaProps extends Omit<ComponentPropsWithoutRef<"textarea">, "value">, FullOnChangeProps<string, ChangeEvent<HTMLTextAreaElement>> {
6
+ resize?: Resize;
7
+ readOnly?: boolean;
8
+ rows?: number;
9
+ disabled?: boolean;
10
+ }
11
+ export declare const TextArea: React.ForwardRefExoticComponent<TextAreaProps & React.RefAttributes<HTMLTextAreaElement>>;
12
+ export {};
@@ -1,43 +1,43 @@
1
- import { IconDefinition } from "@fortawesome/fontawesome-svg-core";
2
- import { InputProps } from "@stenajs-webui/core";
3
- import * as React from "react";
4
- import { ChangeEvent, CSSProperties } from "react";
5
- import { MoveDirection } from "../../../hooks/UseKeyboardNavigation";
6
- import { FullOnChangeProps } from "../types";
7
- export declare type TextInputVariant = "standard" | "loading" | "warning" | "error" | "modified" | "success";
8
- interface ExtraContent {
9
- /** React node to put to the left. Left icon is ignored if this is set. */
10
- contentLeft?: React.ReactNode;
11
- /** React node to put to the right. Right icon is ignored if this is set. */
12
- contentRight?: React.ReactNode;
13
- /** If true, there will be no padding between contentLeft/contentRight and the border. */
14
- disableContentPadding?: boolean;
15
- /** If true, there will be no padding between contentLeft and the border. */
16
- disableContentPaddingLeft?: boolean;
17
- /** If true, there will be no padding between contentRight and the border. */
18
- disableContentPaddingRight?: boolean;
19
- /** Icon on the left side. */
20
- iconLeft?: IconDefinition;
21
- /** Icon on the right side. */
22
- iconRight?: IconDefinition;
23
- /** On click left. */
24
- onClickLeft?: () => void;
25
- /** On click right. */
26
- onClickRight?: () => void;
27
- }
28
- export interface TextInputProps extends FullOnChangeProps<string, ChangeEvent<HTMLInputElement>>, InputProps, ExtraContent {
29
- wrapperStyle?: CSSProperties;
30
- wrapperClassName?: string;
31
- variant?: TextInputVariant;
32
- hideBorder?: boolean;
33
- selectAllOnMount?: boolean;
34
- moveCursorToEndOnMount?: boolean;
35
- onDone?: (value: string) => void;
36
- onEnter?: () => void;
37
- onEsc?: () => void;
38
- autoFocus?: boolean;
39
- /** onMove callback, triggered when user tries to move outside of field using arrow keys, tab or shift+tab. */
40
- onMove?: (direction: MoveDirection) => void;
41
- }
42
- export declare const TextInput: React.FC<TextInputProps>;
43
- export {};
1
+ import { IconDefinition } from "@fortawesome/fontawesome-svg-core";
2
+ import { InputProps } from "@stenajs-webui/core";
3
+ import * as React from "react";
4
+ import { ChangeEvent, CSSProperties } from "react";
5
+ import { MoveDirection } from "../../../hooks/UseKeyboardNavigation";
6
+ import { FullOnChangeProps } from "../types";
7
+ export declare type TextInputVariant = "standard" | "loading" | "warning" | "error" | "modified" | "success";
8
+ interface ExtraContent {
9
+ /** React node to put to the left. Left icon is ignored if this is set. */
10
+ contentLeft?: React.ReactNode;
11
+ /** React node to put to the right. Right icon is ignored if this is set. */
12
+ contentRight?: React.ReactNode;
13
+ /** If true, there will be no padding between contentLeft/contentRight and the border. */
14
+ disableContentPadding?: boolean;
15
+ /** If true, there will be no padding between contentLeft and the border. */
16
+ disableContentPaddingLeft?: boolean;
17
+ /** If true, there will be no padding between contentRight and the border. */
18
+ disableContentPaddingRight?: boolean;
19
+ /** Icon on the left side. */
20
+ iconLeft?: IconDefinition;
21
+ /** Icon on the right side. */
22
+ iconRight?: IconDefinition;
23
+ /** On click left. */
24
+ onClickLeft?: () => void;
25
+ /** On click right. */
26
+ onClickRight?: () => void;
27
+ }
28
+ export interface TextInputProps extends FullOnChangeProps<string, ChangeEvent<HTMLInputElement>>, InputProps, ExtraContent {
29
+ wrapperStyle?: CSSProperties;
30
+ wrapperClassName?: string;
31
+ variant?: TextInputVariant;
32
+ hideBorder?: boolean;
33
+ selectAllOnMount?: boolean;
34
+ moveCursorToEndOnMount?: boolean;
35
+ onDone?: (value: string) => void;
36
+ onEnter?: () => void;
37
+ onEsc?: () => void;
38
+ autoFocus?: boolean;
39
+ /** onMove callback, triggered when user tries to move outside of field using arrow keys, tab or shift+tab. */
40
+ onMove?: (direction: MoveDirection) => void;
41
+ }
42
+ export declare const TextInput: React.FC<TextInputProps>;
43
+ export {};
@@ -1,7 +1,7 @@
1
- import * as React from "react";
2
- import { ReactNode } from "react";
3
- import { TextInputProps } from "./TextInput";
4
- export interface TextInputBoxProps extends Pick<TextInputProps, "variant" | "wrapperClassName" | "disabled" | "wrapperStyle" | "contentLeft" | "contentRight" | "disableContentPadding" | "disableContentPaddingLeft" | "disableContentPaddingRight" | "iconRight" | "iconLeft" | "onClickLeft" | "onClickRight"> {
5
- children?: ReactNode;
6
- }
7
- export declare const TextInputBox: React.FC<TextInputBoxProps>;
1
+ import * as React from "react";
2
+ import { ReactNode } from "react";
3
+ import { TextInputProps } from "./TextInput";
4
+ export interface TextInputBoxProps extends Pick<TextInputProps, "variant" | "wrapperClassName" | "disabled" | "wrapperStyle" | "contentLeft" | "contentRight" | "disableContentPadding" | "disableContentPaddingLeft" | "disableContentPaddingRight" | "iconRight" | "iconLeft" | "onClickLeft" | "onClickRight"> {
5
+ children?: ReactNode;
6
+ }
7
+ export declare const TextInputBox: React.FC<TextInputBoxProps>;
@@ -1,14 +1,14 @@
1
- import { IconDefinition } from "@fortawesome/fontawesome-svg-core";
2
- import * as React from "react";
3
- export interface TextInputIconProps {
4
- iconClassName?: string;
5
- content?: React.ReactNode;
6
- icon?: IconDefinition;
7
- spaceOnRight?: boolean;
8
- spaceOnLeft?: boolean;
9
- disableContentPadding?: boolean;
10
- disableContentPaddingLeft?: boolean;
11
- disableContentPaddingRight?: boolean;
12
- onClick?: () => void;
13
- }
14
- export declare const TextInputIcon: React.FC<TextInputIconProps>;
1
+ import { IconDefinition } from "@fortawesome/fontawesome-svg-core";
2
+ import * as React from "react";
3
+ export interface TextInputIconProps {
4
+ iconClassName?: string;
5
+ content?: React.ReactNode;
6
+ icon?: IconDefinition;
7
+ spaceOnRight?: boolean;
8
+ spaceOnLeft?: boolean;
9
+ disableContentPadding?: boolean;
10
+ disableContentPaddingLeft?: boolean;
11
+ disableContentPaddingRight?: boolean;
12
+ onClick?: () => void;
13
+ }
14
+ export declare const TextInputIcon: React.FC<TextInputIconProps>;
@@ -1 +1 @@
1
- export {};
1
+ export {};
@@ -1,17 +1,17 @@
1
- import { ChangeEvent } from "react";
2
- export declare type FullOnChangeProps<TValue, TEvent extends ChangeEvent> = ValueProps<TValue> & OnChangeProps<TEvent> & OnValueChangeProps<TValue>;
3
- export declare type ValueAndOnChangeProps<TValue, TEvent extends ChangeEvent> = ValueProps<TValue> & OnChangeProps<TEvent>;
4
- export declare type ValueAndOnValueChangeProps<TValue> = ValueProps<TValue> & OnValueChangeProps<TValue>;
5
- interface ValueProps<TValue> {
6
- /** The value of the input. */
7
- value?: TValue;
8
- }
9
- interface OnChangeProps<TEvent extends ChangeEvent> {
10
- /** onChange callback, called when user triggers a value change. */
11
- onChange?: (event: TEvent) => void;
12
- }
13
- interface OnValueChangeProps<TValue> {
14
- /** onChange callback with target value, called when user triggers a value change in the field. */
15
- onValueChange?: (value: TValue) => void;
16
- }
17
- export {};
1
+ import { ChangeEvent } from "react";
2
+ export declare type FullOnChangeProps<TValue, TEvent extends ChangeEvent> = ValueProps<TValue> & OnChangeProps<TEvent> & OnValueChangeProps<TValue>;
3
+ export declare type ValueAndOnChangeProps<TValue, TEvent extends ChangeEvent> = ValueProps<TValue> & OnChangeProps<TEvent>;
4
+ export declare type ValueAndOnValueChangeProps<TValue> = ValueProps<TValue> & OnValueChangeProps<TValue>;
5
+ interface ValueProps<TValue> {
6
+ /** The value of the input. */
7
+ value?: TValue;
8
+ }
9
+ interface OnChangeProps<TEvent extends ChangeEvent> {
10
+ /** onChange callback, called when user triggers a value change. */
11
+ onChange?: (event: TEvent) => void;
12
+ }
13
+ interface OnValueChangeProps<TValue> {
14
+ /** onChange callback with target value, called when user triggers a value change in the field. */
15
+ onValueChange?: (value: TValue) => void;
16
+ }
17
+ export {};
@@ -1,8 +1,8 @@
1
- import { FocusEventHandler, KeyboardEventHandler, RefObject } from "react";
2
- export declare type MoveDirection = "right" | "left" | "down" | "up";
3
- export declare type TextInputElement = HTMLTextAreaElement | HTMLInputElement;
4
- export declare const useKeyboardNavigation: <TElement extends TextInputElement>(ref: RefObject<TElement>, onKeyDown: KeyboardEventHandler<TElement> | undefined, onEnter: (() => void) | undefined, onEsc: (() => void) | undefined, onMove: ((direction: MoveDirection) => void) | undefined, onDone: ((value: string) => void) | undefined, onBlur: FocusEventHandler<TElement> | undefined, onFocus: FocusEventHandler<TElement> | undefined) => {
5
- onKeyDownHandler: KeyboardEventHandler<TElement>;
6
- onBlurHandler: FocusEventHandler<TElement>;
7
- onFocusHandler: FocusEventHandler<TElement>;
8
- };
1
+ import { FocusEventHandler, KeyboardEventHandler, RefObject } from "react";
2
+ export declare type MoveDirection = "right" | "left" | "down" | "up";
3
+ export declare type TextInputElement = HTMLTextAreaElement | HTMLInputElement;
4
+ export declare const useKeyboardNavigation: <TElement extends TextInputElement>(ref: RefObject<TElement>, onKeyDown: KeyboardEventHandler<TElement> | undefined, onEnter: (() => void) | undefined, onEsc: (() => void) | undefined, onMove: ((direction: MoveDirection) => void) | undefined, onDone: ((value: string) => void) | undefined, onBlur: FocusEventHandler<TElement> | undefined, onFocus: FocusEventHandler<TElement> | undefined) => {
5
+ onKeyDownHandler: KeyboardEventHandler<TElement>;
6
+ onBlurHandler: FocusEventHandler<TElement>;
7
+ onFocusHandler: FocusEventHandler<TElement>;
8
+ };
@@ -1,4 +1,4 @@
1
- import { RefObject } from "react";
2
- import { TextInputElement } from "./UseKeyboardNavigation";
3
- export declare function elementHasSelectionRange(element: TextInputElement): boolean;
4
- export declare const useSelectAllOnMount: (ref: RefObject<TextInputElement>, moveCursorToEnd: boolean, enabled: boolean) => void;
1
+ import { RefObject } from "react";
2
+ import { TextInputElement } from "./UseKeyboardNavigation";
3
+ export declare function elementHasSelectionRange(element: TextInputElement): boolean;
4
+ export declare const useSelectAllOnMount: (ref: RefObject<TextInputElement>, moveCursorToEnd: boolean, enabled: boolean) => void;
@@ -1,30 +1,30 @@
1
- import { ChangeEvent, ChangeEventHandler, CSSProperties, FocusEventHandler, KeyboardEventHandler, RefObject } from "react";
2
- import { TextInputVariant } from "../components/ui/text-input/TextInput";
3
- import { MoveDirection, TextInputElement } from "./UseKeyboardNavigation";
4
- import { FullOnChangeProps } from "../components/ui/types";
5
- interface UseTextInputOptions<TElement extends TextInputElement> extends FullOnChangeProps<string, ChangeEvent<TElement>> {
6
- wrapperStyle?: CSSProperties;
7
- wrapperClassName?: string;
8
- variant?: TextInputVariant;
9
- hideBorder?: boolean;
10
- selectAllOnMount?: boolean;
11
- moveCursorToEndOnMount?: boolean;
12
- onDone?: (value: string) => void;
13
- onEnter?: () => void;
14
- onEsc?: () => void;
15
- autoFocus?: boolean;
16
- /** onMove callback, triggered when user tries to move outside of field using arrow keys, tab or shift+tab. */
17
- onMove?: (direction: MoveDirection) => void;
18
- onFocus?: FocusEventHandler<TElement>;
19
- onBlur?: FocusEventHandler<TElement>;
20
- onKeyDown?: KeyboardEventHandler<TElement>;
21
- }
22
- interface UseTextInputHookResult<TElement extends TextInputElement> {
23
- autoFocus?: boolean;
24
- onChange: ChangeEventHandler<TElement>;
25
- onFocus: FocusEventHandler<TElement>;
26
- onBlur: FocusEventHandler<TElement>;
27
- onKeyDown: KeyboardEventHandler<TElement>;
28
- }
29
- export declare const useTextInput: <TElement extends TextInputElement>(ref: RefObject<TElement>, { onEnter, onEsc, onChange, onValueChange, selectAllOnMount, moveCursorToEndOnMount, onDone, onMove, onFocus, onBlur, onKeyDown, autoFocus, }: UseTextInputOptions<TElement>) => UseTextInputHookResult<TElement>;
30
- export {};
1
+ import { ChangeEvent, ChangeEventHandler, CSSProperties, FocusEventHandler, KeyboardEventHandler, RefObject } from "react";
2
+ import { TextInputVariant } from "../components/ui/text-input/TextInput";
3
+ import { MoveDirection, TextInputElement } from "./UseKeyboardNavigation";
4
+ import { FullOnChangeProps } from "../components/ui/types";
5
+ interface UseTextInputOptions<TElement extends TextInputElement> extends FullOnChangeProps<string, ChangeEvent<TElement>> {
6
+ wrapperStyle?: CSSProperties;
7
+ wrapperClassName?: string;
8
+ variant?: TextInputVariant;
9
+ hideBorder?: boolean;
10
+ selectAllOnMount?: boolean;
11
+ moveCursorToEndOnMount?: boolean;
12
+ onDone?: (value: string) => void;
13
+ onEnter?: () => void;
14
+ onEsc?: () => void;
15
+ autoFocus?: boolean;
16
+ /** onMove callback, triggered when user tries to move outside of field using arrow keys, tab or shift+tab. */
17
+ onMove?: (direction: MoveDirection) => void;
18
+ onFocus?: FocusEventHandler<TElement>;
19
+ onBlur?: FocusEventHandler<TElement>;
20
+ onKeyDown?: KeyboardEventHandler<TElement>;
21
+ }
22
+ interface UseTextInputHookResult<TElement extends TextInputElement> {
23
+ autoFocus?: boolean;
24
+ onChange: ChangeEventHandler<TElement>;
25
+ onFocus: FocusEventHandler<TElement>;
26
+ onBlur: FocusEventHandler<TElement>;
27
+ onKeyDown: KeyboardEventHandler<TElement>;
28
+ }
29
+ export declare const useTextInput: <TElement extends TextInputElement>(ref: RefObject<TElement>, { onEnter, onEsc, onChange, onValueChange, selectAllOnMount, moveCursorToEndOnMount, onDone, onMove, onFocus, onBlur, onKeyDown, autoFocus, }: UseTextInputOptions<TElement>) => UseTextInputHookResult<TElement>;
30
+ export {};
package/dist/index.d.ts CHANGED
@@ -1,18 +1,18 @@
1
- export * from "./components/ui/switch/Switch";
2
- export * from "./components/ui/switch/SwitchWithLabel";
3
- export * from "./components/ui/checkbox/CheckboxWithLabel";
4
- export * from "./components/ui/checkbox/Checkbox";
5
- export * from "./components/ui/radio/RadioButton";
6
- export * from "./components/ui/radio/RadioButtonWithLabel";
7
- export * from "./components/ui/numeric-text-input/NumericTextInput";
8
- export * from "./components/ui/numeric-text-input/hooks/UseNumericInputValue";
9
- export * from "./components/ui/password-input/PasswordInput";
10
- export * from "./components/ui/text-input/TextInput";
11
- export * from "./components/ui/text-input/TextInputBox";
12
- export * from "./components/ui/text-area/TextArea";
13
- export * from "./components/ui/types";
14
- export * from "./hooks/UseKeyboardNavigation";
15
- export * from "./hooks/UseSelectAllOnMount";
16
- export * from "./hooks/UseTextInput";
17
- export { onTextValueChange } from "./utils/NumericHelpers";
18
- export { onStepValueChange } from "./utils/NumericHelpers";
1
+ export * from "./components/ui/switch/Switch";
2
+ export * from "./components/ui/switch/SwitchWithLabel";
3
+ export * from "./components/ui/checkbox/CheckboxWithLabel";
4
+ export * from "./components/ui/checkbox/Checkbox";
5
+ export * from "./components/ui/radio/RadioButton";
6
+ export * from "./components/ui/radio/RadioButtonWithLabel";
7
+ export * from "./components/ui/numeric-text-input/NumericTextInput";
8
+ export * from "./components/ui/numeric-text-input/hooks/UseNumericInputValue";
9
+ export * from "./components/ui/password-input/PasswordInput";
10
+ export * from "./components/ui/text-input/TextInput";
11
+ export * from "./components/ui/text-input/TextInputBox";
12
+ export * from "./components/ui/text-area/TextArea";
13
+ export * from "./components/ui/types";
14
+ export * from "./hooks/UseKeyboardNavigation";
15
+ export * from "./hooks/UseSelectAllOnMount";
16
+ export * from "./hooks/UseTextInput";
17
+ export { onTextValueChange } from "./utils/NumericHelpers";
18
+ export { onStepValueChange } from "./utils/NumericHelpers";