@dfds-ui/forms 2.0.20-alpha.4a92bbb9 → 2.0.20-alpha.7dd0f764

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 (39) hide show
  1. package/cjs/assistive-text/AssistiveText.d.ts +9 -0
  2. package/cjs/asterisk/Asterisk.d.ts +11 -0
  3. package/cjs/checkbox/Checkbox.d.ts +65 -0
  4. package/cjs/checkbox/CheckboxContext.d.ts +13 -0
  5. package/cjs/checkbox/CheckboxGroup.d.ts +20 -0
  6. package/cjs/checkbox/index.d.ts +2 -0
  7. package/cjs/counter/Counter.d.ts +66 -0
  8. package/cjs/counter/index.d.ts +1 -0
  9. package/cjs/enhanced/EnhancedField.d.ts +20 -0
  10. package/cjs/enhanced/index.d.ts +1 -0
  11. package/cjs/error-text/ErrorText.d.ts +8 -0
  12. package/cjs/field-wrap/FieldWrap.d.ts +10 -0
  13. package/cjs/field-wrap/index.d.ts +1 -0
  14. package/cjs/help-icon/HelpIcon.d.ts +8 -0
  15. package/cjs/index.d.ts +18 -0
  16. package/cjs/label/Label.d.ts +11 -0
  17. package/cjs/password-field/PasswordField.d.ts +4 -0
  18. package/cjs/radio/Radio.d.ts +51 -0
  19. package/cjs/radio/RadioContext.d.ts +13 -0
  20. package/cjs/radio/RadioGroup.d.ts +12 -0
  21. package/cjs/radio/index.d.ts +2 -0
  22. package/cjs/rating/Rating.d.ts +55 -0
  23. package/cjs/rating/index.d.ts +1 -0
  24. package/cjs/select-field/AsyncSelectField.d.ts +99 -0
  25. package/cjs/select-field/NativeSelectField.d.ts +8 -0
  26. package/cjs/select-field/SelectField.d.ts +93 -0
  27. package/cjs/switch/Switch.d.ts +32 -0
  28. package/cjs/switch/SwitchContext.d.ts +11 -0
  29. package/cjs/switch/SwitchGroup.d.ts +10 -0
  30. package/cjs/switch/index.d.ts +2 -0
  31. package/cjs/tel-field/TelField.d.ts +67 -0
  32. package/cjs/tel-field/TelField.js +16 -17
  33. package/cjs/text-field/TextField.d.ts +57 -0
  34. package/cjs/textarea-field/TextareaField.d.ts +44 -0
  35. package/cjs/types/field.d.ts +52 -0
  36. package/cjs/types/index.d.ts +2 -0
  37. package/cjs/types/size.d.ts +1 -0
  38. package/package.json +7 -7
  39. package/tel-field/TelField.js +17 -18
