@scaleflex/ui-tw 0.0.5 → 0.0.7

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.
Files changed (60) hide show
  1. package/button/button.component.js +3 -7
  2. package/button/button.constants.d.ts +63 -0
  3. package/button/button.constants.js +26 -0
  4. package/button/button.types.d.ts +10 -21
  5. package/button/button.types.js +1 -19
  6. package/button/button.utils.js +1 -1
  7. package/button/components/end-icon.d.ts +3 -6
  8. package/button/components/end-icon.js +3 -6
  9. package/button/components/start-icon.d.ts +3 -8
  10. package/button/components/start-icon.js +3 -7
  11. package/button/index.d.ts +1 -1
  12. package/button/index.js +1 -1
  13. package/form/components/form-field-group.component.d.ts +4 -18
  14. package/form/components/form-field-group.component.js +12 -2
  15. package/form/components/form-field-input.component.d.ts +5 -0
  16. package/form/components/form-field-input.component.js +16 -0
  17. package/form/components/form-switch-field.component.d.ts +5 -0
  18. package/form/components/form-switch-field.component.js +64 -0
  19. package/form/form.component.d.ts +4 -1
  20. package/form/form.component.js +12 -7
  21. package/form/form.constants.d.ts +24 -0
  22. package/form/form.constants.js +14 -0
  23. package/form/form.types.d.ts +40 -6
  24. package/form/form.types.js +1 -5
  25. package/form/index.d.ts +1 -0
  26. package/form/index.js +2 -1
  27. package/input/index.d.ts +1 -1
  28. package/input/index.js +1 -1
  29. package/input/input.component.d.ts +1 -1
  30. package/input/input.component.js +3 -5
  31. package/input/input.constants.d.ts +10 -0
  32. package/input/input.constants.js +8 -0
  33. package/input/input.types.d.ts +2 -13
  34. package/input/input.types.js +1 -10
  35. package/label/components/info-outline-icon.d.ts +2 -2
  36. package/label/components/info-outline-icon.js +2 -2
  37. package/label/components/label-icon.d.ts +2 -5
  38. package/label/components/label-icon.js +2 -4
  39. package/label/label.component.js +12 -12
  40. package/label/label.constants.d.ts +10 -0
  41. package/label/label.constants.js +4 -0
  42. package/label/label.types.d.ts +5 -8
  43. package/label/label.types.js +1 -5
  44. package/label/label.utils.d.ts +2 -2
  45. package/label/label.utils.js +4 -4
  46. package/package.json +3 -2
  47. package/switch/index.d.ts +1 -0
  48. package/switch/index.js +1 -0
  49. package/switch/switch.component.d.ts +4 -0
  50. package/switch/switch.component.js +43 -0
  51. package/switch/switch.constants.d.ts +10 -0
  52. package/switch/switch.constants.js +4 -0
  53. package/switch/switch.types.d.ts +6 -0
  54. package/switch/switch.types.js +1 -0
  55. package/types/form-size.d.ts +7 -0
  56. package/types/form-size.js +5 -0
  57. package/types/values.d.ts +1 -1
  58. package/types/values.js +1 -0
  59. package/button/button.const.d.ts +0 -13
  60. package/button/button.const.js +0 -4
@@ -1,19 +1,15 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
4
3
  var _excluded = ["className", "children", "size", "startIcon", "endIcon", "variant", "loading", "asChild", "disabled"];
5
- var _buttonVariantOptions;
6
4
  import { Slot } from '@radix-ui/react-slot';
7
5
  import SpinnerIcon from '@scaleflex/icons-tw/spinner';
8
- import EndIcon from '@scaleflex/ui-tw/button/components/end-icon';
9
- import StartIcon, { startIconVariants } from '@scaleflex/ui-tw/button/components/start-icon';
6
+ import { ButtonSize, ButtonVariant, buttonSizeOptions, buttonVariantOptions } from '@scaleflex/ui-tw/button/button.constants';
7
+ import { EndIcon } from '@scaleflex/ui-tw/button/components/end-icon';
8
+ import { StartIcon, startIconVariants } from '@scaleflex/ui-tw/button/components/start-icon';
10
9
  import { cn } from '@scaleflex/ui-tw/utils/cn';
11
10
  import { cva } from 'class-variance-authority';
12
11
  import React from 'react';
13
- import { ButtonSize, ButtonVariant } from './button.types';
14
12
  import { getIconSizeInRem } from './button.utils';
