@scaleflex/ui-tw 0.0.27 → 0.0.28

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 (53) hide show
  1. package/button/button.component.d.ts +3 -3
  2. package/button/button.component.js +17 -13
  3. package/button/button.constants.d.ts +32 -26
  4. package/button/button.constants.js +13 -13
  5. package/button/button.utils.d.ts +2 -0
  6. package/button/button.utils.js +5 -1
  7. package/button/components/copy-to-clipboard-button.d.ts +10 -0
  8. package/button/components/copy-to-clipboard-button.js +76 -0
  9. package/button/components/end-icon.d.ts +1 -2
  10. package/button/components/end-icon.js +6 -14
  11. package/button/components/start-icon.d.ts +2 -2
  12. package/button/components/start-icon.js +13 -26
  13. package/button/index.d.ts +1 -0
  14. package/button/index.js +2 -1
  15. package/input/input.component.js +2 -2
  16. package/package.json +2 -2
  17. package/pill/index.d.ts +3 -0
  18. package/pill/index.js +2 -0
  19. package/pill/pill.component.d.ts +8 -0
  20. package/pill/pill.component.js +58 -0
  21. package/pill/pill.constants.d.ts +22 -0
  22. package/pill/pill.constants.js +10 -0
  23. package/pill/pill.types.d.ts +7 -0
  24. package/pill/pill.types.js +1 -0
  25. package/pill/pill.utils.d.ts +2 -0
  26. package/pill/pill.utils.js +16 -0
  27. package/select/select.component.js +2 -2
  28. package/styles/shared-classes.d.ts +4 -0
  29. package/styles/shared-classes.js +6 -0
  30. package/styles/theme-map.css +1 -0
  31. package/styles/variables.css +2 -0
  32. package/switch/switch.component.js +2 -1
  33. package/textarea/components/left-toolbar-buttons.d.ts +3 -0
  34. package/textarea/components/left-toolbar-buttons.js +23 -0
  35. package/textarea/components/right-toolbar-buttons.d.ts +3 -0
  36. package/textarea/components/right-toolbar-buttons.js +28 -0
  37. package/textarea/components/textarea-with-actions.d.ts +4 -0
  38. package/textarea/components/textarea-with-actions.js +37 -0
  39. package/textarea/index.d.ts +3 -0
  40. package/textarea/index.js +4 -1
  41. package/textarea/textarea.component.js +4 -4
  42. package/textarea/textarea.constants.d.ts +5 -0
  43. package/textarea/textarea.constants.js +2 -1
  44. package/textarea/textarea.types.d.ts +18 -1
  45. package/textarea/textarea.utils.d.ts +8 -0
  46. package/textarea/textarea.utils.js +18 -0
  47. package/tooltip/tooltip.component.d.ts +1 -1
  48. package/tooltip/tooltip.component.js +7 -2
  49. package/tooltip/tooltip.constants.d.ts +2 -0
  50. package/tooltip/tooltip.constants.js +3 -2
  51. package/tooltip/tooltip.types.d.ts +3 -1
  52. package/input/input.utils.d.ts +0 -1
  53. package/input/input.utils.js +0 -3
@@ -1,8 +1,8 @@
1
1
  import React from 'react';
2
2
  import { type ButtonProps } from './button.types';
3
3
  declare const buttonVariants: (props?: ({
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
- size?: "xs" | "sm" | "md" | "lg" | null | undefined;
4
+ variant?: "primary" | "secondary" | "outline" | "ghost-primary" | "ghost-secondary" | "error-primary" | "warning-primary" | null | undefined;
5
+ size?: "xs" | "sm" | "md" | "lg" | "icon-xs" | "icon-sm" | "icon-md" | "icon-lg" | null | undefined;
6
6
  } & import("class-variance-authority/dist/types").ClassProp) | undefined) => string;
7
- declare function Button({ className, children, size, startIcon, endIcon, variant, loading, asChild, disabled, ...rest }: ButtonProps): React.JSX.Element;
7
+ declare const Button: React.ForwardRefExoticComponent<Omit<ButtonProps, "ref"> & React.RefAttributes<HTMLButtonElement>>;
8
8
  export { Button, buttonVariants };
@@ -3,11 +3,12 @@ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProper
3
3
  var _excluded = ["className", "children", "size", "startIcon", "endIcon", "variant", "loading", "asChild", "disabled"];
4
4
  import { Slot } from '@radix-ui/react-slot';
5
5
  import SpinnerIcon from '@scaleflex/icons-tw/spinner';
6
+ import { focusRingClassNames } from '@scaleflex/ui-tw/styles/shared-classes';
6
7
  import { cn } from '@scaleflex/ui-tw/utils/cn';
7
8
  import { cva } from 'class-variance-authority';
8
- import React, { useRef } from 'react';
9
+ import React, { useImperativeHandle, useRef } from 'react';
9
10
  import { ButtonSize, ButtonVariant, buttonSizeOptions, buttonVariantOptions } from './button.constants';
10
- import { createRipple, getIconSizeInRem } from './button.utils';
11
+ import { createRipple, isIconSize } from './button.utils';
11
12
  import { EndIcon } from './components/end-icon';
12
13
  import { StartIcon, startIconVariants } from './components/start-icon';
