@scaleflex/ui-tw 0.0.8 → 0.0.10

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,5 @@
1
+ import { FormTextareaFieldProps } from '@scaleflex/ui-tw/form/form.types';
2
+ import React from 'react';
3
+ import { FieldValues, Path } from 'react-hook-form';
4
+ declare function FormTextareaField<TFieldValues extends FieldValues, TName extends Path<TFieldValues>>({ textareaProps, ...rest }: FormTextareaFieldProps<TFieldValues, TName>): React.JSX.Element;
5
+ export { FormTextareaField };
@@ -0,0 +1,16 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
+ var _excluded = ["textareaProps"];
4
+ import { FormFieldGroup } from '@scaleflex/ui-tw/form';
5
+ import { Textarea } from '@scaleflex/ui-tw/textarea';
6
+ import React from 'react';
7
+ function FormTextareaField(_ref) {
8
+ var textareaProps = _ref.textareaProps,
9
+ rest = _objectWithoutProperties(_ref, _excluded);
10
+ return /*#__PURE__*/React.createElement(FormFieldGroup, rest, function (field, args) {
11
+ return /*#__PURE__*/React.createElement(Textarea, _extends({
12
+ placeholder: textareaProps === null || textareaProps === void 0 ? void 0 : textareaProps.placeholder
13
+ }, args, textareaProps, field));
14
+ });
15
+ }
16
+ export { FormTextareaField };
@@ -1,8 +1,9 @@
1
1
  import { FormMessageSize, SwitchLayout } from '@scaleflex/ui-tw/form/form.constants';
2
2
  import { InputProps } from '@scaleflex/ui-tw/input';
3
+ import { TextareaProps } from '@scaleflex/ui-tw/textarea';
3
4
  import { FormSizeType } from '@scaleflex/ui-tw/types/form-size';
4
5
  import type { Values } from '@scaleflex/ui-tw/types/values';
5
- import { ReactNode } from 'react';
6
+ import { ReactElement, ReactNode } from 'react';
6
7
  import { ControllerRenderProps, type FieldPath, FieldValues, Path, UseControllerProps } from 'react-hook-form';
7
8
  export type FormMessageSizeType = Values<typeof FormMessageSize>;
8
9
  export type SwitchLayoutType = Values<typeof SwitchLayout>;
@@ -18,24 +19,27 @@ export interface FormFieldArgs {
18
19
  disabled?: boolean;
19
20
  }
20
21
  export interface FormFieldGroupProps<TFieldValues extends FieldValues, TName extends Path<TFieldValues>> extends UseControllerProps<TFieldValues, TName> {
21
- label?: string;
22
- description?: string;
23
- tooltip?: string;
22
+ children: (field: ControllerRenderProps<TFieldValues, TName>, args?: FormFieldArgs) => ReactNode;
23
+ label?: ReactElement | string;
24
+ description?: ReactElement | string;
25
+ tooltip?: ReactElement | string;
24
26
  size?: FormSizeType;
25
27
  readOnly?: boolean;
26
28
  highlight?: boolean;
27
29
  horizontal?: boolean;
28
30
  horizontalLabelWidth?: string;
29
- children: (field: ControllerRenderProps<TFieldValues, TName>, args?: FormFieldArgs) => ReactNode;
30
31
  }
31
32
  export interface FormSwitchFieldProps<TFieldValues extends FieldValues, TName extends Path<TFieldValues>> extends UseControllerProps<TFieldValues, TName> {
32
- label: string;
33
+ label: ReactElement | string;
33
34
  size?: FormSizeType;
34
- description?: string;
35
+ description?: ReactElement | string;
35
36
  disabled?: boolean;
36
37
  layout?: SwitchLayoutType;
37
- tooltip?: string;
38
+ tooltip?: ReactElement | string;
38
39
  }
39
40
  export type FormInputFieldProps<TFieldValues extends FieldValues, TName extends Path<TFieldValues>> = Omit<FormFieldGroupProps<TFieldValues, TName>, 'children'> & {
40
41
  inputProps?: InputProps;
41
42
  };
43
+ export type FormTextareaFieldProps<TFieldValues extends FieldValues, TName extends Path<TFieldValues>> = Omit<FormFieldGroupProps<TFieldValues, TName>, 'children'> & {
44
+ textareaProps?: TextareaProps;
45
+ };
package/form/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export { Form, FormItem, FormLabel, FormControl, FormDescription, FormMessage, FormField, useFormField, } from './form.component';
2
2
  export { FormFieldGroup } from './components/form-field-group.component';
3
- export { FormSwitchField } from './components/form-switch-field.component';
4
3
  export { FormInputField } from './components/form-input-field.component';
4
+ export { FormTextareaField } from './components/form-textarea-field.component';
5
+ export { FormSwitchField } from './components/form-switch-field.component';
package/form/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  export { Form, FormItem, FormLabel, FormControl, FormDescription, FormMessage, FormField, useFormField } from './form.component';
2
2
  export { FormFieldGroup } from './components/form-field-group.component';
3
- export { FormSwitchField } from './components/form-switch-field.component';
4
- export { FormInputField } from './components/form-input-field.component';
3
+ export { FormInputField } from './components/form-input-field.component';
4
+ export { FormTextareaField } from './components/form-textarea-field.component';
5
+ export { FormSwitchField } from './components/form-switch-field.component';
@@ -4,7 +4,7 @@ import { ComponentProps, ReactElement } from 'react';
4
4
  export interface LabelProps extends Omit<ComponentProps<typeof LabelPrimitive.Root>, 'size'> {
5
5
  size?: FormSizeType;
6
6
  icon?: ReactElement;
7
- tooltip?: string;
7
+ tooltip?: ReactElement | string;
8
8
  }
