@scaleflex/ui-tw 0.0.104 → 0.0.106

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.
@@ -19,9 +19,10 @@ import { getToolbarSizes } from '@scaleflex/ui-tw/textarea/textarea.utils';
19
19
  import { FormSize } from '@scaleflex/ui-tw/types/form-size';
20
20
  import { cn } from '@scaleflex/ui-tw/utils/cn';
21
21
  import { cva } from 'class-variance-authority';
22
+ import { useCommandState } from 'cmdk';
22
23
  import { ChevronsUpDownIcon, UserCircle2Icon } from 'lucide-react';
23
24
  import * as React from 'react';
24
- import { useState } from 'react';
25
+ import { useEffect, useState } from 'react';
25
26
  import { comboboxMultiTagsDefaultSizeOptions, iconSizeInTriggerOptions } from '../combobox.constants';
26
27
  var selectLabelVariants = cva('', {
27
28
  variants: {
@@ -89,6 +90,22 @@ export function ComboboxUsers(_ref) {
89
90
  onBlur === null || onBlur === void 0 || onBlur([]);
90
91
  setOpen(false);
91
92
  };
93
+ var AutoScrollToSelected = function AutoScrollToSelected() {
94
+ var search = useCommandState(function (s) {
95
+ return s.search;
96
+ });
97
+ useEffect(function () {
98
+ var list = document.querySelector('[cmdk-list]');
99
+ if (!list) return;
100
+ requestAnimationFrame(function () {
101
+ var selected = list.querySelector('[data-selected="true"]');
102
+ if (selected) selected.scrollIntoView({
103
+ block: 'nearest'
104
+ });
105
+ });
106
+ }, [search]);
107
+ return null;
108
+ };
92
109
  var _createClearHandlers = createClearHandlers(onClearAll),
93
110
  handleOnTriggerClick = _createClearHandlers.onClick,
94
111
  handleOnTriggerKeyDown = _createClearHandlers.onKeyDown;
@@ -159,7 +176,7 @@ export function ComboboxUsers(_ref) {
159
176
  filter: function filter(value, search) {
160
177
  return value.includes(search.trim().toLowerCase()) ? 1 : 0;
161
178
  }
162
- }, /*#__PURE__*/React.createElement(CommandInput, {
179
+ }, /*#__PURE__*/React.createElement(AutoScrollToSelected, null), /*#__PURE__*/React.createElement(CommandInput, {
163
180
  size: size,
164
181
  placeholder: searchPlaceholder
165
182
  }), /*#__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) {
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ import { FieldValues, Path } from 'react-hook-form';
3
+ import type { FormInputGroupFieldProps } from '../form.types';
4
+ declare function FormInputGroupField<TFieldValues extends FieldValues, TName extends Path<TFieldValues>>({ className, children, size, onBlur, ...rest }: FormInputGroupFieldProps<TFieldValues, TName>): React.JSX.Element;
5
+ export { FormInputGroupField };
@@ -0,0 +1,33 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
+ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
4
+ var _excluded = ["className", "children", "size", "onBlur"];
5
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
6
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
7
+ import { InputGroup } from '@scaleflex/ui-tw/input-group';
8
+ import React from 'react';
9
+ import { Children, cloneElement, isValidElement } from 'react';
10
+ import { FormFieldGroup } from './form-field-group.component';
11
+ function FormInputGroupField(_ref) {
12
+ var className = _ref.className,
13
+ children = _ref.children,
14
+ size = _ref.size,
15
+ _onBlur = _ref.onBlur,
16
+ rest = _objectWithoutProperties(_ref, _excluded);
17
+ return /*#__PURE__*/React.createElement(FormFieldGroup, _extends({
18
+ size: size
19
+ }, rest), function (field, args) {
20
+ return /*#__PURE__*/React.createElement(InputGroup, {
21
+ className: className,
22
+ size: size
23
+ }, Children.map(children, function (child) {
24
+ return /*#__PURE__*/isValidElement(child) ? /*#__PURE__*/cloneElement(child, _objectSpread(_objectSpread(_objectSpread({}, args), field), {}, {
25
+ onBlur: function onBlur(e) {
26
+ field.onBlur();
27
+ _onBlur === null || _onBlur === void 0 || _onBlur(e);
28
+ }
29
+ })) : child;
30
+ }));
31
+ });
32
+ }
33
+ export { FormInputGroupField };
@@ -162,4 +162,9 @@ export interface FormTagsInnerProps<TFieldValues extends FieldValues, TName exte
162
162
  disabled?: boolean;
163
163
  className?: string;
164
164
  }
165
+ export type FormInputGroupFieldProps<TFieldValues extends FieldValues, TName extends Path<TFieldValues>> = Omit<FormFieldGroupProps<TFieldValues, TName>, 'children'> & {
166
+ className?: string;
167
+ children: ReactNode;
168
+ onBlur?: (e: React.FocusEvent<HTMLInputElement> | React.FocusEvent<HTMLTextAreaElement>) => void;
169
+ };
165
170
  export {};
package/form/index.d.ts CHANGED
@@ -13,3 +13,4 @@ export { FormCheckboxGroupField } from './components/form-checkbox-group-field.c
13
13
  export { FormRadioGroupField } from './components/form-radio-group-field.component';
14
14
  export { FormDatePickerField } from './components/form-date-picker-field.component';
15
15
  export { FormTagsField } from './components/form-tags-field.component';
16
+ export { FormInputGroupField } from './components/form-input-group-field.component';
package/form/index.js CHANGED
@@ -11,4 +11,5 @@ 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
13
  export { FormDatePickerField } from './components/form-date-picker-field.component';
14
- export { FormTagsField } from './components/form-tags-field.component';
14
+ export { FormTagsField } from './components/form-tags-field.component';
15
+ export { FormInputGroupField } from './components/form-input-group-field.component';
@@ -0,0 +1 @@
1
+ export { InputGroup, InputGroupAddon, InputGroupButton, InputGroupText, InputGroupInput, InputGroupTextarea, } from './input-group.component';
@@ -0,0 +1 @@
1
+ export { InputGroup, InputGroupAddon, InputGroupButton, InputGroupText, InputGroupInput, InputGroupTextarea } from './input-group.component';
@@ -0,0 +1,18 @@
1
+ import { type VariantProps } from 'class-variance-authority';
2
+ import * as React from 'react';
3
+ import type { ComponentProps } from 'react';
4
+ import { ButtonProps } from '../button';
5
+ import { TextareaProps } from '../textarea';
6
+ declare const inputGroupVariants: (props?: ({
7
+ size?: "sm" | "md" | "lg" | null | undefined;
8
+ } & import("class-variance-authority/dist/types").ClassProp) | undefined) => string;
9
+ declare function InputGroup({ className, size, ...props }: ComponentProps<'div'> & VariantProps<typeof inputGroupVariants>): React.JSX.Element;
10
+ declare const inputGroupAddonVariants: (props?: ({
11
+ align?: "block-end" | "block-start" | "inline-end" | "inline-start" | null | undefined;
12
+ } & import("class-variance-authority/dist/types").ClassProp) | undefined) => string;
13
+ declare function InputGroupAddon({ className, align, ...props }: ComponentProps<'div'> & VariantProps<typeof inputGroupAddonVariants>): React.JSX.Element;
14
+ declare function InputGroupButton({ className, type, variant, size, ...props }: ButtonProps): React.JSX.Element;
15
+ declare function InputGroupText({ className, ...props }: ComponentProps<'span'>): React.JSX.Element;
16
+ declare function InputGroupInput({ className, ...props }: ComponentProps<'input'>): React.JSX.Element;
17
+ declare function InputGroupTextarea({ className, ...props }: TextareaProps): React.JSX.Element;
18
+ export { InputGroup, InputGroupAddon, InputGroupButton, InputGroupText, InputGroupInput, InputGroupTextarea };
@@ -0,0 +1,133 @@
1
+ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
+ import _extends from "@babel/runtime/helpers/extends";
3
+ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
4
+ var _excluded = ["className", "size"],
5
+ _excluded2 = ["className", "align"],
6
+ _excluded3 = ["className", "type", "variant", "size"],
7
+ _excluded4 = ["className"],
8
+ _excluded5 = ["className"],
9
+ _excluded6 = ["className"];
10
+ import { cva } from 'class-variance-authority';
11
+ import * as React from 'react';
12
+ import { Button, ButtonSize, ButtonVariant } from '../button';
13
+ import { getBaseInputClasses } from '../styles/shared-classes';
14
+ import { Textarea } from '../textarea';
15
+ import { FormSize } from '../types/form-size';
16
+ import { cn } from '../utils/cn';
17
+ import { ariaInvalidClassNames, focusRingClassNames, inputGroupInputAlignSizeOptions, inputGroupInputSizeOptions, inputGroupSizeOptions, readOnlyClassNames } from './input-group.constants';
18
+ var inputGroupVariants = cva('', {
19
+ variants: {
20
+ size: inputGroupSizeOptions
21
+ },
22
+ defaultVariants: {
23
+ size: FormSize.Md
24
+ }
25
+ });
26
+ var inputGroupInputVariants = cva('', {
27
+ variants: {
28
+ size: inputGroupInputSizeOptions
29
+ },
30
+ defaultVariants: {
31
+ size: FormSize.Md
32
+ }
33
+ });
34
+ var inputGroupInputAlignVariants = cva('', {
35
+ variants: {
36
+ size: inputGroupInputAlignSizeOptions
37
+ },
38
+ defaultVariants: {
39
+ size: FormSize.Md
40
+ }
41
+ });
42
+ function InputGroup(_ref) {
43
+ var className = _ref.className,
44
+ _ref$size = _ref.size,
45
+ size = _ref$size === void 0 ? FormSize.Md : _ref$size,
46
+ props = _objectWithoutProperties(_ref, _excluded);
47
+ return /*#__PURE__*/React.createElement("div", _extends({
48
+ "data-slot": "input-group",
49
+ role: "group",
50
+ className: cn('group/input-group border-input relative flex w-full items-center rounded-md border p-0.5 shadow-xs transition-[color,box-shadow] outline-none', inputGroupVariants({
51
+ size: size
52
+ }), inputGroupInputVariants({
53
+ size: size
54
+ }), inputGroupInputAlignVariants({
55
+ size: size
56
+ }), 'min-w-0 has-[>textarea]:h-auto', 'has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col', 'has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col', focusRingClassNames, ariaInvalidClassNames, readOnlyClassNames, className)
57
+ }, props));
58
+ }
59
+ var inputGroupAddonVariants = cva("text-muted-foreground flex h-auto cursor-text items-center justify-center gap-2 py-1.5 text-sm font-medium select-none [&>svg:not([class*='size-'])]:size-4 [&>kbd]:rounded-[calc(var(--radius)-5px)] group-data-[disabled=true]/input-group:opacity-50", {
60
+ variants: {
61
+ align: {
62
+ 'inline-start': 'order-first pl-3 has-[>button]:ml-[-0.45rem] has-[>kbd]:ml-[-0.35rem]',
63
+ 'inline-end': 'order-last pr-3 has-[>button]:mr-[-0.45rem] has-[>kbd]:mr-[-0.35rem]',
64
+ 'block-start': 'order-first w-full justify-start px-3 pt-3 [.border-b]:pb-3 group-has-[>input]/input-group:pt-2.5',
65
+ 'block-end': 'order-last w-full justify-start px-3 pb-3 [.border-t]:pt-3 group-has-[>input]/input-group:pb-2.5'
66
+ }
67
+ },
68
+ defaultVariants: {
69
+ align: 'inline-start'
70
+ }
71
+ });
72
+ function InputGroupAddon(_ref2) {
73
+ var className = _ref2.className,
74
+ _ref2$align = _ref2.align,
75
+ align = _ref2$align === void 0 ? 'inline-start' : _ref2$align,
76
+ props = _objectWithoutProperties(_ref2, _excluded2);
77
+ return /*#__PURE__*/React.createElement("div", _extends({
78
+ role: "group",
79
+ "data-slot": "input-group-addon",
80
+ "data-align": align,
81
+ className: cn(inputGroupAddonVariants({
82
+ align: align
83
+ }), className),
84
+ onClick: function onClick(e) {
85
+ var _e$currentTarget$pare;
86
+ if (e.target.closest('button')) {
87
+ return;
88
+ }
89
+ (_e$currentTarget$pare = e.currentTarget.parentElement) === null || _e$currentTarget$pare === void 0 || (_e$currentTarget$pare = _e$currentTarget$pare.querySelector('input')) === null || _e$currentTarget$pare === void 0 || _e$currentTarget$pare.focus();
90
+ }
91
+ }, props));
92
+ }
93
+ function InputGroupButton(_ref3) {
94
+ var className = _ref3.className,
95
+ _ref3$type = _ref3.type,
96
+ type = _ref3$type === void 0 ? 'button' : _ref3$type,
97
+ _ref3$variant = _ref3.variant,
98
+ variant = _ref3$variant === void 0 ? ButtonVariant.GhostPrimary : _ref3$variant,
99
+ _ref3$size = _ref3.size,
100
+ size = _ref3$size === void 0 ? ButtonSize.Md : _ref3$size,
101
+ props = _objectWithoutProperties(_ref3, _excluded3);
102
+ return /*#__PURE__*/React.createElement(Button, _extends({
103
+ type: type,
104
+ "data-size": size,
105
+ size: size,
106
+ variant: variant,
107
+ className: className
108
+ }, props));
109
+ }
110
+ function InputGroupText(_ref4) {
111
+ var className = _ref4.className,
112
+ props = _objectWithoutProperties(_ref4, _excluded4);
113
+ return /*#__PURE__*/React.createElement("span", _extends({
114
+ className: cn("text-muted-foreground flex items-center gap-2 text-sm [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4", className)
115
+ }, props));
116
+ }
117
+ function InputGroupInput(_ref5) {
118
+ var className = _ref5.className,
119
+ props = _objectWithoutProperties(_ref5, _excluded5);
120
+ return /*#__PURE__*/React.createElement("input", _extends({
121
+ "data-slot": "input-group-control",
122
+ className: cn.apply(void 0, _toConsumableArray(getBaseInputClasses(false, false)).concat(['flex h-full min-w-0 flex-1 rounded-none border-0 shadow-none', className]))
123
+ }, props));
124
+ }
125
+ function InputGroupTextarea(_ref6) {
126
+ var className = _ref6.className,
127
+ props = _objectWithoutProperties(_ref6, _excluded6);
128
+ return /*#__PURE__*/React.createElement(Textarea, _extends({
129
+ "data-slot": "input-group-control",
130
+ className: cn('flex-1 resize-none rounded-none border-0 bg-transparent shadow-none focus-visible:ring-0 focus-visible:ring-offset-0', className)
131
+ }, props));
132
+ }
133
+ export { InputGroup, InputGroupAddon, InputGroupButton, InputGroupText, InputGroupInput, InputGroupTextarea };
@@ -0,0 +1,18 @@
1
+ export declare const inputGroupSizeOptions: {
2
+ readonly sm: "h-8 text-sm";
3
+ readonly md: "h-10 text-base";
4
+ readonly lg: "h-12 text-lg";
5
+ };
6
+ export declare const inputGroupInputSizeOptions: {
7
+ readonly sm: "[&>input]:py-1 [&>input]:px-2";
8
+ readonly md: "[&>input]:py-2 [&>input]:px-3";
9
+ readonly lg: "[&>input]:py-3 [&>input]:px-4";
10
+ };
11
+ export declare const inputGroupInputAlignSizeOptions: {
12
+ readonly sm: string;
13
+ readonly md: string;
14
+ readonly lg: string;
15
+ };
16
+ export declare const focusRingClassNames = "has-[[data-slot=input-group-control]:focus-visible]:ring-ring ring-offset-background has-[[data-slot=input-group-control]:focus-visible]:ring-2 has-[[data-slot=input-group-control]:focus-visible]:ring-offset-2 has-[[data-slot=input-group-control]:focus-visible]:outline-none";
17
+ export declare const ariaInvalidClassNames = "has-[[data-slot][aria-invalid=true]]:ring-destructive/20 has-[[data-slot][aria-invalid=true]]:border-destructive";
18
+ export declare const readOnlyClassNames = "has-[[data-slot=input-group-control]:read-only]:bg-secondary has-[[data-slot=input-group-control]:read-only]:[&>input]:bg-secondary has-[[data-slot=input-group-control]:read-only]:text-foreground has-[[data-slot=input-group-control]:read-only]:cursor-default";
@@ -0,0 +1,8 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+ import { FormSize } from '../types/form-size';
3
+ export var inputGroupSizeOptions = _defineProperty(_defineProperty(_defineProperty({}, FormSize.Sm, 'h-8 text-sm'), FormSize.Md, 'h-10 text-base'), FormSize.Lg, 'h-12 text-lg');
4
+ export var inputGroupInputSizeOptions = _defineProperty(_defineProperty(_defineProperty({}, FormSize.Sm, '[&>input]:py-1 [&>input]:px-2'), FormSize.Md, '[&>input]:py-2 [&>input]:px-3'), FormSize.Lg, '[&>input]:py-3 [&>input]:px-4');
5
+ export var inputGroupInputAlignSizeOptions = _defineProperty(_defineProperty(_defineProperty({}, FormSize.Sm, ['has-[>[data-align=inline-start]]:[&>input]:pl-2', 'has-[>[data-align=inline-end]]:[&>input]:pr-2', 'has-[>[data-align=block-start]]:[&>input]:pb-1.5', 'has-[>[data-align=block-end]]:[&>input]:pt-1.5'].join(' ')), FormSize.Md, ['has-[>[data-align=inline-start]]:[&>input]:pl-3', 'has-[>[data-align=inline-end]]:[&>input]:pr-3', 'has-[>[data-align=block-start]]:[&>input]:pb-2.5', 'has-[>[data-align=block-end]]:[&>input]:pt-2.5'].join(' ')), FormSize.Lg, ['has-[>[data-align=inline-start]]:[&>input]:pl-3', 'has-[>[data-align=inline-end]]:[&>input]:pr-3', 'has-[>[data-align=block-start]]:[&>input]:pb-2.5', 'has-[>[data-align=block-end]]:[&>input]:pt-2.5'].join(' '));
6
+ export var focusRingClassNames = 'has-[[data-slot=input-group-control]:focus-visible]:ring-ring ring-offset-background has-[[data-slot=input-group-control]:focus-visible]:ring-2 has-[[data-slot=input-group-control]:focus-visible]:ring-offset-2 has-[[data-slot=input-group-control]:focus-visible]:outline-none';
7
+ export var ariaInvalidClassNames = 'has-[[data-slot][aria-invalid=true]]:ring-destructive/20 has-[[data-slot][aria-invalid=true]]:border-destructive';
8
+ export var readOnlyClassNames = 'has-[[data-slot=input-group-control]:read-only]:bg-secondary has-[[data-slot=input-group-control]:read-only]:[&>input]:bg-secondary has-[[data-slot=input-group-control]:read-only]:text-foreground has-[[data-slot=input-group-control]:read-only]:cursor-default';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scaleflex/ui-tw",
3
- "version": "0.0.104",
3
+ "version": "0.0.106",
4
4
  "author": "scaleflex",
5
5
  "repository": "github:scaleflex/ui",
6
6
  "homepage": "https://github.com/scaleflex/ui/blob/master/README.md",
@@ -25,7 +25,7 @@
25
25
  "@radix-ui/react-slot": "^1.1.2",
26
26
  "@radix-ui/react-switch": "^1.0.1",
27
27
  "@radix-ui/react-tooltip": "^1.2.6",
28
- "@scaleflex/icons-tw": "^0.0.104",
28
+ "@scaleflex/icons-tw": "^0.0.106",
29
29
  "@tanstack/react-table": "^8.21.3",
30
30
  "@types/lodash.merge": "^4.6.9",
31
31
  "class-variance-authority": "^0.7.1",
@@ -2,4 +2,4 @@ export declare const focusRingClassNames = "focus-visible:ring-ring ring-offset-
2
2
  export declare const selectionHighlightClassNames = "selection:bg-primary selection:text-primary-foreground";
3
3
  export declare const readOnlyClassNames = "read-only:bg-secondary read-only:text-foreground read-only:cursor-default";
4
4
  export declare const ariaInvalidClassNames = "aria-invalid:ring-destructive/20 aria-invalid:border-destructive hover:aria-invalid:border-destructive/60 focus-visible:aria-invalid:border-destructive";
5
- export declare const getBaseInputClasses: () => string[];
5
+ export declare const getBaseInputClasses: (focusRing?: boolean, ariaInvalid?: boolean) => (string | false)[];
@@ -3,5 +3,7 @@ export var selectionHighlightClassNames = 'selection:bg-primary selection:text-p
3
3
  export var readOnlyClassNames = 'read-only:bg-secondary read-only:text-foreground read-only:cursor-default';
4
4
  export var ariaInvalidClassNames = 'aria-invalid:ring-destructive/20 aria-invalid:border-destructive hover:aria-invalid:border-destructive/60 focus-visible:aria-invalid:border-destructive';
5
5
  export var getBaseInputClasses = function getBaseInputClasses() {
6
- return ['rounded-md border shadow-xs transition-[color,box-shadow] outline-none', 'border-input text-foreground bg-background', 'placeholder:text-muted-foreground/80 hover:border-secondary-foreground/50', 'disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50', 'focus-visible:border-secondary-foreground/50', 'focus-visible:group-data-[highlight=true]:border-warning group-data-[highlight=true]:border-warning hover:group-data-[highlight=true]:border-warning/60 group-data-[highlight=true]:focus-visible:ring-warning/20', ariaInvalidClassNames, focusRingClassNames];
6
+ var focusRing = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
7
+ var ariaInvalid = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
8
+ return ['rounded-md border shadow-xs transition-[color,box-shadow] outline-none', 'border-input text-foreground bg-background', 'placeholder:text-muted-foreground/80 hover:border-secondary-foreground/50', 'disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50', 'focus-visible:border-secondary-foreground/50', 'focus-visible:group-data-[highlight=true]:border-warning group-data-[highlight=true]:border-warning hover:group-data-[highlight=true]:border-warning/60 group-data-[highlight=true]:focus-visible:ring-warning/20', ariaInvalid && ariaInvalidClassNames, focusRing && focusRingClassNames];
7
9
  };