@diceui/tags-input 0.0.1

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.
@@ -0,0 +1,126 @@
1
+ import { Primitive } from '@radix-ui/react-primitive';
2
+ import * as React from 'react';
3
+ import { Direction } from '@diceui/shared';
4
+
5
+ interface TagsInputInputProps extends React.ComponentPropsWithoutRef<typeof Primitive.input> {
6
+ }
7
+ declare const TagsInputInput: React.ForwardRefExoticComponent<TagsInputInputProps & React.RefAttributes<HTMLInputElement>>;
8
+ declare const Input: React.ForwardRefExoticComponent<TagsInputInputProps & React.RefAttributes<HTMLInputElement>>;
9
+
10
+ type InputValue = string;
11
+ interface TagsInputRootProps<T = InputValue> extends Omit<React.ComponentPropsWithoutRef<typeof Primitive.div>, "value" | "defaultValue" | "onValueChange" | "onInvalid" | "children"> {
12
+ /** Controlled array of tag values. */
13
+ value?: T[];
14
+ /** Initial array of tag values when uncontrolled. */
15
+ defaultValue?: T[];
16
+ /** Callback function to handle changes in the tag values. */
17
+ onValueChange?: (value: T[]) => void;
18
+ /** Callback function to validate tags before they're added. */
19
+ onValidate?: (value: T) => boolean;
20
+ /** Callback function to handle invalid input. */
21
+ onInvalid?: (value: T) => void;
22
+ /** Function to convert a tag value to its display string representation. */
23
+ displayValue?: (value: T) => string;
24
+ /**
25
+ * Enable adding tags by pasting text, which will be split by the delimiter.
26
+ * @default false
27
+ */
28
+ addOnPaste?: boolean;
29
+ /**
30
+ * Enable adding tags when Tab key is pressed.
31
+ * @default false
32
+ */
33
+ addOnTab?: boolean;
34
+ /**
35
+ * Disables the entire tags input.
36
+ * @default false
37
+ */
38
+ disabled?: boolean;
39
+ /**
40
+ * Allow editing of existing tags
41
+ * @default false
42
+ */
43
+ editable?: boolean;
44
+ /**
45
+ * Enable wrapping focus from last to first tag and vice versa.
46
+ * @default false
47
+ */
48
+ loop?: boolean;
49
+ /**
50
+ * Behavior when the input loses focus.
51
+ * - "add": Add the current input value as a new tag.
52
+ * - "clear": Reset the input field, removing its value.
53
+ * By default, the input value will stay in the input field.
54
+ * Can be overridden by the preventDefault() call in the input's onBlur handler.
55
+ */
56
+ blurBehavior?: "add" | "clear";
57
+ /**
58
+ * Character used to split pasted text into multiple tags.
59
+ * @default ","
60
+ */
61
+ delimiter?: string;
62
+ /**
63
+ * Maximum number of tags allowed.
64
+ * @default Number.POSITIVE_INFINITY
65
+ */
66
+ max?: number;
67
+ /** Whether the field is required in a form context. */
68
+ required?: boolean;
69
+ /** Name of the form field when used in a form. */
70
+ name?: string;
71
+ /**
72
+ * The content of the tags input.
73
+ *
74
+ * Can be a function that receives the current value as an argument,
75
+ * or a React node.
76
+ * @default undefined
77
+ */
78
+ children?: ((context: {
79
+ value: InputValue[];
80
+ }) => React.ReactNode) | React.ReactNode;
81
+ /**
82
+ * The reading direction of the tags input.
83
+ * @default "ltr"
84
+ */
85
+ dir?: Direction;
86
+ /** Unique identifier for the tags input. */
87
+ id?: string;
88
+ }
89
+ declare const TagsInputRoot: React.ForwardRefExoticComponent<TagsInputRootProps<string> & React.RefAttributes<HTMLDivElement>>;
90
+ declare const Root: React.ForwardRefExoticComponent<TagsInputRootProps<string> & React.RefAttributes<HTMLDivElement>>;
91
+
92
+ interface TagsInputLabelProps extends React.ComponentPropsWithoutRef<typeof Primitive.label> {
93
+ }
94
+ declare const TagsInputLabel: React.ForwardRefExoticComponent<TagsInputLabelProps & React.RefAttributes<HTMLLabelElement>>;
95
+ declare const Label: React.ForwardRefExoticComponent<TagsInputLabelProps & React.RefAttributes<HTMLLabelElement>>;
96
+
97
+ interface TagsInputItemProps extends React.ComponentPropsWithoutRef<typeof Primitive.div> {
98
+ value: InputValue;
99
+ disabled?: boolean;
100
+ }
101
+ declare const TagsInputItem: React.ForwardRefExoticComponent<TagsInputItemProps & React.RefAttributes<HTMLDivElement>>;
102
+ declare const Item: React.ForwardRefExoticComponent<TagsInputItemProps & React.RefAttributes<HTMLDivElement>>;
103
+
104
+ interface TagsInputItemDeleteProps extends React.ComponentPropsWithoutRef<typeof Primitive.button> {
105
+ }
106
+ declare const TagsInputItemDelete: React.ForwardRefExoticComponent<TagsInputItemDeleteProps & React.RefAttributes<HTMLButtonElement>>;
107
+ declare const Delete: React.ForwardRefExoticComponent<TagsInputItemDeleteProps & React.RefAttributes<HTMLButtonElement>>;
108
+
109
+ interface TagsInputItemTextProps extends React.ComponentPropsWithoutRef<typeof Primitive.span> {
110
+ }
111
+ declare const TagsInputItemText: React.ForwardRefExoticComponent<TagsInputItemTextProps & React.RefAttributes<HTMLSpanElement>>;
112
+ declare const Text: React.ForwardRefExoticComponent<TagsInputItemTextProps & React.RefAttributes<HTMLSpanElement>>;
113
+
114
+ interface TagsInputClearProps extends React.ComponentPropsWithoutRef<typeof Primitive.button> {
115
+ /**
116
+ * Whether the clear button should always be rendered.
117
+ *
118
+ * Can be used to animate the enter and exit of the clear button.
119
+ * @default false
120
+ */
121
+ forceMount?: boolean;
122
+ }
123
+ declare const TagsInputClear: React.ForwardRefExoticComponent<TagsInputClearProps & React.RefAttributes<HTMLButtonElement>>;
124
+ declare const Clear: React.ForwardRefExoticComponent<TagsInputClearProps & React.RefAttributes<HTMLButtonElement>>;
125
+
126
+ export { Clear, Delete, Input, Item, Label, Root, TagsInputClear, type TagsInputClearProps, TagsInputInput, type TagsInputInputProps, TagsInputItem, TagsInputItemDelete, type TagsInputItemDeleteProps, type TagsInputItemProps, TagsInputItemText, type TagsInputItemTextProps, TagsInputLabel, type TagsInputLabelProps, TagsInputRoot, type TagsInputRootProps, Text };
@@ -0,0 +1,126 @@
1
+ import { Primitive } from '@radix-ui/react-primitive';
2
+ import * as React from 'react';
3
+ import { Direction } from '@diceui/shared';
4
+
5
+ interface TagsInputInputProps extends React.ComponentPropsWithoutRef<typeof Primitive.input> {
6
+ }
7
+ declare const TagsInputInput: React.ForwardRefExoticComponent<TagsInputInputProps & React.RefAttributes<HTMLInputElement>>;
8
+ declare const Input: React.ForwardRefExoticComponent<TagsInputInputProps & React.RefAttributes<HTMLInputElement>>;
9
+
10
+ type InputValue = string;
11
+ interface TagsInputRootProps<T = InputValue> extends Omit<React.ComponentPropsWithoutRef<typeof Primitive.div>, "value" | "defaultValue" | "onValueChange" | "onInvalid" | "children"> {
12
+ /** Controlled array of tag values. */
13
+ value?: T[];
14
+ /** Initial array of tag values when uncontrolled. */
15
+ defaultValue?: T[];
16
+ /** Callback function to handle changes in the tag values. */
17
+ onValueChange?: (value: T[]) => void;
18
+ /** Callback function to validate tags before they're added. */
19
+ onValidate?: (value: T) => boolean;
20
+ /** Callback function to handle invalid input. */
21
+ onInvalid?: (value: T) => void;
22
+ /** Function to convert a tag value to its display string representation. */
23
+ displayValue?: (value: T) => string;
24
+ /**
25
+ * Enable adding tags by pasting text, which will be split by the delimiter.
26
+ * @default false
27
+ */
28
+ addOnPaste?: boolean;
29
+ /**
30
+ * Enable adding tags when Tab key is pressed.
31
+ * @default false
32
+ */
33
+ addOnTab?: boolean;
34
+ /**
35
+ * Disables the entire tags input.
36
+ * @default false
37
+ */
38
+ disabled?: boolean;
39
+ /**
40
+ * Allow editing of existing tags
41
+ * @default false
42
+ */
43
+ editable?: boolean;
44
+ /**
45
+ * Enable wrapping focus from last to first tag and vice versa.
46
+ * @default false
47
+ */
48
+ loop?: boolean;
49
+ /**
50
+ * Behavior when the input loses focus.
51
+ * - "add": Add the current input value as a new tag.
52
+ * - "clear": Reset the input field, removing its value.
53
+ * By default, the input value will stay in the input field.
54
+ * Can be overridden by the preventDefault() call in the input's onBlur handler.
55
+ */
56
+ blurBehavior?: "add" | "clear";
57
+ /**
58
+ * Character used to split pasted text into multiple tags.
59
+ * @default ","
60
+ */
61
+ delimiter?: string;
62
+ /**
63
+ * Maximum number of tags allowed.
64
+ * @default Number.POSITIVE_INFINITY
65
+ */
66
+ max?: number;
67
+ /** Whether the field is required in a form context. */
68
+ required?: boolean;
69
+ /** Name of the form field when used in a form. */
70
+ name?: string;
71
+ /**
72
+ * The content of the tags input.
73
+ *
74
+ * Can be a function that receives the current value as an argument,
75
+ * or a React node.
76
+ * @default undefined
77
+ */
78
+ children?: ((context: {
79
+ value: InputValue[];
80
+ }) => React.ReactNode) | React.ReactNode;
81
+ /**
82
+ * The reading direction of the tags input.
83
+ * @default "ltr"
84
+ */
85
+ dir?: Direction;
86
+ /** Unique identifier for the tags input. */
87
+ id?: string;
88
+ }
89
+ declare const TagsInputRoot: React.ForwardRefExoticComponent<TagsInputRootProps<string> & React.RefAttributes<HTMLDivElement>>;
90
+ declare const Root: React.ForwardRefExoticComponent<TagsInputRootProps<string> & React.RefAttributes<HTMLDivElement>>;
91
+
92
+ interface TagsInputLabelProps extends React.ComponentPropsWithoutRef<typeof Primitive.label> {
93
+ }
94
+ declare const TagsInputLabel: React.ForwardRefExoticComponent<TagsInputLabelProps & React.RefAttributes<HTMLLabelElement>>;
95
+ declare const Label: React.ForwardRefExoticComponent<TagsInputLabelProps & React.RefAttributes<HTMLLabelElement>>;
96
+
97
+ interface TagsInputItemProps extends React.ComponentPropsWithoutRef<typeof Primitive.div> {
98
+ value: InputValue;
99
+ disabled?: boolean;
100
+ }
101
+ declare const TagsInputItem: React.ForwardRefExoticComponent<TagsInputItemProps & React.RefAttributes<HTMLDivElement>>;
102
+ declare const Item: React.ForwardRefExoticComponent<TagsInputItemProps & React.RefAttributes<HTMLDivElement>>;
103
+
104
+ interface TagsInputItemDeleteProps extends React.ComponentPropsWithoutRef<typeof Primitive.button> {
105
+ }
106
+ declare const TagsInputItemDelete: React.ForwardRefExoticComponent<TagsInputItemDeleteProps & React.RefAttributes<HTMLButtonElement>>;
107
+ declare const Delete: React.ForwardRefExoticComponent<TagsInputItemDeleteProps & React.RefAttributes<HTMLButtonElement>>;
108
+
109
+ interface TagsInputItemTextProps extends React.ComponentPropsWithoutRef<typeof Primitive.span> {
110
+ }
111
+ declare const TagsInputItemText: React.ForwardRefExoticComponent<TagsInputItemTextProps & React.RefAttributes<HTMLSpanElement>>;
112
+ declare const Text: React.ForwardRefExoticComponent<TagsInputItemTextProps & React.RefAttributes<HTMLSpanElement>>;
113
+
114
+ interface TagsInputClearProps extends React.ComponentPropsWithoutRef<typeof Primitive.button> {
115
+ /**
116
+ * Whether the clear button should always be rendered.
117
+ *
118
+ * Can be used to animate the enter and exit of the clear button.
119
+ * @default false
120
+ */
121
+ forceMount?: boolean;
122
+ }
123
+ declare const TagsInputClear: React.ForwardRefExoticComponent<TagsInputClearProps & React.RefAttributes<HTMLButtonElement>>;
124
+ declare const Clear: React.ForwardRefExoticComponent<TagsInputClearProps & React.RefAttributes<HTMLButtonElement>>;
125
+
126
+ export { Clear, Delete, Input, Item, Label, Root, TagsInputClear, type TagsInputClearProps, TagsInputInput, type TagsInputInputProps, TagsInputItem, TagsInputItemDelete, type TagsInputItemDeleteProps, type TagsInputItemProps, TagsInputItemText, type TagsInputItemTextProps, TagsInputLabel, type TagsInputLabelProps, TagsInputRoot, type TagsInputRootProps, Text };