@seeqdev/qomponents 0.0.34 → 0.0.36
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/dist/ToolbarButton/ToolbarButton.d.ts +3 -0
- package/dist/ToolbarButton/ToolbarButton.js +74 -0
- package/dist/ToolbarButton/ToolbarButton.js.map +1 -0
- package/dist/ToolbarButton/ToolbarButton.stories.d.ts +5 -0
- package/dist/ToolbarButton/ToolbarButton.stories.js +77 -0
- package/dist/ToolbarButton/ToolbarButton.stories.js.map +1 -0
- package/dist/ToolbarButton/ToolbarButton.test.d.ts +1 -0
- package/dist/ToolbarButton/ToolbarButton.test.js +93 -0
- package/dist/ToolbarButton/ToolbarButton.test.js.map +1 -0
- package/dist/ToolbarButton/ToolbarButton.types.d.ts +40 -0
- package/dist/ToolbarButton/ToolbarButton.types.js +2 -0
- package/dist/ToolbarButton/ToolbarButton.types.js.map +1 -0
- package/dist/ToolbarButton/index.d.ts +1 -0
- package/dist/ToolbarButton/index.js +2 -0
- package/dist/ToolbarButton/index.js.map +1 -0
- package/dist/Tooltip/Tooltip.types.d.ts +1 -1
- package/dist/Tooltip/Tooltip.types.js +1 -1
- package/dist/Tooltip/Tooltip.types.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.esm.js +5770 -2488
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +5770 -2487
- package/dist/index.js.map +1 -1
- package/dist/styles.css +106 -0
- package/package.json +3 -2
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import * as PopoverPrimitive from '@radix-ui/react-popover';
|
|
3
|
+
import Icon from '../Icon';
|
|
4
|
+
import { DEFAULT_TOOL_TIP_DELAY } from '../Tooltip/Tooltip.types';
|
|
5
|
+
const borderStyles = [
|
|
6
|
+
'tw-border-solid',
|
|
7
|
+
'tw-border',
|
|
8
|
+
'tw-rounded-sm',
|
|
9
|
+
'hover:tw-border-sq-light-gray',
|
|
10
|
+
'focus:tw-border-sq-light-gray',
|
|
11
|
+
'active:tw-border-sq-sq-light-gray',
|
|
12
|
+
'dark:hover:tw-border-sq-color-dark-dark',
|
|
13
|
+
'dark:focus:tw-border-sq-color-dark-dark',
|
|
14
|
+
'dark:active:tw-border-sq-color-dark-dark',
|
|
15
|
+
].join(' ');
|
|
16
|
+
const triggerBorderStyles = [
|
|
17
|
+
'tw-border-solid',
|
|
18
|
+
'tw-border',
|
|
19
|
+
'tw-rounded-sm',
|
|
20
|
+
'tw-border-transparent',
|
|
21
|
+
'hover:tw-border-solid',
|
|
22
|
+
'hover:tw-border',
|
|
23
|
+
'hover:tw-rounded-sm',
|
|
24
|
+
'hover:tw-border-sq-darkish-gray',
|
|
25
|
+
'active:tw-border-sq-color-dark',
|
|
26
|
+
'dark:hover:tw-border-sq-color-dark-dark',
|
|
27
|
+
'dark:focus:tw-border-sq-color-dark-dark',
|
|
28
|
+
'dark:active:tw-border-sq-color-dark-dark',
|
|
29
|
+
].join(' ');
|
|
30
|
+
const activeBorderStyles = [
|
|
31
|
+
'active',
|
|
32
|
+
'tw-border-solid',
|
|
33
|
+
'tw-border',
|
|
34
|
+
'tw-rounded-sm',
|
|
35
|
+
'tw-border-sq-color-dark',
|
|
36
|
+
'active:tw-border-sq-color-dark',
|
|
37
|
+
'dark:hover:tw-border-sq-color-dark-dark',
|
|
38
|
+
].join(' ');
|
|
39
|
+
const bgStyles = ['tw-bg-sq-white', 'dark:tw-bg-sq-dark-background'].join(' ');
|
|
40
|
+
const disabledClasses = ['disabled:tw-opacity-50', 'tw-cursor-not-allowed'].join(' ');
|
|
41
|
+
const PopoverContent = React.forwardRef(({ className, align = 'center', sideOffset = 4, ...props }, ref) => (React.createElement(PopoverPrimitive.Content, { ref: ref, align: align, sideOffset: sideOffset, ...props, asChild: true })));
|
|
42
|
+
export const ToolbarButton = ({ isSmall = false, label, icon, secondIcon, forceSmallIcon = false, tooltipText, id, popoverContent, extraClassNames, testId, tooltipTestId, tooltipOptions, isActive = false, isHtmlTooltip = true, disabled = false, onClick, onHide, }) => {
|
|
43
|
+
let tooltipData = undefined;
|
|
44
|
+
if (tooltipText) {
|
|
45
|
+
tooltipData = {
|
|
46
|
+
'data-qtip-text': tooltipText,
|
|
47
|
+
'data-qtip-placement': tooltipOptions?.position,
|
|
48
|
+
'data-qtip-is-html': isHtmlTooltip,
|
|
49
|
+
'data-qtip-testid': tooltipTestId,
|
|
50
|
+
'data-qtip-delay': tooltipOptions?.delay ?? DEFAULT_TOOL_TIP_DELAY,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
const onOpenChange = (open) => {
|
|
54
|
+
if (!open) {
|
|
55
|
+
onHide && onHide();
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
return (React.createElement(PopoverPrimitive.Root, { defaultOpen: false, onOpenChange: onOpenChange },
|
|
59
|
+
React.createElement(PopoverPrimitive.Trigger, { id: id },
|
|
60
|
+
React.createElement("button", { ...tooltipData, className: `tw-bg-transparent tw-p-0 tw-flex tw-flex-col tw-items-center ${isSmall ? 'tw-py-[1px] tw-px-[5px]' : 'tw-px-2 tw-py-[3px]'} ${disabled ? disabledClasses : isActive ? activeBorderStyles : triggerBorderStyles} ${extraClassNames || ''}`, "data-testid": testId, disabled: disabled, onClick: (e) => {
|
|
61
|
+
onClick && onClick(e);
|
|
62
|
+
} },
|
|
63
|
+
React.createElement("span", { className: "tw-nowrap" },
|
|
64
|
+
React.createElement(Icon, { icon: icon, testId: "firstIcon", type: "text", large: !isSmall && !label && !secondIcon && !forceSmallIcon, extraClassNames: `tw-text-sq-text-color dark:tw-text-sq-dark-text` }),
|
|
65
|
+
secondIcon && React.createElement(Icon, { icon: secondIcon, type: "text", testId: "secondIcon" }),
|
|
66
|
+
popoverContent ? (React.createElement(Icon, { icon: "fc-arrow-dropdown", extraClassNames: "tw-text-sq-text-color dark:tw-text-sq-dark-text tw-ml-[3px] tw-text-[8px]", type: "text" })) : undefined),
|
|
67
|
+
!isSmall && (React.createElement("small", { className: "tw-text-sq-text-color dark:tw-text-sq-dark-text tw-text-[10px]" }, label)))),
|
|
68
|
+
!!popoverContent ? (React.createElement(PopoverContent, { sideOffset: 4, align: "start" },
|
|
69
|
+
React.createElement("div", { className: bgStyles +
|
|
70
|
+
' tw-relative tw-z-[1000] tw-min-w-6 tw-p-[0.5rem] outline-none data-[state=open]:animate-in data-[state=closed]:animate-out' +
|
|
71
|
+
' data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 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' +
|
|
72
|
+
borderStyles }, popoverContent))) : undefined));
|
|
73
|
+
};
|
|
74
|
+
//# sourceMappingURL=ToolbarButton.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ToolbarButton.js","sourceRoot":"","sources":["../../src/ToolbarButton/ToolbarButton.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,gBAAgB,MAAM,yBAAyB,CAAC;AAE5D,OAAO,IAAI,MAAM,SAAS,CAAC;AAE3B,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAElE,MAAM,YAAY,GAAG;IACnB,iBAAiB;IACjB,WAAW;IACX,eAAe;IACf,+BAA+B;IAC/B,+BAA+B;IAC/B,mCAAmC;IACnC,yCAAyC;IACzC,yCAAyC;IACzC,0CAA0C;CAC3C,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAEZ,MAAM,mBAAmB,GAAG;IAC1B,iBAAiB;IACjB,WAAW;IACX,eAAe;IACf,uBAAuB;IACvB,uBAAuB;IACvB,iBAAiB;IACjB,qBAAqB;IACrB,iCAAiC;IACjC,gCAAgC;IAChC,yCAAyC;IACzC,yCAAyC;IACzC,0CAA0C;CAC3C,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,CAAC,CAAC,SAAS,CACR;gBACN,CAAC,OAAO,IAAI,CACX,+BAAO,SAAS,EAAC,gEAAgE,IAAE,KAAK,CAAS,CAClG,CACM,CACgB;QAC1B,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,CAClB,oBAAC,cAAc,IAAC,UAAU,EAAE,CAAC,EAAE,KAAK,EAAC,OAAO;YAC1C,6BACE,SAAS,EACP,QAAQ;oBACR,6HAA6H;oBAC7H,sRAAsR;oBACtR,YAAY,IAEb,cAAc,CACX,CACS,CAClB,CAAC,CAAC,CAAC,SAAS,CACS,CACzB,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ToolbarButton } from './ToolbarButton';
|
|
3
|
+
import Icon from '../Icon';
|
|
4
|
+
import { QTip } from '../Tooltip/Qtip';
|
|
5
|
+
export default {
|
|
6
|
+
title: 'Toolbar Button',
|
|
7
|
+
};
|
|
8
|
+
export const AllToolbarButtonVariants = () => {
|
|
9
|
+
const options = [
|
|
10
|
+
{ value: 'a', label: 'Chocolate' },
|
|
11
|
+
{ value: 'b', label: 'Strawberry' },
|
|
12
|
+
{ value: 'c', label: 'Vanilla' },
|
|
13
|
+
{ value: 'd', label: 'Rocky Road' },
|
|
14
|
+
{ value: 'e', label: 'Crazy Cow' },
|
|
15
|
+
{ value: 'f', label: 'Almond Joy' },
|
|
16
|
+
{ value: 'g', label: 'All of the above' },
|
|
17
|
+
];
|
|
18
|
+
const colorOptions = [
|
|
19
|
+
{ value: 'h', label: 'pink' },
|
|
20
|
+
{ value: 'i', label: 'purple' },
|
|
21
|
+
{ value: 'j', label: 'green' },
|
|
22
|
+
{ value: 'k', label: 'red' },
|
|
23
|
+
];
|
|
24
|
+
const allToolbarButtons = (isDark) => (React.createElement("div", { className: isDark ? 'tw-dark tw-bg-sq-dark-background' : '' },
|
|
25
|
+
React.createElement("div", { className: "tw-p-5 " },
|
|
26
|
+
React.createElement(ToolbarButton, { icon: "fc-y-axis", label: "Popover", testId: "basic-popover1", tooltipText: "This is a small popover.", tooltipOptions: { position: 'top', delay: 0 }, isHtmlTooltip: false, isSmall: true, popoverContent: React.createElement("div", { className: "tw-text-sm dark:tw-text-white" },
|
|
27
|
+
React.createElement("p", { className: "tw-bg-gray-200 tw-p-2" }, "Flavors"),
|
|
28
|
+
options.map((option) => (React.createElement("div", { key: option.value, className: "tw-flex tw-items-center tw-p-2 hover:tw-bg-green-500" },
|
|
29
|
+
React.createElement(Icon, { type: "color", color: "green", icon: "fc-check", extraClassNames: "tw-mr-2" }),
|
|
30
|
+
React.createElement("span", null, option.label)))),
|
|
31
|
+
React.createElement("p", null, "Colors"),
|
|
32
|
+
colorOptions.map((option) => (React.createElement("div", { key: option.value, className: "tw-flex tw-items-center tw-p-2" },
|
|
33
|
+
React.createElement(Icon, { type: "color", color: "green", icon: "fc-check", extraClassNames: "tw-mr-2" }),
|
|
34
|
+
React.createElement("span", null, option.label))))) })),
|
|
35
|
+
React.createElement("div", { className: "tw-p-5 " },
|
|
36
|
+
React.createElement(ToolbarButton, { icon: "fc-y-axis", label: "Normal", testId: "basic-popover1", tooltipText: "This is a normal popover.", tooltipOptions: { position: 'top', delay: 0 }, isHtmlTooltip: false, popoverContent: React.createElement("div", { className: "tw-text-sm dark:tw-text-white" },
|
|
37
|
+
React.createElement("p", { className: "tw-bg-gray-200 tw-p-2" }, "Flavors"),
|
|
38
|
+
options.map((option) => (React.createElement("div", { key: option.value, className: "tw-flex tw-items-center tw-p-2 hover:tw-bg-green-500" },
|
|
39
|
+
React.createElement(Icon, { type: "color", color: "green", icon: "fc-check", extraClassNames: "tw-mr-2" }),
|
|
40
|
+
React.createElement("span", null, option.label)))),
|
|
41
|
+
React.createElement("p", null, "Colors"),
|
|
42
|
+
colorOptions.map((option) => (React.createElement("div", { key: option.value, className: "tw-flex tw-items-center tw-p-2" },
|
|
43
|
+
React.createElement(Icon, { type: "color", color: "green", icon: "fc-check", extraClassNames: "tw-mr-2" }),
|
|
44
|
+
React.createElement("span", null, option.label))))) })),
|
|
45
|
+
React.createElement("div", { className: "tw-p-5 " },
|
|
46
|
+
React.createElement("p", { className: "tw-text-sq-color-dark tw-text-[10px]" }, "Without popup"),
|
|
47
|
+
React.createElement(ToolbarButton, { icon: "fc-y-axis", label: "Button", testId: "basic-popover3", isHtmlTooltip: false })),
|
|
48
|
+
React.createElement("div", { className: "tw-p-5 " },
|
|
49
|
+
React.createElement(ToolbarButton, { icon: "fc-y-axis", label: "Disabled", testId: "basic-popover2", tooltipText: "This is a popover.", tooltipOptions: { position: 'top' }, isHtmlTooltip: false, disabled: true, popoverContent: React.createElement("div", { className: "tw-border tw-border-gray-100 tw-p-2 tw-rounded-sm tw-text-sm dark:tw-bg-sq-dark-background" },
|
|
50
|
+
React.createElement("p", { className: "tw-bg-gray-200 tw-p-2" }, "Flavors"),
|
|
51
|
+
options.map((option) => (React.createElement("div", { key: option.value, className: "tw-flex tw-items-center tw-p-2 hover:tw-bg-green-500" },
|
|
52
|
+
React.createElement(Icon, { type: "color", color: "green", icon: "fc-check", extraClassNames: "tw-mr-2" }),
|
|
53
|
+
React.createElement("span", null, option.label)))),
|
|
54
|
+
React.createElement("p", null, "Colors"),
|
|
55
|
+
colorOptions.map((option) => (React.createElement("div", { key: option.value, className: "tw-flex tw-items-center tw-p-2" },
|
|
56
|
+
React.createElement(Icon, { type: "color", color: "green", icon: "fc-check", extraClassNames: "tw-mr-2" }),
|
|
57
|
+
React.createElement("span", null, option.label))))) })),
|
|
58
|
+
React.createElement("div", { className: "tw-p-5 " },
|
|
59
|
+
React.createElement(ToolbarButton, { icon: "fc-y-axis", tooltipText: "This is a large popover icon", tooltipOptions: { position: 'top', delay: 0 }, testId: "basic-popover4", isHtmlTooltip: false })),
|
|
60
|
+
React.createElement("div", { className: "tw-p-5 " },
|
|
61
|
+
React.createElement(ToolbarButton, { icon: "fc-y-axis", label: "Active", testId: "basic-popover5", tooltipText: "This is a button.", tooltipOptions: { position: 'top', delay: 0 }, isHtmlTooltip: false, isActive: true }))));
|
|
62
|
+
const renderAllVariations = () => (React.createElement("div", { className: "tw-grid tw-grid-cols-2 tw-gap-4 tw-p-4" },
|
|
63
|
+
allToolbarButtons(),
|
|
64
|
+
allToolbarButtons(true)));
|
|
65
|
+
return (React.createElement("div", { className: "tw-grid tw-grid-cols-3 tw-gap-4" },
|
|
66
|
+
React.createElement(QTip, null),
|
|
67
|
+
React.createElement("div", { className: "color_topic" },
|
|
68
|
+
React.createElement("b", null, "Topic Colors"),
|
|
69
|
+
renderAllVariations()),
|
|
70
|
+
React.createElement("div", { className: "color_analysis" },
|
|
71
|
+
React.createElement("b", null, "Analysis Colors"),
|
|
72
|
+
renderAllVariations()),
|
|
73
|
+
React.createElement("div", { className: "color_datalab" },
|
|
74
|
+
React.createElement("b", null, "Datalab Colors"),
|
|
75
|
+
renderAllVariations())));
|
|
76
|
+
};
|
|
77
|
+
//# sourceMappingURL=ToolbarButton.stories.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ToolbarButton.stories.js","sourceRoot":"","sources":["../../src/ToolbarButton/ToolbarButton.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAEvC,eAAe;IACb,KAAK,EAAE,gBAAgB;CACxB,CAAC;AAEF,MAAM,CAAC,MAAM,wBAAwB,GAAG,GAAG,EAAE;IAC3C,MAAM,OAAO,GAAG;QACd,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,WAAW,EAAE;QAClC,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,YAAY,EAAE;QACnC,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,SAAS,EAAE;QAChC,EAA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
|
1
|
+
import React from 'react';
|
|
2
|
+
import '@testing-library/jest-dom';
|
|
3
|
+
import { render, screen } from '@testing-library/react';
|
|
4
|
+
import userEvent from '@testing-library/user-event';
|
|
5
|
+
import { ToolbarButton } from './ToolbarButton';
|
|
6
|
+
import Icon from '../Icon';
|
|
7
|
+
describe('ToolbarButton', () => {
|
|
8
|
+
const options = [
|
|
9
|
+
{ value: 'a', label: 'Chocolate' },
|
|
10
|
+
{ value: 'b', label: 'Strawberry' },
|
|
11
|
+
{ value: 'c', label: 'Vanilla' },
|
|
12
|
+
{ value: 'd', label: 'Rocky Road' },
|
|
13
|
+
{ value: 'e', label: 'Crazy Cow' },
|
|
14
|
+
{ value: 'f', label: 'Almond Joy' },
|
|
15
|
+
{ value: 'g', label: 'All of the above' },
|
|
16
|
+
];
|
|
17
|
+
const colorOptions = [
|
|
18
|
+
{ value: 'h', label: 'pink' },
|
|
19
|
+
{ value: 'i', label: 'purple' },
|
|
20
|
+
{ value: 'j', label: 'green' },
|
|
21
|
+
{ value: 'k', label: 'red' },
|
|
22
|
+
];
|
|
23
|
+
const popoverContent = (React.createElement("div", { className: "tw-text-sm" },
|
|
24
|
+
React.createElement("p", { className: "tw-bg-gray-200 tw-p-2" }, "Flavors"),
|
|
25
|
+
options.map((option) => (React.createElement("div", { key: option.value, className: "tw-flex tw-items-center tw-p-2 hover:tw-bg-green-500" },
|
|
26
|
+
React.createElement(Icon, { type: "color", color: "green", icon: "fc-check", extraClassNames: "tw-mr-2" }),
|
|
27
|
+
React.createElement("span", null, option.label)))),
|
|
28
|
+
React.createElement("p", null, "Colors"),
|
|
29
|
+
colorOptions.map((option) => (React.createElement("div", { key: option.value, className: "tw-flex tw-items-center tw-p-2" },
|
|
30
|
+
React.createElement(Icon, { type: "color", color: "green", icon: "fc-check", extraClassNames: "tw-mr-2" }),
|
|
31
|
+
React.createElement("span", null, option.label))))));
|
|
32
|
+
const mockOnClick = jest.fn();
|
|
33
|
+
class Context {
|
|
34
|
+
testId = 'popoverTestId';
|
|
35
|
+
label = 'popover label';
|
|
36
|
+
props = {
|
|
37
|
+
label: this.label,
|
|
38
|
+
onClick: mockOnClick,
|
|
39
|
+
testId: this.testId,
|
|
40
|
+
icon: 'fc-y-axis',
|
|
41
|
+
tooltipText: 'This is a popover.',
|
|
42
|
+
tooltipOptions: { position: 'top', delay: 0 },
|
|
43
|
+
isHtmlTooltip: false,
|
|
44
|
+
isSmall: false,
|
|
45
|
+
popoverContent,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
let tc;
|
|
49
|
+
beforeEach(() => {
|
|
50
|
+
tc = new Context();
|
|
51
|
+
jest.clearAllMocks();
|
|
52
|
+
});
|
|
53
|
+
const renderToolbarButton = (props) => render(React.createElement(ToolbarButton, { ...props }));
|
|
54
|
+
const openPopover = async () => {
|
|
55
|
+
const popover = screen.getByTestId(tc.testId);
|
|
56
|
+
await userEvent.click(popover);
|
|
57
|
+
};
|
|
58
|
+
it('renders popover icon without label when small', () => {
|
|
59
|
+
tc.props.isSmall = true;
|
|
60
|
+
renderToolbarButton(tc.props);
|
|
61
|
+
const popoverLabel = screen.queryByText(tc.label);
|
|
62
|
+
expect(popoverLabel).not.toBeInTheDocument();
|
|
63
|
+
});
|
|
64
|
+
it('renders popover trigger button', () => {
|
|
65
|
+
renderToolbarButton(tc.props);
|
|
66
|
+
expect(screen.getByText(tc.label)).toBeInTheDocument();
|
|
67
|
+
});
|
|
68
|
+
it('opens popover on click', async () => {
|
|
69
|
+
renderToolbarButton(tc.props);
|
|
70
|
+
await openPopover();
|
|
71
|
+
expect(screen.getByText(options[2].label)).toBeVisible();
|
|
72
|
+
});
|
|
73
|
+
it('renders disabled popover trigger', async () => {
|
|
74
|
+
renderToolbarButton({ ...tc.props, disabled: true });
|
|
75
|
+
await openPopover();
|
|
76
|
+
expect(mockOnClick).not.toHaveBeenCalled();
|
|
77
|
+
});
|
|
78
|
+
it('handles click events', async () => {
|
|
79
|
+
const handleClick = jest.fn();
|
|
80
|
+
tc.props.onClick = handleClick;
|
|
81
|
+
const { getByTestId } = renderToolbarButton(tc.props);
|
|
82
|
+
await userEvent.click(getByTestId(tc.testId));
|
|
83
|
+
expect(handleClick).toHaveBeenCalled();
|
|
84
|
+
});
|
|
85
|
+
it('handles click events within popover and does not close the popover', async () => {
|
|
86
|
+
renderToolbarButton(tc.props);
|
|
87
|
+
expect(screen.queryByText(options[4].label)).not.toBeInTheDocument();
|
|
88
|
+
await openPopover();
|
|
89
|
+
await userEvent.click(screen.getByText(options[3].label));
|
|
90
|
+
expect(screen.getByText(options[4].label)).toBeInTheDocument();
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
//# sourceMappingURL=ToolbarButton.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ToolbarButton.test.js","sourceRoot":"","sources":["../../src/ToolbarButton/ToolbarButton.test.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,2BAA2B,CAAC;AACnC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,SAAS,MAAM,6BAA6B,CAAC;AAEpD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,OAAO,IAAI,MAAM,SAAS,CAAC;AAE3B,QAAQ,CAAC,eAAe,EAAE,GAAG,EAAE;IAC7B,MAAM,OAAO,GAAG;QACd,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,WAAW,EAAE;QAClC,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,YAAY,EAAE;QACnC,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,SAAS,EAAE;QAChC,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,YAAY,EAAE;QACnC,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,WAAW,EAAE;QAClC,EAAE,KAAK,EAAE,GAAG,EAAE,KA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AAK,CAAC,CAAC,CAAC,GAAG,CAAC,iBAAiB,EAAE,CAAC;QACrE,MAAM,WAAW,EAAE,CAAC;QACpB,MAAM,SAAS,CAAC,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;QAC1D,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,iBAAiB,EAAE,CAAC;IACjE,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import React, { MouseEvent } from 'react';
|
|
2
|
+
import { TooltipProps } from '../Tooltip/Tooltip.types';
|
|
3
|
+
export declare const tooltipPositions: readonly ['top', 'left', 'right', 'bottom'];
|
|
4
|
+
export type TooltipPosition = (typeof tooltipPositions)[number];
|
|
5
|
+
export declare const toolbarButtonVariants: readonly ["outline", "theme", "theme-light", "warning", "danger", "no-border"];
|
|
6
|
+
export type ToolbarButtonVariant = (typeof toolbarButtonVariants)[number];
|
|
7
|
+
export interface ToolbarButtonProps {
|
|
8
|
+
/** icon class to be used with the toolbar (i.e. 'fc-zoom') */
|
|
9
|
+
icon: string;
|
|
10
|
+
/** second icon class to be displayed alongside icon */
|
|
11
|
+
secondIcon?: string;
|
|
12
|
+
/** true to force the icon to be small */
|
|
13
|
+
forceSmallIcon?: boolean;
|
|
14
|
+
/** label for the toolbar item (shown only when toolbar is wide enough) */
|
|
15
|
+
label?: string;
|
|
16
|
+
/** items for the popover content */
|
|
17
|
+
popoverContent?: React.ReactNode;
|
|
18
|
+
/** true to render an icon-only toolbar button */
|
|
19
|
+
isSmall?: boolean;
|
|
20
|
+
id?: string;
|
|
21
|
+
/** extra class names to be placed on the Toolbar container component */
|
|
22
|
+
extraClassNames?: string;
|
|
23
|
+
/** id that will be used in the data-testid attribute on the toolbar button element */
|
|
24
|
+
testId?: string;
|
|
25
|
+
/** the text to be displayed on the icon's tooltip */
|
|
26
|
+
tooltipText?: string;
|
|
27
|
+
/** true if the provided tooltip text should be rendered as HTML */
|
|
28
|
+
isHtmlTooltip?: boolean;
|
|
29
|
+
/** optional testId applied to the tooltip - useful for testing */
|
|
30
|
+
tooltipTestId?: string;
|
|
31
|
+
/** options for the tooltip */
|
|
32
|
+
tooltipOptions?: Omit<TooltipProps, 'text'>;
|
|
33
|
+
disabled?: boolean;
|
|
34
|
+
/** function called when the toolbar is clicked on, i.e. for tracking (does not open the popover) */
|
|
35
|
+
onClick?: (e: MouseEvent) => void;
|
|
36
|
+
/** true to give the toolbar button the "pressed" look */
|
|
37
|
+
isActive?: boolean;
|
|
38
|
+
/** called when popup is hidden */
|
|
39
|
+
onHide?: () => void;
|
|
40
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ToolbarButton.types.js","sourceRoot":"","sources":["../../src/ToolbarButton/ToolbarButton.types.ts"],"names":[],"mappings":"AAKA,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,SAAS,EAAE,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,QAAQ,EAAE,WAAW,CAAU,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ToolbarButton as default } from './ToolbarButton';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/ToolbarButton/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,IAAI,OAAO,EAAE,MAAM,iBAAiB,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const DEFAULT_TOOL_TIP_DELAY =
|
|
1
|
+
export declare const DEFAULT_TOOL_TIP_DELAY = 500;
|
|
2
2
|
export declare const tooltipPositions: readonly ["top", "left", "right", "bottom"];
|
|
3
3
|
export type TooltipPosition = typeof tooltipPositions[number];
|
|
4
4
|
export interface TooltipProps {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tooltip.types.js","sourceRoot":"","sources":["../../src/Tooltip/Tooltip.types.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,sBAAsB,GAAG,
|
|
1
|
+
{"version":3,"file":"Tooltip.types.js","sourceRoot":"","sources":["../../src/Tooltip/Tooltip.types.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,sBAAsB,GAAG,GAAG,CAAC;AAC1C,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,CAAU,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import Button from './Button';
|
|
2
|
+
import ToolbarButton from './ToolbarButton';
|
|
2
3
|
import TextField from './TextField';
|
|
3
4
|
import Checkbox from './Checkbox';
|
|
4
5
|
import TextArea from './TextArea';
|
|
@@ -6,6 +7,7 @@ import { QTip, Tooltip } from './Tooltip';
|
|
|
6
7
|
import Icon from './Icon';
|
|
7
8
|
import Select from './Select';
|
|
8
9
|
export { Button };
|
|
10
|
+
export { ToolbarButton };
|
|
9
11
|
export { TextField };
|
|
10
12
|
export { TextArea };
|
|
11
13
|
export { Tooltip };
|