13
14
  var buttonVariants = cva('', {
@@ -20,7 +21,7 @@ var buttonVariants = cva('', {
20
21
  size: ButtonSize.Md
21
22
  }
22
23
  });
23
- function Button(_ref) {
24
+ var Button = /*#__PURE__*/React.forwardRef(function Button(_ref, ref) {
24
25
  var className = _ref.className,
25
26
  children = _ref.children,
26
27
  _ref$size = _ref.size,
@@ -36,17 +37,21 @@ function Button(_ref) {
36
37
  _ref$disabled = _ref.disabled,
37
38
  disabled = _ref$disabled === void 0 ? false : _ref$disabled,
38
39
  rest = _objectWithoutProperties(_ref, _excluded);
39
- var buttonRef = useRef(null);
40
+ var localRef = useRef(null);
41
+ useImperativeHandle(ref, function () {
42
+ return localRef.current;
43
+ }, [localRef.current]);
40
44
  var Comp = asChild ? Slot : 'button';
45
+ var isIcon = isIconSize(size);
41
46
  var handleClick = function handleClick(e) {
42
- if (buttonRef.current) {
43
- createRipple(e, buttonRef.current);
47
+ if (localRef.current) {
48
+ createRipple(e, localRef.current);
44
49
  }
45
50
  };
46
51
  return /*#__PURE__*/React.createElement(Comp, _extends({
47
- ref: buttonRef,
52
+ ref: localRef,
48
53
  "data-slot": "button",
49
- className: cn('group/button relative inline-flex shrink-0 cursor-pointer items-center justify-center overflow-hidden rounded-md font-medium whitespace-nowrap transition-all outline-none', 'ring-offset-background focus-visible:ring-ring focus-visible:ring-2 focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-40', "[&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4", buttonVariants({
54
+ className: cn('group/button relative inline-flex shrink-0 cursor-pointer items-center justify-center overflow-hidden rounded-md font-medium whitespace-nowrap transition-all outline-none', 'disabled:pointer-events-none disabled:opacity-40', '[&_svg]:pointer-events-none [&_svg]:shrink-0', focusRingClassNames, buttonVariants({
50
55
  variant: variant,
51
56
  size: size,
52
57
  className: className
@@ -61,16 +66,15 @@ function Button(_ref) {
61
66
  loading: loading,
62
67
  icon: startIcon
63
68
  }), loading && !startIcon && /*#__PURE__*/React.createElement("span", {
64
- className: startIconVariants({
69
+ className: cn(startIconVariants({
65
70
  size: size
66
- })
71
+ }), isIcon && 'mr-0')
67
72
  }, /*#__PURE__*/React.createElement(SpinnerIcon, {
68
- size: getIconSizeInRem(size),
69
73
  className: "animate-spin"
70
- })), children, endIcon && /*#__PURE__*/React.createElement(EndIcon, {
74
+ })), !(loading && isIcon) ? children : undefined, endIcon && /*#__PURE__*/React.createElement(EndIcon, {
71
75
  variant: variant,
72
76
  size: size,
73
77
  icon: endIcon
74
78
  })) : children);
75
- }
79
+ });
76
80
  export { Button, buttonVariants };
@@ -3,35 +3,47 @@ export declare const ButtonSize: {
3
3
  readonly Sm: "sm";
4
4
  readonly Md: "md";
5
5
  readonly Lg: "lg";
6
+ readonly IconXs: "icon-xs";
7
+ readonly IconSm: "icon-sm";
8
+ readonly IconMd: "icon-md";
9
+ readonly IconLg: "icon-lg";
6
10
  };
7
11
  export declare const buttonSizeOptions: {
8
12
  readonly xs: "h-6 px-2.5 py-1.5 text-xs";
9
13
  readonly sm: "h-8 px-3 py-2 text-sm";
10
14
  readonly md: "h-10 px-4 py-2.5 text-base";
11
15
  readonly lg: "h-12 px-6 py-3.5 text-lg";
16
+ readonly "icon-xs": "size-6 p-1.5 [&_svg:not([class*='size-'])]:size-3";
17
+ readonly "icon-sm": "size-8 p-2 [&_svg:not([class*='size-'])]:size-3.5";
18
+ readonly "icon-md": "size-10 p-2.5 [&_svg:not([class*='size-'])]:size-4";
19
+ readonly "icon-lg": "size-12 p-3.5 [&_svg:not([class*='size-'])]:size-4.5";
12
20
  };
13
21
  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";
22
+ readonly xs: "ml-1.5 size-3";
23
+ readonly sm: "ml-1.5 size-3.5";
24
+ readonly md: "ml-2 size-4";
25
+ readonly lg: "ml-2 size-4.5";
26
+ readonly "icon-xs": "ml-1.5 size-3";
27
+ readonly "icon-sm": "ml-1.5 size-3.5";
28
+ readonly "icon-md": "ml-2 size-4";
29
+ readonly "icon-lg": "ml-2 size-4.5";
18
30
  };
19
31
  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";
32
+ readonly xs: "mr-1.5 size-3";
33
+ readonly sm: "mr-1.5 size-3.5";
34
+ readonly md: "mr-2 size-4";
35
+ readonly lg: "mr-2 size-4.5";
36
+ readonly "icon-xs": "mr-1.5 size-3";
37
+ readonly "icon-sm": "mr-1.5 size-3.5";
38
+ readonly "icon-md": "mr-2 size-4";
39
+ readonly "icon-lg": "mr-2 size-4.5";
24
40
  };
25
41
  export declare const ButtonVariant: {
26
42
  readonly Primary: "primary";
27
43
  readonly Secondary: "secondary";
28
44
  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";
45
+ readonly GhostPrimary: "ghost-primary";
46
+ readonly GhostSecondary: "ghost-secondary";
35
47
  readonly Error: "error-primary";
36
48
  readonly Warning: "warning-primary";
37
49
  };
@@ -39,12 +51,8 @@ export declare const iconVariantOptions: {
39
51
  readonly primary: "";
40
52
  readonly secondary: "";
41
53
  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": "";
54
+ readonly "ghost-primary": "";
55
+ readonly "ghost-secondary": "text-muted-foreground group-hover/button:text-muted-foreground/80";
48
56
  readonly "error-primary": "";
49
57
  readonly "warning-primary": "";
50
58
  };
@@ -52,12 +60,10 @@ export declare const buttonVariantOptions: {
52
60
  readonly primary: "bg-primary text-primary-foreground shadow-xs hover:bg-primary/80";
53
61
  readonly secondary: "border bg-background shadow-xs text-primary border-primary hover:bg-accent hover:border-primary/80";
54
62
  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";
63
+ readonly "ghost-primary": "text-primary hover:bg-accent";
64
+ readonly "ghost-secondary": "text-secondary-foreground hover:bg-secondary";
61
65
  readonly "error-primary": "bg-destructive text-primary-foreground shadow-xs hover:bg-destructive/80";
62
66
  readonly "warning-primary": "bg-warning text-primary-foreground shadow-xs hover:bg-warning/80";
63
67
  };
68
+ export declare const iconSizes: readonly ["icon-xs", "icon-sm", "icon-md", "icon-lg"];
69
+ export type IconSize = (typeof iconSizes)[number];
@@ -1,26 +1,26 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
- var _iconVariantOptions, _buttonVariantOptions;
3
2
  export var ButtonSize = {
4
3
  Xs: 'xs',
5
4
  Sm: 'sm',
6
5
  Md: 'md',
7
- Lg: 'lg'
6
+ Lg: 'lg',
7
+ IconXs: 'icon-xs',
8
+ IconSm: 'icon-sm',
9
+ IconMd: 'icon-md',
10
+ IconLg: 'icon-lg'
8
11
  };
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 buttonSizeOptions = _defineProperty(_defineProperty(_defineProperty(_defineProperty(_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'), ButtonSize.IconXs, "size-6 p-1.5 [&_svg:not([class*='size-'])]:size-3"), ButtonSize.IconSm, "size-8 p-2 [&_svg:not([class*='size-'])]:size-3.5"), ButtonSize.IconMd, "size-10 p-2.5 [&_svg:not([class*='size-'])]:size-4"), ButtonSize.IconLg, "size-12 p-3.5 [&_svg:not([class*='size-'])]:size-4.5");
13
+ export var buttonEndIconSizes = _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, ButtonSize.Xs, 'ml-1.5 size-3'), ButtonSize.Sm, 'ml-1.5 size-3.5'), ButtonSize.Md, 'ml-2 size-4'), ButtonSize.Lg, 'ml-2 size-4.5'), ButtonSize.IconXs, 'ml-1.5 size-3'), ButtonSize.IconSm, 'ml-1.5 size-3.5'), ButtonSize.IconMd, 'ml-2 size-4'), ButtonSize.IconLg, 'ml-2 size-4.5');
14
+ export var buttonStartIconSizes = _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, ButtonSize.Xs, 'mr-1.5 size-3'), ButtonSize.Sm, 'mr-1.5 size-3.5'), ButtonSize.Md, 'mr-2 size-4'), ButtonSize.Lg, 'mr-2 size-4.5'), ButtonSize.IconXs, 'mr-1.5 size-3'), ButtonSize.IconSm, 'mr-1.5 size-3.5'), ButtonSize.IconMd, 'mr-2 size-4'), ButtonSize.IconLg, 'mr-2 size-4.5');
12
15
  export var ButtonVariant = {
13
16
  Primary: 'primary',
14
17
  Secondary: 'secondary',
15
18
  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',
19
+ GhostPrimary: 'ghost-primary',
20
+ GhostSecondary: 'ghost-secondary',
22
21
  Error: 'error-primary',
23
22
  Warning: 'warning-primary'
24
23
  };
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'));
24
+ export var iconVariantOptions = _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, ButtonVariant.Primary, ''), ButtonVariant.Secondary, ''), ButtonVariant.Outline, 'text-muted-foreground group-hover/button:text-muted-foreground/80'), ButtonVariant.GhostPrimary, ''), ButtonVariant.GhostSecondary, 'text-muted-foreground group-hover/button:text-muted-foreground/80'), ButtonVariant.Error, ''), ButtonVariant.Warning, '');
25
+ export var buttonVariantOptions = _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, 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.GhostPrimary, 'text-primary hover:bg-accent'), ButtonVariant.GhostSecondary, 'text-secondary-foreground hover:bg-secondary'), ButtonVariant.Error, 'bg-destructive text-primary-foreground shadow-xs hover:bg-destructive/80'), ButtonVariant.Warning, 'bg-warning text-primary-foreground shadow-xs hover:bg-warning/80');
26
+ export var iconSizes = [ButtonSize.IconXs, ButtonSize.IconSm, ButtonSize.IconMd, ButtonSize.IconLg];
@@ -1,4 +1,6 @@
1
+ import { IconSize } from '@scaleflex/ui-tw/button/button.constants';
1
2
  import { ButtonSizeType } from '@scaleflex/ui-tw/button/button.types';