15
- var buttonVariantOptions = (_buttonVariantOptions = {}, _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_buttonVariantOptions, ButtonVariant.Primary, 'bg-primary text-primary-foreground shadow-xs hover:bg-primary/80'), ButtonVariant.Secondary, 'border bg-background shadow-xs text-primary border-primary hover:bg-accent hover:border-primary/80'), ButtonVariant.Outline, 'border bg-background text-secondary-foreground shadow-xs border-input hover:bg-secondary hover:border-input/80'), ButtonVariant.LinkPrimary, 'text-primary hover:text-primary/80'), ButtonVariant.LinkSecondary, 'text-secondary-foreground hover:text-secondary-foreground/80'), ButtonVariant.LinkBasicPrimary, 'text-primary font-normal hover:text-primary/80'), ButtonVariant.LinkBasicSecondary, 'text-secondary-foreground font-normal hover:text-secondary-foreground/80'), ButtonVariant.LinkError, 'text-destructive hover:text-destructive/80'), ButtonVariant.LinkWarning, 'text-warning hover:text-warning/80'), ButtonVariant.Error, 'bg-destructive text-primary-foreground shadow-xs hover:bg-destructive/80'), _defineProperty(_buttonVariantOptions, ButtonVariant.Warning, 'bg-warning text-primary-foreground shadow-xs hover:bg-warning/80'));
16
- var buttonSizeOptions = _defineProperty(_defineProperty(_defineProperty(_defineProperty({}, ButtonSize.Xs, 'h-6 px-2.5 py-1.5 text-xs'), ButtonSize.Sm, 'h-8 px-3 py-2 text-sm'), ButtonSize.Md, 'h-10 px-4 py-2.5 text-base'), ButtonSize.Lg, 'h-12 px-6 py-3.5 text-lg');
17
13
  var buttonVariants = cva('', {
18
14
  variants: {
19
15
  variant: buttonVariantOptions,
@@ -0,0 +1,63 @@
1
+ export declare const ButtonSize: {
2
+ readonly Xs: "xs";
3
+ readonly Sm: "sm";
4
+ readonly Md: "md";
5
+ readonly Lg: "lg";
6
+ };
7
+ export declare const buttonSizeOptions: {
8
+ readonly xs: "h-6 px-2.5 py-1.5 text-xs";
9
+ readonly sm: "h-8 px-3 py-2 text-sm";
10
+ readonly md: "h-10 px-4 py-2.5 text-base";
11
+ readonly lg: "h-12 px-6 py-3.5 text-lg";
12
+ };
13
+ export declare const buttonEndIconSizes: {
14
+ readonly xs: "ml-1.5";
15
+ readonly sm: "ml-1.5";
16
+ readonly md: "ml-2";
17
+ readonly lg: "ml-2";
18
+ };
19
+ export declare const buttonStartIconSizes: {
20
+ readonly xs: "mr-1.5";
21
+ readonly sm: "mr-1.5";
22
+ readonly md: "mr-2";
23
+ readonly lg: "mr-2";
24
+ };
25
+ export declare const ButtonVariant: {
26
+ readonly Primary: "primary";
27
+ readonly Secondary: "secondary";
28
+ readonly Outline: "outline";
29
+ readonly LinkPrimary: "link-primary";
30
+ readonly LinkSecondary: "link-secondary";
31
+ readonly LinkBasicPrimary: "link-basic-primary";
32
+ readonly LinkBasicSecondary: "link-basic-secondary";
33
+ readonly LinkError: "link-error";
34
+ readonly LinkWarning: "link-warning";
35
+ readonly Error: "error-primary";
36
+ readonly Warning: "warning-primary";
37
+ };
38
+ export declare const iconVariantOptions: {
39
+ readonly primary: "";
40
+ readonly secondary: "";
41
+ readonly outline: "text-muted-foreground group-hover/button:text-muted-foreground/80";
42
+ readonly "link-primary": "";
43
+ readonly "link-secondary": "text-muted-foreground group-hover/button:text-muted-foreground/80";
44
+ readonly "link-basic-primary": "";
45
+ readonly "link-basic-secondary": "text-muted-foreground group-hover/button:text-muted-foreground/80";
46
+ readonly "link-error": "";
47
+ readonly "link-warning": "";
48
+ readonly "error-primary": "";
49
+ readonly "warning-primary": "";
50
+ };
51
+ export declare const buttonVariantOptions: {
52
+ readonly primary: "bg-primary text-primary-foreground shadow-xs hover:bg-primary/80";
53
+ readonly secondary: "border bg-background shadow-xs text-primary border-primary hover:bg-accent hover:border-primary/80";
54
+ readonly outline: "border bg-background text-secondary-foreground shadow-xs border-input hover:bg-secondary hover:border-input/80";
55
+ readonly "link-primary": "text-primary hover:text-primary/80";
56
+ readonly "link-secondary": "text-secondary-foreground hover:text-secondary-foreground/80";
57
+ readonly "link-basic-primary": "text-primary font-normal hover:text-primary/80";
58
+ readonly "link-basic-secondary": "text-secondary-foreground font-normal hover:text-secondary-foreground/80";
59
+ readonly "link-error": "text-destructive hover:text-destructive/80";
60
+ readonly "link-warning": "text-warning hover:text-warning/80";
61
+ readonly "error-primary": "bg-destructive text-primary-foreground shadow-xs hover:bg-destructive/80";
62
+ readonly "warning-primary": "bg-warning text-primary-foreground shadow-xs hover:bg-warning/80";
63
+ };
@@ -0,0 +1,26 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+ var _iconVariantOptions, _buttonVariantOptions;
3
+ export var ButtonSize = {
4
+ Xs: 'xs',
5
+ Sm: 'sm',
6
+ Md: 'md',
7
+ Lg: 'lg'
8
+ };
9
+ export var buttonSizeOptions = _defineProperty(_defineProperty(_defineProperty(_defineProperty({}, ButtonSize.Xs, 'h-6 px-2.5 py-1.5 text-xs'), ButtonSize.Sm, 'h-8 px-3 py-2 text-sm'), ButtonSize.Md, 'h-10 px-4 py-2.5 text-base'), ButtonSize.Lg, 'h-12 px-6 py-3.5 text-lg');
10
+ export var buttonEndIconSizes = _defineProperty(_defineProperty(_defineProperty(_defineProperty({}, ButtonSize.Xs, 'ml-1.5'), ButtonSize.Sm, 'ml-1.5'), ButtonSize.Md, 'ml-2'), ButtonSize.Lg, 'ml-2');
11
+ export var buttonStartIconSizes = _defineProperty(_defineProperty(_defineProperty(_defineProperty({}, ButtonSize.Xs, 'mr-1.5'), ButtonSize.Sm, 'mr-1.5'), ButtonSize.Md, 'mr-2'), ButtonSize.Lg, 'mr-2');
12
+ export var ButtonVariant = {
13
+ Primary: 'primary',
14
+ Secondary: 'secondary',
15
+ Outline: 'outline',
16
+ LinkPrimary: 'link-primary',
17
+ LinkSecondary: 'link-secondary',
18
+ LinkBasicPrimary: 'link-basic-primary',
19
+ LinkBasicSecondary: 'link-basic-secondary',
20
+ LinkError: 'link-error',
21
+ LinkWarning: 'link-warning',
22
+ Error: 'error-primary',
23
+ Warning: 'warning-primary'
24
+ };
25
+ export var iconVariantOptions = (_iconVariantOptions = {}, _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_iconVariantOptions, ButtonVariant.Primary, ''), ButtonVariant.Secondary, ''), ButtonVariant.Outline, 'text-muted-foreground group-hover/button:text-muted-foreground/80'), ButtonVariant.LinkPrimary, ''), ButtonVariant.LinkSecondary, 'text-muted-foreground group-hover/button:text-muted-foreground/80'), ButtonVariant.LinkBasicPrimary, ''), ButtonVariant.LinkBasicSecondary, 'text-muted-foreground group-hover/button:text-muted-foreground/80'), ButtonVariant.LinkError, ''), ButtonVariant.LinkWarning, ''), ButtonVariant.Error, ''), _defineProperty(_iconVariantOptions, ButtonVariant.Warning, ''));
26
+ export var buttonVariantOptions = (_buttonVariantOptions = {}, _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_buttonVariantOptions, ButtonVariant.Primary, 'bg-primary text-primary-foreground shadow-xs hover:bg-primary/80'), ButtonVariant.Secondary, 'border bg-background shadow-xs text-primary border-primary hover:bg-accent hover:border-primary/80'), ButtonVariant.Outline, 'border bg-background text-secondary-foreground shadow-xs border-input hover:bg-secondary hover:border-input/80'), ButtonVariant.LinkPrimary, 'text-primary hover:text-primary/80'), ButtonVariant.LinkSecondary, 'text-secondary-foreground hover:text-secondary-foreground/80'), ButtonVariant.LinkBasicPrimary, 'text-primary font-normal hover:text-primary/80'), ButtonVariant.LinkBasicSecondary, 'text-secondary-foreground font-normal hover:text-secondary-foreground/80'), ButtonVariant.LinkError, 'text-destructive hover:text-destructive/80'), ButtonVariant.LinkWarning, 'text-warning hover:text-warning/80'), ButtonVariant.Error, 'bg-destructive text-primary-foreground shadow-xs hover:bg-destructive/80'), _defineProperty(_buttonVariantOptions, ButtonVariant.Warning, 'bg-warning text-primary-foreground shadow-xs hover:bg-warning/80'));
@@ -1,19 +1,9 @@
1
1
  import { buttonVariants } from '@scaleflex/ui-tw/button/button.component';
2
+ import { ButtonSize, ButtonVariant } from '@scaleflex/ui-tw/button/button.constants';
2
3
  import type { VariantProps } from 'class-variance-authority';
3
4
  import { ComponentProps, ReactElement } from 'react';
4
- export declare const ButtonVariant: {
5
- readonly Primary: "primary";
6
- readonly Secondary: "secondary";
7
- readonly Outline: "outline";
8
- readonly LinkPrimary: "link-primary";
9
- readonly LinkSecondary: "link-secondary";
10
- readonly LinkBasicPrimary: "link-basic-primary";
11
- readonly LinkBasicSecondary: "link-basic-secondary";
12
- readonly LinkError: "link-error";
13
- readonly LinkWarning: "link-warning";
14
- readonly Error: "error-primary";
15
- readonly Warning: "warning-primary";
16
- };
5
+ export type ButtonSizeType = (typeof ButtonSize)[keyof typeof ButtonSize];
6
+ export type ButtonVariantType = (typeof ButtonVariant)[keyof typeof ButtonVariant];
17
7
  export interface ButtonProps extends ComponentProps<'button'>, VariantProps<typeof buttonVariants> {
18
8
  asChild?: boolean;
19
9
  startIcon?: ReactElement;
@@ -21,11 +11,10 @@ export interface ButtonProps extends ComponentProps<'button'>, VariantProps<type
21
11
  loading?: boolean;
22
12
  disabled?: boolean;
23
13
  }
