@northlight/ui 2.12.2 → 2.12.3
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/es/northlight.d.ts +86 -112
- package/dist/es/northlight.js +221 -106
- package/dist/es/northlight.js.map +1 -1
- package/dist/umd/northlight.cjs +221 -106
- package/dist/umd/northlight.cjs.map +1 -1
- package/dist/umd/northlight.min.cjs +3 -3
- package/dist/umd/northlight.min.cjs.map +1 -1
- package/package.json +2 -2
package/dist/es/northlight.d.ts
CHANGED
|
@@ -3,7 +3,8 @@ export { AbsoluteCenter, AccordionButtonProps, AccordionIcon, AccordionIconProps
|
|
|
3
3
|
import { Props, GroupBase, MultiValue, SingleValue, ActionMeta, MenuListProps, SelectInstance, ChakraStylesConfig } from 'chakra-react-select';
|
|
4
4
|
export { AsyncCreatableSelect, AsyncSelect, Select as ChakraReactSelect, CreatableSelect } from 'chakra-react-select';
|
|
5
5
|
import * as React$1 from 'react';
|
|
6
|
-
import React__default, { ComponentType, Ref, ComponentProps, ChangeEvent, InputHTMLAttributes, ReactNode, ReactElement,
|
|
6
|
+
import React__default, { ComponentType, Ref, RefObject, ComponentProps, ChangeEvent, InputHTMLAttributes, ReactNode, ReactElement, MutableRefObject, EffectCallback, DependencyList } from 'react';
|
|
7
|
+
import * as react_hook_form from 'react-hook-form';
|
|
7
8
|
import { RegisterOptions, FieldValues, UseFormReturn as UseFormReturn$1, SetValueConfig, FieldPath, Control, ControllerRenderProps, UseFormProps, FieldError, Merge, FieldErrorsImpl } from 'react-hook-form';
|
|
8
9
|
export { useController, useFieldArray, useForm, useFormContext, useFormState, useWatch } from 'react-hook-form';
|
|
9
10
|
import * as _chakra_ui_system_dist_system_types from '@chakra-ui/system/dist/system.types';
|
|
@@ -22,7 +23,11 @@ export * from '@dnd-kit/utilities';
|
|
|
22
23
|
export { useInterval as dndUseInterval } from '@dnd-kit/utilities';
|
|
23
24
|
export * from '@dnd-kit/modifiers';
|
|
24
25
|
import { VariableSizeListProps, VariableSizeList, VariableSizeGridProps, VariableSizeGrid } from 'react-window';
|
|
26
|
+
import * as _chakra_ui_layout_dist_stack_stack_utils from '@chakra-ui/layout/dist/stack/stack.utils';
|
|
27
|
+
import * as _chakra_ui_radio_dist_radio_group from '@chakra-ui/radio/dist/radio-group';
|
|
25
28
|
import * as react_select from 'react-select';
|
|
29
|
+
import * as _chakra_ui_switch_dist_switch from '@chakra-ui/switch/dist/switch';
|
|
30
|
+
import * as _chakra_ui_textarea_dist_textarea from '@chakra-ui/textarea/dist/textarea';
|
|
26
31
|
import { Props as Props$1 } from 'react-input-mask';
|
|
27
32
|
import { NumericFormatProps } from 'react-number-format';
|
|
28
33
|
import * as _chakra_ui_toast_dist_toast_types_24f022fd from '@chakra-ui/toast/dist/toast.types-24f022fd';
|
|
@@ -137,6 +142,15 @@ interface SelectProps<T, K extends boolean> extends Omit<Props<T, K, GroupBase<T
|
|
|
137
142
|
customOption?: ((option: T) => JSX.Element) | null;
|
|
138
143
|
isMulti?: K;
|
|
139
144
|
ref?: Ref<SelectInstance<T, K, GroupBase<T>>>;
|
|
145
|
+
/** Points to the container that the select refers to when deciding where to fit menu.
|
|
146
|
+
* E.g if you render the select in a modal you may want to sent
|
|
147
|
+
* containerRef equal to a ref pointing to that modal,
|
|
148
|
+
* because in that case the select dropdown change placement to try and stay within the modal */
|
|
149
|
+
containerRef?: UseAdaptiveMenuPlacementProps['containerRef'];
|
|
150
|
+
/** The min height that will be reserveed for the select dropdown, used to determine wheter to put
|
|
151
|
+
* dropdown on top of or bottom of select
|
|
152
|
+
*/
|
|
153
|
+
dropdownMinHeightPx?: number;
|
|
140
154
|
}
|
|
141
155
|
type SelectFieldProps<T, K extends boolean = false> = SelectProps<T, K> & Omit<InputFieldProps, 'isMulti'> & {
|
|
142
156
|
direction?: StackDirection;
|
|
@@ -145,6 +159,10 @@ type SelectFieldProps<T, K extends boolean = false> = SelectProps<T, K> & Omit<I
|
|
|
145
159
|
validate?: RegisterOptions;
|
|
146
160
|
isRequired?: boolean;
|
|
147
161
|
};
|
|
162
|
+
interface UseAdaptiveMenuPlacementProps {
|
|
163
|
+
dropdownHeightPx: number;
|
|
164
|
+
containerRef?: RefObject<HTMLDivElement>;
|
|
165
|
+
}
|
|
148
166
|
|
|
149
167
|
/**
|
|
150
168
|
* Select component that provides a customizable and accessible select input.
|
|
@@ -271,7 +289,13 @@ render(<CustomSelect />);
|
|
|
271
289
|
*/
|
|
272
290
|
declare const Select: <T extends Option, K extends boolean = false>(props: SelectProps<T, K> & React__default.RefAttributes<SelectInstance<T, K, GroupBase<T>>>) => React__default.ReactElement<any, string | React__default.JSXElementConstructor<any>> | null;
|
|
273
291
|
|
|
274
|
-
declare
|
|
292
|
+
declare const SelectField: <T extends Option, K extends boolean = false>(props: SelectProps<T, K> & Omit<InputFieldProps, "isMulti"> & {
|
|
293
|
+
direction?: _chakra_ui_layout_dist_stack_stack_utils.StackDirection | undefined;
|
|
294
|
+
name: string;
|
|
295
|
+
label: string;
|
|
296
|
+
validate?: react_hook_form.RegisterOptions | undefined;
|
|
297
|
+
isRequired?: boolean | undefined;
|
|
298
|
+
} & React__default.RefAttributes<HTMLDivElement>) => React__default.ReactElement<any, string | React__default.JSXElementConstructor<any>> | null;
|
|
275
299
|
|
|
276
300
|
declare const getMatchingValue: <T extends Option, K extends boolean>(value: (K extends true ? string[] | T[] : string | T) | undefined, options: react_select.OptionsOrGroups<T, react_select.GroupBase<T>> | undefined) => T | T[] | undefined;
|
|
277
301
|
|
|
@@ -572,7 +596,7 @@ declare const Checkbox: ({ value, onChange, name, size, variant, ...rest }: Chec
|
|
|
572
596
|
* ?)
|
|
573
597
|
*
|
|
574
598
|
*/
|
|
575
|
-
declare const CheckboxField: (
|
|
599
|
+
declare const CheckboxField: (props: CheckboxFieldProps & React__default.RefAttributes<HTMLDivElement>) => React__default.ReactElement<any, string | React__default.JSXElementConstructor<any>> | null;
|
|
576
600
|
|
|
577
601
|
type ColorPickerSize = 'sm' | 'md' | 'lg';
|
|
578
602
|
interface ColorPickerProps extends Omit<IconButtonProps$1, 'onChange' | 'value' | 'aria-label' | 'variant'> {
|
|
@@ -828,7 +852,7 @@ declare const FlipButtonGroup: (props: FlipButtonGroupProps) => JSX.Element;
|
|
|
828
852
|
* ?)
|
|
829
853
|
*
|
|
830
854
|
*/
|
|
831
|
-
declare const FlipButtonGroupField: (
|
|
855
|
+
declare const FlipButtonGroupField: (props: FlipButtonGroupFieldProps & React__default.RefAttributes<HTMLDivElement>) => React__default.ReactElement<any, string | React__default.JSXElementConstructor<any>> | null;
|
|
832
856
|
|
|
833
857
|
interface DateRange {
|
|
834
858
|
startDate: string;
|
|
@@ -995,7 +1019,7 @@ declare const DateRangePicker: (props: DateRangePickerProps) => JSX.Element;
|
|
|
995
1019
|
* yyyy-mm-dd on the onSubmit callback on <Form>
|
|
996
1020
|
*
|
|
997
1021
|
*/
|
|
998
|
-
declare const DatePickerField: (
|
|
1022
|
+
declare const DatePickerField: (props: DatePickerFieldProps & React__default.RefAttributes<HTMLDivElement>) => React__default.ReactElement<any, string | React__default.JSXElementConstructor<any>> | null;
|
|
999
1023
|
|
|
1000
1024
|
/**
|
|
1001
1025
|
* The <DateRangePicker /> component wrapped in a <Field />
|
|
@@ -1004,7 +1028,7 @@ declare const DatePickerField: ({ name, minValue, maxValue, isRequired, directio
|
|
|
1004
1028
|
* @see {@link https://northlight.dev/reference/date-range-picker-field}
|
|
1005
1029
|
*
|
|
1006
1030
|
*/
|
|
1007
|
-
declare const DateRangePickerField: (
|
|
1031
|
+
declare const DateRangePickerField: (props: DateRangePickerFieldProps & React__default.RefAttributes<HTMLDivElement>) => React__default.ReactElement<any, string | React__default.JSXElementConstructor<any>> | null;
|
|
1008
1032
|
|
|
1009
1033
|
interface ToolboxProps extends Omit<FlexProps, 'direction'> {
|
|
1010
1034
|
isResizable?: boolean;
|
|
@@ -1225,7 +1249,7 @@ interface SearchBarFieldProps<T extends SearchBarOptionType, K extends boolean =
|
|
|
1225
1249
|
|
|
1226
1250
|
declare const SearchBar: <T extends SearchBarOptionType, K extends boolean = false>(props: SearchBarProps<T, K> & React__default.RefAttributes<SelectInstance<T, K, GroupBase<T>>>) => React__default.ReactElement<any, string | React__default.JSXElementConstructor<any>> | null;
|
|
1227
1251
|
|
|
1228
|
-
declare const SearchBarField: <T extends SearchBarOptionType, K extends boolean = false>(
|
|
1252
|
+
declare const SearchBarField: <T extends SearchBarOptionType, K extends boolean = false>(props: SearchBarFieldProps<T, K> & React__default.RefAttributes<HTMLDivElement>) => React__default.ReactElement<any, string | React__default.JSXElementConstructor<any>> | null;
|
|
1229
1253
|
|
|
1230
1254
|
/**
|
|
1231
1255
|
* Context used for all drag and drop components
|
|
@@ -1426,7 +1450,7 @@ declare const SortableItem: ({ itemLabel, dblClickThreshold, children, disableDr
|
|
|
1426
1450
|
* ?)
|
|
1427
1451
|
*
|
|
1428
1452
|
*/
|
|
1429
|
-
declare const DragItem: (props: DragItemProps & React__default.RefAttributes<
|
|
1453
|
+
declare const DragItem: (props: DragItemProps & React__default.RefAttributes<HTMLSpanElement>) => React__default.ReactElement<any, string | React__default.JSXElementConstructor<any>> | null;
|
|
1430
1454
|
|
|
1431
1455
|
/**
|
|
1432
1456
|
* Util component to display drag handle icon
|
|
@@ -1790,7 +1814,7 @@ interface LabelProps extends FormLabelProps$1 {
|
|
|
1790
1814
|
* under the props tab to right should be passed down via **sx**_)
|
|
1791
1815
|
*
|
|
1792
1816
|
*/
|
|
1793
|
-
declare const Label: (
|
|
1817
|
+
declare const Label: (props: LabelProps & React__default.RefAttributes<HTMLLabelElement>) => React__default.ReactElement<any, string | React__default.JSXElementConstructor<any>> | null;
|
|
1794
1818
|
|
|
1795
1819
|
type HeadingType = typeof Heading;
|
|
1796
1820
|
type BodyType = typeof P;
|
|
@@ -1807,7 +1831,7 @@ interface FormLabelProps extends LabelProps {
|
|
|
1807
1831
|
* @see {@link https://northlight.dev/reference/form-label}
|
|
1808
1832
|
*
|
|
1809
1833
|
*/
|
|
1810
|
-
declare const FormLabel: (
|
|
1834
|
+
declare const FormLabel: (props: FormLabelProps & React__default.RefAttributes<HTMLLabelElement>) => React__default.ReactElement<any, string | React__default.JSXElementConstructor<any>> | null;
|
|
1811
1835
|
|
|
1812
1836
|
interface FastListProps extends Omit<VariableSizeListProps, 'itemSize' | 'children' | 'height' | 'width' | 'direction'> {
|
|
1813
1837
|
itemSize: number | ((index: number) => number);
|
|
@@ -2493,7 +2517,18 @@ declare const NumberInput: ({ variant, size, onChange, onInputChange, enableStep
|
|
|
2493
2517
|
* @see {@link https://northlight.dev/reference/number-input-field}
|
|
2494
2518
|
*
|
|
2495
2519
|
*/
|
|
2496
|
-
declare const NumberInputField: (
|
|
2520
|
+
declare const NumberInputField: (props: Omit<NumberInputProps, "onChange"> & InputFieldProps & {
|
|
2521
|
+
name: string;
|
|
2522
|
+
label: string;
|
|
2523
|
+
validate?: react_hook_form.RegisterOptions | undefined;
|
|
2524
|
+
size?: NumberInputSizeProps | undefined;
|
|
2525
|
+
isRequired?: boolean | undefined;
|
|
2526
|
+
unit?: string | undefined;
|
|
2527
|
+
direction?: _chakra_ui_layout_dist_stack_stack_utils.StackDirection | undefined;
|
|
2528
|
+
onChange?: ((e: string | number) => void) | undefined;
|
|
2529
|
+
inputLeftElement?: React__default.ReactNode;
|
|
2530
|
+
inputRightElement?: React__default.ReactNode;
|
|
2531
|
+
} & React__default.RefAttributes<HTMLDivElement>) => React__default.ReactElement<any, string | React__default.JSXElementConstructor<any>> | null;
|
|
2497
2532
|
|
|
2498
2533
|
declare const advancedParseFloat: (value: number | string) => string | number;
|
|
2499
2534
|
|
|
@@ -2638,7 +2673,14 @@ declare const RadioGroup: ({ direction, children, name, ...rest }: RadioGroupPro
|
|
|
2638
2673
|
* @see {@link https://northlight.dev/reference/radio-group-field}
|
|
2639
2674
|
*
|
|
2640
2675
|
*/
|
|
2641
|
-
declare const RadioGroupField: (
|
|
2676
|
+
declare const RadioGroupField: (props: _chakra_ui_radio_dist_radio_group.RadioGroupProps & {
|
|
2677
|
+
direction?: _chakra_ui_layout_dist_stack_stack_utils.StackDirection | undefined;
|
|
2678
|
+
name: string;
|
|
2679
|
+
label: string;
|
|
2680
|
+
validate?: react_hook_form.RegisterOptions | undefined;
|
|
2681
|
+
isRequired?: boolean | undefined;
|
|
2682
|
+
value?: string | undefined;
|
|
2683
|
+
} & React__default.RefAttributes<HTMLDivElement>) => React__default.ReactElement<any, string | React__default.JSXElementConstructor<any>> | null;
|
|
2642
2684
|
|
|
2643
2685
|
type SpinnerProps = SpinnerProps$1;
|
|
2644
2686
|
|
|
@@ -2660,7 +2702,8 @@ type SwitchFieldProps = SwitchProps$1 & {
|
|
|
2660
2702
|
validate?: RegisterOptions;
|
|
2661
2703
|
isRequired?: boolean;
|
|
2662
2704
|
direction?: StackDirection;
|
|
2663
|
-
|
|
2705
|
+
labelPlacement?: 'left' | 'right';
|
|
2706
|
+
labelSize?: '2xs' | 'xs' | 'md' | 'lg';
|
|
2664
2707
|
};
|
|
2665
2708
|
|
|
2666
2709
|
/**
|
|
@@ -2694,18 +2737,30 @@ declare const Switch: ({ value, onChange, name, size, ...rest }: SwitchProps) =>
|
|
|
2694
2737
|
* @see {@link https://northlight.dev/reference/switch-field}
|
|
2695
2738
|
* @example (Example)
|
|
2696
2739
|
* ## Basic
|
|
2740
|
+
* Tip:
|
|
2741
|
+
* * For `labelPlacement` you can use `"left" | "right"`
|
|
2742
|
+
* * For `labelSize` you can use `"2xs" | "xs" | "md" | "lg"` or leave it blank
|
|
2697
2743
|
* (?
|
|
2698
2744
|
* <Form initialValues={{name: ''}}>
|
|
2699
2745
|
* <SwitchField
|
|
2700
2746
|
* name="terms"
|
|
2701
2747
|
* label="I agree to the Terms & Conditions"
|
|
2702
|
-
*
|
|
2748
|
+
* labelPlacement="right"
|
|
2749
|
+
* labelSize="md"
|
|
2703
2750
|
* />
|
|
2704
2751
|
* </Form>
|
|
2705
2752
|
* ?)
|
|
2706
2753
|
*
|
|
2707
2754
|
*/
|
|
2708
|
-
declare const SwitchField: (
|
|
2755
|
+
declare const SwitchField: (props: _chakra_ui_switch_dist_switch.SwitchProps & {
|
|
2756
|
+
name: string;
|
|
2757
|
+
label: string;
|
|
2758
|
+
validate?: react_hook_form.RegisterOptions | undefined;
|
|
2759
|
+
isRequired?: boolean | undefined;
|
|
2760
|
+
direction?: _chakra_ui_layout_dist_stack_stack_utils.StackDirection | undefined;
|
|
2761
|
+
labelPlacement?: "right" | "left" | undefined;
|
|
2762
|
+
labelSize?: "md" | "lg" | "2xs" | "xs" | undefined;
|
|
2763
|
+
} & React__default.RefAttributes<HTMLDivElement>) => React__default.ReactElement<any, string | React__default.JSXElementConstructor<any>> | null;
|
|
2709
2764
|
|
|
2710
2765
|
interface TableProps extends Omit<TableProps$1, 'variant'> {
|
|
2711
2766
|
variant?: TableProps$1['variant'] | 'rounded';
|
|
@@ -2817,7 +2872,7 @@ interface TagGroupProps extends StackProps {
|
|
|
2817
2872
|
* ?)
|
|
2818
2873
|
*
|
|
2819
2874
|
*/
|
|
2820
|
-
declare const Tag: (props: TagProps & React__default.RefAttributes<
|
|
2875
|
+
declare const Tag: (props: TagProps & React__default.RefAttributes<HTMLSpanElement>) => React__default.ReactElement<any, string | React__default.JSXElementConstructor<any>> | null;
|
|
2821
2876
|
|
|
2822
2877
|
/**
|
|
2823
2878
|
* Used when rending multiple tags in limited container for responsive layout
|
|
@@ -2869,7 +2924,14 @@ type TextareaFieldProps = TextareaProps$1 & {
|
|
|
2869
2924
|
*/
|
|
2870
2925
|
declare const Textarea: ({ size, onChange, name, value, ...rest }: TextareaProps) => JSX.Element;
|
|
2871
2926
|
|
|
2872
|
-
declare const TextareaField: (
|
|
2927
|
+
declare const TextareaField: (props: _chakra_ui_textarea_dist_textarea.TextareaProps & {
|
|
2928
|
+
name: string;
|
|
2929
|
+
label: string;
|
|
2930
|
+
validate?: react_hook_form.RegisterOptions | undefined;
|
|
2931
|
+
isRequired?: boolean | undefined;
|
|
2932
|
+
size?: TextSizeProps | undefined;
|
|
2933
|
+
direction?: _chakra_ui_layout_dist_stack_stack_utils.StackDirection | undefined;
|
|
2934
|
+
} & React__default.RefAttributes<HTMLDivElement>) => React__default.ReactElement<any, string | React__default.JSXElementConstructor<any>> | null;
|
|
2873
2935
|
|
|
2874
2936
|
interface TextInputFormatter {
|
|
2875
2937
|
format: (value: string) => string;
|
|
@@ -2903,6 +2965,8 @@ interface FormattedNumberInputProps extends Omit<NumericFormatProps, 'onChange'
|
|
|
2903
2965
|
isPercentage?: boolean;
|
|
2904
2966
|
/** Will round up and restrict number of decimals */
|
|
2905
2967
|
numberOfDecimals?: number;
|
|
2968
|
+
inputLeftElement?: React.ReactNode;
|
|
2969
|
+
inputRightElement?: React.ReactNode;
|
|
2906
2970
|
}
|
|
2907
2971
|
interface FormattedNumberInputFieldProps extends FormattedNumberInputProps {
|
|
2908
2972
|
name: string;
|
|
@@ -2953,7 +3017,7 @@ interface FormattedNumberInputFieldProps extends FormattedNumberInputProps {
|
|
|
2953
3017
|
?)
|
|
2954
3018
|
|
|
2955
3019
|
*/
|
|
2956
|
-
declare const FormattedNumberInput: ({ preset, isPercentage, onChange, value, numberOfDecimals, max, min, ...rest }: FormattedNumberInputProps) => JSX.Element;
|
|
3020
|
+
declare const FormattedNumberInput: ({ preset, isPercentage, onChange, value, numberOfDecimals, max, min, inputLeftElement, inputRightElement, ...rest }: FormattedNumberInputProps) => JSX.Element;
|
|
2957
3021
|
|
|
2958
3022
|
/**
|
|
2959
3023
|
* The formatted number input component wrapped in a <Field />
|
|
@@ -2972,7 +3036,7 @@ declare const FormattedNumberInput: ({ preset, isPercentage, onChange, value, nu
|
|
|
2972
3036
|
* ?)
|
|
2973
3037
|
*
|
|
2974
3038
|
*/
|
|
2975
|
-
declare const FormattedNumberInputField: (
|
|
3039
|
+
declare const FormattedNumberInputField: (props: FormattedNumberInputFieldProps & React__default.RefAttributes<HTMLDivElement>) => React__default.ReactElement<any, string | React__default.JSXElementConstructor<any>> | null;
|
|
2976
3040
|
|
|
2977
3041
|
declare const MaskedTextInput: ({ mask, maskPlaceholder, alwaysShowMask, name, value, placeholder, onChange, onBlur, ...rest }: MaskedTextInputProps) => JSX.Element;
|
|
2978
3042
|
|
|
@@ -2986,7 +3050,7 @@ declare const MaskedTextInput: ({ mask, maskPlaceholder, alwaysShowMask, name, v
|
|
|
2986
3050
|
*
|
|
2987
3051
|
*
|
|
2988
3052
|
*/
|
|
2989
|
-
declare const TextField: (
|
|
3053
|
+
declare const TextField: (props: TextFieldProps & React__default.RefAttributes<HTMLDivElement>) => React__default.ReactElement<any, string | React__default.JSXElementConstructor<any>> | null;
|
|
2990
3054
|
|
|
2991
3055
|
interface ToastProps extends AlertProps {
|
|
2992
3056
|
title?: string;
|
|
@@ -3341,97 +3405,7 @@ You can move up the form state using a ref as well
|
|
|
3341
3405
|
*/
|
|
3342
3406
|
declare const Form: <FormValues extends FieldValues>(props: FormProps<FormValues> & React__default.RefAttributes<UseFormReturn$1<FormValues>>) => React__default.ReactElement<any, string | React__default.JSXElementConstructor<any>> | null;
|
|
3343
3407
|
|
|
3344
|
-
|
|
3345
|
-
* Wraps children under form context
|
|
3346
|
-
* @see TextField
|
|
3347
|
-
* @see Form
|
|
3348
|
-
* @see {@link https://northlight.dev/reference/field}
|
|
3349
|
-
*
|
|
3350
|
-
* @example (Example)
|
|
3351
|
-
* ## Input example
|
|
3352
|
-
* (?
|
|
3353
|
-
* <Form initialValues={{name: ''}}>
|
|
3354
|
-
* <Box p="2">
|
|
3355
|
-
* <Field name="name" label="Input name">
|
|
3356
|
-
* {({value, onChange}) => (
|
|
3357
|
-
* <Input value={value} onChange={onChange} />
|
|
3358
|
-
* )}
|
|
3359
|
-
* </Field>
|
|
3360
|
-
* </Box>
|
|
3361
|
-
*
|
|
3362
|
-
* </Form>
|
|
3363
|
-
* ?)
|
|
3364
|
-
* <br />
|
|
3365
|
-
* As you can see the field component acts as a middleman to connect
|
|
3366
|
-
* any component to the form context, via a controlled value and onChange prop.
|
|
3367
|
-
* Most of the common use cases for field,
|
|
3368
|
-
* such as text input have been abstracted into their own components, for example _TextField_
|
|
3369
|
-
*
|
|
3370
|
-
* @example (Example)
|
|
3371
|
-
* ## Example with validation and form submition
|
|
3372
|
-
* (?
|
|
3373
|
-
* () => {
|
|
3374
|
-
* const toast = useToast()
|
|
3375
|
-
* const handleSubmit =(v) => {
|
|
3376
|
-
* toast({title: 'Sent Message', description: `"${v.message}"`})
|
|
3377
|
-
* }
|
|
3378
|
-
* return (
|
|
3379
|
-
* <Form initialValues={{message: ''}} onSubmit={handleSubmit}>
|
|
3380
|
-
* <Stack p="2">
|
|
3381
|
-
* <Field
|
|
3382
|
-
* name="message"
|
|
3383
|
-
* label="Write email"
|
|
3384
|
-
* isRequired={true}
|
|
3385
|
-
* validate={{maxLength: {message: 'Message must be under 30 characters', value: 30}}}
|
|
3386
|
-
* >
|
|
3387
|
-
* {({value, onChange}) => (
|
|
3388
|
-
* <Textarea value={value} onChange={onChange} />
|
|
3389
|
-
* )}
|
|
3390
|
-
* </Field>
|
|
3391
|
-
* <Button type="submit" variant="brand">Send Message</Button>
|
|
3392
|
-
* </Stack>
|
|
3393
|
-
*
|
|
3394
|
-
* </Form>
|
|
3395
|
-
* )
|
|
3396
|
-
* }
|
|
3397
|
-
* ?)
|
|
3398
|
-
*
|
|
3399
|
-
* @example (Example)
|
|
3400
|
-
* ## Type-safety
|
|
3401
|
-
* There are multiple ways to provide types for
|
|
3402
|
-
* the field callback values. To ensure that each
|
|
3403
|
-
* component within the field receives the correct
|
|
3404
|
-
* value, it's essential to make the field aware
|
|
3405
|
-
* of the form state values. When the Field component
|
|
3406
|
-
* does not receive any types, the "value" callback
|
|
3407
|
-
* argument will have the type of "any".
|
|
3408
|
-
* <br /><br />
|
|
3409
|
-
* ### Passing down the control prop (Recommended)
|
|
3410
|
-
* (?
|
|
3411
|
-
* <Form initialValues={{username: 'Alex'}}>
|
|
3412
|
-
* {
|
|
3413
|
-
* ({ control }) => {
|
|
3414
|
-
* <Box p="2">
|
|
3415
|
-
* <Field name="username" label="Input name" control={ control }>
|
|
3416
|
-
* {({value, onChange}) => ( // "value" has type of "string"
|
|
3417
|
-
* <Input value={value} onChange={onChange} />
|
|
3418
|
-
* )}
|
|
3419
|
-
* </Field>
|
|
3420
|
-
* </Box>
|
|
3421
|
-
* }
|
|
3422
|
-
* }
|
|
3423
|
-
* </Form>
|
|
3424
|
-
* ?)
|
|
3425
|
-
* <br /><br />
|
|
3426
|
-
* ### Specifying generic arguments
|
|
3427
|
-
* You can also specify generic arguments on the Field
|
|
3428
|
-
* component to ensure that "value" has a valid type.
|
|
3429
|
-
* The passed generic type combined with the valid
|
|
3430
|
-
* "name" property ensures that "value" has the expected
|
|
3431
|
-
* type received from the generic type:
|
|
3432
|
-
* `<Field<MyFormBody> name="username">...</Field>`
|
|
3433
|
-
*/
|
|
3434
|
-
declare function Field<FormValues extends FieldValues = FieldValues, FieldName extends FieldPath<FormValues> = FieldPath<FormValues>>({ name, label, children, direction, isRequired, noLabelConnection, validate, control: passedControl, ...rest }: FieldProps<FormValues, FieldName>): JSX.Element;
|
|
3408
|
+
declare const Field: <FormValues extends FieldValues = FieldValues, FieldName extends FieldPath<FormValues> = FieldPath<FormValues>>(props: FieldProps<FormValues, FieldName> & React__default.RefAttributes<HTMLDivElement>) => React__default.ReactElement<any, string | React__default.JSXElementConstructor<any>> | null;
|
|
3435
3409
|
|
|
3436
3410
|
declare const useSetValueRefreshed: () => (name: any, value: any, options: SetValueOptionsType) => void;
|
|
3437
3411
|
|
|
@@ -3766,4 +3740,4 @@ declare const useDidUpdateEffect: (effect: EffectCallback, dependencies: Depende
|
|
|
3766
3740
|
declare const theme: Record<string, any>;
|
|
3767
3741
|
declare const tottTheme: Record<string, any>;
|
|
3768
3742
|
|
|
3769
|
-
export { Accordion, AccordionButton, AccordionItem, AccordionPanel, Alert, AlertProps, AlertVariants, AspectRatio, AsyncError, AsyncErrorProps, Avatar, AvatarBadgeProps, AvatarGroup, AvatarGroupProps, AvatarProps, Badge, BasicOption, Blinker, BlinkerProps, BlockVariant, BlockVariantColorTuple, Blockquote, BodyType, Button, ButtonProps, ButtonVariants, Capitalized, Carousel, Checkbox, CheckboxField, CheckboxFieldProps, CheckboxProps, CheckboxVariants, ChildrenType, Clickable, ClickableProps, ClipboardInput, ClipboardInputProps, Collapse, CollapseProps, Color, ColorButtonProps, ColorGrade, ColorPicker, ColorPickerField, ColorPickerFieldProps, ColorPickerProps, ColorShades, ColorsExpandButtonProps, ConfirmDeleteModalProps, CurrentTheme, CustomContainerPropsType, CustomElementType, CustomFlipButtonProps, CustomFlipButtonPropsType, CustomTheme, DatePicker, DatePickerField, DatePickerFieldProps, DatePickerProps, DateRange, DateRangePicker, DateRangePickerField, DateRangePickerFieldProps, DateRangePickerProps, DragAndDrop, DragHandle, DragHandleProps, DragItem, DragItemProps, Draggable, DraggableProps, DropZone, DropZoneProps, Droppable, DroppableProps, DurationType, EditableControlsProps, EditableProps, EditableSizes, EditableText, Fade, FadeProps, FastGrid, FastGridProps, FastList, FastListProps, Field, FieldErrorType, FieldProps, FileEditorModalProps, FileFormat, FileIconButtonProps, FileItemProps, FilePicker, FilePickerField, FilePickerFieldProps, FilePickerProps, FileWithSizeAndType, FileWithSrcNameType, FileWithType, FlipButton, FlipButtonGroup, FlipButtonGroupField, FlipButtonGroupFieldProps, FlipButtonGroupProps, FlipButtonProps, Form, FormBody, FormLabel, FormLabelProps, FormProps, FormattedNumberInput, FormattedNumberInputField, FormattedNumberInputFieldProps, FormattedNumberInputPreset, FormattedNumberInputProps, GenericAsProps, H1, H2, H3, H4, H5, H6, HeadingProps, HeadingType, Icon, IconButton, IconButtonProps, IconProps, InputFieldProps, Label, LabelProps, LabelSizes, LabelType, Lead, ListenersType, MaskedTextInput, MaskedTextInputProps, MediatoolThemeProvider, MediatoolThemeProviderProps, Message, Modal, ModalBase, ModalBooleans, ModalProps, ModalSizes, MultiFileList, MultiFileListProps, MultiFilePicker, MultiFilePickerField, MultiFilePickerFieldProps, MultiFilePickerProps, MultiFileUploader, MultiFileUploaderProps, MultiItemType, MultiSort, MultiSortProps, NotificationIconButton, NotificationIconButtonProps, NumberInput, NumberInputField, NumberInputFieldProps, NumberInputProps, NumberInputSizeProps, NumberInputStepperProps, OffsetType, Option, OrganizationLogo, OrganizationLogoProps, OverflowGroup, OverflowGroupProps, OverflowIndicatorProps, P, PProps, PaneDivider, PaneItem, PinInput, PinInputProps, PinSize, PinSizeTuple, PinVariant, PresetOptions, ProgressBar, Radio, RadioFieldGroupProps, RadioFieldProps, RadioGroup, RadioGroupField, RadioGroupProps, RadioProps, ScaleFade, ScaleFadeProps, SearchBar, SearchBarField, SearchBarFieldProps, SearchBarOptionType, SearchBarProps, Select, SelectActionMeta, SelectField, SelectFieldProps, SelectProps, SetValueOptionsType, Slide, SlideFade, SlideFadeProps, SlideProps, Small, Sortable, SortableContainer, SortableContainerProps, SortableItem, SortableItemProps, SortableList, SortableListProps, Spinner, SpinnerProps, SplitPane, SplitPaneProps, StatusBlock, StatusBlockProps, StatusPin, StatusPinProps, Step, StepList, StepListProps, StepPanel, StepPanelProps, StepProps, StepStack, Steps, StepsProps, StylizedType, Switch, SwitchField, SwitchFieldProps, SwitchProps, TabPanel, TabPanelProps, Table, TableProps, Tabs, TabsProps, Tag, TagGroup, TagGroupProps, TagProps, TagsInput, TagsInputProps, TextField, TextFieldProps, TextInputFormatter, TextSizeProps, Textarea, TextareaField, TextareaFieldProps, TextareaProps, Tiny, Toast, ToastProps, Toolbox, ToolboxContent, ToolboxContentProps, ToolboxFooter, ToolboxFooterProps, ToolboxHeader, ToolboxHeaderProps, ToolboxProps, TransitionDirection, UseFormReturn, UseSelectCallbacksProps, UseToastOptions, addAlpha, advancedParseFloat, createDebounceFunctionInstance, getChildrenWithProps, getContrastColor, getFieldError, getInitials, getMatchingValue, getShades, highlight, luminosity, ring, statusIconMap, theme, tottTheme, trimFormValues, useArrowFocus, useCurrentTheme, useDebounce, useDidUpdateEffect, useLoadingMessage, useOutsideRectClick, useOverflowGroup, useScreenSize, useScrollToBottom, useSelectCallbacks, useSetValueRefreshed, useToast };
|
|
3743
|
+
export { Accordion, AccordionButton, AccordionItem, AccordionPanel, Alert, AlertProps, AlertVariants, AspectRatio, AsyncError, AsyncErrorProps, Avatar, AvatarBadgeProps, AvatarGroup, AvatarGroupProps, AvatarProps, Badge, BasicOption, Blinker, BlinkerProps, BlockVariant, BlockVariantColorTuple, Blockquote, BodyType, Button, ButtonProps, ButtonVariants, Capitalized, Carousel, Checkbox, CheckboxField, CheckboxFieldProps, CheckboxProps, CheckboxVariants, ChildrenType, Clickable, ClickableProps, ClipboardInput, ClipboardInputProps, Collapse, CollapseProps, Color, ColorButtonProps, ColorGrade, ColorPicker, ColorPickerField, ColorPickerFieldProps, ColorPickerProps, ColorShades, ColorsExpandButtonProps, ConfirmDeleteModalProps, CurrentTheme, CustomContainerPropsType, CustomElementType, CustomFlipButtonProps, CustomFlipButtonPropsType, CustomTheme, DatePicker, DatePickerField, DatePickerFieldProps, DatePickerProps, DateRange, DateRangePicker, DateRangePickerField, DateRangePickerFieldProps, DateRangePickerProps, DragAndDrop, DragHandle, DragHandleProps, DragItem, DragItemProps, Draggable, DraggableProps, DropZone, DropZoneProps, Droppable, DroppableProps, DurationType, EditableControlsProps, EditableProps, EditableSizes, EditableText, Fade, FadeProps, FastGrid, FastGridProps, FastList, FastListProps, Field, FieldErrorType, FieldProps, FileEditorModalProps, FileFormat, FileIconButtonProps, FileItemProps, FilePicker, FilePickerField, FilePickerFieldProps, FilePickerProps, FileWithSizeAndType, FileWithSrcNameType, FileWithType, FlipButton, FlipButtonGroup, FlipButtonGroupField, FlipButtonGroupFieldProps, FlipButtonGroupProps, FlipButtonProps, Form, FormBody, FormLabel, FormLabelProps, FormProps, FormattedNumberInput, FormattedNumberInputField, FormattedNumberInputFieldProps, FormattedNumberInputPreset, FormattedNumberInputProps, GenericAsProps, H1, H2, H3, H4, H5, H6, HeadingProps, HeadingType, Icon, IconButton, IconButtonProps, IconProps, InputFieldProps, Label, LabelProps, LabelSizes, LabelType, Lead, ListenersType, MaskedTextInput, MaskedTextInputProps, MediatoolThemeProvider, MediatoolThemeProviderProps, Message, Modal, ModalBase, ModalBooleans, ModalProps, ModalSizes, MultiFileList, MultiFileListProps, MultiFilePicker, MultiFilePickerField, MultiFilePickerFieldProps, MultiFilePickerProps, MultiFileUploader, MultiFileUploaderProps, MultiItemType, MultiSort, MultiSortProps, NotificationIconButton, NotificationIconButtonProps, NumberInput, NumberInputField, NumberInputFieldProps, NumberInputProps, NumberInputSizeProps, NumberInputStepperProps, OffsetType, Option, OrganizationLogo, OrganizationLogoProps, OverflowGroup, OverflowGroupProps, OverflowIndicatorProps, P, PProps, PaneDivider, PaneItem, PinInput, PinInputProps, PinSize, PinSizeTuple, PinVariant, PresetOptions, ProgressBar, Radio, RadioFieldGroupProps, RadioFieldProps, RadioGroup, RadioGroupField, RadioGroupProps, RadioProps, ScaleFade, ScaleFadeProps, SearchBar, SearchBarField, SearchBarFieldProps, SearchBarOptionType, SearchBarProps, Select, SelectActionMeta, SelectField, SelectFieldProps, SelectProps, SetValueOptionsType, Slide, SlideFade, SlideFadeProps, SlideProps, Small, Sortable, SortableContainer, SortableContainerProps, SortableItem, SortableItemProps, SortableList, SortableListProps, Spinner, SpinnerProps, SplitPane, SplitPaneProps, StatusBlock, StatusBlockProps, StatusPin, StatusPinProps, Step, StepList, StepListProps, StepPanel, StepPanelProps, StepProps, StepStack, Steps, StepsProps, StylizedType, Switch, SwitchField, SwitchFieldProps, SwitchProps, TabPanel, TabPanelProps, Table, TableProps, Tabs, TabsProps, Tag, TagGroup, TagGroupProps, TagProps, TagsInput, TagsInputProps, TextField, TextFieldProps, TextInputFormatter, TextSizeProps, Textarea, TextareaField, TextareaFieldProps, TextareaProps, Tiny, Toast, ToastProps, Toolbox, ToolboxContent, ToolboxContentProps, ToolboxFooter, ToolboxFooterProps, ToolboxHeader, ToolboxHeaderProps, ToolboxProps, TransitionDirection, UseAdaptiveMenuPlacementProps, UseFormReturn, UseSelectCallbacksProps, UseToastOptions, addAlpha, advancedParseFloat, createDebounceFunctionInstance, getChildrenWithProps, getContrastColor, getFieldError, getInitials, getMatchingValue, getShades, highlight, luminosity, ring, statusIconMap, theme, tottTheme, trimFormValues, useArrowFocus, useCurrentTheme, useDebounce, useDidUpdateEffect, useLoadingMessage, useOutsideRectClick, useOverflowGroup, useScreenSize, useScrollToBottom, useSelectCallbacks, useSetValueRefreshed, useToast };
|