2
3
  import type { MouseEvent } from 'react';
3
4
  export declare const getIconSizeInRem: (sizeName?: ButtonSizeType | null) => string;
4
5
  export declare const createRipple: (event: MouseEvent, container: HTMLElement) => void;
6
+ export declare const isIconSize: (size: unknown) => size is IconSize;
@@ -1,4 +1,5 @@
1
- import { ButtonSize } from '@scaleflex/ui-tw/button/button.constants';
1
+ import { ButtonSize, iconSizes } from '@scaleflex/ui-tw/button/button.constants';
2
+ // TODO: remove this function completely and start using size-x classes (check start/end icons in button)
2
3
  export var getIconSizeInRem = function getIconSizeInRem(sizeName) {
3
4
  switch (sizeName) {
4
5
  case ButtonSize.Lg:
@@ -31,4 +32,7 @@ export var createRipple = function createRipple(event, container) {
31
32
  setTimeout(function () {
32
33
  return ripple.remove();
33
34
  }, 500);
35
+ };
36
+ export var isIconSize = function isIconSize(size) {
37
+ return typeof size === 'string' && iconSizes.includes(size);
34
38
  };
@@ -0,0 +1,10 @@
1
+ import { ButtonSizeType } from '@scaleflex/ui-tw/button/button.types';
2
+ import React from 'react';
3
+ export interface CopyToClipboardButtonProps {
4
+ text: string;
5
+ disabled?: boolean;
6
+ size?: ButtonSizeType;
7
+ initialTooltip?: string;
8
+ copiedTooltip?: string;
9
+ }
10
+ export declare const CopyToClipboardButton: (props: CopyToClipboardButtonProps) => React.JSX.Element;
@@ -0,0 +1,76 @@
1
+ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
2
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
4
+ import { Button, ButtonSize } from '@scaleflex/ui-tw/button';
5
+ import { WithTooltip } from '@scaleflex/ui-tw/tooltip';
6
+ import { Copy } from 'lucide-react';
7
+ import { useState } from 'react';
8
+ import React from 'react';
9
+ export var CopyToClipboardButton = function CopyToClipboardButton(props) {
10
+ var text = props.text,
11
+ _props$size = props.size,
12
+ size = _props$size === void 0 ? ButtonSize.IconMd : _props$size,
13
+ _props$initialTooltip = props.initialTooltip,
14
+ initialTooltip = _props$initialTooltip === void 0 ? 'Copy to clipboard' : _props$initialTooltip,
15
+ _props$copiedTooltip = props.copiedTooltip,
16
+ copiedTooltip = _props$copiedTooltip === void 0 ? 'Copied!' : _props$copiedTooltip,
17
+ _props$disabled = props.disabled,
18
+ disabled = _props$disabled === void 0 ? false : _props$disabled;
19
+ var _useState = useState(initialTooltip),
20
+ _useState2 = _slicedToArray(_useState, 2),
21
+ tooltipText = _useState2[0],
22
+ setTooltipText = _useState2[1];
23
+ var _useState3 = useState('default'),
24
+ _useState4 = _slicedToArray(_useState3, 2),
25
+ tooltipVariant = _useState4[0],
26
+ setTooltipVariant = _useState4[1];
27
+ var _useState5 = useState(false),
28
+ _useState6 = _slicedToArray(_useState5, 2),
29
+ open = _useState6[0],
30
+ setOpen = _useState6[1];
31
+ var handleCopy = /*#__PURE__*/function () {
32
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
33
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
34
+ while (1) switch (_context.prev = _context.next) {
35
+ case 0:
36
+ _context.prev = 0;
37
+ _context.next = 3;
38
+ return navigator.clipboard.writeText(text);
39
+ case 3:
40
+ setTooltipText(copiedTooltip);
41
+ setTooltipVariant('success');
42
+ setOpen(true);
43
+ setTimeout(function () {
44
+ setOpen(false);
45
+ }, 1500);
46
+ setTimeout(function () {
47
+ setTooltipText(initialTooltip);
48
+ setTooltipVariant('default');
49
+ }, 2000);
50
+ _context.next = 13;
51
+ break;
52
+ case 10:
53
+ _context.prev = 10;
54
+ _context.t0 = _context["catch"](0);
55
+ console.error('Failed to copy', _context.t0);
56
+ case 13:
57
+ case "end":
58
+ return _context.stop();
59
+ }
60
+ }, _callee, null, [[0, 10]]);
61
+ }));
62
+ return function handleCopy() {
63
+ return _ref.apply(this, arguments);
64
+ };
65
+ }();
66
+ return /*#__PURE__*/React.createElement(WithTooltip, {
67
+ content: tooltipText,
68
+ variant: tooltipVariant,
69
+ open: open ? true : undefined
70
+ }, /*#__PURE__*/React.createElement(Button, {
71
+ variant: "ghost-secondary",
72
+ size: size,
73
+ onClick: handleCopy,
74
+ disabled: disabled || !text
75
+ }, /*#__PURE__*/React.createElement(Copy, null)));
76
+ };
@@ -1,4 +1,3 @@
1
1
  import { EndIconProps } from '@scaleflex/ui-tw/button/button.types';
2
- import React from 'react';
3
- declare const EndIcon: (props: EndIconProps) => React.JSX.Element | null;
2
+ declare const EndIcon: (props: EndIconProps) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | null;
4
3
  export { EndIcon };