24
- export declare const ButtonSize: {
25
- readonly Xs: "xs";
26
- readonly Sm: "sm";
27
- readonly Md: "md";
28
- readonly Lg: "lg";
29
- };
30
- export type ButtonSizeType = (typeof ButtonSize)[keyof typeof ButtonSize];
31
- export type ButtonVariantType = (typeof ButtonVariant)[keyof typeof ButtonVariant];
14
+ export interface EndIconProps extends ComponentProps<'span'>, Pick<ButtonProps, 'size' | 'variant'> {
15
+ icon?: ReactElement;
16
+ }
17
+ export interface StartIconProps extends ComponentProps<'span'>, Pick<ButtonProps, 'size' | 'variant'> {
18
+ icon?: ReactElement;
19
+ loading?: boolean;
20
+ }
@@ -1,19 +1 @@
1
- export var ButtonVariant = {
2
- Primary: 'primary',
3
- Secondary: 'secondary',
4
- Outline: 'outline',
5
- LinkPrimary: 'link-primary',
6
- LinkSecondary: 'link-secondary',
7
- LinkBasicPrimary: 'link-basic-primary',
8
- LinkBasicSecondary: 'link-basic-secondary',
9
- LinkError: 'link-error',
10
- LinkWarning: 'link-warning',
11
- Error: 'error-primary',
12
- Warning: 'warning-primary'
13
- };
14
- export var ButtonSize = {
15
- Xs: 'xs',
16
- Sm: 'sm',
17
- Md: 'md',
18
- Lg: 'lg'
19
- };
1
+ export {};
@@ -1,4 +1,4 @@
1
- import { ButtonSize } from '@scaleflex/ui-tw/button/button.types';
1
+ import { ButtonSize } from '@scaleflex/ui-tw/button/button.constants';
2
2
  export var getIconSizeInRem = function getIconSizeInRem(sizeName) {
3
3
  switch (sizeName) {
4
4
  case ButtonSize.Lg:
@@ -1,7 +1,4 @@
1
- import { type ButtonProps } from '@scaleflex/ui-tw/button';
2
- import React, { ComponentProps, ReactElement } from 'react';
3
- interface EndIconProps extends ComponentProps<'span'>, Pick<ButtonProps, 'size' | 'variant'> {
4
- icon?: ReactElement;
5
- }
1
+ import { EndIconProps } from '@scaleflex/ui-tw/button/button.types';
2
+ import React from 'react';
6
3
  declare const EndIcon: (props: EndIconProps) => React.JSX.Element | null;
7
- export default EndIcon;
4
+ export { EndIcon };
@@ -1,17 +1,14 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
4
3
  var _excluded = ["size", "icon", "variant"];
5
- import { ButtonSize } from '@scaleflex/ui-tw/button';
6
- import { iconVariantOptions } from '@scaleflex/ui-tw/button/button.const';
4
+ import { buttonEndIconSizes, iconVariantOptions } from '@scaleflex/ui-tw/button/button.constants';
7
5
  import { getIconSizeInRem } from '@scaleflex/ui-tw/button/button.utils';
8
6
  import { cva } from 'class-variance-authority';
9
7
  import React, { cloneElement, useMemo } from 'react';
10
- var endIconSizes = _defineProperty(_defineProperty(_defineProperty(_defineProperty({}, ButtonSize.Xs, 'ml-1.5'), ButtonSize.Sm, 'ml-1.5'), ButtonSize.Md, 'ml-2'), ButtonSize.Lg, 'ml-2');
11
8
  var endIconVariants = cva('', {
12
9
  variants: {
13
10
  variant: iconVariantOptions,
14
- size: endIconSizes
11
+ size: buttonEndIconSizes
15
12
  }
16
13
  });
17
14
  var EndIcon = function EndIcon(props) {
@@ -36,4 +33,4 @@ var EndIcon = function EndIcon(props) {
36
33
  }
37
34
  }));
38
35
  };
39
- export default EndIcon;
36
+ export { EndIcon };
@@ -1,13 +1,8 @@
1
- import { type ButtonProps } from '@scaleflex/ui-tw/button';
2
- import React, { ComponentProps, ReactElement } from 'react';
1
+ import { StartIconProps } from '@scaleflex/ui-tw/button/button.types';
2
+ import React from 'react';
3
3
  declare const startIconVariants: (props?: ({
4
4
  variant?: "primary" | "secondary" | "outline" | "link-primary" | "link-secondary" | "link-basic-primary" | "link-basic-secondary" | "link-error" | "link-warning" | "error-primary" | "warning-primary" | null | undefined;
5
5
  size?: "xs" | "sm" | "md" | "lg" | null | undefined;
6
6
  } & import("class-variance-authority/dist/types").ClassProp) | undefined) => string;
7
- interface StartIconProps extends ComponentProps<'span'>, Pick<ButtonProps, 'size' | 'variant'> {
8
- icon?: ReactElement;
9
- loading?: boolean;
10
- }
11
7
  declare const StartIcon: (props: StartIconProps) => React.JSX.Element | null;
12
- export { startIconVariants };
13
- export default StartIcon;
8
+ export { StartIcon, startIconVariants };
@@ -1,18 +1,15 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
4
3
  var _excluded = ["size", "variant", "icon", "loading"];
5
4
  import SpinnerIcon from '@scaleflex/icons-tw/spinner';
6
- import { ButtonSize } from '@scaleflex/ui-tw/button';
7
- import { iconVariantOptions } from '@scaleflex/ui-tw/button/button.const';
5
+ import { buttonStartIconSizes, iconVariantOptions } from '@scaleflex/ui-tw/button/button.constants';
8
6
  import { getIconSizeInRem } from '@scaleflex/ui-tw/button/button.utils';
9
7
  import { cva } from 'class-variance-authority';
10
8
  import React, { cloneElement, useMemo } from 'react';
11
- var startIconSizes = _defineProperty(_defineProperty(_defineProperty(_defineProperty({}, ButtonSize.Xs, 'mr-1.5'), ButtonSize.Sm, 'mr-1.5'), ButtonSize.Md, 'mr-2'), ButtonSize.Lg, 'mr-2');
12
9
  var startIconVariants = cva('', {
13
10
  variants: {
14
11
  variant: iconVariantOptions,
15
- size: startIconSizes
12
+ size: buttonStartIconSizes
16
13
  }
17
14
  });
18
15
  var StartIcon = function StartIcon(props) {
@@ -49,5 +46,4 @@ var StartIcon = function StartIcon(props) {
49
46
  })
50
47
  })));
51
48
  };
52
- export { startIconVariants };
53
- export default StartIcon;
49
+ export { StartIcon, startIconVariants };
package/button/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  export { Button, buttonVariants } from './button.component';
2
2
  export type { ButtonProps } from './button.types';
3
- export { ButtonVariant, ButtonSize } from './button.types';
3
+ export { ButtonVariant, ButtonSize } from './button.constants';
package/button/index.js CHANGED
@@ -1,2 +1,2 @@
1
1
  export { Button, buttonVariants } from './button.component';
2
- export { ButtonVariant, ButtonSize } from './button.types';
2
+ export { ButtonVariant, ButtonSize } from './button.constants';
@@ -1,19 +1,5 @@
1
- import { InputSizeType } from '@scaleflex/ui-tw/input/input.types';
2
- import React, { ReactNode } from 'react';
3
- import { ControllerRenderProps, FieldValues, Path, UseControllerProps } from 'react-hook-form';
4
- export interface FormFieldArgs {
5
- size?: InputSizeType;
6
- readOnly?: boolean;
7
- disabled?: boolean;
8
- }
9
- export interface FormFieldGroupProps<TFieldValues extends FieldValues, TName extends Path<TFieldValues>> extends UseControllerProps<TFieldValues, TName> {
10
- label?: string;
11
- description?: string;
12
- tooltip?: string;
13
- size?: InputSizeType;
14
- readOnly?: boolean;
15
- highlight?: boolean;
16
- children: (field: ControllerRenderProps<TFieldValues, TName>, args?: FormFieldArgs) => ReactNode;
17
- }
18
- declare function FormFieldGroup<TFieldValues extends FieldValues, TName extends Path<TFieldValues>>({ control, name, label, description, size, readOnly, disabled, tooltip, highlight, children, }: FormFieldGroupProps<TFieldValues, TName>): React.JSX.Element;
1
+ import { FormFieldGroupProps } from '@scaleflex/ui-tw/form/form.types';
2
+ import React from 'react';
3
+ import { FieldValues, Path } from 'react-hook-form';
4
+ declare function FormFieldGroup<TFieldValues extends FieldValues, TName extends Path<TFieldValues>>({ control, name, label, description, size, readOnly, disabled, tooltip, highlight, horizontal, horizontalLabelWidth, children, }: FormFieldGroupProps<TFieldValues, TName>): React.JSX.Element;
19
5
  export { FormFieldGroup };
