@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.
- package/button/button.component.d.ts +3 -3
- package/button/button.component.js +17 -13
- package/button/button.constants.d.ts +32 -26
- package/button/button.constants.js +13 -13
- package/button/button.utils.d.ts +2 -0
- package/button/button.utils.js +5 -1
- package/button/components/copy-to-clipboard-button.d.ts +10 -0
- package/button/components/copy-to-clipboard-button.js +76 -0
- package/button/components/end-icon.d.ts +1 -2
- package/button/components/end-icon.js +6 -14
- package/button/components/start-icon.d.ts +2 -2
- package/button/components/start-icon.js +13 -26
- package/button/index.d.ts +1 -0
- package/button/index.js +2 -1
- package/form/components/form-select-field.component.d.ts +5 -0
- package/form/components/form-select-field.component.js +86 -0
- package/form/form.types.d.ts +30 -0
- package/form/form.utils.d.ts +2 -0
- package/form/form.utils.js +3 -0
- package/form/index.d.ts +3 -0
- package/form/index.js +4 -1
- package/input/input.component.js +4 -2
- package/input/input.constants.d.ts +1 -1
- package/input/input.constants.js +1 -1
- package/package.json +3 -2
- package/pill/index.d.ts +3 -0
- package/pill/index.js +2 -0
- package/pill/pill.component.d.ts +8 -0
- package/pill/pill.component.js +58 -0
- package/pill/pill.constants.d.ts +22 -0
- package/pill/pill.constants.js +10 -0
- package/pill/pill.types.d.ts +7 -0
- package/pill/pill.types.js +1 -0
- package/pill/pill.utils.d.ts +2 -0
- package/pill/pill.utils.js +16 -0
- package/select/components/select-icon.d.ts +2 -0
- package/select/components/select-icon.js +22 -0
- package/select/index.d.ts +1 -0
- package/select/index.js +1 -0
- package/select/select.component.d.ts +14 -0
- package/select/select.component.js +165 -0
- package/select/select.constants.d.ts +5 -0
- package/select/select.constants.js +3 -0
- package/select/select.types.d.ts +22 -0
- package/select/select.types.js +1 -0
- package/select/select.utils.d.ts +3 -0
- package/select/select.utils.js +28 -0
- package/styles/shared-classes.d.ts +4 -0
- package/styles/shared-classes.js +6 -0
- package/styles/theme-map.css +1 -0
- package/styles/variables.css +4 -0
- package/switch/switch.component.js +2 -1
- package/textarea/components/left-toolbar-buttons.d.ts +3 -0
- package/textarea/components/left-toolbar-buttons.js +23 -0
- package/textarea/components/right-toolbar-buttons.d.ts +3 -0
- package/textarea/components/right-toolbar-buttons.js +28 -0
- package/textarea/components/textarea-with-actions.d.ts +4 -0
- package/textarea/components/textarea-with-actions.js +37 -0
- package/textarea/index.d.ts +3 -0
- package/textarea/index.js +4 -1
- package/textarea/textarea.component.js +4 -4
- package/textarea/textarea.constants.d.ts +5 -0
- package/textarea/textarea.constants.js +2 -1
- package/textarea/textarea.types.d.ts +18 -1
- package/textarea/textarea.utils.d.ts +8 -0
- package/textarea/textarea.utils.js +18 -0
- package/tooltip/tooltip.component.d.ts +1 -1
- package/tooltip/tooltip.component.js +10 -9
- package/tooltip/tooltip.constants.d.ts +2 -0
- package/tooltip/tooltip.constants.js +3 -2
- package/tooltip/tooltip.types.d.ts +3 -1
|
@@ -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" | "
|
|
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
|
|
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,
|
|
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
|
|
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 (
|
|
43
|
-
createRipple(e,
|
|
47
|
+
if (localRef.current) {
|
|
48
|
+
createRipple(e, localRef.current);
|
|
44
49
|
}
|
|
45
50
|
};
|
|
46
51
|
return /*#__PURE__*/React.createElement(Comp, _extends({
|
|
47
|
-
ref:
|
|
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', '
|
|
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
|
|
30
|
-
readonly
|
|
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 "
|
|
43
|
-
readonly "
|
|
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 "
|
|
56
|
-
readonly "
|
|
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
|
-
|
|
17
|
-
|
|
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 =
|
|
26
|
-
export var buttonVariantOptions =
|
|
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];
|
package/button/button.utils.d.ts
CHANGED
|
@@ -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;
|
package/button/button.utils.js
CHANGED
|
@@ -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
|
|
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
|
|
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
|
|
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__*/
|
|
21
|
+
return /*#__PURE__*/cloneElement(icon, _objectSpread({
|
|
24
22
|
className: endIconVariants({
|
|
25
23
|
size: size,
|
|
26
24
|
variant: variant
|
|
27
25
|
})
|
|
28
|
-
}, rest)
|
|
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" | "
|
|
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
|
|
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 {
|
|
8
|
+
import { cn } from '@scaleflex/ui-tw/utils/cn';
|
|
7
9
|
import { cva } from 'class-variance-authority';
|
|
8
|
-
import React, { cloneElement
|
|
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(
|
|
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
|
-
|
|
29
|
-
|
|
31
|
+
variant: variant,
|
|
32
|
+
size: size
|
|
30
33
|
})
|
|
31
|
-
}, rest)
|
|
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
package/button/index.js
CHANGED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { FieldValues, Path } from 'react-hook-form';
|
|
3
|
+
import { FormSelectFieldProps } from '../form.types';
|
|
4
|
+
declare function FormSelectField<TFieldValues extends FieldValues, TName extends Path<TFieldValues>>({ selectProps, ...rest }: FormSelectFieldProps<TFieldValues, TName>): React.JSX.Element;
|
|
5
|
+
export { FormSelectField };
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
+
var _excluded = ["icon", "placeholder", "options"],
|
|
4
|
+
_excluded2 = ["selectProps"];
|
|
5
|
+
import { isOptionGroup, useFormField } from '@scaleflex/ui-tw/form';
|
|
6
|
+
import { FormFieldGroup } from '@scaleflex/ui-tw/form';
|
|
7
|
+
import { Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectSeparator, SelectTrigger, SelectValue } from '@scaleflex/ui-tw/select';
|
|
8
|
+
import React from 'react';
|
|
9
|
+
function FormSelectInner(_ref) {
|
|
10
|
+
var field = _ref.field,
|
|
11
|
+
args = _ref.args,
|
|
12
|
+
selectProps = _ref.selectProps,
|
|
13
|
+
readOnly = _ref.readOnly,
|
|
14
|
+
disabled = _ref.disabled,
|
|
15
|
+
className = _ref.className;
|
|
16
|
+
var _useFormField = useFormField(),
|
|
17
|
+
error = _useFormField.error,
|
|
18
|
+
formItemId = _useFormField.formItemId;
|
|
19
|
+
var _ref2 = selectProps || {},
|
|
20
|
+
icon = _ref2.icon,
|
|
21
|
+
placeholder = _ref2.placeholder,
|
|
22
|
+
options = _ref2.options,
|
|
23
|
+
restSelectProps = _objectWithoutProperties(_ref2, _excluded);
|
|
24
|
+
return /*#__PURE__*/React.createElement(Select, _extends({
|
|
25
|
+
onValueChange: readOnly ? undefined : field.onChange,
|
|
26
|
+
defaultValue: field.value,
|
|
27
|
+
disabled: disabled || readOnly
|
|
28
|
+
}, restSelectProps), /*#__PURE__*/React.createElement(SelectTrigger, {
|
|
29
|
+
id: formItemId,
|
|
30
|
+
"aria-invalid": !!error,
|
|
31
|
+
size: args === null || args === void 0 ? void 0 : args.size,
|
|
32
|
+
readOnly: readOnly,
|
|
33
|
+
className: className,
|
|
34
|
+
icon: icon
|
|
35
|
+
}, /*#__PURE__*/React.createElement(SelectValue, {
|
|
36
|
+
placeholder: placeholder !== null && placeholder !== void 0 ? placeholder : 'Select'
|
|
37
|
+
})), /*#__PURE__*/React.createElement(SelectContent, null, options === null || options === void 0 ? void 0 : options.map(function (option, groupIndex) {
|
|
38
|
+
if (isOptionGroup(option)) {
|
|
39
|
+
return /*#__PURE__*/React.createElement(SelectGroup, {
|
|
40
|
+
key: groupIndex
|
|
41
|
+
}, option.label && /*#__PURE__*/React.createElement(SelectLabel, {
|
|
42
|
+
size: args === null || args === void 0 ? void 0 : args.size
|
|
43
|
+
}, option.label), option.options.map(function (_ref3) {
|
|
44
|
+
var label = _ref3.label,
|
|
45
|
+
value = _ref3.value,
|
|
46
|
+
disabled = _ref3.disabled,
|
|
47
|
+
icon = _ref3.icon,
|
|
48
|
+
tooltip = _ref3.tooltip;
|
|
49
|
+
return /*#__PURE__*/React.createElement(SelectItem, {
|
|
50
|
+
key: value,
|
|
51
|
+
value: value,
|
|
52
|
+
disabled: disabled,
|
|
53
|
+
size: args === null || args === void 0 ? void 0 : args.size,
|
|
54
|
+
icon: icon,
|
|
55
|
+
tooltip: tooltip,
|
|
56
|
+
isGroup: !!option.label
|
|
57
|
+
}, label);
|
|
58
|
+
}), groupIndex !== options.length - 1 && /*#__PURE__*/React.createElement(SelectSeparator, null));
|
|
59
|
+
}
|
|
60
|
+
return /*#__PURE__*/React.createElement(SelectGroup, {
|
|
61
|
+
key: "default"
|
|
62
|
+
}, /*#__PURE__*/React.createElement(SelectItem, {
|
|
63
|
+
value: option.value,
|
|
64
|
+
disabled: option.disabled,
|
|
65
|
+
size: args === null || args === void 0 ? void 0 : args.size,
|
|
66
|
+
icon: option.icon,
|
|
67
|
+
tooltip: option.tooltip
|
|
68
|
+
}, option.label));
|
|
69
|
+
})));
|
|
70
|
+
}
|
|
71
|
+
function FormSelectField(_ref4) {
|
|
72
|
+
var selectProps = _ref4.selectProps,
|
|
73
|
+
rest = _objectWithoutProperties(_ref4, _excluded2);
|
|
74
|
+
var readOnly = rest.readOnly,
|
|
75
|
+
disabled = rest.disabled;
|
|
76
|
+
return /*#__PURE__*/React.createElement(FormFieldGroup, rest, function (field, args) {
|
|
77
|
+
return /*#__PURE__*/React.createElement(FormSelectInner, {
|
|
78
|
+
field: field,
|
|
79
|
+
args: args,
|
|
80
|
+
selectProps: selectProps,
|
|
81
|
+
readOnly: readOnly,
|
|
82
|
+
disabled: disabled
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
export { FormSelectField };
|
package/form/form.types.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { InputProps } from '@scaleflex/ui-tw/input';
|
|
2
|
+
import { SelectProps } from '@scaleflex/ui-tw/select/select.types';
|
|
2
3
|
import { SwitchProps } from '@scaleflex/ui-tw/switch/switch.types';
|
|
3
4
|
import { TextareaProps } from '@scaleflex/ui-tw/textarea';
|
|
4
5
|
import { FormSizeType } from '@scaleflex/ui-tw/types/form-size';
|
|
@@ -45,3 +46,32 @@ export type FormInputFieldProps<TFieldValues extends FieldValues, TName extends
|
|
|
45
46
|
export type FormTextareaFieldProps<TFieldValues extends FieldValues, TName extends Path<TFieldValues>> = Omit<FormFieldGroupProps<TFieldValues, TName>, 'children'> & {
|
|
46
47
|
textareaProps?: TextareaProps;
|
|
47
48
|
};
|
|
49
|
+
export interface FlatOption {
|
|
50
|
+
label: ReactElement | string;
|
|
51
|
+
value: string;
|
|
52
|
+
disabled?: boolean;
|
|
53
|
+
icon?: ReactElement;
|
|
54
|
+
tooltip?: ReactElement | string;
|
|
55
|
+
}
|
|
56
|
+
export interface OptionGroup {
|
|
57
|
+
label?: ReactElement | string;
|
|
58
|
+
options: FlatOption[];
|
|
59
|
+
}
|
|
60
|
+
export type SelectOption = FlatOption | OptionGroup;
|
|
61
|
+
export type FormSelectProps = SelectProps & {
|
|
62
|
+
options: SelectOption[];
|
|
63
|
+
placeholder?: string;
|
|
64
|
+
icon?: ReactElement;
|
|
65
|
+
};
|
|
66
|
+
export type FormSelectFieldProps<TFieldValues extends FieldValues, TName extends Path<TFieldValues>> = Omit<FormFieldGroupProps<TFieldValues, TName>, 'children'> & {
|
|
67
|
+
icon?: ReactElement;
|
|
68
|
+
selectProps?: FormSelectProps;
|
|
69
|
+
};
|
|
70
|
+
export interface FormSelectInnerProps<TFieldValues extends FieldValues, TName extends Path<TFieldValues>> {
|
|
71
|
+
field: ControllerRenderProps<TFieldValues, TName>;
|
|
72
|
+
args: FormFieldArgs | undefined;
|
|
73
|
+
selectProps?: FormSelectProps;
|
|
74
|
+
readOnly?: boolean;
|
|
75
|
+
disabled?: boolean;
|
|
76
|
+
className?: string;
|
|
77
|
+
}
|
package/form/index.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
export { Form, FormItem, FormLabel, FormControl, FormDescription, FormMessage, FormField, useFormField, } from './form.component';
|
|
2
|
+
export { isOptionGroup } from './form.utils';
|
|
3
|
+
export { SelectOption, FlatOption, OptionGroup } from './form.types';
|
|
2
4
|
export { FormFieldGroup } from './components/form-field-group.component';
|
|
3
5
|
export { FormInputField } from './components/form-input-field.component';
|
|
4
6
|
export { FormPasswordField } from './components/form-password-field.component';
|
|
5
7
|
export { FormTextareaField } from './components/form-textarea-field.component';
|
|
6
8
|
export { FormSwitchField } from './components/form-switch-field.component';
|
|
9
|
+
export { FormSelectField } from './components/form-select-field.component';
|
package/form/index.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
export { Form, FormItem, FormLabel, FormControl, FormDescription, FormMessage, FormField, useFormField } from './form.component';
|
|
2
|
+
export { isOptionGroup } from './form.utils';
|
|
3
|
+
export { SelectOption, FlatOption, OptionGroup } from './form.types';
|
|
2
4
|
export { FormFieldGroup } from './components/form-field-group.component';
|
|
3
5
|
export { FormInputField } from './components/form-input-field.component';
|
|
4
6
|
export { FormPasswordField } from './components/form-password-field.component';
|
|
5
7
|
export { FormTextareaField } from './components/form-textarea-field.component';
|
|
6
|
-
export { FormSwitchField } from './components/form-switch-field.component';
|
|
8
|
+
export { FormSwitchField } from './components/form-switch-field.component';
|
|
9
|
+
export { FormSelectField } from './components/form-select-field.component';
|