@scaleflex/ui-tw 0.0.95 → 0.0.98

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.
@@ -153,8 +153,13 @@ export function ComboboxUsers(_ref) {
153
153
  })) : /*#__PURE__*/React.createElement(ChevronsUpDownIcon, {
154
154
  className: cn('text-muted-foreground/70 my-auto ml-auto shrink-0', iconSizeInTriggerOptions[size])
155
155
  }))), /*#__PURE__*/React.createElement(PopoverContent, _extends({
156
- className: cn('p-0', popoverClassName)
157
- }, popoverContentProps), /*#__PURE__*/React.createElement(Command, null, /*#__PURE__*/React.createElement(CommandInput, {
156
+ className: cn('w-[var(--radix-popover-trigger-width)] max-w-[var(--radix-popover-trigger-width)] min-w-0 p-0', popoverClassName),
157
+ align: "start"
158
+ }, popoverContentProps), /*#__PURE__*/React.createElement(Command, {
159
+ filter: function filter(value, search) {
160
+ return value.includes(search.trim().toLowerCase()) ? 1 : 0;
161
+ }
162
+ }, /*#__PURE__*/React.createElement(CommandInput, {
158
163
  size: size,
159
164
  placeholder: searchPlaceholder
160
165
  }), /*#__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) {
@@ -30,7 +30,7 @@ import { cva } from 'class-variance-authority';
30
30
  import { Command as CommandPrimitive } from 'cmdk';
31
31
  import { useCommandState } from 'cmdk';
32
32
  import { CheckIcon, SearchIcon, UserCircle2Icon, XIcon } from 'lucide-react';
33
- import React from 'react';
33
+ import React, { useEffect, useRef } from 'react';
34
34
  import { useCallback } from 'react';
35
35
  import { selectCommandHeadingOptions } from './command.utils';
36
36
  function Command(_ref) {
@@ -133,7 +133,25 @@ function CommandClear(_ref4) {
133
133
  function CommandList(_ref5) {
134
134
  var className = _ref5.className,
135
135
  props = _objectWithoutProperties(_ref5, _excluded5);
136
+ var listRef = useRef(null);
137
+ useEffect(function () {
138
+ var listNode = listRef.current;
139
+ if (!listNode) return;
140
+ var observer = new MutationObserver(function () {
141
+ listNode.scrollTo({
142
+ top: 0
143
+ });
144
+ });
145
+ observer.observe(listNode, {
146
+ childList: true,
147
+ subtree: true
148
+ });
149
+ return function () {
150
+ return observer.disconnect();
151
+ };
152
+ }, []);
136
153
  return /*#__PURE__*/React.createElement(CommandPrimitive.List, _extends({
154
+ ref: listRef,
137
155
  "data-slot": "command-list",
138
156
  className: cn('max-h-[300px] scroll-py-1 overflow-x-hidden overflow-y-auto', className)
139
157
  }, props));
@@ -250,6 +268,7 @@ function CommandUserItem(_ref10) {
250
268
  src: profileUrl,
251
269
  alt: "profile image"
252
270
  }) : /*#__PURE__*/React.createElement(UserCircle2Icon, {
271
+ strokeWidth: "1",
253
272
  className: "size-8"
254
273
  })), /*#__PURE__*/React.createElement("div", {
255
274
  className: "max-w-10/12"
@@ -3,5 +3,5 @@ import type { InputProps } from './input.types';
3
3
  declare const inputVariants: (props?: ({
4
4
  size?: "sm" | "md" | "lg" | null | undefined;
5
5
  } & import("class-variance-authority/dist/types").ClassProp) | undefined) => string;
6
- declare function Input({ className, type, size, disabled, readOnly, ...props }: InputProps): React.JSX.Element;
6
+ declare function Input({ className, type, size, disabled, readOnly, icon: Icon, ...props }: InputProps): React.JSX.Element;
7
7
  export { Input, inputVariants };
@@ -1,13 +1,13 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
3
3
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
4
- var _excluded = ["className", "type", "size", "disabled", "readOnly"];
4
+ var _excluded = ["className", "type", "size", "disabled", "readOnly", "icon"];
5
5
  import { getBaseInputClasses, readOnlyClassNames, selectionHighlightClassNames } from '@scaleflex/ui-tw/styles/shared-classes';
6
6
  import { FormSize } from '@scaleflex/ui-tw/types/form-size';
7
7
  import { cn } from '@scaleflex/ui-tw/utils/cn';
8
8
  import { cva } from 'class-variance-authority';
9
9
  import React from 'react';
10
- import { InputType, inputSizeOptions } from './input.constants';
10
+ import { InputType, inputIconSizeOptions, inputSizeOptions, inputWithIconSizeOptions } from './input.constants';
11
11
  var inputVariants = cva('', {
12
12
  variants: {
13
13
  size: inputSizeOptions
@@ -16,6 +16,22 @@ var inputVariants = cva('', {
16
16
  size: FormSize.Md
17
17
  }
18
18
  });
19
+ var inputIconSizeVariants = cva('', {
20
+ variants: {
21
+ size: inputIconSizeOptions
22
+ },
23
+ defaultVariants: {
24
+ size: FormSize.Md
25
+ }
26
+ });
27
+ var inputWithIconVariants = cva('', {
28
+ variants: {
29
+ size: inputWithIconSizeOptions
30
+ },
31
+ defaultVariants: {
32
+ size: FormSize.Md
33
+ }
34
+ });
19
35
  function Input(_ref) {
20
36
  var className = _ref.className,
21
37
  _ref$type = _ref.type,
@@ -26,8 +42,9 @@ function Input(_ref) {
26
42
  disabled = _ref$disabled === void 0 ? false : _ref$disabled,
27
43
  _ref$readOnly = _ref.readOnly,
28
44
  readOnly = _ref$readOnly === void 0 ? false : _ref$readOnly,
45
+ Icon = _ref.icon,
29
46
  props = _objectWithoutProperties(_ref, _excluded);
30
- return /*#__PURE__*/React.createElement("input", _extends({
47
+ var inputElement = /*#__PURE__*/React.createElement("input", _extends({
31
48
  type: type,
32
49
  "data-slot": "input",
33
50
  disabled: disabled,
@@ -35,7 +52,19 @@ function Input(_ref) {
35
52
  className: cn.apply(void 0, ['flex w-full min-w-0'].concat(_toConsumableArray(getBaseInputClasses()), [readOnlyClassNames, selectionHighlightClassNames, inputVariants({
36
53
  size: size,
37
54
  className: className
55
+ }), Icon && inputWithIconVariants({
56
+ size: size
38
57
  })]))
39
58
  }, props));
59
+ if (!Icon) {
60
+ return inputElement;
61
+ }
62
+ return /*#__PURE__*/React.createElement("div", {
63
+ className: cn('relative', className)
64
+ }, inputElement, /*#__PURE__*/React.createElement(Icon, {
65
+ className: cn(inputIconSizeVariants({
66
+ size: size
67
+ }), 'text-muted-foreground absolute top-1/2 -translate-y-1/2 transform', disabled && 'opacity-50')
68
+ }));
40
69
  }
41
70
  export { Input, inputVariants };
@@ -13,3 +13,13 @@ export declare const InputType: {
13
13
  readonly Email: "email";
14
14
  readonly Number: "number";
15
15
  };
16
+ export declare const inputIconSizeOptions: {
17
+ sm: string;
18
+ md: string;
19
+ lg: string;
20
+ };
21
+ export declare const inputWithIconSizeOptions: {
22
+ sm: string;
23
+ md: string;
24
+ lg: string;
25
+ };
@@ -6,4 +6,6 @@ export var InputType = {
6
6
  Text: 'text',
7
7
  Email: 'email',
8
8
  Number: 'number'
9
- };
9
+ };
10
+ export var inputIconSizeOptions = _defineProperty(_defineProperty(_defineProperty({}, FormSize.Sm, 'right-2 size-3'), FormSize.Md, 'right-3 size-4'), FormSize.Lg, 'right-4 size-5');
11
+ export var inputWithIconSizeOptions = _defineProperty(_defineProperty(_defineProperty({}, FormSize.Sm, 'pr-6'), FormSize.Md, 'pr-8'), FormSize.Lg, 'pr-10');
@@ -1,6 +1,8 @@
1
1
  import { FormSizeType } from '@scaleflex/ui-tw/types/form-size';
2
+ import type { LucideIcon } from 'lucide-react';
2
3
  import type { ComponentProps } from 'react';
3
4
  export interface InputProps extends Omit<ComponentProps<'input'>, 'size'> {
4
5
  size?: FormSizeType;
5
6
  'aria-invalid'?: boolean;
7
+ icon?: LucideIcon;
6
8
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scaleflex/ui-tw",
3
- "version": "0.0.95",
3
+ "version": "0.0.98",
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.95",
26
+ "@scaleflex/icons-tw": "^0.0.98",
27
27
  "@tanstack/react-table": "^8.21.3",
28
28
  "@types/lodash.merge": "^4.6.9",
29
29
  "class-variance-authority": "^0.7.1",