@@ -1,4 +1,6 @@
1
1
  import { FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage } from '@scaleflex/ui-tw/form';
2
+ import { labelHeightVariants } from '@scaleflex/ui-tw/form/form.constants';
3
+ import { cn } from '@scaleflex/ui-tw/utils/cn';
2
4
  import React from 'react';
3
5
  function FormFieldGroup(_ref) {
4
6
  var control = _ref.control,
@@ -13,6 +15,9 @@ function FormFieldGroup(_ref) {
13
15
  disabled = _ref$disabled === void 0 ? false : _ref$disabled,
14
16
  tooltip = _ref.tooltip,
15
17
  highlight = _ref.highlight,
18
+ _ref$horizontal = _ref.horizontal,
19
+ horizontal = _ref$horizontal === void 0 ? false : _ref$horizontal,
20
+ horizontalLabelWidth = _ref.horizontalLabelWidth,
16
21
  children = _ref.children;
17
22
  return /*#__PURE__*/React.createElement(FormField, {
18
23
  control: control,
@@ -21,12 +26,17 @@ function FormFieldGroup(_ref) {
21
26
  var field = _ref2.field;
22
27
  return /*#__PURE__*/React.createElement(FormItem, {
23
28
  className: "group",
29
+ horizontal: horizontal,
30
+ firstColumnWidth: horizontalLabelWidth,
24
31
  "data-disabled": disabled,
25
32
  "data-highlight": highlight
26
33
  }, label && /*#__PURE__*/React.createElement(FormLabel, {
34
+ className: cn(horizontal && 'self-start', horizontal && labelHeightVariants[size]),
27
35
  size: size,
28
36
  tooltip: tooltip
29
- }, label), /*#__PURE__*/React.createElement(FormControl, null, children(field, {
37
+ }, label), /*#__PURE__*/React.createElement("div", {
38
+ className: "grid gap-1.5"
39
+ }, /*#__PURE__*/React.createElement(FormControl, null, children(field, {
30
40
  size: size,
31
41
  readOnly: readOnly,
32
42
  disabled: disabled
@@ -34,7 +44,7 @@ function FormFieldGroup(_ref) {
34
44
  size: size
35
45
  }, description), /*#__PURE__*/React.createElement(FormMessage, {
36
46
  size: size
37
- }));
47
+ })));
38
48
  }
39
49
  });
40
50
  }
@@ -0,0 +1,5 @@
1
+ import { FormInputFieldProps } from '@scaleflex/ui-tw/form/form.types';
2
+ import React from 'react';
3
+ import { FieldValues, Path } from 'react-hook-form';
4
+ declare function FormInputField<TFieldValues extends FieldValues, TName extends Path<TFieldValues>>({ inputProps, ...rest }: FormInputFieldProps<TFieldValues, TName>): React.JSX.Element;
5
+ export { FormInputField };
@@ -0,0 +1,16 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
+ var _excluded = ["inputProps"];
4
+ import { FormFieldGroup } from '@scaleflex/ui-tw/form';
5
+ import { Input } from '@scaleflex/ui-tw/input';
6
+ import React from 'react';
7
+ function FormInputField(_ref) {
8
+ var inputProps = _ref.inputProps,
9
+ rest = _objectWithoutProperties(_ref, _excluded);
10
+ return /*#__PURE__*/React.createElement(FormFieldGroup, rest, function (field, args) {
11
+ return /*#__PURE__*/React.createElement(Input, _extends({
12
+ placeholder: inputProps === null || inputProps === void 0 ? void 0 : inputProps.placeholder
13
+ }, args, inputProps, field));
14
+ });
15
+ }
16
+ export { FormInputField };
@@ -0,0 +1,5 @@
1
+ import { FormSwitchFieldProps } from '@scaleflex/ui-tw/form/form.types';
2
+ import React from 'react';
3
+ import { FieldValues, Path } from 'react-hook-form';
4
+ declare function FormSwitchField<TFieldValues extends FieldValues, TName extends Path<TFieldValues>>({ control, name, label, description, disabled, tooltip, size, layout, }: FormSwitchFieldProps<TFieldValues, TName>): React.JSX.Element;
5
+ export { FormSwitchField };
@@ -0,0 +1,64 @@
1
+ import { FormControl, FormDescription, FormField, FormItem, FormMessage } from '@scaleflex/ui-tw/form';
2
+ import { SwitchLayout, formSwitchFieldSizeOptions } from '@scaleflex/ui-tw/form/form.constants';
3
+ import { Label } from '@scaleflex/ui-tw/label';
4
+ import { Switch } from '@scaleflex/ui-tw/switch';
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 formSwitchFieldVariants = cva('', {
10
+ variants: {
11
+ size: formSwitchFieldSizeOptions
12
+ },
13
+ defaultVariants: {
14
+ size: FormSize.Md
15
+ }
16
+ });
17
+ function FormSwitchField(_ref) {
18
+ var control = _ref.control,
19
+ name = _ref.name,
20
+ label = _ref.label,
21
+ description = _ref.description,
22
+ disabled = _ref.disabled,
23
+ tooltip = _ref.tooltip,
24
+ _ref$size = _ref.size,
25
+ size = _ref$size === void 0 ? FormSize.Md : _ref$size,
26
+ _ref$layout = _ref.layout,
27
+ layout = _ref$layout === void 0 ? SwitchLayout.Inline : _ref$layout;
28
+ var isInlineLayout = layout === SwitchLayout.Inline;
29
+ return /*#__PURE__*/React.createElement(FormField, {
30
+ control: control,
31
+ name: name,
32
+ render: function render(_ref2) {
33
+ var field = _ref2.field;
34
+ return /*#__PURE__*/React.createElement(FormItem, null, /*#__PURE__*/React.createElement("div", {
35
+ className: cn('flex items-center', isInlineLayout ? formSwitchFieldVariants({
36
+ size: size
37
+ }) : 'w-full justify-between gap-2')
38
+ }, isInlineLayout ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(FormControl, null, /*#__PURE__*/React.createElement(Switch, {
39
+ id: field.name,
40
+ checked: field.value,
41
+ onCheckedChange: field.onChange,
42
+ disabled: disabled,
43
+ size: size
44
+ })), /*#__PURE__*/React.createElement(Label, {
45
+ htmlFor: field.name,
46
+ tooltip: tooltip,
47
+ size: size
48
+ }, label)) : /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Label, {
49
+ htmlFor: field.name,
50
+ tooltip: tooltip,
51
+ size: size
52
+ }, label), /*#__PURE__*/React.createElement(FormControl, null, /*#__PURE__*/React.createElement(Switch, {
53
+ id: field.name,
54
+ checked: field.value,
55
+ onCheckedChange: field.onChange,
56
+ disabled: disabled,
57
+ size: size
58
+ })))), description && /*#__PURE__*/React.createElement(FormDescription, {
59
+ size: size
60
+ }, description), /*#__PURE__*/React.createElement(FormMessage, null));
61
+ }
62
+ });
63
+ }
64
+ export { FormSwitchField };
@@ -18,7 +18,10 @@ declare const useFormField: () => {
18
18
  formDescriptionId: string;
19
19
  formMessageId: string;
20
20
  };
