@scaleflex/ui-tw 0.0.127 → 0.0.128
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/breadcrumb/breadcrumb.component.d.ts +2 -2
- package/breadcrumb/breadcrumb.component.js +13 -4
- package/breadcrumb/breadcrumb.constants.d.ts +11 -0
- package/breadcrumb/breadcrumb.constants.js +27 -0
- package/breadcrumb/breadcrumb.types.d.ts +3 -0
- package/breadcrumb/index.d.ts +2 -0
- package/breadcrumb/index.js +2 -1
- package/button/components/copy-button.d.ts +13 -0
- package/button/components/copy-button.js +78 -0
- package/button/components/copy-to-clipboard-button.d.ts +9 -2
- package/button/components/copy-to-clipboard-button.js +17 -4
- package/button/index.d.ts +4 -1
- package/button/index.js +2 -1
- package/copyable-text/copyable-text.component.d.ts +4 -0
- package/copyable-text/copyable-text.component.js +86 -0
- package/copyable-text/copyable-text.types.d.ts +13 -0
- package/copyable-text/copyable-text.types.js +1 -0
- package/copyable-text/index.d.ts +2 -0
- package/copyable-text/index.js +1 -0
- package/dialog/dialog.component.d.ts +2 -4
- package/dialog/dialog.component.js +7 -3
- package/dialog/dialog.constants.d.ts +3 -0
- package/dialog/dialog.constants.js +11 -0
- package/dialog/dialog.types.d.ts +4 -0
- package/dialog/index.d.ts +2 -2
- package/dialog/index.js +1 -1
- package/package.json +2 -2
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { BreadcrumbEllipsisProps, BreadcrumbItemProps, BreadcrumbLinkProps, BreadcrumbListProps, BreadcrumbPageProps, BreadcrumbProps, BreadcrumbSeparatorProps } from './breadcrumb.types';
|
|
3
3
|
declare function Breadcrumb({ className, ...props }: BreadcrumbProps): React.JSX.Element;
|
|
4
|
-
declare function BreadcrumbList({ className, ...props }: BreadcrumbListProps): React.JSX.Element;
|
|
4
|
+
declare function BreadcrumbList({ className, size, ...props }: BreadcrumbListProps): React.JSX.Element;
|
|
5
5
|
declare function BreadcrumbItem({ className, ...props }: BreadcrumbItemProps): React.JSX.Element;
|
|
6
6
|
declare function BreadcrumbLink({ asChild, className, ...props }: BreadcrumbLinkProps): React.JSX.Element;
|
|
7
7
|
declare function BreadcrumbPage({ className, ...props }: BreadcrumbPageProps): React.JSX.Element;
|
|
8
|
-
declare function BreadcrumbSeparator({ children, className, ...props }: BreadcrumbSeparatorProps): React.JSX.Element;
|
|
8
|
+
declare function BreadcrumbSeparator({ children, className, size, ...props }: BreadcrumbSeparatorProps): React.JSX.Element;
|
|
9
9
|
declare function BreadcrumbEllipsis({ className, ...props }: BreadcrumbEllipsisProps): React.JSX.Element;
|
|
10
10
|
export { Breadcrumb, BreadcrumbList, BreadcrumbItem, BreadcrumbLink, BreadcrumbPage, BreadcrumbSeparator, BreadcrumbEllipsis, };
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
3
|
var _excluded = ["className"],
|
|
4
|
-
_excluded2 = ["className"],
|
|
4
|
+
_excluded2 = ["className", "size"],
|
|
5
5
|
_excluded3 = ["className"],
|
|
6
6
|
_excluded4 = ["asChild", "className"],
|
|
7
7
|
_excluded5 = ["className"],
|
|
8
|
-
_excluded6 = ["children", "className"],
|
|
8
|
+
_excluded6 = ["children", "className", "size"],
|
|
9
9
|
_excluded7 = ["className"];
|
|
10
10
|
import { Slot } from '@radix-ui/react-slot';
|
|
11
11
|
import { cn } from '@scaleflex/ui-tw/utils/cn';
|
|
12
12
|
import { ChevronRightIcon, MoreHorizontalIcon } from 'lucide-react';
|
|
13
13
|
import React from 'react';
|
|
14
|
+
import { breadcrumbListVariants, breadcrumbSeparatorVariants } from './breadcrumb.constants';
|
|
14
15
|
function Breadcrumb(_ref) {
|
|
15
16
|
var className = _ref.className,
|
|
16
17
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
@@ -22,10 +23,14 @@ function Breadcrumb(_ref) {
|
|
|
22
23
|
}
|
|
23
24
|
function BreadcrumbList(_ref2) {
|
|
24
25
|
var className = _ref2.className,
|
|
26
|
+
_ref2$size = _ref2.size,
|
|
27
|
+
size = _ref2$size === void 0 ? 'md' : _ref2$size,
|
|
25
28
|
props = _objectWithoutProperties(_ref2, _excluded2);
|
|
26
29
|
return /*#__PURE__*/React.createElement("ol", _extends({
|
|
27
30
|
"data-slot": "breadcrumb-list",
|
|
28
|
-
className: cn(
|
|
31
|
+
className: cn(breadcrumbListVariants({
|
|
32
|
+
size: size
|
|
33
|
+
}), className)
|
|
29
34
|
}, props));
|
|
30
35
|
}
|
|
31
36
|
function BreadcrumbItem(_ref3) {
|
|
@@ -60,12 +65,16 @@ function BreadcrumbPage(_ref5) {
|
|
|
60
65
|
function BreadcrumbSeparator(_ref6) {
|
|
61
66
|
var children = _ref6.children,
|
|
62
67
|
className = _ref6.className,
|
|
68
|
+
_ref6$size = _ref6.size,
|
|
69
|
+
size = _ref6$size === void 0 ? 'md' : _ref6$size,
|
|
63
70
|
props = _objectWithoutProperties(_ref6, _excluded6);
|
|
64
71
|
return /*#__PURE__*/React.createElement("li", _extends({
|
|
65
72
|
"data-slot": "breadcrumb-separator",
|
|
66
73
|
role: "presentation",
|
|
67
74
|
"aria-hidden": "true",
|
|
68
|
-
className: cn(
|
|
75
|
+
className: cn(breadcrumbSeparatorVariants({
|
|
76
|
+
size: size
|
|
77
|
+
}), className)
|
|
69
78
|
}, props), children !== null && children !== void 0 ? children : /*#__PURE__*/React.createElement(ChevronRightIcon, null));
|
|
70
79
|
}
|
|
71
80
|
function BreadcrumbEllipsis(_ref7) {
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare const BreadcrumbSize: {
|
|
2
|
+
readonly Md: "md";
|
|
3
|
+
readonly Lg: "lg";
|
|
4
|
+
};
|
|
5
|
+
export type BreadcrumbSizeType = (typeof BreadcrumbSize)[keyof typeof BreadcrumbSize];
|
|
6
|
+
export declare const breadcrumbListVariants: (props?: ({
|
|
7
|
+
size?: "md" | "lg" | null | undefined;
|
|
8
|
+
} & import("class-variance-authority/dist/types").ClassProp) | undefined) => string;
|
|
9
|
+
export declare const breadcrumbSeparatorVariants: (props?: ({
|
|
10
|
+
size?: "md" | "lg" | null | undefined;
|
|
11
|
+
} & import("class-variance-authority/dist/types").ClassProp) | undefined) => string;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { cva } from 'class-variance-authority';
|
|
2
|
+
export var BreadcrumbSize = {
|
|
3
|
+
Md: 'md',
|
|
4
|
+
Lg: 'lg'
|
|
5
|
+
};
|
|
6
|
+
export var breadcrumbListVariants = cva('text-muted-foreground flex flex-wrap items-center gap-1.5 break-words sm:gap-2.5', {
|
|
7
|
+
variants: {
|
|
8
|
+
size: {
|
|
9
|
+
md: 'text-sm',
|
|
10
|
+
lg: 'text-base'
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
defaultVariants: {
|
|
14
|
+
size: 'md'
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
export var breadcrumbSeparatorVariants = cva('', {
|
|
18
|
+
variants: {
|
|
19
|
+
size: {
|
|
20
|
+
md: '[&>svg]:size-3.5',
|
|
21
|
+
lg: '[&>svg]:size-4'
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
defaultVariants: {
|
|
25
|
+
size: 'md'
|
|
26
|
+
}
|
|
27
|
+
});
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import type { ComponentProps } from 'react';
|
|
2
|
+
import type { BreadcrumbSizeType } from './breadcrumb.constants';
|
|
2
3
|
export interface BreadcrumbProps extends ComponentProps<'nav'> {
|
|
3
4
|
separator?: React.ReactNode;
|
|
4
5
|
}
|
|
5
6
|
export interface BreadcrumbListProps extends ComponentProps<'ol'> {
|
|
7
|
+
size?: BreadcrumbSizeType;
|
|
6
8
|
}
|
|
7
9
|
export interface BreadcrumbItemProps extends ComponentProps<'li'> {
|
|
8
10
|
}
|
|
@@ -12,6 +14,7 @@ export interface BreadcrumbLinkProps extends ComponentProps<'a'> {
|
|
|
12
14
|
export interface BreadcrumbPageProps extends ComponentProps<'span'> {
|
|
13
15
|
}
|
|
14
16
|
export interface BreadcrumbSeparatorProps extends ComponentProps<'li'> {
|
|
17
|
+
size?: BreadcrumbSizeType;
|
|
15
18
|
}
|
|
16
19
|
export interface BreadcrumbEllipsisProps extends ComponentProps<'span'> {
|
|
17
20
|
}
|
package/breadcrumb/index.d.ts
CHANGED
|
@@ -1,2 +1,4 @@
|
|
|
1
1
|
export { Breadcrumb, BreadcrumbList, BreadcrumbItem, BreadcrumbLink, BreadcrumbPage, BreadcrumbSeparator, BreadcrumbEllipsis, } from './breadcrumb.component';
|
|
2
|
+
export { BreadcrumbSize, breadcrumbListVariants, breadcrumbSeparatorVariants } from './breadcrumb.constants';
|
|
3
|
+
export type { BreadcrumbSizeType } from './breadcrumb.constants';
|
|
2
4
|
export type { BreadcrumbProps, BreadcrumbListProps, BreadcrumbItemProps, BreadcrumbLinkProps, BreadcrumbPageProps, BreadcrumbSeparatorProps, BreadcrumbEllipsisProps, } from './breadcrumb.types';
|
package/breadcrumb/index.js
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export { Breadcrumb, BreadcrumbList, BreadcrumbItem, BreadcrumbLink, BreadcrumbPage, BreadcrumbSeparator, BreadcrumbEllipsis } from './breadcrumb.component';
|
|
1
|
+
export { Breadcrumb, BreadcrumbList, BreadcrumbItem, BreadcrumbLink, BreadcrumbPage, BreadcrumbSeparator, BreadcrumbEllipsis } from './breadcrumb.component';
|
|
2
|
+
export { BreadcrumbSize, breadcrumbListVariants, breadcrumbSeparatorVariants } from './breadcrumb.constants';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ButtonProps } from '@scaleflex/ui-tw/button/button.types';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
export interface CopyButtonProps extends Omit<ButtonProps, 'onClick'> {
|
|
4
|
+
/** Text to copy to clipboard */
|
|
5
|
+
textToCopy: string;
|
|
6
|
+
/** Tooltip message shown after copying (default: "Copied!") */
|
|
7
|
+
copiedMessage?: string;
|
|
8
|
+
/** How long to show the tooltip in ms (default: 2000) */
|
|
9
|
+
tooltipDuration?: number;
|
|
10
|
+
/** Callback after successful copy */
|
|
11
|
+
onCopy?: () => void;
|
|
12
|
+
}
|
|
13
|
+
export declare function CopyButton({ textToCopy, copiedMessage, tooltipDuration, onCopy, children, disabled, ...buttonProps }: CopyButtonProps): React.JSX.Element;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
3
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
4
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
5
|
+
var _excluded = ["textToCopy", "copiedMessage", "tooltipDuration", "onCopy", "children", "disabled"];
|
|
6
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
7
|
+
import { Button } from '@scaleflex/ui-tw/button';
|
|
8
|
+
import { WithTooltip } from '@scaleflex/ui-tw/tooltip';
|
|
9
|
+
import React, { useState } from 'react';
|
|
10
|
+
export function CopyButton(_ref) {
|
|
11
|
+
var textToCopy = _ref.textToCopy,
|
|
12
|
+
_ref$copiedMessage = _ref.copiedMessage,
|
|
13
|
+
copiedMessage = _ref$copiedMessage === void 0 ? 'Copied!' : _ref$copiedMessage,
|
|
14
|
+
_ref$tooltipDuration = _ref.tooltipDuration,
|
|
15
|
+
tooltipDuration = _ref$tooltipDuration === void 0 ? 2000 : _ref$tooltipDuration,
|
|
16
|
+
onCopy = _ref.onCopy,
|
|
17
|
+
children = _ref.children,
|
|
18
|
+
disabled = _ref.disabled,
|
|
19
|
+
buttonProps = _objectWithoutProperties(_ref, _excluded);
|
|
20
|
+
var _useState = useState(''),
|
|
21
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
22
|
+
tooltipText = _useState2[0],
|
|
23
|
+
setTooltipText = _useState2[1];
|
|
24
|
+
var _useState3 = useState('default'),
|
|
25
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
26
|
+
tooltipVariant = _useState4[0],
|
|
27
|
+
setTooltipVariant = _useState4[1];
|
|
28
|
+
var _useState5 = useState(false),
|
|
29
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
30
|
+
open = _useState6[0],
|
|
31
|
+
setOpen = _useState6[1];
|
|
32
|
+
var handleCopy = /*#__PURE__*/function () {
|
|
33
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
34
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
35
|
+
while (1) switch (_context.prev = _context.next) {
|
|
36
|
+
case 0:
|
|
37
|
+
_context.prev = 0;
|
|
38
|
+
_context.next = 3;
|
|
39
|
+
return navigator.clipboard.writeText(textToCopy);
|
|
40
|
+
case 3:
|
|
41
|
+
setTooltipText(copiedMessage);
|
|
42
|
+
setTooltipVariant('success');
|
|
43
|
+
setOpen(true);
|
|
44
|
+
onCopy === null || onCopy === void 0 || onCopy();
|
|
45
|
+
setTimeout(function () {
|
|
46
|
+
setOpen(false);
|
|
47
|
+
}, tooltipDuration - 500);
|
|
48
|
+
setTimeout(function () {
|
|
49
|
+
setTooltipText('');
|
|
50
|
+
setTooltipVariant('default');
|
|
51
|
+
}, tooltipDuration);
|
|
52
|
+
_context.next = 14;
|
|
53
|
+
break;
|
|
54
|
+
case 11:
|
|
55
|
+
_context.prev = 11;
|
|
56
|
+
_context.t0 = _context["catch"](0);
|
|
57
|
+
console.error('Failed to copy', _context.t0);
|
|
58
|
+
case 14:
|
|
59
|
+
case "end":
|
|
60
|
+
return _context.stop();
|
|
61
|
+
}
|
|
62
|
+
}, _callee, null, [[0, 11]]);
|
|
63
|
+
}));
|
|
64
|
+
return function handleCopy() {
|
|
65
|
+
return _ref2.apply(this, arguments);
|
|
66
|
+
};
|
|
67
|
+
}();
|
|
68
|
+
return /*#__PURE__*/React.createElement(WithTooltip, {
|
|
69
|
+
content: tooltipText,
|
|
70
|
+
variant: tooltipVariant,
|
|
71
|
+
open: open ? true : undefined
|
|
72
|
+
}, /*#__PURE__*/React.createElement(Button, _extends({
|
|
73
|
+
"data-slot": "copy-button",
|
|
74
|
+
type: "button",
|
|
75
|
+
onClick: handleCopy,
|
|
76
|
+
disabled: disabled || !textToCopy
|
|
77
|
+
}, buttonProps), children));
|
|
78
|
+
}
|
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
import type { ButtonSizeType } from '@scaleflex/ui-tw/button/button.types';
|
|
2
2
|
import React from 'react';
|
|
3
|
-
export interface
|
|
3
|
+
export interface CopyIconProps {
|
|
4
4
|
text: string;
|
|
5
5
|
disabled?: boolean;
|
|
6
6
|
size?: ButtonSizeType;
|
|
7
7
|
initialTooltip?: string;
|
|
8
8
|
copiedTooltip?: string;
|
|
9
9
|
}
|
|
10
|
-
|
|
10
|
+
/** @deprecated Use CopyIcon instead */
|
|
11
|
+
export type CopyToClipboardButtonProps = CopyIconProps;
|
|
12
|
+
export declare function CopyIcon(props: CopyIconProps): React.JSX.Element;
|
|
13
|
+
/**
|
|
14
|
+
* @deprecated Use `CopyIcon` for icon-only copy button, or `CopyButton` for custom content.
|
|
15
|
+
* Import from '@scaleflex/ui-tw/button'
|
|
16
|
+
*/
|
|
17
|
+
export declare function CopyToClipboardButton(props: CopyIconProps): React.JSX.Element;
|
|
@@ -4,9 +4,11 @@ import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
|
4
4
|
import { Button, ButtonSize } from '@scaleflex/ui-tw/button';
|
|
5
5
|
import { WithTooltip } from '@scaleflex/ui-tw/tooltip';
|
|
6
6
|
import { Copy } from 'lucide-react';
|
|
7
|
-
import { useState } from 'react';
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
import React, { useState } from 'react';
|
|
8
|
+
|
|
9
|
+
/** @deprecated Use CopyIcon instead */
|
|
10
|
+
|
|
11
|
+
export function CopyIcon(props) {
|
|
10
12
|
var text = props.text,
|
|
11
13
|
_props$size = props.size,
|
|
12
14
|
size = _props$size === void 0 ? ButtonSize.IconMd : _props$size,
|
|
@@ -74,4 +76,15 @@ export var CopyToClipboardButton = function CopyToClipboardButton(props) {
|
|
|
74
76
|
onClick: handleCopy,
|
|
75
77
|
disabled: disabled || !text
|
|
76
78
|
}, /*#__PURE__*/React.createElement(Copy, null)));
|
|
77
|
-
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* @deprecated Use `CopyIcon` for icon-only copy button, or `CopyButton` for custom content.
|
|
83
|
+
* Import from '@scaleflex/ui-tw/button'
|
|
84
|
+
*/
|
|
85
|
+
export function CopyToClipboardButton(props) {
|
|
86
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
87
|
+
console.warn('[Deprecation Warning] CopyToClipboardButton is deprecated. ' + 'Use CopyIcon for icon-only copy button, or CopyButton for custom content. ' + "Import from '@scaleflex/ui-tw/button'.");
|
|
88
|
+
}
|
|
89
|
+
return /*#__PURE__*/React.createElement(CopyIcon, props);
|
|
90
|
+
}
|
package/button/index.d.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
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';
|
|
4
|
+
export { CopyIcon, CopyToClipboardButton } from './components/copy-to-clipboard-button';
|
|
5
|
+
export type { CopyIconProps, CopyToClipboardButtonProps } from './components/copy-to-clipboard-button';
|
|
6
|
+
export { CopyButton } from './components/copy-button';
|
|
7
|
+
export type { CopyButtonProps } from './components/copy-button';
|
package/button/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export { Button, buttonVariants } from './button.component';
|
|
2
2
|
export { ButtonVariant, ButtonSize } from './button.constants';
|
|
3
|
-
export { CopyToClipboardButton } from './components/copy-to-clipboard-button';
|
|
3
|
+
export { CopyIcon, CopyToClipboardButton } from './components/copy-to-clipboard-button';
|
|
4
|
+
export { CopyButton } from './components/copy-button';
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { CopyableTextProps } from './copyable-text.types';
|
|
3
|
+
declare function CopyableText({ value, textToCopy, copiedMessage, tooltipDuration, onCopy, className, ...props }: CopyableTextProps): React.JSX.Element;
|
|
4
|
+
export { CopyableText };
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
3
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
4
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
5
|
+
var _excluded = ["value", "textToCopy", "copiedMessage", "tooltipDuration", "onCopy", "className"];
|
|
6
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
7
|
+
import { WithTooltip } from '@scaleflex/ui-tw/tooltip';
|
|
8
|
+
import { cn } from '@scaleflex/ui-tw/utils/cn';
|
|
9
|
+
import { Copy } from 'lucide-react';
|
|
10
|
+
import React, { useState } from 'react';
|
|
11
|
+
function CopyableText(_ref) {
|
|
12
|
+
var value = _ref.value,
|
|
13
|
+
textToCopy = _ref.textToCopy,
|
|
14
|
+
_ref$copiedMessage = _ref.copiedMessage,
|
|
15
|
+
copiedMessage = _ref$copiedMessage === void 0 ? 'Copied!' : _ref$copiedMessage,
|
|
16
|
+
_ref$tooltipDuration = _ref.tooltipDuration,
|
|
17
|
+
tooltipDuration = _ref$tooltipDuration === void 0 ? 2000 : _ref$tooltipDuration,
|
|
18
|
+
onCopy = _ref.onCopy,
|
|
19
|
+
className = _ref.className,
|
|
20
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
21
|
+
var _useState = useState(''),
|
|
22
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
23
|
+
tooltipText = _useState2[0],
|
|
24
|
+
setTooltipText = _useState2[1];
|
|
25
|
+
var _useState3 = useState('default'),
|
|
26
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
27
|
+
tooltipVariant = _useState4[0],
|
|
28
|
+
setTooltipVariant = _useState4[1];
|
|
29
|
+
var _useState5 = useState(false),
|
|
30
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
31
|
+
open = _useState6[0],
|
|
32
|
+
setOpen = _useState6[1];
|
|
33
|
+
var handleCopy = /*#__PURE__*/function () {
|
|
34
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
35
|
+
var text;
|
|
36
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
37
|
+
while (1) switch (_context.prev = _context.next) {
|
|
38
|
+
case 0:
|
|
39
|
+
_context.prev = 0;
|
|
40
|
+
text = textToCopy !== null && textToCopy !== void 0 ? textToCopy : typeof value === 'string' ? value : '';
|
|
41
|
+
_context.next = 4;
|
|
42
|
+
return navigator.clipboard.writeText(text);
|
|
43
|
+
case 4:
|
|
44
|
+
setTooltipText(copiedMessage);
|
|
45
|
+
setTooltipVariant('success');
|
|
46
|
+
setOpen(true);
|
|
47
|
+
onCopy === null || onCopy === void 0 || onCopy();
|
|
48
|
+
setTimeout(function () {
|
|
49
|
+
setOpen(false);
|
|
50
|
+
}, tooltipDuration - 500);
|
|
51
|
+
setTimeout(function () {
|
|
52
|
+
setTooltipText('');
|
|
53
|
+
setTooltipVariant('default');
|
|
54
|
+
}, tooltipDuration);
|
|
55
|
+
_context.next = 15;
|
|
56
|
+
break;
|
|
57
|
+
case 12:
|
|
58
|
+
_context.prev = 12;
|
|
59
|
+
_context.t0 = _context["catch"](0);
|
|
60
|
+
console.error('Failed to copy', _context.t0);
|
|
61
|
+
case 15:
|
|
62
|
+
case "end":
|
|
63
|
+
return _context.stop();
|
|
64
|
+
}
|
|
65
|
+
}, _callee, null, [[0, 12]]);
|
|
66
|
+
}));
|
|
67
|
+
return function handleCopy() {
|
|
68
|
+
return _ref2.apply(this, arguments);
|
|
69
|
+
};
|
|
70
|
+
}();
|
|
71
|
+
return /*#__PURE__*/React.createElement("div", _extends({
|
|
72
|
+
"data-slot": "copyable-text",
|
|
73
|
+
className: cn('group inline-flex items-center gap-1', className)
|
|
74
|
+
}, props), /*#__PURE__*/React.createElement("span", null, value), /*#__PURE__*/React.createElement(WithTooltip, {
|
|
75
|
+
content: tooltipText,
|
|
76
|
+
variant: tooltipVariant,
|
|
77
|
+
open: open ? true : undefined
|
|
78
|
+
}, /*#__PURE__*/React.createElement("button", {
|
|
79
|
+
type: "button",
|
|
80
|
+
onClick: handleCopy,
|
|
81
|
+
className: "text-muted-foreground hover:text-foreground cursor-pointer opacity-0 transition-opacity group-hover:opacity-100"
|
|
82
|
+
}, /*#__PURE__*/React.createElement(Copy, {
|
|
83
|
+
className: "size-3.5"
|
|
84
|
+
}))));
|
|
85
|
+
}
|
|
86
|
+
export { CopyableText };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ComponentProps, ReactNode } from 'react';
|
|
2
|
+
export interface CopyableTextProps extends Omit<ComponentProps<'div'>, 'children'> {
|
|
3
|
+
/** Text to display and copy */
|
|
4
|
+
value: string | ReactNode;
|
|
5
|
+
/** Text to copy (if different from displayed value) */
|
|
6
|
+
textToCopy?: string;
|
|
7
|
+
/** Copied tooltip message */
|
|
8
|
+
copiedMessage?: string;
|
|
9
|
+
/** Tooltip duration in ms */
|
|
10
|
+
tooltipDuration?: number;
|
|
11
|
+
/** Callback after successful copy */
|
|
12
|
+
onCopy?: () => void;
|
|
13
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { CopyableText } from './copyable-text.component';
|
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
import * as DialogPrimitive from '@radix-ui/react-dialog';
|
|
2
2
|
import React, { type ComponentProps } from 'react';
|
|
3
|
-
import type { DialogWideHeaderProps, DialogWideTitleProps } from './dialog.types';
|
|
3
|
+
import type { DialogWideContentProps, DialogWideHeaderProps, DialogWideTitleProps } from './dialog.types';
|
|
4
4
|
declare function Dialog({ ...props }: ComponentProps<typeof DialogPrimitive.Root>): React.JSX.Element;
|
|
5
5
|
declare function DialogTrigger({ ...props }: ComponentProps<typeof DialogPrimitive.Trigger>): React.JSX.Element;
|
|
6
6
|
declare function DialogPortal({ ...props }: ComponentProps<typeof DialogPrimitive.Portal>): React.JSX.Element;
|
|
7
7
|
declare function DialogClose({ ...props }: ComponentProps<typeof DialogPrimitive.Close>): React.JSX.Element;
|
|
8
8
|
declare function DialogOverlay({ className, ...props }: ComponentProps<typeof DialogPrimitive.Overlay>): React.JSX.Element;
|
|
9
|
-
declare function DialogWideContent({ className, children, overlayClassName, ...props }:
|
|
10
|
-
overlayClassName?: string;
|
|
11
|
-
}): React.JSX.Element;
|
|
9
|
+
declare function DialogWideContent({ className, children, overlayClassName, headerSize, ...props }: DialogWideContentProps): React.JSX.Element;
|
|
12
10
|
declare function DialogFormContent({ className, children, overlayClassName, ...props }: ComponentProps<typeof DialogPrimitive.Content> & {
|
|
13
11
|
overlayClassName?: string;
|
|
14
12
|
}): React.JSX.Element;
|
|
@@ -2,7 +2,7 @@ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProper
|
|
|
2
2
|
import _objectDestructuringEmpty from "@babel/runtime/helpers/objectDestructuringEmpty";
|
|
3
3
|
import _extends from "@babel/runtime/helpers/extends";
|
|
4
4
|
var _excluded = ["className"],
|
|
5
|
-
_excluded2 = ["className", "children", "overlayClassName"],
|
|
5
|
+
_excluded2 = ["className", "children", "overlayClassName", "headerSize"],
|
|
6
6
|
_excluded3 = ["className", "children", "overlayClassName"],
|
|
7
7
|
_excluded4 = ["className", "size"],
|
|
8
8
|
_excluded5 = ["className"],
|
|
@@ -22,7 +22,7 @@ import { focusRingClassNames } from '@scaleflex/ui-tw/styles/shared-classes';
|
|
|
22
22
|
import { cn } from '@scaleflex/ui-tw/utils/cn';
|
|
23
23
|
import { CircleAlertIcon, XIcon } from 'lucide-react';
|
|
24
24
|
import React from 'react';
|
|
25
|
-
import { dialogWideHeaderVariants, dialogWideTitleVariants } from './dialog.constants';
|
|
25
|
+
import { dialogCloseButtonPositionVariants, dialogWideHeaderVariants, dialogWideTitleVariants } from './dialog.constants';
|
|
26
26
|
function Dialog(_ref) {
|
|
27
27
|
var props = _extends({}, (_objectDestructuringEmpty(_ref), _ref));
|
|
28
28
|
return /*#__PURE__*/React.createElement(DialogPrimitive.Root, _extends({
|
|
@@ -59,6 +59,8 @@ function DialogWideContent(_ref6) {
|
|
|
59
59
|
var className = _ref6.className,
|
|
60
60
|
children = _ref6.children,
|
|
61
61
|
overlayClassName = _ref6.overlayClassName,
|
|
62
|
+
_ref6$headerSize = _ref6.headerSize,
|
|
63
|
+
headerSize = _ref6$headerSize === void 0 ? 'md' : _ref6$headerSize,
|
|
62
64
|
props = _objectWithoutProperties(_ref6, _excluded2);
|
|
63
65
|
return /*#__PURE__*/React.createElement(DialogPortal, {
|
|
64
66
|
"data-slot": "dialog-portal"
|
|
@@ -70,7 +72,9 @@ function DialogWideContent(_ref6) {
|
|
|
70
72
|
}, props), children, /*#__PURE__*/React.createElement(DialogPrimitive.Close, {
|
|
71
73
|
"data-state": "open",
|
|
72
74
|
asChild: true,
|
|
73
|
-
className: cn('text-muted-foreground/70 hover:text-muted-foreground absolute
|
|
75
|
+
className: cn('text-muted-foreground/70 hover:text-muted-foreground absolute right-3 cursor-pointer rounded-xs transition-opacity disabled:pointer-events-none', "[&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-5", dialogCloseButtonPositionVariants({
|
|
76
|
+
headerSize: headerSize
|
|
77
|
+
}), focusRingClassNames)
|
|
74
78
|
}, /*#__PURE__*/React.createElement(Button, {
|
|
75
79
|
variant: "ghost-secondary",
|
|
76
80
|
size: "icon-sm"
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
export declare const dialogWideHeaderVariants: (props?: ({
|
|
2
2
|
size?: "sm" | "md" | null | undefined;
|
|
3
3
|
} & import("class-variance-authority/dist/types").ClassProp) | undefined) => string;
|
|
4
|
+
export declare const dialogCloseButtonPositionVariants: (props?: ({
|
|
5
|
+
headerSize?: "sm" | "md" | null | undefined;
|
|
6
|
+
} & import("class-variance-authority/dist/types").ClassProp) | undefined) => string;
|
|
4
7
|
export declare const dialogWideTitleVariants: (props?: ({
|
|
5
8
|
size?: "sm" | "md" | null | undefined;
|
|
6
9
|
align?: "center" | "left" | null | undefined;
|
|
@@ -10,6 +10,17 @@ export var dialogWideHeaderVariants = cva('border-border text-foreground relativ
|
|
|
10
10
|
size: 'md'
|
|
11
11
|
}
|
|
12
12
|
});
|
|
13
|
+
export var dialogCloseButtonPositionVariants = cva('', {
|
|
14
|
+
variants: {
|
|
15
|
+
headerSize: {
|
|
16
|
+
sm: 'top-3',
|
|
17
|
+
md: 'top-4'
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
defaultVariants: {
|
|
21
|
+
headerSize: 'md'
|
|
22
|
+
}
|
|
23
|
+
});
|
|
13
24
|
export var dialogWideTitleVariants = cva('', {
|
|
14
25
|
variants: {
|
|
15
26
|
size: {
|
package/dialog/dialog.types.d.ts
CHANGED
|
@@ -2,6 +2,10 @@ import type * as DialogPrimitive from '@radix-ui/react-dialog';
|
|
|
2
2
|
import type { ComponentProps } from 'react';
|
|
3
3
|
export type DialogSize = 'sm' | 'md';
|
|
4
4
|
export type DialogAlign = 'center' | 'left';
|
|
5
|
+
export interface DialogWideContentProps extends ComponentProps<typeof DialogPrimitive.Content> {
|
|
6
|
+
overlayClassName?: string;
|
|
7
|
+
headerSize?: DialogSize;
|
|
8
|
+
}
|
|
5
9
|
export interface DialogWideHeaderProps extends ComponentProps<'div'> {
|
|
6
10
|
size?: DialogSize;
|
|
7
11
|
}
|
package/dialog/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { Dialog, DialogClose, DialogWideFooter, DialogOverlay, DialogPortal, DialogTrigger, DialogWideTitle, DialogWideHeader, DialogWideContent, DialogWideBody, DialogFormContent, DialogFormDescription, DialogFormIcon, DialogFormWarningIcon, DialogFormErrorIcon, DialogFormHeader, DialogFormTitle, DialogFormBody, DialogFormFooter, } from './dialog.component';
|
|
2
|
-
export { dialogWideHeaderVariants, dialogWideTitleVariants } from './dialog.constants';
|
|
3
|
-
export type { DialogWideHeaderProps, DialogWideTitleProps, DialogSize, DialogAlign } from './dialog.types';
|
|
2
|
+
export { dialogCloseButtonPositionVariants, dialogWideHeaderVariants, dialogWideTitleVariants, } from './dialog.constants';
|
|
3
|
+
export type { DialogWideContentProps, DialogWideHeaderProps, DialogWideTitleProps, DialogSize, DialogAlign, } from './dialog.types';
|
package/dialog/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { Dialog, DialogClose, DialogWideFooter, DialogOverlay, DialogPortal, DialogTrigger, DialogWideTitle, DialogWideHeader, DialogWideContent, DialogWideBody, DialogFormContent, DialogFormDescription, DialogFormIcon, DialogFormWarningIcon, DialogFormErrorIcon, DialogFormHeader, DialogFormTitle, DialogFormBody, DialogFormFooter } from './dialog.component';
|
|
2
|
-
export { dialogWideHeaderVariants, dialogWideTitleVariants } from './dialog.constants';
|
|
2
|
+
export { dialogCloseButtonPositionVariants, dialogWideHeaderVariants, dialogWideTitleVariants } from './dialog.constants';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scaleflex/ui-tw",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.128",
|
|
4
4
|
"author": "scaleflex",
|
|
5
5
|
"repository": "github:scaleflex/ui",
|
|
6
6
|
"homepage": "https://github.com/scaleflex/ui/blob/master/README.md",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"@radix-ui/react-switch": "^1.0.1",
|
|
29
29
|
"@radix-ui/react-tabs": "^1.1.13",
|
|
30
30
|
"@radix-ui/react-tooltip": "^1.2.6",
|
|
31
|
-
"@scaleflex/icons-tw": "^0.0.
|
|
31
|
+
"@scaleflex/icons-tw": "^0.0.128",
|
|
32
32
|
"@tanstack/react-table": "^8.21.3",
|
|
33
33
|
"@types/lodash.merge": "^4.6.9",
|
|
34
34
|
"class-variance-authority": "^0.7.1",
|