@@ -0,0 +1,93 @@
1
+ import React from 'react';
2
+ import Select, { ActionMeta, createFilter, GroupBase, OptionsOrGroups, SingleValue } from 'react-select';
3
+ import { BaseFieldProps } from '../types';
4
+ export declare type BaseReactSelectProps = Omit<React.PropsWithRef<Select>, 'size' | 'css'>;
5
+ export declare type Size = 'small' | 'medium' | 'large';
6
+ export declare const ReactSelectWrapper: import("@emotion/styled").StyledComponent<{
7
+ theme?: import("@emotion/react").Theme | undefined;
8
+ as?: React.ElementType<any> | undefined;
9
+ } & {
10
+ error?: boolean | undefined;
11
+ size?: string | undefined;
12
+ arrow?: boolean | undefined;
13
+ selected?: boolean | undefined;
14
+ }, React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
15
+ export declare const Menu: (props: any) => JSX.Element;
16
+ export declare type SelectFieldProps<T = string> = BaseFieldProps & {
17
+ assistiveText?: string;
18
+ autoFocus?: boolean;
19
+ className?: string;
20
+ components?: any;
21
+ defaultValue?: SingleValue<T>;
22
+ errorMessage?: string;
23
+ /**
24
+ * Configuration object passed to react-select createFilter function to create [custom filter
25
+ * logic](https://react-select.com/advanced#custom-filter-logic)
26
+ * @param ignoreCase - boolean (optional)
27
+ * @param ignoreAccents - boolean (optional)
28
+ * @param stringify (obj: any) => string (optional)
29
+ * @param trim - boolean (optional)
30
+ * @param matchForm - 'any' | 'start'
31
+ */
32
+ filterConfig?: Parameters<typeof createFilter>[0];
33
+ /**
34
+ * Indicates that the Select can be cleared after selecting an Option.
35
+ *
36
+ * Setting this to true will display a small dismiss cross when a value is selected
37
+ */
38
+ isClearable?: boolean;
39
+ isSearchable?: boolean;
40
+ menuIsOpen?: boolean;
41
+ menuPlacement?: 'bottom' | 'auto' | 'top';
42
+ onBlur?: (value: any) => void;
43
+ onChange?: (newValue: SingleValue<T>, actionMeta: ActionMeta<T>) => void;
44
+ onSelect?: (value: SingleValue<T>) => void;
45
+ options?: OptionsOrGroups<T, GroupBase<T>>;
46
+ placeholder?: string;
47
+ prefix?: React.ReactNode;
48
+ styles?: any;
49
+ suffix?: React.ReactNode;
50
+ value?: SingleValue<T>;
51
+ visualSize?: Size;
52
+ };
53
+ declare function SelectFieldInner<T>({ assistiveText, components, defaultValue, disabled, errorMessage, filterConfig, help, helpPlacement, hideAsterisk, isClearable, isSearchable, label, name, onBlur, onChange, onSelect, options, placeholder, required, styles, value, visualSize, ...rest }: SelectFieldProps<T>, ref: React.ForwardedRef<any>): JSX.Element;
54
+ export declare const SelectField: <T>(props: BaseFieldProps & {
55
+ assistiveText?: string | undefined;
56
+ autoFocus?: boolean | undefined;
57
+ className?: string | undefined;
58
+ components?: any;
59
+ defaultValue?: SingleValue<T> | undefined;
60
+ errorMessage?: string | undefined;
61
+ /**
62
+ * Configuration object passed to react-select createFilter function to create [custom filter
63
+ * logic](https://react-select.com/advanced#custom-filter-logic)
64
+ * @param ignoreCase - boolean (optional)
65
+ * @param ignoreAccents - boolean (optional)
66
+ * @param stringify (obj: any) => string (optional)
67
+ * @param trim - boolean (optional)
68
+ * @param matchForm - 'any' | 'start'
69
+ */
70
+ filterConfig?: Parameters<typeof createFilter>[0];
71
+ /**
72
+ * Indicates that the Select can be cleared after selecting an Option.
73
+ *
74
+ * Setting this to true will display a small dismiss cross when a value is selected
75
+ */
76
+ isClearable?: boolean | undefined;
77
+ isSearchable?: boolean | undefined;
78
+ menuIsOpen?: boolean | undefined;
79
+ menuPlacement?: "auto" | "top" | "bottom" | undefined;
80
+ onBlur?: ((value: any) => void) | undefined;
81
+ onChange?: ((newValue: SingleValue<T>, actionMeta: ActionMeta<T>) => void) | undefined;
82
+ onSelect?: ((value: SingleValue<T>) => void) | undefined;
83
+ options?: OptionsOrGroups<T, GroupBase<T>> | undefined;
84
+ placeholder?: string | undefined;
85
+ prefix?: React.ReactNode;
86
+ styles?: any;
87
+ suffix?: React.ReactNode;
88
+ value?: SingleValue<T> | undefined;
89
+ visualSize?: Size | undefined;
90
+ } & {
91
+ ref?: React.ForwardedRef<any> | undefined;
92
+ }) => ReturnType<typeof SelectFieldInner>;
93
+ export default SelectField;
@@ -0,0 +1,32 @@
1
+ import React, { ChangeEvent } from 'react';
2
+ declare type Size = 'small' | 'medium';
3
+ export declare type SwitchProps = React.PropsWithRef<JSX.IntrinsicElements['label']> & {
4
+ /**
5
+ * Name of the input element
6
+ */
7
+ name?: string;
8
+ /**
9
+ * State of the switch
10
+ *
11
+ */
12
+ checked?: boolean;
13
+ /**
14
+ * Controls whether the input is disabled
15
+ */
16
+ disabled?: boolean;
17
+ /**
18
+ * Callback to fire when the state of the input changes
19
+ */
20
+ onChange?: (e: ChangeEvent<HTMLInputElement>) => void;
21
+ /**
22
+ * Controls whether the input label should be displayed on the right of the input, displayed on the left by default
23
+ */
24
+ right?: boolean;
25
+ /**
26
+ * Visual size of the switch
27
+ */
28
+ size?: Size;
29
+ error?: boolean;
30
+ };
31
+ export declare const Switch: React.ForwardRefExoticComponent<Pick<SwitchProps, "error" | "key" | "name" | "right" | "disabled" | "size" | "checked" | "css" | keyof React.LabelHTMLAttributes<HTMLLabelElement>> & React.RefAttributes<HTMLInputElement>>;
32
+ export {};
@@ -0,0 +1,11 @@
1
+ import React from 'react';
2
+ import { SwitchProps } from './Switch';
3
+ declare type SwitchContextProps = Required<Pick<SwitchProps, 'size' | 'error'>> & {
4
+ children?: React.ReactNode;
5
+ };
6
+ export declare const SwitchContext: React.Context<SwitchContextProps | undefined>;
7
+ export declare const SwitchContextProvider: React.FC<{
8
+ value: SwitchContextProps;
9
+ }>;
10
+ declare const useSwitchContext: () => SwitchContextProps | undefined;
11
+ export default useSwitchContext;
@@ -0,0 +1,10 @@
1
+ import { ReactNode } from 'react';
2
+ import { BaseFieldProps } from '../types';
3
+ import { SwitchProps } from './Switch';
4
+ export declare type SwitchGroupProps = Pick<BaseFieldProps, 'label' | 'errorMessage' | 'hideAsterisk' | 'required'> & {
5
+ /**
6
+ * JSX enclosed by the group.
7
+ */
8
+ children: ReactNode;
9
+ } & Pick<SwitchProps, 'size'>;
10
+ export declare const SwitchGroup: ({ size, label, errorMessage, required, hideAsterisk, children, }: SwitchGroupProps) => JSX.Element;
@@ -0,0 +1,2 @@
1
+ export * from './Switch';
2
+ export * from './SwitchGroup';
@@ -0,0 +1,67 @@
1
+ import React from 'react';
2
+ import { Locale } from '@dfds-ui/react-components';
3
+ import { BaseFieldProps } from '../types';
4
+ export declare type TelFieldProps = BaseFieldProps & {
5
+ /**
6
+ * Class name to be added to the TelField.
7
+ */
8
+ className?: string;
9
+ /**
10
+ * Default value for the phone number
11
+ */
12
+ defaultValue?: string;
13
+ /**
14
+ * Default locale. Will set the matching country in the dropdown
15
+ */
16
+ defaultLocale?: Locale;
17
+ /**
18
+ * Show trunk values (the local area code shown in parenthesis)
19
+ */
20
+ showTrunkValues?: boolean;
21
+ /**
22
+ * Makes value splitted so easier to convert to object
23
+ */
24
+ splitValues?: boolean;
25
+ /**
26
+ * Callback when value changes
27
+ */
28
+ onChange?: (newValue: string) => void;
29
+ /**
30
+ * Callback when blur
31
+ */
32
+ onBlur?: () => void;
33
+ };
34
+ export declare type TelFieldElement = {
35
+ focus?: () => void;
36
+ };
37
+ export declare const TelField: React.ForwardRefExoticComponent<BaseFieldProps & {
38
+ /**
39
+ * Class name to be added to the TelField.
40
+ */
41
+ className?: string | undefined;
42
+ /**
43
+ * Default value for the phone number
44
+ */
45
+ defaultValue?: string | undefined;
46
+ /**
47
+ * Default locale. Will set the matching country in the dropdown
48
+ */
49
+ defaultLocale?: "en" | "nl-BE" | "bg-BG" | "pt-BR" | "en-CA" | "zh-CN" | "cs-CZ" | "da-DK" | "et-EE" | "fi-FI" | "fr-BE" | "fr-FR" | "fr-MA" | "de-DE" | "hu-HU" | "it-IT" | "ja-JP" | "lv-LV" | "lt-LT" | "nl-NL" | "nb-NO" | "pl-PL" | "ro-RO" | "ru-RU" | "sk-SK" | "ko-KR" | "es-ES" | "sv-SE" | "tr-TR" | "en-GB" | "en-US" | undefined;
50
+ /**
51
+ * Show trunk values (the local area code shown in parenthesis)
52
+ */
53
+ showTrunkValues?: boolean | undefined;
54
+ /**
55
+ * Makes value splitted so easier to convert to object
56
+ */
57
+ splitValues?: boolean | undefined;
58
+ /**
59
+ * Callback when value changes
60
+ */
61
+ onChange?: ((newValue: string) => void) | undefined;
62
+ /**
63
+ * Callback when blur
64
+ */
65
+ onBlur?: (() => void) | undefined;
66
+ } & React.RefAttributes<TelFieldElement>>;
67
+ export default TelField;