21
- declare function FormItem({ className, ...props }: ComponentProps<'div'>): React.JSX.Element;
21
+ declare function FormItem({ className, horizontal, firstColumnWidth, ...props }: ComponentProps<'div'> & {
22
+ horizontal?: boolean;
23
+ firstColumnWidth?: string;
24
+ }): React.JSX.Element;
22
25
  declare function FormLabel({ className, ...props }: LabelProps): React.JSX.Element;
23
26
  declare function FormControl({ ...props }: ComponentProps<typeof Slot>): React.JSX.Element;
24
27
  declare function FormDescription({ className, size, ...props }: ComponentProps<'p'> & {
@@ -2,14 +2,14 @@ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProper
2
2
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
3
  import _objectDestructuringEmpty from "@babel/runtime/helpers/objectDestructuringEmpty";
4
4
  import _extends from "@babel/runtime/helpers/extends";
5
- var _excluded = ["className"],
5
+ var _excluded = ["className", "horizontal", "firstColumnWidth"],
6
6
  _excluded2 = ["className"],
7
7
  _excluded3 = ["className", "size"],
8
8
  _excluded4 = ["className", "size"];
9
9
  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; }
10
10
  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; }
11
11
  import { Slot } from '@radix-ui/react-slot';
12
- import { FormMessageSize } from '@scaleflex/ui-tw/form/form.types';
12
+ import { FormMessageSize, formMessageSizeOptions } from '@scaleflex/ui-tw/form/form.constants';
13
13
  import { Label } from '@scaleflex/ui-tw/label';
14
14
  import { cn } from '@scaleflex/ui-tw/utils/cn';
15
15
  import * as React from 'react';
@@ -49,6 +49,9 @@ var useFormField = function useFormField() {
49
49
  var FormItemContext = /*#__PURE__*/createContext({});
50
50
  function FormItem(_ref2) {
51
51
  var className = _ref2.className,
52
+ horizontal = _ref2.horizontal,
53
+ _ref2$firstColumnWidt = _ref2.firstColumnWidth,
54
+ firstColumnWidth = _ref2$firstColumnWidt === void 0 ? '11.25rem' : _ref2$firstColumnWidt,
52
55
  props = _objectWithoutProperties(_ref2, _excluded);
53
56
  var id = useId();
54
57
  return /*#__PURE__*/React.createElement(FormItemContext.Provider, {
@@ -57,7 +60,10 @@ function FormItem(_ref2) {
57
60
  }
58
61
  }, /*#__PURE__*/React.createElement("div", _extends({
59
62
  "data-slot": "form-item",
60
- className: cn('grid gap-1.5', className)
63
+ className: cn('grid gap-1.5', horizontal && 'items-start gap-4', className),
64
+ style: horizontal ? {
65
+ gridTemplateColumns: "".concat(firstColumnWidth, " 1fr")
66
+ } : undefined
61
67
  }, props)));
62
68
  }
63
69
  function FormLabel(_ref3) {
@@ -69,7 +75,7 @@ function FormLabel(_ref3) {
69
75
  return /*#__PURE__*/React.createElement(Label, _extends({
70
76
  "data-slot": "form-label",
71
77
  "data-error": !!error,
72
- className: cn('data-[error=true]:text-destructive', className),
78
+ className: cn('truncate', 'data-[error=true]:text-destructive-foreground', className),
73
79
  htmlFor: formItemId
74
80
  }, props));
75
81
  }
@@ -87,7 +93,6 @@ function FormControl(_ref4) {
87
93
  "aria-invalid": !!error
88
94
  }, props));
89
95
  }
