@scaleflex/ui-tw 0.0.26 → 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 (71) 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/form/components/form-select-field.component.d.ts +5 -0
  16. package/form/components/form-select-field.component.js +86 -0
  17. package/form/form.types.d.ts +30 -0
  18. package/form/form.utils.d.ts +2 -0
  19. package/form/form.utils.js +3 -0
  20. package/form/index.d.ts +3 -0
  21. package/form/index.js +4 -1
  22. package/input/input.component.js +4 -2
  23. package/input/input.constants.d.ts +1 -1
  24. package/input/input.constants.js +1 -1
  25. package/package.json +3 -2
  26. package/pill/index.d.ts +3 -0
  27. package/pill/index.js +2 -0
  28. package/pill/pill.component.d.ts +8 -0
  29. package/pill/pill.component.js +58 -0
  30. package/pill/pill.constants.d.ts +22 -0
  31. package/pill/pill.constants.js +10 -0
  32. package/pill/pill.types.d.ts +7 -0
  33. package/pill/pill.types.js +1 -0
  34. package/pill/pill.utils.d.ts +2 -0
  35. package/pill/pill.utils.js +16 -0
  36. package/select/components/select-icon.d.ts +2 -0
  37. package/select/components/select-icon.js +22 -0
  38. package/select/index.d.ts +1 -0
  39. package/select/index.js +1 -0
  40. package/select/select.component.d.ts +14 -0
  41. package/select/select.component.js +165 -0
  42. package/select/select.constants.d.ts +5 -0
  43. package/select/select.constants.js +3 -0
  44. package/select/select.types.d.ts +22 -0
  45. package/select/select.types.js +1 -0
  46. package/select/select.utils.d.ts +3 -0
  47. package/select/select.utils.js +28 -0
  48. package/styles/shared-classes.d.ts +4 -0
  49. package/styles/shared-classes.js +6 -0
  50. package/styles/theme-map.css +1 -0
  51. package/styles/variables.css +4 -0
  52. package/switch/switch.component.js +2 -1
  53. package/textarea/components/left-toolbar-buttons.d.ts +3 -0
  54. package/textarea/components/left-toolbar-buttons.js +23 -0
  55. package/textarea/components/right-toolbar-buttons.d.ts +3 -0
  56. package/textarea/components/right-toolbar-buttons.js +28 -0
  57. package/textarea/components/textarea-with-actions.d.ts +4 -0
  58. package/textarea/components/textarea-with-actions.js +37 -0
  59. package/textarea/index.d.ts +3 -0
  60. package/textarea/index.js +4 -1
  61. package/textarea/textarea.component.js +4 -4
  62. package/textarea/textarea.constants.d.ts +5 -0
  63. package/textarea/textarea.constants.js +2 -1
  64. package/textarea/textarea.types.d.ts +18 -1
  65. package/textarea/textarea.utils.d.ts +8 -0
  66. package/textarea/textarea.utils.js +18 -0
  67. package/tooltip/tooltip.component.d.ts +1 -1
  68. package/tooltip/tooltip.component.js +10 -9
  69. package/tooltip/tooltip.constants.d.ts +2 -0
  70. package/tooltip/tooltip.constants.js +3 -2
  71. package/tooltip/tooltip.types.d.ts +3 -1
@@ -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';
@@ -41,7 +41,7 @@ var tooltipVariants = cva('', {
41
41
  function TooltipContent(_ref4) {
42
42
  var className = _ref4.className,
43
43
  _ref4$sideOffset = _ref4.sideOffset,
44
- sideOffset = _ref4$sideOffset === void 0 ? 0 : _ref4$sideOffset,
44
+ sideOffset = _ref4$sideOffset === void 0 ? 6 : _ref4$sideOffset,
45
45
  children = _ref4.children,
46
46
  _ref4$variant = _ref4.variant,
47
47
  variant = _ref4$variant === void 0 ? TooltipVariant.Default : _ref4$variant,
@@ -49,22 +49,23 @@ function TooltipContent(_ref4) {
49
49
  return /*#__PURE__*/React.createElement(TooltipPrimitive.Portal, null, /*#__PURE__*/React.createElement(TooltipPrimitive.Content, _extends({
50
50
  "data-slot": "tooltip-content",
51
51
  sideOffset: sideOffset,
52
- className: cn('animate-in fade-in-0 zoom-in-95 text-md z-50 w-fit max-w-lg origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-2', 'data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2', 'data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95', tooltipVariants({
52
+ className: cn('animate-in fade-in-0 zoom-in-95 text-md shadow-shadow z-50 w-fit max-w-lg origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-2 shadow-sm', 'data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2', 'data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95', tooltipVariants({
53
53
  variant: variant
54
54
  }), className)
55
- }, props), children, /*#__PURE__*/React.createElement(TooltipPrimitive.Arrow, {
56
- className: cn('z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px] fill-transparent', tooltipVariants({
57
- variant: variant
58
- }))
59
- })));
55
+ }, props), children));
60
56
  }
61
57
  function WithTooltip(_ref5) {
62
58
  var variant = _ref5.variant,
63
59
  content = _ref5.content,
64
60
  children = _ref5.children,
61
+ delayDuration = _ref5.delayDuration,
62
+ open = _ref5.open,
65
63
  otherProps = _objectWithoutProperties(_ref5, _excluded3);
66
64
  if (!content) return children;
67
- 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, {
68
69
  asChild: true
69
70
  }, children), /*#__PURE__*/React.createElement(TooltipContent, _extends({
70
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;