@scaleflex/ui-tw 0.0.92 → 0.0.94
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-users/combobox-users.component.d.ts +3 -0
- package/combobox/combobox-users/combobox-users.component.js +228 -0
- package/combobox/combobox.types.d.ts +12 -0
- package/combobox/combobox.utils.d.ts +3 -0
- package/combobox/combobox.utils.js +8 -0
- package/combobox/index.d.ts +1 -0
- package/combobox/index.js +1 -0
- package/command/command.component.d.ts +3 -2
- package/command/command.component.js +57 -13
- package/dropdown-menu/dropdown-menu.component.js +4 -4
- package/form/form.types.d.ts +17 -0
- package/package.json +2 -2
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { ComboboxUsersProps } from '../combobox.types';
|
|
3
|
+
export declare function ComboboxUsers({ options, value, onChange, placeholder, className, disabled, size, readOnly, popoverClassName, onBlur, showGroupSeparator, defaultOpen, searchPlaceholder, popoverContentProps, actions, fixedActions, triggerProps, ...rest }: ComboboxUsersProps): React.JSX.Element;
|
|
@@ -0,0 +1,228 @@
|
|
|
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 = ["options", "value", "onChange", "placeholder", "className", "disabled", "size", "readOnly", "popoverClassName", "onBlur", "showGroupSeparator", "defaultOpen", "searchPlaceholder", "popoverContentProps", "actions", "fixedActions", "triggerProps"];
|
|
6
|
+
import { ButtonVariant, buttonVariants } from '@scaleflex/ui-tw/button';
|
|
7
|
+
import { buttonBaseClassNames } from '@scaleflex/ui-tw/button/button.constants';
|
|
8
|
+
import { SelectActions } from '@scaleflex/ui-tw/combobox/combobox.component';
|
|
9
|
+
import { createClearHandlers, flattenUsersOptions, isUserOptionGroup } from '@scaleflex/ui-tw/combobox/combobox.utils';
|
|
10
|
+
import { Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList } from '@scaleflex/ui-tw/command';
|
|
11
|
+
import { CommandUserItem } from '@scaleflex/ui-tw/command/command.component';
|
|
12
|
+
import { Pill } from '@scaleflex/ui-tw/pill';
|
|
13
|
+
import { Popover, PopoverContent, PopoverTrigger } from '@scaleflex/ui-tw/popover';
|
|
14
|
+
import { SelectSeparator } from '@scaleflex/ui-tw/select';
|
|
15
|
+
import { selectLabelSizeOptions } from '@scaleflex/ui-tw/select/select.constants';
|
|
16
|
+
import { focusRingClassNames, getBaseInputClasses, readOnlyClassNames, selectionHighlightClassNames } from '@scaleflex/ui-tw/styles/shared-classes';
|
|
17
|
+
import { textareaVariants } from '@scaleflex/ui-tw/textarea';
|
|
18
|
+
import { getToolbarSizes } from '@scaleflex/ui-tw/textarea/textarea.utils';
|
|
19
|
+
import { FormSize } from '@scaleflex/ui-tw/types/form-size';
|
|
20
|
+
import { cn } from '@scaleflex/ui-tw/utils/cn';
|
|
21
|
+
import { cva } from 'class-variance-authority';
|
|
22
|
+
import { ChevronsUpDownIcon, UserCircle2Icon } from 'lucide-react';
|
|
23
|
+
import * as React from 'react';
|
|
24
|
+
import { useState } from 'react';
|
|
25
|
+
import { comboboxMultiTagsDefaultSizeOptions, iconSizeInTriggerOptions } from '../combobox.constants';
|
|
26
|
+
var selectLabelVariants = cva('', {
|
|
27
|
+
variants: {
|
|
28
|
+
size: selectLabelSizeOptions
|
|
29
|
+
},
|
|
30
|
+
defaultVariants: {
|
|
31
|
+
size: FormSize.Md
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
export function ComboboxUsers(_ref) {
|
|
35
|
+
var options = _ref.options,
|
|
36
|
+
value = _ref.value,
|
|
37
|
+
onChange = _ref.onChange,
|
|
38
|
+
_ref$placeholder = _ref.placeholder,
|
|
39
|
+
placeholder = _ref$placeholder === void 0 ? 'Select options...' : _ref$placeholder,
|
|
40
|
+
className = _ref.className,
|
|
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
|
+
_ref$readOnly = _ref.readOnly,
|
|
46
|
+
readOnly = _ref$readOnly === void 0 ? false : _ref$readOnly,
|
|
47
|
+
popoverClassName = _ref.popoverClassName,
|
|
48
|
+
onBlur = _ref.onBlur,
|
|
49
|
+
_ref$showGroupSeparat = _ref.showGroupSeparator,
|
|
50
|
+
showGroupSeparator = _ref$showGroupSeparat === void 0 ? false : _ref$showGroupSeparat,
|
|
51
|
+
_ref$defaultOpen = _ref.defaultOpen,
|
|
52
|
+
defaultOpen = _ref$defaultOpen === void 0 ? false : _ref$defaultOpen,
|
|
53
|
+
searchPlaceholder = _ref.searchPlaceholder,
|
|
54
|
+
popoverContentProps = _ref.popoverContentProps,
|
|
55
|
+
actions = _ref.actions,
|
|
56
|
+
fixedActions = _ref.fixedActions,
|
|
57
|
+
triggerProps = _ref.triggerProps,
|
|
58
|
+
rest = _objectWithoutProperties(_ref, _excluded);
|
|
59
|
+
var _getToolbarSizes = getToolbarSizes(size),
|
|
60
|
+
buttonSize = _getToolbarSizes.buttonSize;
|
|
61
|
+
var _useState = useState(defaultOpen),
|
|
62
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
63
|
+
open = _useState2[0],
|
|
64
|
+
setOpen = _useState2[1];
|
|
65
|
+
var selectedOptions = flattenUsersOptions(options).filter(function (option) {
|
|
66
|
+
return value.includes(option.value);
|
|
67
|
+
});
|
|
68
|
+
var isSelected = selectedOptions.length > 0;
|
|
69
|
+
var toggleValue = function toggleValue(v) {
|
|
70
|
+
var _ref2 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
|
|
71
|
+
_ref2$isTriggerOnBlur = _ref2.isTriggerOnBlur,
|
|
72
|
+
isTriggerOnBlur = _ref2$isTriggerOnBlur === void 0 ? false : _ref2$isTriggerOnBlur;
|
|
73
|
+
var nextValue = value.includes(v) ? value.filter(function (val) {
|
|
74
|
+
return val !== v;
|
|
75
|
+
}) : [].concat(_toConsumableArray(value), [v]);
|
|
76
|
+
onChange(nextValue);
|
|
77
|
+
if (isTriggerOnBlur) {
|
|
78
|
+
onBlur === null || onBlur === void 0 || onBlur(nextValue);
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
var onOpenChange = function onOpenChange(isOpen) {
|
|
82
|
+
if (!isOpen) {
|
|
83
|
+
onBlur === null || onBlur === void 0 || onBlur(value);
|
|
84
|
+
}
|
|
85
|
+
setOpen(isOpen);
|
|
86
|
+
};
|
|
87
|
+
var onClearAll = function onClearAll() {
|
|
88
|
+
onChange([]);
|
|
89
|
+
onBlur === null || onBlur === void 0 || onBlur([]);
|
|
90
|
+
setOpen(false);
|
|
91
|
+
};
|
|
92
|
+
var _createClearHandlers = createClearHandlers(onClearAll),
|
|
93
|
+
handleOnTriggerClick = _createClearHandlers.onClick,
|
|
94
|
+
handleOnTriggerKeyDown = _createClearHandlers.onKeyDown;
|
|
95
|
+
return /*#__PURE__*/React.createElement(Popover, {
|
|
96
|
+
open: open,
|
|
97
|
+
defaultOpen: defaultOpen,
|
|
98
|
+
onOpenChange: onOpenChange
|
|
99
|
+
}, /*#__PURE__*/React.createElement(PopoverTrigger, {
|
|
100
|
+
asChild: true
|
|
101
|
+
}, /*#__PURE__*/React.createElement("button", _extends({
|
|
102
|
+
role: "combobox",
|
|
103
|
+
"aria-expanded": open,
|
|
104
|
+
"aria-invalid": rest['aria-invalid'],
|
|
105
|
+
className: cn.apply(void 0, ['flex w-full', isSelected ? 'flex-col' : 'items-center'].concat(_toConsumableArray(getBaseInputClasses()), [readOnly && readOnlyClassNames, selectionHighlightClassNames, focusRingClassNames, !isSelected && textareaVariants({
|
|
106
|
+
size: size
|
|
107
|
+
}), !isSelected && comboboxMultiTagsDefaultSizeOptions[size], className])),
|
|
108
|
+
disabled: disabled,
|
|
109
|
+
onClick: handleOnTriggerClick,
|
|
110
|
+
onKeyDown: handleOnTriggerKeyDown
|
|
111
|
+
}, triggerProps), !isSelected ? /*#__PURE__*/React.createElement("span", {
|
|
112
|
+
className: "text-muted-foreground"
|
|
113
|
+
}, placeholder) : /*#__PURE__*/React.createElement("div", {
|
|
114
|
+
className: cn('flex w-full flex-wrap justify-start gap-2 overflow-y-auto', textareaVariants({
|
|
115
|
+
size: size
|
|
116
|
+
}), 'min-h-auto')
|
|
117
|
+
}, selectedOptions.map(function (option) {
|
|
118
|
+
return /*#__PURE__*/React.createElement(Pill, {
|
|
119
|
+
key: option.value,
|
|
120
|
+
size: size,
|
|
121
|
+
variant: "default",
|
|
122
|
+
removable: true,
|
|
123
|
+
className: "max-w-xs",
|
|
124
|
+
onRemove: function onRemove(event) {
|
|
125
|
+
event.preventDefault();
|
|
126
|
+
event.stopPropagation();
|
|
127
|
+
toggleValue(option.value, {
|
|
128
|
+
isTriggerOnBlur: true
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
132
|
+
className: "flex items-center gap-1.5"
|
|
133
|
+
}, option.profileUrl ? /*#__PURE__*/React.createElement("img", {
|
|
134
|
+
className: "size-5 rounded-full",
|
|
135
|
+
src: option.profileUrl,
|
|
136
|
+
alt: "profile image"
|
|
137
|
+
}) : /*#__PURE__*/React.createElement(UserCircle2Icon, {
|
|
138
|
+
className: "text-muted-foreground size-5"
|
|
139
|
+
}), /*#__PURE__*/React.createElement("span", null, option.email)));
|
|
140
|
+
})), isSelected ? /*#__PURE__*/React.createElement("div", {
|
|
141
|
+
className: "flex w-full items-center justify-between p-1.5"
|
|
142
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
143
|
+
role: "button",
|
|
144
|
+
tabIndex: 0,
|
|
145
|
+
"data-clear-icon": "true",
|
|
146
|
+
"aria-label": "Clear all",
|
|
147
|
+
className: cn.apply(void 0, _toConsumableArray(buttonBaseClassNames).concat([focusRingClassNames, buttonVariants({
|
|
148
|
+
size: buttonSize,
|
|
149
|
+
variant: ButtonVariant.GhostSecondary
|
|
150
|
+
})]))
|
|
151
|
+
}, "Clear all"), /*#__PURE__*/React.createElement(ChevronsUpDownIcon, {
|
|
152
|
+
className: cn('text-muted-foreground/70 mr-1.5 ml-auto shrink-0', iconSizeInTriggerOptions[size])
|
|
153
|
+
})) : /*#__PURE__*/React.createElement(ChevronsUpDownIcon, {
|
|
154
|
+
className: cn('text-muted-foreground/70 my-auto ml-auto shrink-0', iconSizeInTriggerOptions[size])
|
|
155
|
+
}))), /*#__PURE__*/React.createElement(PopoverContent, _extends({
|
|
156
|
+
className: cn('p-0', popoverClassName)
|
|
157
|
+
}, popoverContentProps), /*#__PURE__*/React.createElement(Command, null, /*#__PURE__*/React.createElement(CommandInput, {
|
|
158
|
+
size: size,
|
|
159
|
+
placeholder: searchPlaceholder
|
|
160
|
+
}), /*#__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) {
|
|
161
|
+
if (isUserOptionGroup(option)) {
|
|
162
|
+
return /*#__PURE__*/React.createElement(CommandGroup, {
|
|
163
|
+
key: groupIndex,
|
|
164
|
+
heading: !option.value ? option.label : undefined,
|
|
165
|
+
size: size
|
|
166
|
+
}, option.value && /*#__PURE__*/React.createElement(CommandItem, {
|
|
167
|
+
size: size,
|
|
168
|
+
multiple: true,
|
|
169
|
+
disabled: option.disabled,
|
|
170
|
+
key: option.value,
|
|
171
|
+
icon: option.icon,
|
|
172
|
+
value: option.value,
|
|
173
|
+
tooltip: option.tooltip,
|
|
174
|
+
disabledTooltip: option.disabledTooltip,
|
|
175
|
+
isGroup: true,
|
|
176
|
+
selectedValue: value,
|
|
177
|
+
onSelect: function onSelect() {
|
|
178
|
+
return toggleValue(option.value);
|
|
179
|
+
},
|
|
180
|
+
className: cn('text-secondary-foreground', selectLabelVariants({
|
|
181
|
+
size: size
|
|
182
|
+
}))
|
|
183
|
+
}, option.label), option.options.map(function (_ref3) {
|
|
184
|
+
var name = _ref3.name,
|
|
185
|
+
email = _ref3.email,
|
|
186
|
+
profileUrl = _ref3.profileUrl,
|
|
187
|
+
value = _ref3.value,
|
|
188
|
+
disabled = _ref3.disabled;
|
|
189
|
+
var isGroupSelected = option.value && Array.isArray(value) && value.includes(option.value);
|
|
190
|
+
return /*#__PURE__*/React.createElement(CommandUserItem, {
|
|
191
|
+
size: size,
|
|
192
|
+
multiple: true,
|
|
193
|
+
disabled: disabled || !!isGroupSelected,
|
|
194
|
+
key: value,
|
|
195
|
+
name: name,
|
|
196
|
+
email: email,
|
|
197
|
+
profileUrl: profileUrl,
|
|
198
|
+
value: value,
|
|
199
|
+
isGroup: !!option.label,
|
|
200
|
+
selectedValue: value,
|
|
201
|
+
onSelect: function onSelect() {
|
|
202
|
+
return toggleValue(value);
|
|
203
|
+
}
|
|
204
|
+
});
|
|
205
|
+
}), showGroupSeparator && groupIndex !== options.length - 1 && /*#__PURE__*/React.createElement(SelectSeparator, null));
|
|
206
|
+
}
|
|
207
|
+
return /*#__PURE__*/React.createElement(CommandGroup, {
|
|
208
|
+
key: groupIndex
|
|
209
|
+
}, /*#__PURE__*/React.createElement(CommandUserItem, {
|
|
210
|
+
size: size,
|
|
211
|
+
multiple: true,
|
|
212
|
+
disabled: option.disabled,
|
|
213
|
+
key: option.value,
|
|
214
|
+
name: option.name,
|
|
215
|
+
email: option.email,
|
|
216
|
+
profileUrl: option.profileUrl,
|
|
217
|
+
value: option.value,
|
|
218
|
+
selectedValue: value,
|
|
219
|
+
onSelect: function onSelect() {
|
|
220
|
+
return toggleValue(option.value);
|
|
221
|
+
}
|
|
222
|
+
}));
|
|
223
|
+
}), !fixedActions && /*#__PURE__*/React.createElement(SelectActions, {
|
|
224
|
+
actions: actions
|
|
225
|
+
})), fixedActions && /*#__PURE__*/React.createElement(SelectActions, {
|
|
226
|
+
actions: actions
|
|
227
|
+
}))));
|
|
228
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as PopoverPrimitive from '@radix-ui/react-popover';
|
|
2
2
|
import { SelectOption } from '@scaleflex/ui-tw/form';
|
|
3
|
+
import { SelectUserOption } from '@scaleflex/ui-tw/form/form.types';
|
|
3
4
|
import { FormSizeType } from '@scaleflex/ui-tw/types/form-size';
|
|
4
5
|
import { Command as CommandPrimitive } from 'cmdk';
|
|
5
6
|
import type { ButtonHTMLAttributes, ComponentProps, ElementType, KeyboardEvent, MouseEvent, ReactElement, ReactNode } from 'react';
|
|
@@ -71,6 +72,11 @@ export interface CommandItemProps extends ComponentProps<typeof CommandPrimitive
|
|
|
71
72
|
iconClassName?: string;
|
|
72
73
|
textClassName?: string;
|
|
73
74
|
}
|
|
75
|
+
export interface CommandUserItemProps extends Omit<CommandItemProps, 'icon' | 'children' | 'tooltip' | 'disabledTooltip'> {
|
|
76
|
+
name: ReactElement | string;
|
|
77
|
+
email: ReactElement | string;
|
|
78
|
+
profileUrl?: string;
|
|
79
|
+
}
|
|
74
80
|
interface ComboboxCommonProps {
|
|
75
81
|
options: SelectOption[];
|
|
76
82
|
placeholder?: string;
|
|
@@ -116,4 +122,10 @@ export interface ComboboxMultiTagProps extends ComboboxCommonProps {
|
|
|
116
122
|
onChange: (value: string[]) => void;
|
|
117
123
|
onBlur?: (value: string[]) => void;
|
|
118
124
|
}
|
|
125
|
+
export interface ComboboxUsersProps extends Omit<ComboboxCommonProps, 'options'> {
|
|
126
|
+
value: string[];
|
|
127
|
+
options: SelectUserOption[];
|
|
128
|
+
onChange: (value: string[]) => void;
|
|
129
|
+
onBlur?: (value: string[]) => void;
|
|
130
|
+
}
|
|
119
131
|
export {};
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { FlatOption, SelectOption } from '@scaleflex/ui-tw/form';
|
|
2
|
+
import { SelectUserOption, UserFlatOption, UserOptionGroup } from '@scaleflex/ui-tw/form/form.types';
|
|
2
3
|
import { FormSizeType } from '@scaleflex/ui-tw/types/form-size';
|
|
3
4
|
import { KeyboardEvent, MouseEvent } from 'react';
|
|
4
5
|
export declare const flattenOptions: (options: SelectOption[]) => FlatOption[];
|
|
6
|
+
export declare const isUserOptionGroup: (option: UserFlatOption | UserOptionGroup) => option is UserOptionGroup;
|
|
7
|
+
export declare const flattenUsersOptions: (options: SelectUserOption[]) => UserFlatOption[];
|
|
5
8
|
export declare const createClearHandlers: (onClearAll?: () => void, optionsLength?: number, toggleFirstOption?: () => void) => {
|
|
6
9
|
onClick: (e: MouseEvent<HTMLButtonElement>) => void;
|
|
7
10
|
onKeyDown: (e: KeyboardEvent<HTMLButtonElement>) => void;
|
|
@@ -5,6 +5,14 @@ export var flattenOptions = function flattenOptions(options) {
|
|
|
5
5
|
return isOptionGroup(option) ? option.options : [option];
|
|
6
6
|
});
|
|
7
7
|
};
|
|
8
|
+
export var isUserOptionGroup = function isUserOptionGroup(option) {
|
|
9
|
+
return 'options' in option;
|
|
10
|
+
};
|
|
11
|
+
export var flattenUsersOptions = function flattenUsersOptions(options) {
|
|
12
|
+
return options.flatMap(function (option) {
|
|
13
|
+
return isUserOptionGroup(option) ? option.options : [option];
|
|
14
|
+
});
|
|
15
|
+
};
|
|
8
16
|
function isClearIconEvent(event) {
|
|
9
17
|
var target = event.type === 'keydown' ? document.activeElement : event.target;
|
|
10
18
|
return !!target.closest('[data-clear-icon]');
|
package/combobox/index.d.ts
CHANGED
|
@@ -3,4 +3,5 @@ export { ComboboxSingle } from './combobox-single/combobox-single.component';
|
|
|
3
3
|
export { ComboboxMultiInline } from './combobox-multi-inline/combobox-multi-inline.component';
|
|
4
4
|
export { ComboboxMultiTag } from './combobox-multi-tag/combobox-multi-tag.component';
|
|
5
5
|
export { ComboboxMultiCheckbox } from './combobox-multi-checkbox/combobox-multi-checkbox.component';
|
|
6
|
+
export { ComboboxUsers } from './combobox-users/combobox-users.component';
|
|
6
7
|
export { flattenOptions } from './combobox.utils';
|
package/combobox/index.js
CHANGED
|
@@ -3,4 +3,5 @@ export { ComboboxSingle } from './combobox-single/combobox-single.component';
|
|
|
3
3
|
export { ComboboxMultiInline } from './combobox-multi-inline/combobox-multi-inline.component';
|
|
4
4
|
export { ComboboxMultiTag } from './combobox-multi-tag/combobox-multi-tag.component';
|
|
5
5
|
export { ComboboxMultiCheckbox } from './combobox-multi-checkbox/combobox-multi-checkbox.component';
|
|
6
|
+
export { ComboboxUsers } from './combobox-users/combobox-users.component';
|
|
6
7
|
export { flattenOptions } from './combobox.utils';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { CommandClearProps, CommandGroupProps, CommandInputProps, CommandItemProps, CommandUserItemProps } from '@scaleflex/ui-tw/combobox/combobox.types';
|
|
2
2
|
import { Dialog } from '@scaleflex/ui-tw/dialog';
|
|
3
3
|
import { Command as CommandPrimitive } from 'cmdk';
|
|
4
4
|
import React from 'react';
|
|
@@ -15,6 +15,7 @@ declare function CommandEmpty({ className, ...rest }: ComponentProps<typeof Comm
|
|
|
15
15
|
declare function CommandGroup({ className, size, ...props }: CommandGroupProps): React.JSX.Element;
|
|
16
16
|
declare function CommandSeparator({ className, ...props }: ComponentProps<typeof CommandPrimitive.Separator>): React.JSX.Element;
|
|
17
17
|
declare function CommandItem({ className, size, isGroup, icon, tooltip, children, selectedValue, multiple, value, shortcut, disabledTooltip, disabled, iconClassName, textClassName, ...props }: CommandItemProps): React.JSX.Element;
|
|
18
|
+
declare function CommandUserItem({ className, size, isGroup, name, email, profileUrl, selectedValue, multiple, value, disabled, textClassName, ...props }: CommandUserItemProps): React.JSX.Element;
|
|
18
19
|
declare function CommandCheckboxItem({ className, textClassName, size, isGroup, children, selectedValue, value, icon, disabled, tooltip, disabledTooltip, ...props }: CommandItemProps): React.JSX.Element;
|
|
19
20
|
declare function CommandShortcut({ className, ...props }: ComponentProps<'span'>): React.JSX.Element;
|
|
20
|
-
export { Command, CommandDialog, CommandInput, CommandList, CommandEmpty, CommandGroup, CommandItem, CommandCheckboxItem, CommandShortcut, CommandSeparator, CommandClear, };
|
|
21
|
+
export { Command, CommandDialog, CommandInput, CommandList, CommandEmpty, CommandGroup, CommandItem, CommandCheckboxItem, CommandShortcut, CommandSeparator, CommandClear, CommandUserItem, };
|
|
@@ -10,8 +10,9 @@ var _excluded = ["className"],
|
|
|
10
10
|
_excluded7 = ["className", "size"],
|
|
11
11
|
_excluded8 = ["className"],
|
|
12
12
|
_excluded9 = ["className", "size", "isGroup", "icon", "tooltip", "children", "selectedValue", "multiple", "value", "shortcut", "disabledTooltip", "disabled", "iconClassName", "textClassName"],
|
|
13
|
-
_excluded10 = ["className", "
|
|
14
|
-
_excluded11 = ["className"]
|
|
13
|
+
_excluded10 = ["className", "size", "isGroup", "name", "email", "profileUrl", "selectedValue", "multiple", "value", "disabled", "textClassName"],
|
|
14
|
+
_excluded11 = ["className", "textClassName", "size", "isGroup", "children", "selectedValue", "value", "icon", "disabled", "tooltip", "disabledTooltip"],
|
|
15
|
+
_excluded12 = ["className"];
|
|
15
16
|
import { ButtonVariant, buttonVariants } from '@scaleflex/ui-tw/button';
|
|
16
17
|
import { buttonBaseClassNames } from '@scaleflex/ui-tw/button/button.constants';
|
|
17
18
|
import { Checkbox } from '@scaleflex/ui-tw/checkbox';
|
|
@@ -28,7 +29,7 @@ import { cn } from '@scaleflex/ui-tw/utils/cn';
|
|
|
28
29
|
import { cva } from 'class-variance-authority';
|
|
29
30
|
import { Command as CommandPrimitive } from 'cmdk';
|
|
30
31
|
import { useCommandState } from 'cmdk';
|
|
31
|
-
import { CheckIcon, SearchIcon, XIcon } from 'lucide-react';
|
|
32
|
+
import { CheckIcon, SearchIcon, UserCircle2Icon, XIcon } from 'lucide-react';
|
|
32
33
|
import React from 'react';
|
|
33
34
|
import { useCallback } from 'react';
|
|
34
35
|
import { selectCommandHeadingOptions } from './command.utils';
|
|
@@ -219,19 +220,62 @@ function CommandItem(_ref9) {
|
|
|
219
220
|
className: cn('text-primary ml-auto h-4 w-4', selected ? 'opacity-100' : 'opacity-0')
|
|
220
221
|
})));
|
|
221
222
|
}
|
|
222
|
-
function
|
|
223
|
+
function CommandUserItem(_ref10) {
|
|
223
224
|
var className = _ref10.className,
|
|
224
|
-
textClassName = _ref10.textClassName,
|
|
225
225
|
size = _ref10.size,
|
|
226
226
|
isGroup = _ref10.isGroup,
|
|
227
|
-
|
|
227
|
+
name = _ref10.name,
|
|
228
|
+
email = _ref10.email,
|
|
229
|
+
profileUrl = _ref10.profileUrl,
|
|
228
230
|
selectedValue = _ref10.selectedValue,
|
|
231
|
+
multiple = _ref10.multiple,
|
|
229
232
|
value = _ref10.value,
|
|
230
|
-
icon = _ref10.icon,
|
|
231
233
|
disabled = _ref10.disabled,
|
|
232
|
-
|
|
233
|
-
disabledTooltip = _ref10.disabledTooltip,
|
|
234
|
+
textClassName = _ref10.textClassName,
|
|
234
235
|
props = _objectWithoutProperties(_ref10, _excluded10);
|
|
236
|
+
var selected = value && (multiple ? selectedValue === null || selectedValue === void 0 ? void 0 : selectedValue.includes(value) : value === selectedValue);
|
|
237
|
+
return /*#__PURE__*/React.createElement(CommandPrimitive.Item, _extends({
|
|
238
|
+
"data-slot": "command-item",
|
|
239
|
+
className: cn('relative flex w-full cursor-pointer items-center justify-between gap-2 outline-hidden select-none', '*:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2', 'data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground', '!opacity-100 data-[disabled=true]:cursor-not-allowed', "[&_svg:not([class*='text-'])]:text-muted-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4", selectItemVariants({
|
|
240
|
+
size: size,
|
|
241
|
+
className: className
|
|
242
|
+
}), isGroup && getOptionInGroupPaddingLeft(size), selected && 'text-primary pr-7', className),
|
|
243
|
+
disabled: disabled
|
|
244
|
+
}, props), /*#__PURE__*/React.createElement("div", {
|
|
245
|
+
className: "flex flex-1 items-center gap-2 overflow-hidden"
|
|
246
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
247
|
+
className: "shrink-0"
|
|
248
|
+
}, profileUrl ? /*#__PURE__*/React.createElement("img", {
|
|
249
|
+
className: "size-10 rounded-full",
|
|
250
|
+
src: profileUrl,
|
|
251
|
+
alt: "profile image"
|
|
252
|
+
}) : /*#__PURE__*/React.createElement(UserCircle2Icon, {
|
|
253
|
+
className: "size-10"
|
|
254
|
+
})), /*#__PURE__*/React.createElement("div", {
|
|
255
|
+
className: "max-w-10/12"
|
|
256
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
257
|
+
className: cn('w-full overflow-hidden text-ellipsis whitespace-nowrap', textClassName)
|
|
258
|
+
}, name), /*#__PURE__*/React.createElement("div", {
|
|
259
|
+
className: cn('text-secondary-foreground w-full overflow-hidden text-ellipsis whitespace-nowrap', textClassName)
|
|
260
|
+
}, email))), /*#__PURE__*/React.createElement("span", {
|
|
261
|
+
className: "absolute right-2 flex size-3.5 items-center justify-center"
|
|
262
|
+
}, /*#__PURE__*/React.createElement(CheckIcon, {
|
|
263
|
+
className: cn('text-primary ml-auto h-4 w-4', selected ? 'opacity-100' : 'opacity-0')
|
|
264
|
+
})));
|
|
265
|
+
}
|
|
266
|
+
function CommandCheckboxItem(_ref11) {
|
|
267
|
+
var className = _ref11.className,
|
|
268
|
+
textClassName = _ref11.textClassName,
|
|
269
|
+
size = _ref11.size,
|
|
270
|
+
isGroup = _ref11.isGroup,
|
|
271
|
+
children = _ref11.children,
|
|
272
|
+
selectedValue = _ref11.selectedValue,
|
|
273
|
+
value = _ref11.value,
|
|
274
|
+
icon = _ref11.icon,
|
|
275
|
+
disabled = _ref11.disabled,
|
|
276
|
+
tooltip = _ref11.tooltip,
|
|
277
|
+
disabledTooltip = _ref11.disabledTooltip,
|
|
278
|
+
props = _objectWithoutProperties(_ref11, _excluded11);
|
|
235
279
|
var selected = value && (selectedValue === null || selectedValue === void 0 ? void 0 : selectedValue.includes(value));
|
|
236
280
|
return /*#__PURE__*/React.createElement(CommandPrimitive.Item, _extends({
|
|
237
281
|
"data-slot": "command-checkbox-item",
|
|
@@ -260,12 +304,12 @@ function CommandCheckboxItem(_ref10) {
|
|
|
260
304
|
tooltip: disabled ? disabledTooltip : tooltip
|
|
261
305
|
}))));
|
|
262
306
|
}
|
|
263
|
-
function CommandShortcut(
|
|
264
|
-
var className =
|
|
265
|
-
props = _objectWithoutProperties(
|
|
307
|
+
function CommandShortcut(_ref12) {
|
|
308
|
+
var className = _ref12.className,
|
|
309
|
+
props = _objectWithoutProperties(_ref12, _excluded12);
|
|
266
310
|
return /*#__PURE__*/React.createElement("span", _extends({
|
|
267
311
|
"data-slot": "command-shortcut",
|
|
268
312
|
className: cn('text-muted-foreground ml-auto text-xs tracking-widest', className)
|
|
269
313
|
}, props));
|
|
270
314
|
}
|
|
271
|
-
export { Command, CommandDialog, CommandInput, CommandList, CommandEmpty, CommandGroup, CommandItem, CommandCheckboxItem, CommandShortcut, CommandSeparator, CommandClear };
|
|
315
|
+
export { Command, CommandDialog, CommandInput, CommandList, CommandEmpty, CommandGroup, CommandItem, CommandCheckboxItem, CommandShortcut, CommandSeparator, CommandClear, CommandUserItem };
|
|
@@ -69,13 +69,13 @@ function DropdownMenuCheckboxItem(_ref7) {
|
|
|
69
69
|
props = _objectWithoutProperties(_ref7, _excluded3);
|
|
70
70
|
return /*#__PURE__*/React.createElement(DropdownMenuPrimitive.CheckboxItem, _extends({
|
|
71
71
|
"data-slot": "dropdown-menu-checkbox-item",
|
|
72
|
-
className: cn('relative flex cursor-default items-center gap-2 rounded-sm py-1.5 pr-2 pl-
|
|
72
|
+
className: cn('relative flex cursor-default items-center gap-2 rounded-sm py-1.5 pr-2 pl-2 text-sm outline-hidden select-none', 'data-[disabled]:pointer-events-none data-[disabled]:opacity-50', 'focus:bg-accent focus:text-accent-foreground', "[&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4", className),
|
|
73
73
|
checked: checked
|
|
74
|
-
}, props), /*#__PURE__*/React.createElement("span", {
|
|
75
|
-
className: "pointer-events-none absolute
|
|
74
|
+
}, props), children, /*#__PURE__*/React.createElement("span", {
|
|
75
|
+
className: "pointer-events-none absolute right-2 flex size-3.5 items-center justify-center"
|
|
76
76
|
}, /*#__PURE__*/React.createElement(DropdownMenuPrimitive.ItemIndicator, null, /*#__PURE__*/React.createElement(CheckIcon, {
|
|
77
77
|
className: "size-4"
|
|
78
|
-
})))
|
|
78
|
+
}))));
|
|
79
79
|
}
|
|
80
80
|
function DropdownMenuRadioGroup(_ref8) {
|
|
81
81
|
var props = _extends({}, (_objectDestructuringEmpty(_ref8), _ref8));
|
package/form/form.types.d.ts
CHANGED
|
@@ -68,7 +68,24 @@ export interface OptionGroup extends Omit<FlatOption, 'value' | 'label'> {
|
|
|
68
68
|
value?: string;
|
|
69
69
|
options: FlatOption[];
|
|
70
70
|
}
|
|
71
|
+
export interface UserFlatOption {
|
|
72
|
+
name: ReactElement | string;
|
|
73
|
+
email: ReactElement | string;
|
|
74
|
+
value: string;
|
|
75
|
+
disabled?: boolean;
|
|
76
|
+
profileUrl?: string;
|
|
77
|
+
}
|
|
78
|
+
export interface UserOptionGroup {
|
|
79
|
+
label?: ReactElement | string;
|
|
80
|
+
value?: string;
|
|
81
|
+
options: UserFlatOption[];
|
|
82
|
+
icon?: ReactElement;
|
|
83
|
+
disabled?: boolean;
|
|
84
|
+
tooltip?: ReactElement | string;
|
|
85
|
+
disabledTooltip?: ReactElement | string;
|
|
86
|
+
}
|
|
71
87
|
export type SelectOption = FlatOption | OptionGroup;
|
|
88
|
+
export type SelectUserOption = UserFlatOption | UserOptionGroup;
|
|
72
89
|
export type FormSelectProps = SelectProps & {
|
|
73
90
|
options: SelectOption[];
|
|
74
91
|
placeholder?: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scaleflex/ui-tw",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.94",
|
|
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.94",
|
|
27
27
|
"@tanstack/react-table": "^8.21.3",
|
|
28
28
|
"@types/lodash.merge": "^4.6.9",
|
|
29
29
|
"class-variance-authority": "^0.7.1",
|