90
- var formMessageSizeOptions = _defineProperty(_defineProperty(_defineProperty({}, FormMessageSize.Sm, 'text-xs'), FormMessageSize.Md, 'text-xs'), FormMessageSize.Lg, 'text-sm');
91
96
  function FormDescription(_ref5) {
92
97
  var className = _ref5.className,
93
98
  _ref5$size = _ref5.size,
@@ -98,7 +103,7 @@ function FormDescription(_ref5) {
98
103
  return /*#__PURE__*/React.createElement("p", _extends({
99
104
  "data-slot": "form-description",
100
105
  id: formDescriptionId,
101
- className: cn('text-muted-foreground', 'group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50', 'group-data-[highlight=true]:text-warning', formMessageSizeOptions[size], className)
106
+ className: cn('text-muted-foreground', 'group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50', 'group-data-[highlight=true]:text-warning-foreground', formMessageSizeOptions[size], className)
102
107
  }, props));
103
108
  }
104
109
  function FormMessage(_ref6) {
@@ -117,7 +122,7 @@ function FormMessage(_ref6) {
117
122
  return /*#__PURE__*/React.createElement("p", _extends({
118
123
  "data-slot": "form-message",
119
124
  id: formMessageId,
120
- className: cn('text-destructive', 'group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50', formMessageSizeOptions[size], className)
125
+ className: cn('text-destructive-foreground', 'group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50', formMessageSizeOptions[size], className)
121
126
  }, props), body);
122
127
  }
123
128
  export { useFormField, Form, FormItem, FormLabel, FormControl, FormDescription, FormMessage, FormField };
@@ -0,0 +1,24 @@
1
+ export declare const FormMessageSize: {
2
+ readonly Sm: "sm";
3
+ readonly Md: "md";
4
+ readonly Lg: "lg";
5
+ };
6
+ export declare const labelHeightVariants: {
7
+ readonly sm: "h-8";
8
+ readonly md: "h-10";
9
+ readonly lg: "h-12";
10
+ };
11
+ export declare const SwitchLayout: {
12
+ readonly Inline: "inline";
13
+ readonly Justified: "justified";
14
+ };
15
+ export declare const formMessageSizeOptions: {
16
+ readonly sm: "text-xs";
17
+ readonly md: "text-xs";
18
+ readonly lg: "text-sm";
19
+ };
20
+ export declare const formSwitchFieldSizeOptions: {
21
+ readonly sm: "space-x-2";
22
+ readonly md: "space-x-2.5";
23
+ readonly lg: "space-x-3";
24
+ };
@@ -0,0 +1,14 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+ import { FormSize } from '@scaleflex/ui-tw/types/form-size';
3
+ export var FormMessageSize = {
4
+ Sm: 'sm',
5
+ Md: 'md',
6
+ Lg: 'lg'
7
+ };
8
+ export var labelHeightVariants = _defineProperty(_defineProperty(_defineProperty({}, FormSize.Sm, 'h-8'), FormSize.Md, 'h-10'), FormSize.Lg, 'h-12');
9
+ export var SwitchLayout = {
10
+ Inline: 'inline',
11
+ Justified: 'justified'
12
+ };
13
+ export var formMessageSizeOptions = _defineProperty(_defineProperty(_defineProperty({}, FormMessageSize.Sm, 'text-xs'), FormMessageSize.Md, 'text-xs'), FormMessageSize.Lg, 'text-sm');
14
+ export var formSwitchFieldSizeOptions = _defineProperty(_defineProperty(_defineProperty({}, FormMessageSize.Sm, 'space-x-2'), FormMessageSize.Md, 'space-x-2.5'), FormMessageSize.Lg, 'space-x-3');
@@ -1,7 +1,41 @@
1
- import type { Values } from 'packages/ui/src/types/values';
2
- export declare const FormMessageSize: {
3
- readonly Sm: "sm";
4
- readonly Md: "md";
5
- readonly Lg: "lg";
6
- };
1
+ import { FormMessageSize, SwitchLayout } from '@scaleflex/ui-tw/form/form.constants';
2
+ import { InputProps } from '@scaleflex/ui-tw/input';
3
+ import { FormSizeType } from '@scaleflex/ui-tw/types/form-size';
4
+ import type { Values } from '@scaleflex/ui-tw/types/values';
5
+ import { ReactNode } from 'react';
6
+ import { ControllerRenderProps, type FieldPath, FieldValues, Path, UseControllerProps } from 'react-hook-form';
7
7
  export type FormMessageSizeType = Values<typeof FormMessageSize>;
8
+ export type SwitchLayoutType = Values<typeof SwitchLayout>;
9
+ export type FormItemContextValue = {
10
+ id: string;
11
+ };
12
+ export type FormFieldContextValue<TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>> = {
13
+ name: TName;
14
+ };
15
+ export interface FormFieldArgs {
16
+ size?: FormSizeType;
17
+ readOnly?: boolean;
18
+ disabled?: boolean;
19
+ }
20
+ export interface FormFieldGroupProps<TFieldValues extends FieldValues, TName extends Path<TFieldValues>> extends UseControllerProps<TFieldValues, TName> {
21
+ label?: string;
22
+ description?: string;
23
+ tooltip?: string;
24
+ size?: FormSizeType;
25
+ readOnly?: boolean;
26
+ highlight?: boolean;
27
+ horizontal?: boolean;
28
+ horizontalLabelWidth?: string;
29
+ children: (field: ControllerRenderProps<TFieldValues, TName>, args?: FormFieldArgs) => ReactNode;
30
+ }
31
+ export interface FormSwitchFieldProps<TFieldValues extends FieldValues, TName extends Path<TFieldValues>> extends UseControllerProps<TFieldValues, TName> {
32
+ label: string;
33
+ size?: FormSizeType;
34
+ description?: string;
35
+ disabled?: boolean;
36
+ layout?: SwitchLayoutType;
37
+ tooltip?: string;
38
+ }
39
+ export type FormInputFieldProps<TFieldValues extends FieldValues, TName extends Path<TFieldValues>> = Omit<FormFieldGroupProps<TFieldValues, TName>, 'children'> & {
40
+ inputProps?: InputProps;
41
+ };
@@ -1,5 +1 @@
1
- export var FormMessageSize = {
2
- Sm: 'sm',
3
- Md: 'md',
4
- Lg: 'lg'
5
- };
1
+ export {};
package/form/index.d.ts CHANGED
@@ -1,2 +1,3 @@
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';
package/form/index.js CHANGED
@@ -1,2 +1,3 @@
1
1
  export { Form, FormItem, FormLabel, FormControl, FormDescription, FormMessage, FormField, useFormField } from './form.component';
2
- export { FormFieldGroup } from './components/form-field-group.component';
2
+ export { FormFieldGroup } from './components/form-field-group.component';
3
+ export { FormSwitchField } from './components/form-switch-field.component';
package/input/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  export { Input, inputVariants } from './input.component';
2
2
  export type { InputProps } from './input.types';
3
- export { InputType, InputSize } from './input.types';
3
+ export { InputType } from './input.constants';
package/input/index.js CHANGED
@@ -1,2 +1,2 @@
1
1
  export { Input, inputVariants } from './input.component';
2
- export { InputType, InputSize } from './input.types';
2
+ export { InputType } from './input.constants';
@@ -1,5 +1,5 @@
1
+ import { InputProps } from '@scaleflex/ui-tw/input/input.types';
1
2
  import React from 'react';
2
- import { 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;
@@ -1,14 +1,12 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
4
3
  var _excluded = ["className", "type", "size", "disabled", "readOnly"];
5
4
  import { ButtonSize } from '@scaleflex/ui-tw/button';
5
+ import { InputType, inputSizeOptions } from '@scaleflex/ui-tw/input/input.constants';
6
+ import { FormSize } from '@scaleflex/ui-tw/types/form-size';
6
7
  import { cn } from '@scaleflex/ui-tw/utils/cn';
7
8
  import { cva } from 'class-variance-authority';
8
9
  import React from 'react';
9
- import { InputType } from './input.types';
10
- import { InputSize } from './input.types';
11
- var inputSizeOptions = _defineProperty(_defineProperty(_defineProperty({}, InputSize.Sm, 'py-2 px-3 text-sm h-8'), InputSize.Md, 'py-3 px-4 h-10 text-base '), InputSize.Lg, 'py-3 px-4 h-12 text-lg ');
12
10
  var inputVariants = cva('', {
13
11
  variants: {
14
12
  size: inputSizeOptions
@@ -22,7 +20,7 @@ function Input(_ref) {
22
20
  _ref$type = _ref.type,
23
21
  type = _ref$type === void 0 ? InputType.Text : _ref$type,
24
22
  _ref$size = _ref.size,
25
- size = _ref$size === void 0 ? InputSize.Md : _ref$size,
23
+ size = _ref$size === void 0 ? FormSize.Md : _ref$size,
26
24
  _ref$disabled = _ref.disabled,
27
25
  disabled = _ref$disabled === void 0 ? false : _ref$disabled,
28
26
  _ref$readOnly = _ref.readOnly,
@@ -0,0 +1,10 @@
1
+ export declare const inputSizeOptions: {
2
+ readonly sm: "py-2 px-3 text-sm h-8";
3
+ readonly md: "py-3 px-4 h-10 text-base ";
4
+ readonly lg: "py-3 px-4 h-12 text-lg ";
5
+ };
6
+ export declare const InputType: {
7
+ readonly Text: "text";
8
+ readonly Email: "email";
9
+ readonly Number: "number";
10
+ };
@@ -0,0 +1,8 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+ import { FormSize } from '@scaleflex/ui-tw/types/form-size';
3
+ export var inputSizeOptions = _defineProperty(_defineProperty(_defineProperty({}, FormSize.Sm, 'py-2 px-3 text-sm h-8'), FormSize.Md, 'py-3 px-4 h-10 text-base '), FormSize.Lg, 'py-3 px-4 h-12 text-lg ');
4
+ export var InputType = {
5
+ Text: 'text',
6
+ Email: 'email',
7
+ Number: 'number'
8
+ };
@@ -1,17 +1,6 @@
1
- import type { Values } from 'packages/ui/src/types/values';
1
+ import { FormSizeType } from '@scaleflex/ui-tw/types/form-size';
2
2
  import { ComponentProps } from 'react';
3
3
  export interface InputProps extends Omit<ComponentProps<'input'>, 'size'> {
4
- size?: InputSizeType;
4
+ size?: FormSizeType;
5
5
  'aria-invalid'?: boolean;
6
6
  }
7
- export declare const InputType: {
8
- readonly Text: "text";
9
- readonly Email: "email";
10
- readonly Number: "number";
11
- };
12
- export declare const InputSize: {
13
- readonly Sm: "sm";
14
- readonly Md: "md";
15
- readonly Lg: "lg";
16
- };
17
- export type InputSizeType = Values<typeof InputSize>;
@@ -1,10 +1 @@
1
- export var InputType = {
2
- Text: 'text',
3
- Email: 'email',
4
- Number: 'number'
5
- };
6
- export var InputSize = {
7
- Sm: 'sm',
8
- Md: 'md',
9
- Lg: 'lg'
10
- };
1
+ export {};
@@ -1,3 +1,3 @@
1
1
  import { IconProps } from '@scaleflex/icons-tw/icon.props';
2
- export declare const InfoOutlineIcon: ({ color, size, ref, ...rest }: IconProps) => JSX.Element;
3
- export default InfoOutlineIcon;
2
+ declare const InfoOutlineIcon: ({ color, size, ref, ...rest }: IconProps) => JSX.Element;
3
+ export { InfoOutlineIcon };
@@ -2,7 +2,7 @@ import _extends from "@babel/runtime/helpers/extends";
2
2
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
3
  var _excluded = ["color", "size", "ref"];
4
4
  import React from 'react';
5
- export var InfoOutlineIcon = function InfoOutlineIcon(_ref) {
5
+ var InfoOutlineIcon = function InfoOutlineIcon(_ref) {
6
6
  var _ref$color = _ref.color,
7
7
  color = _ref$color === void 0 ? 'currentColor' : _ref$color,
8
8
  _ref$size = _ref.size,
@@ -27,4 +27,4 @@ export var InfoOutlineIcon = function InfoOutlineIcon(_ref) {
27
27
  fill: color
28
28
  }));
29
29
  };
30
- export default InfoOutlineIcon;
30
+ export { InfoOutlineIcon };
@@ -1,7 +1,4 @@
1
- import { LabelProps } from '@scaleflex/ui-tw/label/label.types';
2
- import React, { ComponentProps, ReactElement } from 'react';
3
- interface LabelIconProps extends ComponentProps<'span'>, Pick<LabelProps, 'size' | 'tooltip'> {
4
- icon?: ReactElement;
5
- }
1
+ import { LabelIconProps } from '@scaleflex/ui-tw/label/label.types';
2
+ import React from 'react';
6
3
  declare const LabelIcon: (props: LabelIconProps) => React.JSX.Element | null;
7
4
  export { LabelIcon };
@@ -1,15 +1,13 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
4
3
  var _excluded = ["size", "icon", "tooltip"];
5
- import InfoOutlineIcon from '@scaleflex/ui-tw/label/components/info-outline-icon';
6
- import { LabelSize } from '@scaleflex/ui-tw/label/label.types';
4
+ import { InfoOutlineIcon } from '@scaleflex/ui-tw/label/components/info-outline-icon';
5
+ import { labelIconSizes } from '@scaleflex/ui-tw/label/label.constants';
7
6
  import { getLabelIconSizeInRem } from '@scaleflex/ui-tw/label/label.utils';
8
7
  import { Tooltip, TooltipContent, TooltipTrigger } from '@scaleflex/ui-tw/tooltip';
9
8
  import { cn } from '@scaleflex/ui-tw/utils/cn';
10
9
  import { cva } from 'class-variance-authority';
11
10
  import React, { cloneElement, useMemo } from 'react';
12
- var labelIconSizes = _defineProperty(_defineProperty(_defineProperty({}, LabelSize.Sm, 'ml-1'), LabelSize.Md, 'ml-1.5'), LabelSize.Lg, 'ml-1.5');
13
11
  var labelIconVariants = cva('', {
14
12
  variants: {
15
13
  size: labelIconSizes
@@ -1,44 +1,44 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
4
3
  var _excluded = ["className", "size", "children", "icon", "tooltip"];
5
4
  import * as LabelPrimitive from '@radix-ui/react-label';
6
- import { ButtonSize } from '@scaleflex/ui-tw/button';
7
- import { InputSize } from '@scaleflex/ui-tw/input';
8
5
  import { LabelIcon } from '@scaleflex/ui-tw/label/components/label-icon';
9
- import { LabelSize } from '@scaleflex/ui-tw/label/label.types';
6
+ import { labelSizeOptions } from '@scaleflex/ui-tw/label/label.constants';
7
+ import { FormSize } from '@scaleflex/ui-tw/types/form-size';
10
8
  import { cn } from '@scaleflex/ui-tw/utils/cn';
11
9
  import { cva } from 'class-variance-authority';
12
10
  import * as React from 'react';
13
- var labelSizeOptions = _defineProperty(_defineProperty(_defineProperty({}, InputSize.Sm, 'text-xs'), InputSize.Md, 'text-sm'), InputSize.Lg, 'text-base');
14
11
  var labelVariants = cva('', {
15
12
  variants: {
16
13
  size: labelSizeOptions
17
14
  },
18
15
  defaultVariants: {
19
- size: ButtonSize.Md
16
+ size: FormSize.Md
20
17
  }
21
18
  });
22
19
  function Label(_ref) {
23
20
  var className = _ref.className,
24
21
  _ref$size = _ref.size,
25
- size = _ref$size === void 0 ? LabelSize.Md : _ref$size,
22
+ size = _ref$size === void 0 ? FormSize.Md : _ref$size,
26
23
  children = _ref.children,
27
24
  icon = _ref.icon,
28
25
  tooltip = _ref.tooltip,
29
26
  props = _objectWithoutProperties(_ref, _excluded);
30
27
  return /*#__PURE__*/React.createElement(LabelPrimitive.Root, _extends({
31
28
  "data-slot": "label",
32
- className: cn('text-secondary-foreground flex items-center gap-2 leading-none font-normal select-none', 'peer-disabled:cursor-not-allowed peer-disabled:opacity-50', 'group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50', 'group-data-[highlight=true]:text-warning', labelVariants({
29
+ className: cn('text-secondary-foreground flex items-center leading-none font-normal select-none', 'peer-disabled:cursor-not-allowed peer-disabled:opacity-50', 'group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50', 'group-data-[highlight=true]:text-warning-foreground', labelVariants({
33
30
  size: size,
34
31
  className: className
35
32
  }))
36
- }, props), icon || tooltip ? /*#__PURE__*/React.createElement("span", {
37
- className: "flex items-center"
38
- }, children, /*#__PURE__*/React.createElement(LabelIcon, {
33
+ }, props), /*#__PURE__*/React.createElement("span", {
34
+ className: "truncate",
35
+ style: {
36
+ maxWidth: icon || tooltip ? 'calc(100% - 2rem)' : undefined
37
+ }
38
+ }, children), (icon || tooltip) && /*#__PURE__*/React.createElement(LabelIcon, {
39
39
  size: size,
40
40
  icon: icon,
41
41
  tooltip: tooltip
42
- })) : children);
42
+ }));
43
43
  }
44
44
  export { Label };
@@ -0,0 +1,10 @@
1
+ export declare const labelSizeOptions: {
2
+ readonly sm: "text-xs";
3
+ readonly md: "text-sm";
4
+ readonly lg: "text-base";
5
+ };
6
+ export declare const labelIconSizes: {
7
+ readonly sm: "ml-1";
8
+ readonly md: "ml-1.5";
9
+ readonly lg: "ml-1.5";
10
+ };
@@ -0,0 +1,4 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+ import { FormSize } from '@scaleflex/ui-tw/types/form-size';
3
+ export var labelSizeOptions = _defineProperty(_defineProperty(_defineProperty({}, FormSize.Sm, 'text-xs'), FormSize.Md, 'text-sm'), FormSize.Lg, 'text-base');
4
+ export var labelIconSizes = _defineProperty(_defineProperty(_defineProperty({}, FormSize.Sm, 'ml-1'), FormSize.Md, 'ml-1.5'), FormSize.Lg, 'ml-1.5');
@@ -1,14 +1,11 @@
1
1
  import * as LabelPrimitive from '@radix-ui/react-label';
2
- import type { Values } from 'packages/ui/src/types/values';
2
+ import { FormSizeType } from '@scaleflex/ui-tw/types/form-size';
3
3
  import { ComponentProps, ReactElement } from 'react';
4
- export declare const LabelSize: {
5
- readonly Sm: "sm";
6
- readonly Md: "md";
7
- readonly Lg: "lg";
8
- };
9
- export type LabelSizeType = Values<typeof LabelSize>;
10
4
  export interface LabelProps extends Omit<ComponentProps<typeof LabelPrimitive.Root>, 'size'> {
11
- size?: LabelSizeType;
5
+ size?: FormSizeType;
12
6
  icon?: ReactElement;
13
7
  tooltip?: string;
14
8
  }
9
+ export interface LabelIconProps extends ComponentProps<'span'>, Pick<LabelProps, 'size' | 'tooltip'> {
10
+ icon?: ReactElement;
11
+ }
@@ -1,5 +1 @@
1
- export var LabelSize = {
2
- Sm: 'sm',
3
- Md: 'md',
4
- Lg: 'lg'
5
- };
1
+ export {};
@@ -1,2 +1,2 @@
1
- import { LabelSizeType } from '@scaleflex/ui-tw/label/label.types';
2
- export declare const getLabelIconSizeInRem: (sizeName?: LabelSizeType | null) => string;
1
+ import { FormSizeType } from '@scaleflex/ui-tw/types/form-size';
2
+ export declare const getLabelIconSizeInRem: (sizeName?: FormSizeType | null) => string;
@@ -1,13 +1,13 @@
1
- import { LabelSize } from '@scaleflex/ui-tw/label/label.types';
1
+ import { FormSize } from '@scaleflex/ui-tw/types/form-size';
2
2
  export var getLabelIconSizeInRem = function getLabelIconSizeInRem(sizeName) {
3
3
  switch (sizeName) {
4
- case LabelSize.Lg:
4
+ case FormSize.Lg:
5
5
  return '1rem';
6
6
  // 16px
7
- case LabelSize.Md:
7
+ case FormSize.Md:
8
8
  return '0.875rem';
9
9
  // 14px
10
- case LabelSize.Sm:
10
+ case FormSize.Sm:
11
11
  return '0.75rem';
12
12
  // 14px
13
13
  default:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scaleflex/ui-tw",
3
- "version": "0.0.5",
3
+ "version": "0.0.7",
4
4
  "author": "scaleflex",
5
5
  "repository": "github:scaleflex/ui",
6
6
  "homepage": "https://github.com/scaleflex/ui/blob/master/README.md",
@@ -15,8 +15,9 @@
15
15
  "@popperjs/core": "^2.6.0",
16
16
  "@radix-ui/react-label": "^2.1.6",
17
17
  "@radix-ui/react-slot": "^1.1.2",
18
+ "@radix-ui/react-switch": "^1.0.1",
18
19
  "@radix-ui/react-tooltip": "^1.2.6",
19
- "@scaleflex/icons-tw": "^0.0.5",
20
+ "@scaleflex/icons-tw": "^0.0.7",
20
21
  "@types/lodash.merge": "^4.6.9",
21
22
  "class-variance-authority": "^0.7.1",
22
23
  "lodash.merge": "^4.6.2",
@@ -0,0 +1 @@
1
+ export { Switch } from './switch.component';
@@ -0,0 +1 @@
1
+ export { Switch } from './switch.component';
@@ -0,0 +1,4 @@
1
+ import { SwitchProps } from '@scaleflex/ui-tw/switch/switch.types';
2
+ import * as React from 'react';
3
+ declare function Switch({ className, size, ...props }: SwitchProps): React.JSX.Element;
4
+ export { Switch };
@@ -0,0 +1,43 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
+ var _excluded = ["className", "size"];
4
+ import * as SwitchPrimitive from '@radix-ui/react-switch';
5
+ import { switchSizeOptions, switchThumbSizeOptions } from '@scaleflex/ui-tw/switch/switch.constants';
6
+ import { FormSize } from '@scaleflex/ui-tw/types/form-size';
7
+ import { cn } from '@scaleflex/ui-tw/utils/cn';
8
+ import { cva } from 'class-variance-authority';
9
+ import * as React from 'react';
10
+ var switchVariants = cva('', {
11
+ variants: {
12
+ size: switchSizeOptions
13
+ },
14
+ defaultVariants: {
15
+ size: FormSize.Md
16
+ }
17
+ });
18
+ var switchThumbVariants = cva('', {
19
+ variants: {
20
+ size: switchThumbSizeOptions
21
+ },
22
+ defaultVariants: {
23
+ size: FormSize.Md
24
+ }
25
+ });
26
+ function Switch(_ref) {
27
+ var className = _ref.className,
28
+ _ref$size = _ref.size,
29
+ size = _ref$size === void 0 ? FormSize.Md : _ref$size,
30
+ props = _objectWithoutProperties(_ref, _excluded);
31
+ return /*#__PURE__*/React.createElement(SwitchPrimitive.Root, _extends({
32
+ "data-slot": "switch",
33
+ className: cn('peer inline-flex shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent shadow-xs transition-all outline-none', 'disabled:cursor-not-allowed disabled:opacity-50', 'data-[state=checked]:bg-primary data-[state=unchecked]:bg-input', 'ring-offset-background focus-visible:ring-ring focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none', switchVariants({
34
+ size: size
35
+ }), className)
36
+ }, props), /*#__PURE__*/React.createElement(SwitchPrimitive.Thumb, {
37
+ "data-slot": "switch-thumb",
38
+ className: cn('bg-background pointer-events-none block rounded-full ring-0 transition-transform', 'data-[state=checked]:translate-x-full data-[state=unchecked]:translate-x-0', switchThumbVariants({
39
+ size: size
40
+ }))
41
+ }));
42
+ }
43
+ export { Switch };
@@ -0,0 +1,10 @@
1
+ export declare const switchSizeOptions: {
2
+ readonly sm: "h-4 w-7";
3
+ readonly md: "h-5 w-9";
4
+ readonly lg: "h-7 w-13";
5
+ };
6
+ export declare const switchThumbSizeOptions: {
7
+ readonly sm: "size-3";
8
+ readonly md: "size-4";
9
+ readonly lg: "size-6";
10
+ };
@@ -0,0 +1,4 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+ import { FormSize } from '@scaleflex/ui-tw/types/form-size';
3
+ export var switchSizeOptions = _defineProperty(_defineProperty(_defineProperty({}, FormSize.Sm, 'h-4 w-7'), FormSize.Md, 'h-5 w-9'), FormSize.Lg, 'h-7 w-13');
4
+ export var switchThumbSizeOptions = _defineProperty(_defineProperty(_defineProperty({}, FormSize.Sm, 'size-3'), FormSize.Md, 'size-4'), FormSize.Lg, 'size-6');
@@ -0,0 +1,6 @@
1
+ import * as SwitchPrimitive from '@radix-ui/react-switch';
2
+ import { FormSizeType } from '@scaleflex/ui-tw/types/form-size';
3
+ import { ComponentProps } from 'react';
4
+ export interface SwitchProps extends ComponentProps<typeof SwitchPrimitive.Root> {
5
+ size?: FormSizeType;
6
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,7 @@
1
+ import type { Values } from '@scaleflex/ui-tw/types/values';
2
+ export declare const FormSize: {
3
+ readonly Sm: "sm";
4
+ readonly Md: "md";
5
+ readonly Lg: "lg";
6
+ };
7
+ export type FormSizeType = Values<typeof FormSize>;
@@ -0,0 +1,5 @@
1
+ export var FormSize = {
2
+ Sm: 'sm',
3
+ Md: 'md',
4
+ Lg: 'lg'
5
+ };
package/types/values.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  /**
2
2
  * Type-only Object.values
3
3
  */
4
- export type Values<E> = E extends Record<string, unknown> ? E[keyof E] : E extends unknown[] ? E[number] : unknown
4
+ export type Values<E> = E extends Record<string, unknown> ? E[keyof E] : E extends unknown[] ? E[number] : unknown;
@@ -0,0 +1 @@
1
+ export {};
@@ -1,13 +0,0 @@
1
- export declare const iconVariantOptions: {
2
- primary: string;
3
- secondary: string;
4
- outline: string;
5
- "link-primary": string;
6
- "link-secondary": string;
7
- "link-basic-primary": string;
8
- "link-basic-secondary": string;
9
- "link-error": string;
10
- "link-warning": string;
11
- "error-primary": string;
12
- "warning-primary": string;
13
- };
@@ -1,4 +0,0 @@
1
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
- var _iconVariantOptions;
3
- import { ButtonVariant } from '@scaleflex/ui-tw/button/button.types';
4
- export var iconVariantOptions = (_iconVariantOptions = {}, _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_iconVariantOptions, ButtonVariant.Primary, ''), ButtonVariant.Secondary, ''), ButtonVariant.Outline, 'text-muted-foreground group-hover/button:text-muted-foreground/80'), ButtonVariant.LinkPrimary, ''), ButtonVariant.LinkSecondary, 'text-muted-foreground group-hover/button:text-muted-foreground/80'), ButtonVariant.LinkBasicPrimary, ''), ButtonVariant.LinkBasicSecondary, 'text-muted-foreground group-hover/button:text-muted-foreground/80'), ButtonVariant.LinkError, ''), ButtonVariant.LinkWarning, ''), ButtonVariant.Error, ''), _defineProperty(_iconVariantOptions, ButtonVariant.Warning, ''));