@scaleflex/ui-tw 0.0.44 → 0.0.46
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/combobox/combobox-multi-inline/combobox-multi-inline.component.d.ts +1 -1
- package/combobox/combobox-multi-inline/combobox-multi-inline.component.js +4 -2
- package/combobox/combobox.component.js +1 -3
- package/form/components/form-tags-field.component.d.ts +5 -0
- package/form/components/form-tags-field.component.js +57 -0
- package/form/form.types.d.ts +13 -1
- package/form/index.d.ts +1 -0
- package/form/index.js +2 -1
- package/input-tags/index.d.ts +1 -0
- package/input-tags/index.js +1 -0
- package/input-tags/input-tags.component.d.ts +3 -0
- package/input-tags/input-tags.component.js +212 -0
- package/input-tags/input-tags.types.d.ts +24 -0
- package/input-tags/input-tags.types.js +1 -0
- package/package.json +2 -2
- package/types/react-table.d.ts +7 -0
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { ComboboxMultiInlineProps } from '../combobox.types';
|
|
3
|
-
export declare function ComboboxMultiInline({ options, value, onChange, placeholder, className, disabled, size, readOnly, showClear, popoverClassName, onBlur, showGroupSeparator, defaultOpen, popoverContentProps, ...rest }: ComboboxMultiInlineProps): React.JSX.Element;
|
|
3
|
+
export declare function ComboboxMultiInline({ options, value, onChange, placeholder, className, disabled, size, readOnly, showClear, popoverClassName, onBlur, showGroupSeparator, defaultOpen, popoverContentProps, formItemId, ...rest }: ComboboxMultiInlineProps): React.JSX.Element;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
2
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
3
3
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
4
|
-
var _excluded = ["options", "value", "onChange", "placeholder", "className", "disabled", "size", "readOnly", "showClear", "popoverClassName", "onBlur", "showGroupSeparator", "defaultOpen", "popoverContentProps"];
|
|
4
|
+
var _excluded = ["options", "value", "onChange", "placeholder", "className", "disabled", "size", "readOnly", "showClear", "popoverClassName", "onBlur", "showGroupSeparator", "defaultOpen", "popoverContentProps", "formItemId"];
|
|
5
5
|
import { Popover } from '@scaleflex/ui-tw/popover';
|
|
6
6
|
import { FormSize } from '@scaleflex/ui-tw/types/form-size';
|
|
7
7
|
import React from 'react';
|
|
@@ -30,6 +30,7 @@ export function ComboboxMultiInline(_ref) {
|
|
|
30
30
|
_ref$defaultOpen = _ref.defaultOpen,
|
|
31
31
|
defaultOpen = _ref$defaultOpen === void 0 ? false : _ref$defaultOpen,
|
|
32
32
|
popoverContentProps = _ref.popoverContentProps,
|
|
33
|
+
formItemId = _ref.formItemId,
|
|
33
34
|
rest = _objectWithoutProperties(_ref, _excluded);
|
|
34
35
|
var _useState = useState(defaultOpen),
|
|
35
36
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -76,7 +77,8 @@ export function ComboboxMultiInline(_ref) {
|
|
|
76
77
|
showClear: showClear,
|
|
77
78
|
selected: selectedLabels.length > 0,
|
|
78
79
|
onClearAll: onClearAll,
|
|
79
|
-
"aria-invalid": rest['aria-invalid']
|
|
80
|
+
"aria-invalid": rest['aria-invalid'],
|
|
81
|
+
formItemId: formItemId
|
|
80
82
|
}, displayValue), /*#__PURE__*/React.createElement(ComboboxContent, {
|
|
81
83
|
showGroupSeparator: showGroupSeparator,
|
|
82
84
|
className: popoverClassName,
|
|
@@ -94,9 +94,7 @@ export function ComboboxContent(_ref2) {
|
|
|
94
94
|
}, popoverContentProps), /*#__PURE__*/React.createElement(Command, null, /*#__PURE__*/React.createElement(CommandInput, {
|
|
95
95
|
size: size,
|
|
96
96
|
placeholder: "Search..."
|
|
97
|
-
}), /*#__PURE__*/React.createElement(CommandList, null, /*#__PURE__*/React.createElement(CommandEmpty, {
|
|
98
|
-
className: "text-muted-foreground"
|
|
99
|
-
}, "No results found."), options === null || options === void 0 ? void 0 : options.map(function (option, groupIndex) {
|
|
97
|
+
}), /*#__PURE__*/React.createElement(CommandList, null, /*#__PURE__*/React.createElement(CommandEmpty, null, "No results found."), options === null || options === void 0 ? void 0 : options.map(function (option, groupIndex) {
|
|
100
98
|
if (isOptionGroup(option)) {
|
|
101
99
|
return /*#__PURE__*/React.createElement(CommandGroup, {
|
|
102
100
|
key: groupIndex,
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { FieldValues, Path } from 'react-hook-form';
|
|
3
|
+
import type { FormTagsFieldProps } from '../form.types';
|
|
4
|
+
declare function FormTagsField<TFieldValues extends FieldValues, TName extends Path<TFieldValues>>({ tagsProps, ...rest }: FormTagsFieldProps<TFieldValues, TName>): React.JSX.Element;
|
|
5
|
+
export { FormTagsField };
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
+
var _excluded = ["placeholder", "suggestedTags", "allTags", "allowCustomTags", "onGenerateTags"],
|
|
4
|
+
_excluded2 = ["tagsProps"];
|
|
5
|
+
import { useFormField } from '@scaleflex/ui-tw/form';
|
|
6
|
+
import { FormFieldGroup } from '@scaleflex/ui-tw/form';
|
|
7
|
+
import { InputTags } from '@scaleflex/ui-tw/input-tags';
|
|
8
|
+
import React from 'react';
|
|
9
|
+
function FormTagsInner(_ref) {
|
|
10
|
+
var field = _ref.field,
|
|
11
|
+
args = _ref.args,
|
|
12
|
+
tagsProps = _ref.tagsProps,
|
|
13
|
+
readOnly = _ref.readOnly,
|
|
14
|
+
disabled = _ref.disabled,
|
|
15
|
+
className = _ref.className;
|
|
16
|
+
var _useFormField = useFormField(),
|
|
17
|
+
error = _useFormField.error,
|
|
18
|
+
formItemId = _useFormField.formItemId;
|
|
19
|
+
var _ref2 = tagsProps || {},
|
|
20
|
+
placeholder = _ref2.placeholder,
|
|
21
|
+
suggestedTags = _ref2.suggestedTags,
|
|
22
|
+
allTags = _ref2.allTags,
|
|
23
|
+
allowCustomTags = _ref2.allowCustomTags,
|
|
24
|
+
onGenerateTags = _ref2.onGenerateTags,
|
|
25
|
+
restTagsProps = _objectWithoutProperties(_ref2, _excluded);
|
|
26
|
+
return /*#__PURE__*/React.createElement(InputTags, _extends({
|
|
27
|
+
value: field.value,
|
|
28
|
+
onChange: field.onChange,
|
|
29
|
+
placeholder: placeholder,
|
|
30
|
+
suggestedTags: suggestedTags,
|
|
31
|
+
allTags: allTags,
|
|
32
|
+
allowCustomTags: allowCustomTags,
|
|
33
|
+
onGenerateTags: onGenerateTags,
|
|
34
|
+
disabled: disabled,
|
|
35
|
+
readOnly: readOnly,
|
|
36
|
+
formItemId: formItemId,
|
|
37
|
+
size: args === null || args === void 0 ? void 0 : args.size,
|
|
38
|
+
"aria-invalid": !!error,
|
|
39
|
+
className: className
|
|
40
|
+
}, restTagsProps));
|
|
41
|
+
}
|
|
42
|
+
function FormTagsField(_ref3) {
|
|
43
|
+
var tagsProps = _ref3.tagsProps,
|
|
44
|
+
rest = _objectWithoutProperties(_ref3, _excluded2);
|
|
45
|
+
var readOnly = rest.readOnly,
|
|
46
|
+
disabled = rest.disabled;
|
|
47
|
+
return /*#__PURE__*/React.createElement(FormFieldGroup, rest, function (field, args) {
|
|
48
|
+
return /*#__PURE__*/React.createElement(FormTagsInner, {
|
|
49
|
+
field: field,
|
|
50
|
+
args: args,
|
|
51
|
+
tagsProps: tagsProps,
|
|
52
|
+
readOnly: readOnly,
|
|
53
|
+
disabled: disabled
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
export { FormTagsField };
|
package/form/form.types.d.ts
CHANGED
|
@@ -2,13 +2,14 @@ import { CheckboxProps } from '@scaleflex/ui-tw/checkbox/checkbox.types';
|
|
|
2
2
|
import type { ComboboxMultiInlineProps, ComboboxMultiTagProps, ComboboxSingleProps } from '@scaleflex/ui-tw/combobox/combobox.types';
|
|
3
3
|
import type { DatePickerProps } from '@scaleflex/ui-tw/date-picker/date-picker.types';
|
|
4
4
|
import type { InputProps } from '@scaleflex/ui-tw/input';
|
|
5
|
+
import { InputTagsProps } from '@scaleflex/ui-tw/input-tags/input-tags.types';
|
|
5
6
|
import type { RadioGroupItemProps } from '@scaleflex/ui-tw/radio-group/radio-group.types';
|
|
6
7
|
import type { SelectProps } from '@scaleflex/ui-tw/select/select.types';
|
|
7
8
|
import type { SwitchProps } from '@scaleflex/ui-tw/switch/switch.types';
|
|
8
9
|
import type { TextareaProps } from '@scaleflex/ui-tw/textarea';
|
|
9
10
|
import type { FormSizeType } from '@scaleflex/ui-tw/types/form-size';
|
|
10
11
|
import type { Values } from '@scaleflex/ui-tw/types/values';
|
|
11
|
-
import { ReactElement, ReactNode } from 'react';
|
|
12
|
+
import type { ReactElement, ReactNode } from 'react';
|
|
12
13
|
import { Control, type ControllerRenderProps, type FieldPath, type FieldValues, type Path, type UseControllerProps } from 'react-hook-form';
|
|
13
14
|
import { FormMessageSize, SwitchLayout } from './form.constants';
|
|
14
15
|
export type FormMessageSizeType = Values<typeof FormMessageSize>;
|
|
@@ -127,4 +128,15 @@ export interface FormDatePickerInnerProps<TFieldValues extends FieldValues, TNam
|
|
|
127
128
|
readOnly?: boolean;
|
|
128
129
|
disabled?: boolean;
|
|
129
130
|
}
|
|
131
|
+
export type FormTagsFieldProps<TFieldValues extends FieldValues, TName extends Path<TFieldValues>> = Omit<FormFieldGroupProps<TFieldValues, TName>, 'children'> & {
|
|
132
|
+
tagsProps?: Partial<InputTagsProps>;
|
|
133
|
+
};
|
|
134
|
+
export interface FormTagsInnerProps<TFieldValues extends FieldValues, TName extends Path<TFieldValues>> {
|
|
135
|
+
field: ControllerRenderProps<TFieldValues, TName>;
|
|
136
|
+
args?: FormFieldArgs;
|
|
137
|
+
tagsProps?: Partial<InputTagsProps>;
|
|
138
|
+
readOnly?: boolean;
|
|
139
|
+
disabled?: boolean;
|
|
140
|
+
className?: string;
|
|
141
|
+
}
|
|
130
142
|
export {};
|
package/form/index.d.ts
CHANGED
|
@@ -12,3 +12,4 @@ export { FormCheckboxField } from './components/form-checkbox-field.component';
|
|
|
12
12
|
export { FormCheckboxGroupField } from './components/form-checkbox-group-field.component';
|
|
13
13
|
export { FormRadioGroupField } from './components/form-radio-group-field.component';
|
|
14
14
|
export { FormDatePickerField } from './components/form-date-picker-field.component';
|
|
15
|
+
export { FormTagsField } from './components/form-tags-field.component';
|
package/form/index.js
CHANGED
|
@@ -10,4 +10,5 @@ export { FormComboboxField } from './components/form-combobox-field.component';
|
|
|
10
10
|
export { FormCheckboxField } from './components/form-checkbox-field.component';
|
|
11
11
|
export { FormCheckboxGroupField } from './components/form-checkbox-group-field.component';
|
|
12
12
|
export { FormRadioGroupField } from './components/form-radio-group-field.component';
|
|
13
|
-
export { FormDatePickerField } from './components/form-date-picker-field.component';
|
|
13
|
+
export { FormDatePickerField } from './components/form-date-picker-field.component';
|
|
14
|
+
export { FormTagsField } from './components/form-tags-field.component';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { InputTags } from './input-tags.component';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { InputTags } from './input-tags.component';
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { InputTagsProps } from '@scaleflex/ui-tw/input-tags/input-tags.types';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
export declare function InputTags({ value, onChange, suggestedTags, allTags, placeholder, allowCustomTags, disabled, size, onGenerateTags, popoverClassName, popoverContentProps, formItemId, readOnly, className, ...rest }: InputTagsProps): React.JSX.Element;
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
3
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
4
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
5
|
+
var _excluded = ["value", "onChange", "suggestedTags", "allTags", "placeholder", "allowCustomTags", "disabled", "size", "onGenerateTags", "popoverClassName", "popoverContentProps", "formItemId", "readOnly", "className"];
|
|
6
|
+
import { SparkleIcon } from '@scaleflex/icons-tw/sparkle-icon';
|
|
7
|
+
import { Button } from '@scaleflex/ui-tw/button';
|
|
8
|
+
import { iconSizeInTriggerOptions } from '@scaleflex/ui-tw/combobox/combobox.constants';
|
|
9
|
+
import { Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList } from '@scaleflex/ui-tw/command';
|
|
10
|
+
import { Pill } from '@scaleflex/ui-tw/pill';
|
|
11
|
+
import { Popover, PopoverContent, PopoverTrigger } from '@scaleflex/ui-tw/popover';
|
|
12
|
+
import { selectReadOnlyClassNames } from '@scaleflex/ui-tw/select/select.constants';
|
|
13
|
+
import { focusRingClassNames, getBaseInputClasses, selectionHighlightClassNames } from '@scaleflex/ui-tw/styles/shared-classes';
|
|
14
|
+
import { textareaSizeOptions } from '@scaleflex/ui-tw/textarea/textarea.constants';
|
|
15
|
+
import { getToolbarSizes } from '@scaleflex/ui-tw/textarea/textarea.utils';
|
|
16
|
+
import { FormSize } from '@scaleflex/ui-tw/types/form-size';
|
|
17
|
+
import { cn } from '@scaleflex/ui-tw/utils/cn';
|
|
18
|
+
import { cva } from 'class-variance-authority';
|
|
19
|
+
import { ChevronsUpDownIcon } from 'lucide-react';
|
|
20
|
+
import * as React from 'react';
|
|
21
|
+
import { useMemo, useState } from 'react';
|
|
22
|
+
var inputTagsVariants = cva('', {
|
|
23
|
+
variants: {
|
|
24
|
+
size: textareaSizeOptions
|
|
25
|
+
},
|
|
26
|
+
defaultVariants: {
|
|
27
|
+
size: FormSize.Md
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
export function InputTags(_ref) {
|
|
31
|
+
var value = _ref.value,
|
|
32
|
+
onChange = _ref.onChange,
|
|
33
|
+
_ref$suggestedTags = _ref.suggestedTags,
|
|
34
|
+
suggestedTags = _ref$suggestedTags === void 0 ? [] : _ref$suggestedTags,
|
|
35
|
+
_ref$allTags = _ref.allTags,
|
|
36
|
+
allTags = _ref$allTags === void 0 ? [] : _ref$allTags,
|
|
37
|
+
_ref$placeholder = _ref.placeholder,
|
|
38
|
+
placeholder = _ref$placeholder === void 0 ? 'Select or create tags...' : _ref$placeholder,
|
|
39
|
+
_ref$allowCustomTags = _ref.allowCustomTags,
|
|
40
|
+
allowCustomTags = _ref$allowCustomTags === void 0 ? true : _ref$allowCustomTags,
|
|
41
|
+
_ref$disabled = _ref.disabled,
|
|
42
|
+
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
43
|
+
_ref$size = _ref.size,
|
|
44
|
+
size = _ref$size === void 0 ? FormSize.Md : _ref$size,
|
|
45
|
+
onGenerateTags = _ref.onGenerateTags,
|
|
46
|
+
popoverClassName = _ref.popoverClassName,
|
|
47
|
+
popoverContentProps = _ref.popoverContentProps,
|
|
48
|
+
formItemId = _ref.formItemId,
|
|
49
|
+
readOnly = _ref.readOnly,
|
|
50
|
+
className = _ref.className,
|
|
51
|
+
rest = _objectWithoutProperties(_ref, _excluded);
|
|
52
|
+
var _useState = useState(false),
|
|
53
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
54
|
+
open = _useState2[0],
|
|
55
|
+
setOpen = _useState2[1];
|
|
56
|
+
var _useState3 = useState(''),
|
|
57
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
58
|
+
search = _useState4[0],
|
|
59
|
+
setSearch = _useState4[1];
|
|
60
|
+
var tagsList = [].concat(_toConsumableArray(suggestedTags), _toConsumableArray(allTags));
|
|
61
|
+
var _getToolbarSizes = getToolbarSizes(size),
|
|
62
|
+
buttonSize = _getToolbarSizes.buttonSize;
|
|
63
|
+
var searchTrimmed = search.trim().toLowerCase();
|
|
64
|
+
var isSameTag = function isSameTag(a, b) {
|
|
65
|
+
return a.value.trim().toLowerCase() === b.value.trim().toLowerCase();
|
|
66
|
+
};
|
|
67
|
+
var isSelected = function isSelected(tag) {
|
|
68
|
+
return value.some(function (t) {
|
|
69
|
+
return isSameTag(t, tag);
|
|
70
|
+
});
|
|
71
|
+
};
|
|
72
|
+
var normalizeLabel = function normalizeLabel(label) {
|
|
73
|
+
return label.trim().replace(/\s+/g, ' ');
|
|
74
|
+
};
|
|
75
|
+
var normalizeValue = function normalizeValue(label) {
|
|
76
|
+
return normalizeLabel(label).toLowerCase().replace(/\s+/g, '-');
|
|
77
|
+
};
|
|
78
|
+
var createTag = function createTag(label) {
|
|
79
|
+
return {
|
|
80
|
+
label: normalizeLabel(label),
|
|
81
|
+
value: normalizeValue(label)
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
var newTag = createTag(search);
|
|
85
|
+
var canCreate = useMemo(function () {
|
|
86
|
+
if (!allowCustomTags || !searchTrimmed) return false;
|
|
87
|
+
return !value.some(function (v) {
|
|
88
|
+
return isSameTag(v, newTag);
|
|
89
|
+
}) && !tagsList.some(function (t) {
|
|
90
|
+
return isSameTag(t, newTag);
|
|
91
|
+
});
|
|
92
|
+
}, [newTag, value, tagsList, allowCustomTags, searchTrimmed]);
|
|
93
|
+
var handleAddTag = function handleAddTag(tag) {
|
|
94
|
+
if (isSelected(tag)) return;
|
|
95
|
+
onChange([].concat(_toConsumableArray(value), [tag]));
|
|
96
|
+
setSearch('');
|
|
97
|
+
setOpen(true);
|
|
98
|
+
};
|
|
99
|
+
var handleRemoveTag = function handleRemoveTag(tag) {
|
|
100
|
+
onChange(value.filter(function (t) {
|
|
101
|
+
return !isSameTag(t, tag);
|
|
102
|
+
}));
|
|
103
|
+
};
|
|
104
|
+
var handleClearAll = function handleClearAll() {
|
|
105
|
+
onChange([]);
|
|
106
|
+
setSearch('');
|
|
107
|
+
setOpen(false);
|
|
108
|
+
};
|
|
109
|
+
var filteredSuggested = suggestedTags.filter(function (tag) {
|
|
110
|
+
return !isSelected(tag) && tag.label.toLowerCase().includes(searchTrimmed);
|
|
111
|
+
});
|
|
112
|
+
var filteredAll = allTags.filter(function (tag) {
|
|
113
|
+
return !isSelected(tag) && tag.label.toLowerCase().includes(searchTrimmed);
|
|
114
|
+
});
|
|
115
|
+
return /*#__PURE__*/React.createElement(Popover, {
|
|
116
|
+
open: open,
|
|
117
|
+
onOpenChange: setOpen
|
|
118
|
+
}, /*#__PURE__*/React.createElement(PopoverTrigger, {
|
|
119
|
+
asChild: true
|
|
120
|
+
}, /*#__PURE__*/React.createElement("button", {
|
|
121
|
+
id: formItemId,
|
|
122
|
+
role: "combobox-tags",
|
|
123
|
+
"aria-expanded": open,
|
|
124
|
+
"aria-invalid": rest['aria-invalid'],
|
|
125
|
+
disabled: disabled,
|
|
126
|
+
className: cn.apply(void 0, ['relative flex w-full', onGenerateTags || value.length > 0 ? 'flex-col' : 'items-center'].concat(_toConsumableArray(getBaseInputClasses()), [selectionHighlightClassNames, focusRingClassNames, readOnly && selectReadOnlyClassNames, className])),
|
|
127
|
+
onClick: function onClick() {
|
|
128
|
+
return !disabled && setOpen(true);
|
|
129
|
+
}
|
|
130
|
+
}, /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
131
|
+
className: cn('flex w-full flex-wrap gap-2', inputTagsVariants({
|
|
132
|
+
size: size
|
|
133
|
+
}), 'min-h-auto')
|
|
134
|
+
}, value.length === 0 ? /*#__PURE__*/React.createElement("span", {
|
|
135
|
+
className: "text-muted-foreground"
|
|
136
|
+
}, placeholder) : value.map(function (tag) {
|
|
137
|
+
return /*#__PURE__*/React.createElement(Pill, {
|
|
138
|
+
key: tag.value,
|
|
139
|
+
size: size,
|
|
140
|
+
removable: true,
|
|
141
|
+
onRemove: function onRemove() {
|
|
142
|
+
return handleRemoveTag(tag);
|
|
143
|
+
}
|
|
144
|
+
}, tag.label);
|
|
145
|
+
})), onGenerateTags || value.length > 0 ? /*#__PURE__*/React.createElement("div", {
|
|
146
|
+
className: "flex w-full items-center justify-between p-1.5 pt-0"
|
|
147
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
148
|
+
className: "flex gap-2"
|
|
149
|
+
}, value.length > 0 && /*#__PURE__*/React.createElement(Button, {
|
|
150
|
+
type: "button",
|
|
151
|
+
variant: "ghost-secondary",
|
|
152
|
+
size: buttonSize,
|
|
153
|
+
"aria-label": "Clear all",
|
|
154
|
+
"data-clear-icon": "true",
|
|
155
|
+
onClick: handleClearAll
|
|
156
|
+
}, "Clear all"), onGenerateTags && /*#__PURE__*/React.createElement(Button, {
|
|
157
|
+
tabIndex: 0,
|
|
158
|
+
"aria-label": "Generate tags",
|
|
159
|
+
type: "button",
|
|
160
|
+
variant: "ghost-primary",
|
|
161
|
+
size: buttonSize,
|
|
162
|
+
startIcon: /*#__PURE__*/React.createElement(SparkleIcon, {
|
|
163
|
+
className: "size-3.5"
|
|
164
|
+
}),
|
|
165
|
+
onClick: function onClick(e) {
|
|
166
|
+
e.stopPropagation();
|
|
167
|
+
onGenerateTags === null || onGenerateTags === void 0 || onGenerateTags();
|
|
168
|
+
}
|
|
169
|
+
}, "Generate")), /*#__PURE__*/React.createElement(ChevronsUpDownIcon, {
|
|
170
|
+
className: cn('mr-1.5 ml-auto shrink-0 opacity-50', iconSizeInTriggerOptions[size])
|
|
171
|
+
})) : /*#__PURE__*/React.createElement(ChevronsUpDownIcon, {
|
|
172
|
+
className: cn('my-auto mr-1.5 ml-auto shrink-0 opacity-50', iconSizeInTriggerOptions[size])
|
|
173
|
+
})))), /*#__PURE__*/React.createElement(PopoverContent, _extends({
|
|
174
|
+
className: cn('w-[--radix-popover-trigger-width] p-0', popoverClassName)
|
|
175
|
+
}, popoverContentProps), /*#__PURE__*/React.createElement(Command, {
|
|
176
|
+
shouldFilter: false
|
|
177
|
+
}, /*#__PURE__*/React.createElement(CommandInput, {
|
|
178
|
+
size: size,
|
|
179
|
+
value: search,
|
|
180
|
+
onValueChange: setSearch,
|
|
181
|
+
placeholder: "Search or create a tag"
|
|
182
|
+
}), /*#__PURE__*/React.createElement(CommandList, null, filteredSuggested.length > 0 && /*#__PURE__*/React.createElement(CommandGroup, {
|
|
183
|
+
size: size,
|
|
184
|
+
heading: "Suggested"
|
|
185
|
+
}, filteredSuggested.map(function (tag) {
|
|
186
|
+
return /*#__PURE__*/React.createElement(CommandItem, {
|
|
187
|
+
key: tag.value,
|
|
188
|
+
size: size,
|
|
189
|
+
onSelect: function onSelect() {
|
|
190
|
+
return handleAddTag(tag);
|
|
191
|
+
},
|
|
192
|
+
isGroup: true
|
|
193
|
+
}, tag.label);
|
|
194
|
+
})), filteredAll.length > 0 && /*#__PURE__*/React.createElement(CommandGroup, {
|
|
195
|
+
size: size,
|
|
196
|
+
heading: "All Tags"
|
|
197
|
+
}, filteredAll.map(function (tag) {
|
|
198
|
+
return /*#__PURE__*/React.createElement(CommandItem, {
|
|
199
|
+
key: tag.value,
|
|
200
|
+
size: size,
|
|
201
|
+
onSelect: function onSelect() {
|
|
202
|
+
return handleAddTag(tag);
|
|
203
|
+
},
|
|
204
|
+
isGroup: true
|
|
205
|
+
}, tag.label);
|
|
206
|
+
})), !canCreate && filteredSuggested.length === 0 && filteredAll.length === 0 && /*#__PURE__*/React.createElement(CommandEmpty, null, "No results found."), canCreate && /*#__PURE__*/React.createElement(CommandItem, {
|
|
207
|
+
size: size,
|
|
208
|
+
onSelect: function onSelect() {
|
|
209
|
+
return handleAddTag(newTag);
|
|
210
|
+
}
|
|
211
|
+
}, "Create \"", search.trim(), "\"")))));
|
|
212
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import * as PopoverPrimitive from '@radix-ui/react-popover';
|
|
2
|
+
import type { FormSizeType } from '@scaleflex/ui-tw/types/form-size';
|
|
3
|
+
import type { ComponentProps } from 'react';
|
|
4
|
+
export interface TagOption {
|
|
5
|
+
label: string;
|
|
6
|
+
value: string;
|
|
7
|
+
}
|
|
8
|
+
export interface InputTagsProps {
|
|
9
|
+
value: TagOption[];
|
|
10
|
+
onChange: (value: TagOption[]) => void;
|
|
11
|
+
suggestedTags?: TagOption[];
|
|
12
|
+
allTags?: TagOption[];
|
|
13
|
+
placeholder?: string;
|
|
14
|
+
allowCustomTags?: boolean;
|
|
15
|
+
disabled?: boolean;
|
|
16
|
+
popoverClassName?: string;
|
|
17
|
+
popoverContentProps?: ComponentProps<typeof PopoverPrimitive.Content>;
|
|
18
|
+
size?: FormSizeType;
|
|
19
|
+
onGenerateTags?: () => void;
|
|
20
|
+
formItemId?: string;
|
|
21
|
+
readOnly?: boolean;
|
|
22
|
+
className?: string;
|
|
23
|
+
'aria-invalid'?: boolean;
|
|
24
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scaleflex/ui-tw",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.46",
|
|
4
4
|
"author": "scaleflex",
|
|
5
5
|
"repository": "github:scaleflex/ui",
|
|
6
6
|
"homepage": "https://github.com/scaleflex/ui/blob/master/README.md",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"@radix-ui/react-slot": "^1.1.2",
|
|
24
24
|
"@radix-ui/react-switch": "^1.0.1",
|
|
25
25
|
"@radix-ui/react-tooltip": "^1.2.6",
|
|
26
|
-
"@scaleflex/icons-tw": "^0.0.
|
|
26
|
+
"@scaleflex/icons-tw": "^0.0.46",
|
|
27
27
|
"@tanstack/react-table": "^8.21.3",
|
|
28
28
|
"@types/lodash.merge": "^4.6.9",
|
|
29
29
|
"class-variance-authority": "^0.7.1",
|