9
9
  export interface LabelIconProps extends ComponentProps<'span'>, Pick<LabelProps, 'size' | 'tooltip'> {
10
10
  icon?: ReactElement;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scaleflex/ui-tw",
3
- "version": "0.0.8",
3
+ "version": "0.0.10",
4
4
  "author": "scaleflex",
5
5
  "repository": "github:scaleflex/ui",
6
6
  "homepage": "https://github.com/scaleflex/ui/blob/master/README.md",
@@ -17,7 +17,7 @@
17
17
  "@radix-ui/react-slot": "^1.1.2",
18
18
  "@radix-ui/react-switch": "^1.0.1",
19
19
  "@radix-ui/react-tooltip": "^1.2.6",
20
- "@scaleflex/icons-tw": "^0.0.8",
20
+ "@scaleflex/icons-tw": "^0.0.10",
21
21
  "@types/lodash.merge": "^4.6.9",
22
22
  "class-variance-authority": "^0.7.1",
23
23
  "lodash.merge": "^4.6.2",
@@ -0,0 +1,2 @@
1
+ export { Textarea, textareaVariants } from './textarea.component';
2
+ export type { TextareaProps } from './textarea.types';
@@ -0,0 +1 @@
1
+ export { Textarea, textareaVariants } from './textarea.component';
@@ -0,0 +1,7 @@
1
+ import { TextareaProps } from '@scaleflex/ui-tw/textarea/textarea.types';
2
+ import React from 'react';
3
+ declare const textareaVariants: (props?: ({
4
+ size?: "sm" | "md" | "lg" | null | undefined;
5
+ } & import("class-variance-authority/dist/types").ClassProp) | undefined) => string;
6
+ declare function Textarea({ className, size, disabled, readOnly, ...props }: TextareaProps): React.JSX.Element;
7
+ export { Textarea, textareaVariants };
@@ -0,0 +1,36 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
+ var _excluded = ["className", "size", "disabled", "readOnly"];
4
+ import { textareaSizeOptions } from '@scaleflex/ui-tw/textarea/textarea.constants';
5
+ import { FormSize } from '@scaleflex/ui-tw/types/form-size';
6
+ import { cn } from '@scaleflex/ui-tw/utils/cn';
7
+ import { cva } from 'class-variance-authority';
8
+ import React from 'react';
9
+ var textareaVariants = cva('', {
10
+ variants: {
11
+ size: textareaSizeOptions
12
+ },
13
+ defaultVariants: {
14
+ size: FormSize.Md
15
+ }
16
+ });
17
+ function Textarea(_ref) {
18
+ var className = _ref.className,
19
+ _ref$size = _ref.size,
20
+ size = _ref$size === void 0 ? FormSize.Md : _ref$size,
21
+ _ref$disabled = _ref.disabled,
22
+ disabled = _ref$disabled === void 0 ? false : _ref$disabled,
23
+ _ref$readOnly = _ref.readOnly,
24
+ readOnly = _ref$readOnly === void 0 ? false : _ref$readOnly,
25
+ props = _objectWithoutProperties(_ref, _excluded);
26
+ return /*#__PURE__*/React.createElement("textarea", _extends({
27
+ "data-slot": "textarea",
28
+ disabled: disabled,
29
+ readOnly: readOnly,
30
+ className: cn('field-sizing-content', 'border-input text-foreground bg-background flex w-full rounded-md border shadow-xs transition-[color,box-shadow] outline-none', 'placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50', 'focus-visible:ring-ring ring-offset-background focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none', 'read-only:bg-secondary read-only:text-foreground read-only:cursor-default', 'aria-invalid:ring-destructive/20 aria-invalid:border-destructive', 'group-data-[highlight=true]:border-warning group-data-[highlight=true]:focus-visible:ring-warning/20', textareaVariants({
31
+ size: size,
32
+ className: className
33
+ }))
34
+ }, props));
35
+ }
36
+ export { Textarea, textareaVariants };
@@ -0,0 +1,5 @@
1
+ export declare const textareaSizeOptions: {
2
+ readonly sm: "py-2 px-3 text-sm min-h-14 max-h-44";
3
+ readonly md: "py-3 px-4 text-base min-h-16 max-h-48";
4
+ readonly lg: "py-3 px-4 text-lg min-h-20 max-h-60";
5
+ };
@@ -0,0 +1,3 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+ import { FormSize } from '@scaleflex/ui-tw/types/form-size';
3
+ export var textareaSizeOptions = _defineProperty(_defineProperty(_defineProperty({}, FormSize.Sm, 'py-2 px-3 text-sm min-h-14 max-h-44'), FormSize.Md, 'py-3 px-4 text-base min-h-16 max-h-48'), FormSize.Lg, 'py-3 px-4 text-lg min-h-20 max-h-60');
@@ -0,0 +1,6 @@
1
+ import { FormSizeType } from '@scaleflex/ui-tw/types/form-size';
2
+ import { ComponentProps } from 'react';
3
+ export interface TextareaProps extends Omit<ComponentProps<'textarea'>, 'size'> {
4
+ size?: FormSizeType;
5
+ 'aria-invalid'?: boolean;
6
+ }
@@ -0,0 +1 @@
1
+ export {};