@@ -1,10 +1,11 @@
1
- import _extends from "@babel/runtime/helpers/extends";
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
3
  var _excluded = ["size", "icon", "variant"];
4
+ 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; }
5
+ 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; }
4
6
  import { buttonEndIconSizes, iconVariantOptions } from '@scaleflex/ui-tw/button/button.constants';
5
- import { getIconSizeInRem } from '@scaleflex/ui-tw/button/button.utils';
6
7
  import { cva } from 'class-variance-authority';
7
- import React, { cloneElement, useMemo } from 'react';
8
+ import { cloneElement } from 'react';
8
9
  var endIconVariants = cva('', {
9
10
  variants: {
10
11
  variant: iconVariantOptions,
@@ -16,21 +17,12 @@ var EndIcon = function EndIcon(props) {
16
17
  icon = props.icon,
17
18
  variant = props.variant,
18
19
  rest = _objectWithoutProperties(props, _excluded);
19
- var sizeInRem = useMemo(function () {
20
- return getIconSizeInRem(size);
21
- }, [size]);
22
20
  if (!icon) return null;
23
- return /*#__PURE__*/React.createElement("span", _extends({
21
+ return /*#__PURE__*/cloneElement(icon, _objectSpread({
24
22
  className: endIconVariants({
25
23
  size: size,
26
24
  variant: variant
27
25
  })
28
- }, rest), /*#__PURE__*/cloneElement(icon, {
29
- size: sizeInRem,
30
- style: {
31
- width: sizeInRem,
32
- height: sizeInRem
33
- }
34
- }));
26
+ }, rest));
35
27
  };
36
28
  export { EndIcon };
@@ -1,8 +1,8 @@
1
1
  import { StartIconProps } from '@scaleflex/ui-tw/button/button.types';
2
2
  import React from 'react';
3
3
  declare const startIconVariants: (props?: ({
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
- size?: "xs" | "sm" | "md" | "lg" | null | undefined;
4
+ variant?: "primary" | "secondary" | "outline" | "ghost-primary" | "ghost-secondary" | "error-primary" | "warning-primary" | null | undefined;
5
+ size?: "xs" | "sm" | "md" | "lg" | "icon-xs" | "icon-sm" | "icon-md" | "icon-lg" | null | undefined;
6
6
  } & import("class-variance-authority/dist/types").ClassProp) | undefined) => string;
7
7
  declare const StartIcon: (props: StartIconProps) => React.JSX.Element | null;
8
8
  export { StartIcon, startIconVariants };
@@ -1,11 +1,13 @@
1
- import _extends from "@babel/runtime/helpers/extends";
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
3
  var _excluded = ["size", "variant", "icon", "loading"];
4
+ 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; }
5
+ 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; }
4
6
  import SpinnerIcon from '@scaleflex/icons-tw/spinner';
5
7
  import { buttonStartIconSizes, iconVariantOptions } from '@scaleflex/ui-tw/button/button.constants';
6
- import { getIconSizeInRem } from '@scaleflex/ui-tw/button/button.utils';
8
+ import { cn } from '@scaleflex/ui-tw/utils/cn';
7
9
  import { cva } from 'class-variance-authority';
8
- import React, { cloneElement, useMemo } from 'react';
10
+ import React, { cloneElement } from 'react';
9
11
  var startIconVariants = cva('', {
10
12
  variants: {
11
13
  variant: iconVariantOptions,
@@ -19,31 +21,16 @@ var StartIcon = function StartIcon(props) {
19
21
  _props$loading = props.loading,
20
22
  loading = _props$loading === void 0 ? false : _props$loading,
21
23
  rest = _objectWithoutProperties(props, _excluded);
22
- var sizeInRem = useMemo(function () {
23
- return getIconSizeInRem(size);
24
- }, [size]);
25
24
  if (!icon) return null;
26
- return /*#__PURE__*/React.createElement("span", _extends({
25
+ return loading ? /*#__PURE__*/React.createElement(SpinnerIcon, {
26
+ className: cn(startIconVariants({
27
+ size: size
28
+ }), 'animate-spin')
29
+ }) : (/*#__PURE__*/cloneElement(icon, _objectSpread({
27
30
  className: startIconVariants({
28
- size: size,
29
- className: 'flex'
31
+ variant: variant,
32
+ size: size
30
33
  })
31
- }, rest), loading ? /*#__PURE__*/React.createElement(SpinnerIcon, {
32
- size: sizeInRem,
33
- className: "animate-spin",
34
- style: {
35
- width: sizeInRem,
36
- height: sizeInRem
37
- }
38
- }) : (/*#__PURE__*/cloneElement(icon, {
39
- size: sizeInRem,
40
- style: {
41
- width: sizeInRem,
42
- height: sizeInRem
43
- },
44
- className: startIconVariants({
45
- variant: variant
46
- })
47
- })));
34
+ }, rest)));
48
35
  };
49
36
  export { StartIcon, startIconVariants };
package/button/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export { Button, buttonVariants } from './button.component';
2
2
  export type { ButtonProps } from './button.types';
3
3
  export { ButtonVariant, ButtonSize } from './button.constants';
4
+ export { CopyToClipboardButton } from './components/copy-to-clipboard-button';
package/button/index.js CHANGED
@@ -1,2 +1,3 @@
1
1
  export { Button, buttonVariants } from './button.component';
2
- export { ButtonVariant, ButtonSize } from './button.constants';
2
+ export { ButtonVariant, ButtonSize } from './button.constants';
3
+ export { CopyToClipboardButton } from './components/copy-to-clipboard-button';
@@ -2,7 +2,7 @@ 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
4
  var _excluded = ["className", "type", "size", "disabled", "readOnly"];
5
- import { getBaseInputClasses } from '@scaleflex/ui-tw/input/input.utils';
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';
@@ -32,7 +32,7 @@ function Input(_ref) {
32
32
  "data-slot": "input",
33
33
  disabled: disabled,
34
34
  readOnly: readOnly,
35
- className: cn.apply(void 0, ['flex w-full min-w-0'].concat(_toConsumableArray(getBaseInputClasses()), ['read-only:bg-secondary read-only:text-foreground read-only:cursor-default', 'selection:bg-primary selection:text-primary-foreground', inputVariants({
35
+ className: cn.apply(void 0, ['flex w-full min-w-0'].concat(_toConsumableArray(getBaseInputClasses()), [readOnlyClassNames, selectionHighlightClassNames, inputVariants({
36
36
  size: size,
37
37
  className: className
38
38
  })]))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scaleflex/ui-tw",
3
- "version": "0.0.27",
3
+ "version": "0.0.28",
4
4
  "author": "scaleflex",
5
5
  "repository": "github:scaleflex/ui",
6
6
  "homepage": "https://github.com/scaleflex/ui/blob/master/README.md",
@@ -19,7 +19,7 @@
19
19
  "@radix-ui/react-slot": "^1.1.2",
20
20
  "@radix-ui/react-switch": "^1.0.1",
21
21
  "@radix-ui/react-tooltip": "^1.2.6",
22
- "@scaleflex/icons-tw": "^0.0.27",
22
+ "@scaleflex/icons-tw": "^0.0.28",
23
23
  "@types/lodash.merge": "^4.6.9",
24
24
  "class-variance-authority": "^0.7.1",
25
25
  "lodash.merge": "^4.6.2",
@@ -0,0 +1,3 @@
1
+ export { Pill, pillVariants } from './pill.component';
2
+ export type { PillProps } from './pill.types';
3
+ export { pillSizeOptions, pillVariantOptions } from './pill.constants';
package/pill/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export { Pill, pillVariants } from './pill.component';
2
+ export { pillSizeOptions, pillVariantOptions } from './pill.constants';
@@ -0,0 +1,8 @@
1
+ import { PillProps } from '@scaleflex/ui-tw/pill/pill.types';
2
+ import React from 'react';
3
+ declare const pillVariants: (props?: ({
4
+ size?: "sm" | "md" | "lg" | null | undefined;
5
+ variant?: "outline" | "default" | null | undefined;
6
+ } & import("class-variance-authority/dist/types").ClassProp) | undefined) => string;
7
+ declare function Pill({ className, size, variant, removable, onRemove, ...props }: PillProps): React.JSX.Element;
8
+ export { Pill, pillVariants };
@@ -0,0 +1,58 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
+ var _excluded = ["className", "size", "variant", "removable", "onRemove"];
4
+ import { PillVariant, pillSizeOptions, pillVariantOptions, removePillSizeOptions, removePillVariantOptions } from '@scaleflex/ui-tw/pill/pill.constants';
5
+ import { getPillCrossIconClassName } from '@scaleflex/ui-tw/pill/pill.utils';
6
+ import { focusRingClassNames } from '@scaleflex/ui-tw/styles/shared-classes';
7
+ import { FormSize } from '@scaleflex/ui-tw/types/form-size';
8
+ import { cn } from '@scaleflex/ui-tw/utils/cn';
9
+ import { cva } from 'class-variance-authority';
10
+ import { X } from 'lucide-react';
11
+ import React from 'react';
12
+ var pillVariants = cva('', {
13
+ variants: {
14
+ size: pillSizeOptions,
15
+ variant: pillVariantOptions
16
+ },
17
+ defaultVariants: {
18
+ size: FormSize.Md,
19
+ variant: PillVariant.Default
20
+ }
21
+ });
22
+ var removePillVariants = cva('', {
23
+ variants: {
24
+ size: removePillSizeOptions,
25
+ variant: removePillVariantOptions
26
+ },
27
+ defaultVariants: {
28
+ size: FormSize.Md,
29
+ variant: PillVariant.Default
30
+ }
31
+ });
32
+ function Pill(_ref) {
33
+ var className = _ref.className,
34
+ size = _ref.size,
35
+ variant = _ref.variant,
36
+ removable = _ref.removable,
37
+ onRemove = _ref.onRemove,
38
+ props = _objectWithoutProperties(_ref, _excluded);
39
+ return /*#__PURE__*/React.createElement("div", _extends({
40
+ className: cn('border-input text-foreground border', 'inline-flex items-center rounded-full text-sm font-medium whitespace-nowrap shadow-xs transition-colors', pillVariants({
41
+ size: size,
42
+ variant: variant
43
+ }), className)
44
+ }, props), /*#__PURE__*/React.createElement("span", {
45
+ className: "select-none"
46
+ }, props.children), removable && /*#__PURE__*/React.createElement("button", {
47
+ type: "button",
48
+ onClick: onRemove,
49
+ className: cn('text-muted-foreground shrink-0 cursor-pointer transition-transform duration-150 ease-in-out active:scale-85', removePillVariants({
50
+ size: size,
51
+ variant: variant
52
+ }), focusRingClassNames),
53
+ "aria-label": "Remove"
54
+ }, /*#__PURE__*/React.createElement(X, {
55
+ className: getPillCrossIconClassName(size)
56
+ })));
57
+ }
58
+ export { Pill, pillVariants };
@@ -0,0 +1,22 @@
1
+ export declare const PillVariant: {
2
+ readonly Default: "default";
3
+ readonly Outline: "outline";
4
+ };
5
+ export declare const pillSizeOptions: {
6
+ readonly sm: "h-6 px-2 text-xs gap-1";
7
+ readonly md: "h-8 px-2.5 text-sm gap-1";
8
+ readonly lg: "h-10 px-3 text-base gap-1";
9
+ };
10
+ export declare const pillVariantOptions: {
11
+ readonly default: "bg-secondary";
12
+ readonly outline: "";
13
+ };
14
+ export declare const removePillSizeOptions: {
15
+ sm: string;
16
+ md: string;
17
+ lg: string;
18
+ };
19
+ export declare const removePillVariantOptions: {
20
+ default: string;
21
+ outline: string;
22
+ };
@@ -0,0 +1,10 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+ import { FormSize } from '@scaleflex/ui-tw/types/form-size';
3
+ export var PillVariant = {
4
+ Default: 'default',
5
+ Outline: 'outline'
6
+ };
7
+ export var pillSizeOptions = _defineProperty(_defineProperty(_defineProperty({}, FormSize.Sm, 'h-6 px-2 text-xs gap-1'), FormSize.Md, 'h-8 px-2.5 text-sm gap-1'), FormSize.Lg, 'h-10 px-3 text-base gap-1');
8
+ export var pillVariantOptions = _defineProperty(_defineProperty({}, PillVariant.Default, 'bg-secondary'), PillVariant.Outline, '');
9
+ export var removePillSizeOptions = _defineProperty(_defineProperty(_defineProperty({}, FormSize.Sm, 'p-0.25 -mr-0.25 rounded-sm'), FormSize.Md, 'p-0.5 -mr-0.5 rounded-md'), FormSize.Lg, 'p-0.75 -mr-0.75 rounded-md');
10
+ export var removePillVariantOptions = _defineProperty(_defineProperty({}, PillVariant.Default, 'hover:bg-muted-foreground/10'), PillVariant.Outline, 'hover:bg-muted/70');
@@ -0,0 +1,7 @@
1
+ import { pillVariants } from '@scaleflex/ui-tw/pill/pill.component';
2
+ import type { VariantProps } from 'class-variance-authority';
3
+ import { ComponentProps } from 'react';
4
+ export interface PillProps extends ComponentProps<'div'>, VariantProps<typeof pillVariants> {
5
+ removable?: boolean;
6
+ onRemove?: () => void;
7
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ import { FormSizeType } from '@scaleflex/ui-tw/types/form-size';
2
+ export declare const getPillCrossIconClassName: (size?: FormSizeType | null) => "size-3" | "size-4" | "size-5";
@@ -0,0 +1,16 @@
1
+ import { FormSize } from '@scaleflex/ui-tw/types/form-size';
2
+ export var getPillCrossIconClassName = function getPillCrossIconClassName(size) {
3
+ if (!size) {
4
+ return 'size-4';
5
+ }
6
+ switch (size) {
7
+ case FormSize.Sm:
8
+ return 'size-3';
9
+ case FormSize.Md:
10
+ return 'size-4';
11
+ case FormSize.Lg:
12
+ return 'size-5';
13
+ default:
14
+ return 'size-4';
15
+ }
16
+ };
@@ -11,11 +11,11 @@ var _excluded = ["className", "size", "children", "readOnly", "icon"],
11
11
  _excluded7 = ["className"];
12
12
  import * as SelectPrimitive from '@radix-ui/react-select';
13
13
  import { inputSizeOptions } from '@scaleflex/ui-tw/input/input.constants';
14
- import { getBaseInputClasses } from '@scaleflex/ui-tw/input/input.utils';
15
14
  import { LabelIcon } from '@scaleflex/ui-tw/label/components/label-icon';
16
15
  import { SelectIcon } from '@scaleflex/ui-tw/select/components/select-icon';
17
16
  import { selectLabelSizeOptions } from '@scaleflex/ui-tw/select/select.constants';
18
17
  import { getOptionInGroupPaddingLeft } from '@scaleflex/ui-tw/select/select.utils';
18
+ import { getBaseInputClasses } from '@scaleflex/ui-tw/styles/shared-classes';
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';
@@ -67,7 +67,7 @@ function SelectTrigger(_ref4) {
67
67
  return /*#__PURE__*/React.createElement(SelectPrimitive.Trigger, _extends({
68
68
  "data-slot": "select-trigger",
69
69
  "data-size": size,
70
- className: cn.apply(void 0, ['flex w-full cursor-pointer items-center justify-between gap-2 px-3 py-2 text-sm whitespace-nowrap'].concat(_toConsumableArray(getBaseInputClasses()), ['data-[placeholder]:text-muted-foreground/80 hover:border-secondary-foreground/50', "[&_svg:not([class*='text-'])]:text-muted-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4", selectTriggerVariants({
70
+ className: cn.apply(void 0, ['flex w-full cursor-pointer items-center justify-between gap-2 px-3 py-2 text-sm whitespace-nowrap', 'data-[placeholder]:text-muted-foreground/80 hover:border-secondary-foreground/50', "[&_svg:not([class*='text-'])]:text-muted-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4"].concat(_toConsumableArray(getBaseInputClasses()), [selectTriggerVariants({
71
71
  size: size,
72
72
  className: className
73
73
  }), readOnly && 'bg-secondary text-foreground pointer-events-none cursor-default disabled:opacity-100', className]))
@@ -0,0 +1,4 @@
1
+ export declare const focusRingClassNames = "focus-visible:ring-ring ring-offset-background focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none";
2
+ export declare const selectionHighlightClassNames = "selection:bg-primary selection:text-primary-foreground";
3
+ export declare const readOnlyClassNames = "read-only:bg-secondary read-only:text-foreground read-only:cursor-default";
4
+ export declare const getBaseInputClasses: () => string[];
@@ -0,0 +1,6 @@
1
+ export var focusRingClassNames = 'focus-visible:ring-ring ring-offset-background focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none';
2
+ export var selectionHighlightClassNames = 'selection:bg-primary selection:text-primary-foreground';
3
+ export var readOnlyClassNames = 'read-only:bg-secondary read-only:text-foreground read-only:cursor-default';
4
+ export var getBaseInputClasses = function getBaseInputClasses() {
5
+ 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', 'aria-invalid:ring-destructive/20 aria-invalid:border-destructive hover:aria-invalid:border-destructive/60 focus-visible:aria-invalid:border-destructive', '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', focusRingClassNames];
6
+ };
@@ -33,6 +33,7 @@
33
33
 
34
34
  --color-success: var(--success);
35
35
  --color-success-foreground: var(--success-foreground);
36
+ --color-success-10: var(--success-10);
36
37
  --color-info: var(--info);
37
38
  --color-info-foreground: var(--info-foreground);
38
39
  --color-warning: var(--warning);
@@ -16,6 +16,7 @@
16
16
 
17
17
  --success: oklch(0.637 0.17 151.295);
18
18
  --success-foreground: oklch(0.429 0.107 154.754);
19
+ --success-10: oklch(0.978 0.025 163.82);
19
20
  --destructive: oklch(0.577 0.215 27.325);
20
21
  --destructive-foreground: oklch(0.472 0.173 26.157);
21
22
  --destructive-10: oklch(0.967 0.016 17.438);
@@ -74,6 +75,7 @@
74
75
 
75
76
  --success: oklch(0.6 0.2 154.83);
76
77
  --success-foreground: oklch(0.2 0.1 165.45);
78
+ --success-10: oklch(0.2 0.01 163.82);
77
79
  --destructive: oklch(0.55 0.2 27.325);
78
80
  --destructive-foreground: oklch(0.704 0.183 22.984);
79
81
  --destructive-10: oklch(0.2 0.01 17.438);
@@ -2,6 +2,7 @@ import _extends from "@babel/runtime/helpers/extends";
2
2
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
3
  var _excluded = ["className", "size"];
4
4
  import * as SwitchPrimitive from '@radix-ui/react-switch';
5
+ import { focusRingClassNames } from '@scaleflex/ui-tw/styles/shared-classes';
5
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';
@@ -30,7 +31,7 @@ function Switch(_ref) {
30
31
  props = _objectWithoutProperties(_ref, _excluded);
31
32
  return /*#__PURE__*/React.createElement(SwitchPrimitive.Root, _extends({
32
33
  "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', 'hover:opacity-80 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
+ className: cn('peer inline-flex shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent shadow-xs transition-all outline-none', 'hover:opacity-80 disabled:cursor-not-allowed disabled:opacity-50', 'data-[state=checked]:bg-primary data-[state=unchecked]:bg-input', focusRingClassNames, switchVariants({
34
35
  size: size
35
36
  }), className)
36
37
  }, props), /*#__PURE__*/React.createElement(SwitchPrimitive.Thumb, {
@@ -0,0 +1,3 @@
1
+ import { LeftToolbarButtonsProps } from '@scaleflex/ui-tw/textarea/textarea.types';
2
+ import React from 'react';
3
+ export declare const LeftToolbarButtons: (props: LeftToolbarButtonsProps) => React.JSX.Element;
@@ -0,0 +1,23 @@
1
+ import { SparkleIcon } from '@scaleflex/icons-tw/sparkle-icon';
2
+ import { Button } from '@scaleflex/ui-tw/button';
3
+ import React from 'react';
4
+ import { getToolbarSizes } from '../textarea.utils';
5
+ export var LeftToolbarButtons = function LeftToolbarButtons(props) {
6
+ var size = props.size,
7
+ onGenerate = props.onGenerate,
8
+ onClearAll = props.onClearAll;
9
+ var _getToolbarSizes = getToolbarSizes(size),
10
+ buttonSize = _getToolbarSizes.buttonSize;
11
+ return /*#__PURE__*/React.createElement(React.Fragment, null, onGenerate && /*#__PURE__*/React.createElement(Button, {
12
+ variant: "ghost-primary",
13
+ size: buttonSize,
14
+ startIcon: /*#__PURE__*/React.createElement(SparkleIcon, {
15
+ className: "size-3.5"
16
+ }),
17
+ onClick: onGenerate
18
+ }, "Generate"), onClearAll && /*#__PURE__*/React.createElement(Button, {
19
+ variant: "ghost-secondary",
20
+ size: buttonSize,
21
+ onClick: onClearAll
22
+ }, "Clear all"));
23
+ };
@@ -0,0 +1,3 @@
1
+ import { RightToolbarButtonsProps } from '@scaleflex/ui-tw/textarea/textarea.types';
2
+ import React from 'react';
3
+ export declare const RightToolbarButtons: (props: RightToolbarButtonsProps) => React.JSX.Element;
@@ -0,0 +1,28 @@
1
+ import { Button } from '@scaleflex/ui-tw/button';
2
+ import { CopyToClipboardButton } from '@scaleflex/ui-tw/button/components/copy-to-clipboard-button';
3
+ import { WithTooltip } from '@scaleflex/ui-tw/tooltip';
4
+ import { Languages } from 'lucide-react';
5
+ import React from 'react';
6
+ import { getToolbarSizes } from '../textarea.utils';
7
+ export var RightToolbarButtons = function RightToolbarButtons(props) {
8
+ var size = props.size,
9
+ textToCopy = props.textToCopy,
10
+ translateActionTooltip = props.translateActionTooltip,
11
+ initialCopyActionTooltip = props.initialCopyActionTooltip,
12
+ copiedActionTooltip = props.copiedActionTooltip,
13
+ onTranslate = props.onTranslate;
14
+ var _getToolbarSizes = getToolbarSizes(size),
15
+ iconSize = _getToolbarSizes.iconSize;
16
+ return /*#__PURE__*/React.createElement(React.Fragment, null, onTranslate && /*#__PURE__*/React.createElement(WithTooltip, {
17
+ content: translateActionTooltip
18
+ }, /*#__PURE__*/React.createElement(Button, {
19
+ variant: "ghost-primary",
20
+ size: iconSize,
21
+ onClick: onTranslate
22
+ }, /*#__PURE__*/React.createElement(Languages, null))), textToCopy && /*#__PURE__*/React.createElement(CopyToClipboardButton, {
23
+ size: iconSize,
24
+ text: textToCopy,
25
+ initialTooltip: initialCopyActionTooltip,
26
+ copiedTooltip: copiedActionTooltip
27
+ }));
28
+ };
@@ -0,0 +1,4 @@
1
+ import { TextareaWithActionsProps } from '@scaleflex/ui-tw/textarea/textarea.types';
2
+ import React from 'react';
3
+ declare function TextareaWithActions({ leftToolbar, rightToolbar, className, ...textareaProps }: TextareaWithActionsProps): React.JSX.Element;
4
+ export { TextareaWithActions };
@@ -0,0 +1,37 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
+ var _excluded = ["leftToolbar", "rightToolbar", "className"];
4
+ import { textareaWithActionsSizeOptions } 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
+ import { Textarea } from '../';
10
+ var textareaWithActionsVariants = cva('', {
11
+ variants: {
12
+ size: textareaWithActionsSizeOptions
13
+ },
14
+ defaultVariants: {
15
+ size: FormSize.Md
16
+ }
17
+ });
18
+ function TextareaWithActions(_ref) {
19
+ var leftToolbar = _ref.leftToolbar,
20
+ rightToolbar = _ref.rightToolbar,
21
+ className = _ref.className,
22
+ textareaProps = _objectWithoutProperties(_ref, _excluded);
23
+ var _ref2 = textareaProps || {},
24
+ size = _ref2.size;
25
+ return /*#__PURE__*/React.createElement("div", {
26
+ className: "relative"
27
+ }, /*#__PURE__*/React.createElement(Textarea, _extends({}, textareaProps, {
28
+ className: cn(className, textareaWithActionsVariants({
29
+ size: size
30
+ }))
31
+ })), leftToolbar && /*#__PURE__*/React.createElement("div", {
32
+ className: "absolute bottom-1.5 left-1.5 flex items-center gap-0.5"
33
+ }, leftToolbar), rightToolbar && /*#__PURE__*/React.createElement("div", {
34
+ className: "absolute right-1.5 bottom-1.5 flex items-center gap-0.5"
35
+ }, rightToolbar));
36
+ }
37
+ export { TextareaWithActions };
@@ -1,2 +1,5 @@
1
1
  export { Textarea, textareaVariants } from './textarea.component';
2
+ export { TextareaWithActions } from './components/textarea-with-actions';
3
+ export { RightToolbarButtons } from './components/right-toolbar-buttons';
4
+ export { LeftToolbarButtons } from './components/left-toolbar-buttons';
2
5
  export type { TextareaProps } from './textarea.types';
package/textarea/index.js CHANGED
@@ -1 +1,4 @@
1
- export { Textarea, textareaVariants } from './textarea.component';
1
+ export { Textarea, textareaVariants } from './textarea.component';
2
+ export { TextareaWithActions } from './components/textarea-with-actions';
3
+ export { RightToolbarButtons } from './components/right-toolbar-buttons';
4
+ export { LeftToolbarButtons } from './components/left-toolbar-buttons';
@@ -1,6 +1,7 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
3
  var _excluded = ["className", "size", "disabled", "readOnly"];
4
+ import { focusRingClassNames, getBaseInputClasses, readOnlyClassNames, selectionHighlightClassNames } from '@scaleflex/ui-tw/styles/shared-classes';
4
5
  import { FormSize } from '@scaleflex/ui-tw/types/form-size';
5
6
  import { cn } from '@scaleflex/ui-tw/utils/cn';
6
7
  import { cva } from 'class-variance-authority';
@@ -27,10 +28,9 @@ function Textarea(_ref) {
27
28
  "data-slot": "textarea",
28
29
  disabled: disabled,
29
30
  readOnly: readOnly,
30
- className: cn('field-sizing-content resize-y', 'border-input text-foreground bg-background flex w-full rounded-md border shadow-xs transition-[color,box-shadow] outline-none', 'focus-visible:border-secondary-foreground/50 placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground hover:border-secondary-foreground/50 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 hover:aria-invalid:border-destructive/60 focus-visible:aria-invalid:border-destructive', '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', textareaVariants({
31
- size: size,
32
- className: className
33
- }))
31
+ className: cn('flex field-sizing-content w-full resize-y', getBaseInputClasses(), readOnlyClassNames, selectionHighlightClassNames, focusRingClassNames, textareaVariants({
32
+ size: size
33
+ }), className)
34
34
  }, props));
35
35
  }
36
36
  export { Textarea, textareaVariants };
@@ -3,3 +3,8 @@ export declare const textareaSizeOptions: {
3
3
  readonly md: "py-3 px-4 text-base min-h-16 max-h-48";
4
4
  readonly lg: "py-3 px-4 text-lg min-h-20 max-h-60";
5
5
  };
6
+ export declare const textareaWithActionsSizeOptions: {
7
+ readonly sm: "pb-10";
8
+ readonly md: "pb-12";
9
+ readonly lg: "pb-14";
10
+ };
@@ -1,3 +1,4 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
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');
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');
4
+ export var textareaWithActionsSizeOptions = _defineProperty(_defineProperty(_defineProperty({}, FormSize.Sm, 'pb-10'), FormSize.Md, 'pb-12'), FormSize.Lg, 'pb-14');
@@ -1,6 +1,23 @@
1
1
  import { FormSizeType } from '@scaleflex/ui-tw/types/form-size';
2
- import { ComponentProps } from 'react';
2
+ import { ComponentProps, ReactElement } from 'react';
3
3
  export interface TextareaProps extends Omit<ComponentProps<'textarea'>, 'size'> {
4
4
  size?: FormSizeType;
5
5
  'aria-invalid'?: boolean;
6
6
  }
7
+ export interface TextareaWithActionsProps extends TextareaProps {
8
+ leftToolbar?: ReactElement;
9
+ rightToolbar?: ReactElement;
10
+ }
11
+ export interface RightToolbarButtonsProps {
12
+ size?: FormSizeType;
13
+ textToCopy?: string;
14
+ initialCopyActionTooltip?: string;
15
+ copiedActionTooltip?: string;
16
+ translateActionTooltip?: string;
17
+ onTranslate?: () => void;
18
+ }
19
+ export interface LeftToolbarButtonsProps {
20
+ size?: FormSizeType;
21
+ onGenerate?: () => void;
22
+ onClearAll?: () => void;
23
+ }
@@ -0,0 +1,8 @@
1
+ import { FormSizeType } from '@scaleflex/ui-tw/types/form-size';
2
+ export declare const getToolbarSizes: (textareaSize?: FormSizeType) => {
3
+ buttonSize: "xs";
4
+ iconSize: "icon-xs";
5
+ } | {
6
+ buttonSize: "sm";
7
+ iconSize: "icon-sm";
8
+ };
@@ -0,0 +1,18 @@
1
+ import { ButtonSize } from '@scaleflex/ui-tw/button';
2
+ import { FormSize } from '@scaleflex/ui-tw/types/form-size';
3
+ export var getToolbarSizes = function getToolbarSizes(textareaSize) {
4
+ switch (textareaSize) {
5
+ case FormSize.Sm:
6
+ return {
7
+ buttonSize: ButtonSize.Xs,
8
+ iconSize: ButtonSize.IconXs
9
+ };
10
+ case FormSize.Md:
11
+ case FormSize.Lg:
12
+ default:
13
+ return {
14
+ buttonSize: ButtonSize.Sm,
15
+ iconSize: ButtonSize.IconSm
16
+ };
17
+ }
18
+ };
@@ -6,5 +6,5 @@ declare function TooltipProvider({ delayDuration, ...props }: ComponentProps<typ
6
6
  declare function Tooltip({ ...props }: ComponentProps<typeof TooltipPrimitive.Root>): React.JSX.Element;
7
7
  declare function TooltipTrigger({ ...props }: ComponentProps<typeof TooltipPrimitive.Trigger>): React.JSX.Element;
8
8
  declare function TooltipContent({ className, sideOffset, children, variant, ...props }: TooltipContentProps): React.JSX.Element;
9
- declare function WithTooltip({ variant, content, children, ...otherProps }: WithTooltipProps): React.JSX.Element;
9
+ declare function WithTooltip({ variant, content, children, delayDuration, open, ...otherProps }: WithTooltipProps): React.JSX.Element;
10
10
  export { Tooltip, TooltipTrigger, TooltipContent, TooltipProvider, WithTooltip };
@@ -3,7 +3,7 @@ import _extends from "@babel/runtime/helpers/extends";
3
3
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
4
4
  var _excluded = ["delayDuration"],
5
5
  _excluded2 = ["className", "sideOffset", "children", "variant"],
6
- _excluded3 = ["variant", "content", "children"];
6
+ _excluded3 = ["variant", "content", "children", "delayDuration", "open"];
7
7
  import * as TooltipPrimitive from '@radix-ui/react-tooltip';
8
8
  import { cn } from '@scaleflex/ui-tw/utils/cn';
9
9
  import { cva } from 'class-variance-authority';
@@ -58,9 +58,14 @@ function WithTooltip(_ref5) {
58
58
  var variant = _ref5.variant,
59
59
  content = _ref5.content,
60
60
  children = _ref5.children,
61
+ delayDuration = _ref5.delayDuration,
62
+ open = _ref5.open,
61
63
  otherProps = _objectWithoutProperties(_ref5, _excluded3);
62
64
  if (!content) return children;
63
- return /*#__PURE__*/React.createElement(Tooltip, null, /*#__PURE__*/React.createElement(TooltipTrigger, {
65
+ return /*#__PURE__*/React.createElement(Tooltip, {
66
+ open: open,
67
+ delayDuration: delayDuration || 700
68
+ }, /*#__PURE__*/React.createElement(TooltipTrigger, {
64
69
  asChild: true
65
70
  }, children), /*#__PURE__*/React.createElement(TooltipContent, _extends({
66
71
  variant: variant
@@ -2,9 +2,11 @@ export declare const TooltipVariant: {
2
2
  readonly Default: "default";
3
3
  readonly Error: "error";
4
4
  readonly Warning: "warning";
5
+ readonly Success: "success";
5
6
  };
6
7
  export declare const tooltipVariantOptions: {
7
8
  readonly default: "bg-muted text-foreground";
8
9
  readonly warning: "bg-warning-10 text-warning-foreground";
9
10
  readonly error: "bg-destructive-10 text-destructive-foreground";
11
+ readonly success: "bg-success-10 text-success-foreground";
10
12
  };
@@ -2,6 +2,7 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  export var TooltipVariant = {
3
3
  Default: 'default',
4
4
  Error: 'error',
5
- Warning: 'warning'
5
+ Warning: 'warning',
6
+ Success: 'success'
6
7
  };
7
- export var tooltipVariantOptions = _defineProperty(_defineProperty(_defineProperty({}, TooltipVariant.Default, 'bg-muted text-foreground'), TooltipVariant.Warning, 'bg-warning-10 text-warning-foreground'), TooltipVariant.Error, 'bg-destructive-10 text-destructive-foreground');
8
+ export var tooltipVariantOptions = _defineProperty(_defineProperty(_defineProperty(_defineProperty({}, TooltipVariant.Default, 'bg-muted text-foreground'), TooltipVariant.Warning, 'bg-warning-10 text-warning-foreground'), TooltipVariant.Error, 'bg-destructive-10 text-destructive-foreground'), TooltipVariant.Success, 'bg-success-10 text-success-foreground');
@@ -3,9 +3,11 @@ import { ComponentProps, ReactElement } from 'react';
3
3
  import { TooltipVariant } from './tooltip.constants';
4
4
  export type TooltipVariantType = (typeof TooltipVariant)[keyof typeof TooltipVariant];
5
5
  export interface WithTooltipProps extends Omit<ComponentProps<typeof TooltipPrimitive.Content>, 'content'> {
6
- content?: ReactElement | undefined | string;
7
6
  children: ReactElement;
7
+ open?: boolean;
8
+ content?: ReactElement | undefined | string;
8
9
  variant?: TooltipVariantType;
10
+ delayDuration?: number;
9
11
  }
10
12
  export interface TooltipContentProps extends ComponentProps<typeof TooltipPrimitive.Content> {
11
13
  variant?: TooltipVariantType;
@@ -1 +0,0 @@
1
- export declare const getBaseInputClasses: () => string[];
@@ -1,3 +0,0 @@
1
- export var getBaseInputClasses = function getBaseInputClasses() {
2
- 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:ring-ring ring-offset-background focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none', 'aria-invalid:ring-destructive/20 aria-invalid:border-destructive hover:aria-invalid:border-destructive/60 focus-visible:aria-invalid:border-destructive', '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'];
3
- };