@seeqdev/qomponents 0.0.62 → 0.0.64

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/dist/ButtonWithDropdown/ButtonWithDropdown.js +39 -0
  2. package/dist/ButtonWithDropdown/ButtonWithDropdown.js.map +1 -0
  3. package/dist/ButtonWithDropdown/ButtonWithDropdown.stories.js +66 -0
  4. package/dist/ButtonWithDropdown/ButtonWithDropdown.stories.js.map +1 -0
  5. package/dist/ButtonWithDropdown/ButtonWithDropdown.test.js +72 -0
  6. package/dist/ButtonWithDropdown/ButtonWithDropdown.test.js.map +1 -0
  7. package/dist/ButtonWithDropdown/ButtonWithDropdown.types.d.ts +16 -12
  8. package/dist/ButtonWithDropdown/ButtonWithDropdown.types.js +2 -0
  9. package/dist/ButtonWithDropdown/ButtonWithDropdown.types.js.map +1 -0
  10. package/dist/ButtonWithDropdown/index.js +2 -0
  11. package/dist/ButtonWithDropdown/index.js.map +1 -0
  12. package/dist/ButtonWithPopover/ButtonWithPopover.js +27 -0
  13. package/dist/ButtonWithPopover/ButtonWithPopover.js.map +1 -0
  14. package/dist/ButtonWithPopover/ButtonWithPopover.stories.js +50 -0
  15. package/dist/ButtonWithPopover/ButtonWithPopover.stories.js.map +1 -0
  16. package/dist/ButtonWithPopover/ButtonWithPopover.test.js +61 -0
  17. package/dist/ButtonWithPopover/ButtonWithPopover.test.js.map +1 -0
  18. package/dist/ButtonWithPopover/ButtonWithPopover.types.d.ts +2 -12
  19. package/dist/ButtonWithPopover/ButtonWithPopover.types.js +2 -0
  20. package/dist/ButtonWithPopover/ButtonWithPopover.types.js.map +1 -0
  21. package/dist/ButtonWithPopover/index.js +2 -0
  22. package/dist/ButtonWithPopover/index.js.map +1 -0
  23. package/dist/Checkbox/Checkbox.js +4 -2
  24. package/dist/Checkbox/Checkbox.js.map +1 -1
  25. package/dist/Checkbox/Checkbox.stories.js +7 -5
  26. package/dist/Checkbox/Checkbox.stories.js.map +1 -1
  27. package/dist/Checkbox/Checkbox.types.d.ts +2 -1
  28. package/dist/Icon/Icon.js +3 -11
  29. package/dist/Icon/Icon.js.map +1 -1
  30. package/dist/Icon/Icon.types.d.ts +3 -12
  31. package/dist/Select/Select.js.map +1 -1
  32. package/dist/ToolbarButton/ToolbarButton.js +8 -6
  33. package/dist/ToolbarButton/ToolbarButton.js.map +1 -1
  34. package/dist/ToolbarButton/ToolbarButton.stories.js +10 -0
  35. package/dist/ToolbarButton/ToolbarButton.stories.js.map +1 -1
  36. package/dist/Tooltip/Qtip.js +9 -3
  37. package/dist/Tooltip/Qtip.js.map +1 -1
  38. package/dist/Tooltip/Tooltip.types.d.ts +13 -1
  39. package/dist/Tooltip/qTip.utilities.d.ts +3 -0
  40. package/dist/Tooltip/qTip.utilities.js +11 -0
  41. package/dist/Tooltip/qTip.utilities.js.map +1 -0
  42. package/dist/index.esm.js +45 -41
  43. package/dist/index.esm.js.map +1 -1
  44. package/dist/index.js +45 -41
  45. package/dist/index.js.map +1 -1
  46. package/package.json +1 -1
@@ -0,0 +1,39 @@
1
+ import * as React from 'react';
2
+ import * as DropdownMenu from '@radix-ui/react-dropdown-menu';
3
+ import Icon from '../Icon';
4
+ import { getQTipData } from '../Tooltip/qTip.utilities';
5
+ const borderStyles = [
6
+ 'tw-border-solid',
7
+ 'tw-border',
8
+ 'tw-rounded-sm',
9
+ 'tw-border-sq-disabled-gray',
10
+ 'dark:tw-border-gray-700',
11
+ ].join(' ');
12
+ const bgStyles = ['tw-bg-sq-white', 'dark:tw-bg-sq-dark-background'].join(' ');
13
+ const disabledClasses = ['tw-opacity-50', 'tw-cursor-not-allowed'].join(' ');
14
+ const ButtonWithDropdown = ({ dropdownItems, triggerIcon, id, extraClassNames, containerTestId, disabled = false, align = 'end', placement = 'bottom', placementOffset = 2, alignOffset = -5, hasArrow = false, onOpenChange, isOpen, setFocusOnTriggerOnClose = true, keepFocusInsideDropdown = true, ...tooltipProps }) => {
15
+ const tooltipData = getQTipData(tooltipProps);
16
+ return (React.createElement(DropdownMenu.Root, { defaultOpen: false, open: isOpen, onOpenChange: onOpenChange, modal: keepFocusInsideDropdown },
17
+ React.createElement(DropdownMenu.Trigger, { id: id, className: `tw-border-none focus-visible:tw-outline-none focus:tw-outline-none focus-within:tw-outline-none`, disabled: disabled },
18
+ React.createElement("div", { ...tooltipData, className: `tw-bg-transparent tw-flex tw-flex-col tw-items-center focus-visible:tw-outline-none focus:tw-outline-none focus-within:tw-outline-none ${disabled ? disabledClasses : ''} ${extraClassNames || ''}` }, triggerIcon)),
19
+ React.createElement(DropdownMenu.Content, { sideOffset: placementOffset, side: placement, align: align, alignOffset: alignOffset, asChild: true, onCloseAutoFocus: (e) => !setFocusOnTriggerOnClose && e.preventDefault(), className: "focus-visible:tw-outline-none tw-outline-none" },
20
+ React.createElement("div", { "data-testid": containerTestId, className: bgStyles +
21
+ ' tw-relative tw-z-[1000] tw-min-w-6 focus-visible:tw-outline-none tw-outline-none data-[state=open]:tw-animate-in data-[state=closed]:tw-animate-out' +
22
+ ' forceFont data-[side=top]:tw-animate-slideDownAndFade data-[side=right]:tw-animate-slideLeftAndFade data-[side=bottom]:tw-animate-slideUpAndFade data-[side=left]:tw-animate-slideRightAndFade ' +
23
+ borderStyles },
24
+ hasArrow && (React.createElement(DropdownMenu.Arrow, { asChild: true },
25
+ React.createElement("div", { className: " tw-fill-transparent tw-bg-white tw-w-[6px] tw-h-[6px] tw-rotate-45 dark:tw-bg-sq-dark-background tw-border-b tw-border-r tw-border-sq-disabled-gray dark:tw-border-gray-700 tw-mt-[-2px]" }))),
26
+ dropdownItems.map((item, index) => {
27
+ return item.isLabel ? (React.createElement(DropdownMenu.Label, { key: (item.label || '') + index, className: item.containerExtraClassNames },
28
+ item.icon && (React.createElement(Icon, { icon: item.icon, testId: item.iconTestId, type: "text", color: item.iconColor, extraClassNames: "tw-text-sq-text-color dark:tw-text-sq-white tw-w-[18px]" })),
29
+ React.createElement("div", { "data-testid": item.labelTestId, className: "tw-text-[13px] tw-ml-1" }, item.label))) : (React.createElement("div", { key: item.label + index },
30
+ React.createElement(DropdownMenu.Item, { key: item.label + index, "data-customid": item.itemCustomId, onSelect: (e) => {
31
+ item.onClick(e);
32
+ }, className: `tw-cursor-pointer tw-flex dark:tw-text-sq-white hover:tw-bg-sq-colored-hover hover:dark:tw-bg-sq-colored-hover-dark tw-leading-none tw-items-center tw-h-[27px] tw-px-[19px] tw-relative tw-select-none tw-outline-none data-[disabled]:tw-text-sq-disabled-gray data-[disabled]:tw-pointer-events-none ${item.containerExtraClassNames || ''}`, "data-testid": item.testId, disabled: item.disabled },
33
+ item.icon && (React.createElement(Icon, { icon: item.icon, testId: item.iconTestId, type: (item.iconType || 'text'), color: item.iconColor, customId: item.iconCustomId, extraClassNames: `tw-text-sq-text-color dark:tw-text-sq-white tw-w-[18px] ${item.iconExtraClassNames || ''}` })),
34
+ React.createElement("div", { "data-testid": item.labelTestId, "data-customid": item.labelCustomId, className: `tw-text-[13px] tw-ml-1 ${item.labelClasses}` }, item.label)),
35
+ item.hasDivider && (React.createElement(DropdownMenu.Separator, { "data-testid": `dropdown-divider-${index}`, className: "tw-h-[1px] tw-bg-sq-disabled-gray dark:tw-bg-gray-700 tw-my-[8px]" }))));
36
+ })))));
37
+ };
38
+ export default ButtonWithDropdown;
39
+ //# sourceMappingURL=ButtonWithDropdown.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ButtonWithDropdown.js","sourceRoot":"","sources":["../../src/ButtonWithDropdown/ButtonWithDropdown.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,YAAY,MAAM,+BAA+B,CAAC;AAC9D,OAAO,IAAI,MAAM,SAAS,CAAC;AAI3B,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAExD,MAAM,YAAY,GAAG;IACnB,iBAAiB;IACjB,WAAW;IACX,eAAe;IACf,4BAA4B;IA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AAM,EACxB,QAAQ,EAAE,IAAI,CAAC,QAAQ;4BACtB,IAAI,CAAC,IAAI,IAAI,CACZ,oBAAC,IAAI,IACH,IAAI,EAAE,IAAI,CAAC,IAAI,EACf,MAAM,EAAE,IAAI,CAAC,UAAU,EACvB,IAAI,EAAE,CAAC,IAAI,CAAC,QAAQ,IAAI,MAAM,CAAa,EAC3C,KAAK,EAAE,IAAI,CAAC,SAAS,EACrB,QAAQ,EAAE,IAAI,CAAC,YAAY,EAC3B,eAAe,EAAE,2DACf,IAAI,CAAC,mBAAmB,IAAI,EAC9B,EAAE,GACF,CACH;4BACD,4CACe,IAAI,CAAC,WAAW,mBACd,IAAI,CAAC,aAAa,EACjC,SAAS,EAAE,0BAA0B,IAAI,CAAC,YAAY,EAAE,IACvD,IAAI,CAAC,KAAK,CACP,CACY;wBACnB,IAAI,CAAC,UAAU,IAAI,CAClB,oBAAC,YAAY,CAAC,SAAS,mBACR,oBAAoB,KAAK,EAAE,EACxC,SAAS,EAAC,mEAAmE,GAC7E,CACH,CACG,CACP,CAAC;gBACJ,CAAC,CAAC,CACE,CACe,CACL,CACrB,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,kBAAkB,CAAC"}
@@ -0,0 +1,66 @@
1
+ import React from 'react';
2
+ import ButtonWithDropdown from './ButtonWithDropdown';
3
+ import Icon from '../Icon';
4
+ import { QTip } from '../Tooltip/Qtip';
5
+ export default {
6
+ title: 'Button with Dropdown',
7
+ };
8
+ export const AllButtonWithDropdownVariants = () => {
9
+ const [openDropdown, setOpenDropdown] = React.useState('');
10
+ const allButtonWithDropdowns = (color, isDark) => (React.createElement("div", { className: isDark ? 'tw-dark tw-bg-sq-dark-background' : '' },
11
+ React.createElement("div", { className: "tw-p-5 " },
12
+ React.createElement(ButtonWithDropdown, { onOpenChange: (isOpen) => setOpenDropdown(isOpen ? `dropdown-1-${color}-${isDark ? 'dark' : 'light'}` : ''), isOpen: openDropdown === `dropdown-1-${color}-${isDark ? 'dark' : 'light'}`, triggerIcon: React.createElement(Icon, { icon: "fc-more", type: "text", extraClassNames: "tw-text-sq-text-color dark:tw-text-sq-white tw-w-[18px]" }), containerTestId: "basic-dropdown1", tooltip: "This is a small dropdown.", tooltipDelay: 0, tooltipPlacement: "top", dropdownItems: [
13
+ { label: 'Orange', icon: 'fc-data-file', onClick: () => setOpenDropdown('') },
14
+ { label: 'Mango', icon: 'fc-user-community', onClick: () => setOpenDropdown('') },
15
+ { label: 'Guava', icon: 'fc-user-community', onClick: () => setOpenDropdown('') },
16
+ { label: 'Banana', icon: 'fc-user-community', onClick: () => setOpenDropdown('') },
17
+ ] })),
18
+ React.createElement("div", { className: "tw-p-5 " },
19
+ React.createElement(ButtonWithDropdown, { triggerIcon: React.createElement(Icon, { icon: "fc-more", type: "text", extraClassNames: "tw-text-sq-text-color dark:tw-text-sq-white tw-w-[18px]" }), onOpenChange: (isOpen) => setOpenDropdown(isOpen ? `dropdown-2-${color}-${isDark ? 'dark' : 'light'}` : ''), isOpen: openDropdown === `dropdown-2-${color}-${isDark ? 'dark' : 'light'}`, dropdownItems: [
20
+ { label: 'Orange', icon: 'fc-data-file', onClick: () => setOpenDropdown(''), hasDivider: true },
21
+ { label: 'Mango', icon: 'fc-user-community', onClick: () => setOpenDropdown('') },
22
+ { label: 'Guava', icon: 'fc-user-community', onClick: () => setOpenDropdown(''), hasDivider: true },
23
+ { label: 'Banana', icon: 'fc-user-community', onClick: () => setOpenDropdown('') },
24
+ ], containerTestId: "basic-dropdown1", tooltip: "This is a normal dropdown.", tooltipDelay: 0, tooltipPlacement: "top" })),
25
+ React.createElement("div", { className: "tw-p-5 " },
26
+ React.createElement("div", { className: "dark:tw-text-white tw-text-xs" }, "Dropdown with arrow"),
27
+ React.createElement(ButtonWithDropdown, { triggerIcon: React.createElement(Icon, { icon: "fc-more", type: "text", extraClassNames: "tw-text-sq-text-color dark:tw-text-sq-white tw-w-[18px]" }), onOpenChange: (isOpen) => setOpenDropdown(isOpen ? `dropdown-3-${color}-${isDark ? 'dark' : 'light'}` : ''), isOpen: openDropdown === `dropdown-3-${color}-${isDark ? 'dark' : 'light'}`, dropdownItems: [
28
+ { label: 'Orange', icon: 'fc-data-file', onClick: () => setOpenDropdown(''), hasDivider: true },
29
+ { label: 'Mango', icon: 'fc-user-community', onClick: () => setOpenDropdown('') },
30
+ { label: 'Guava', icon: 'fc-user-community', onClick: () => setOpenDropdown(''), hasDivider: true },
31
+ { label: 'Banana', icon: 'fc-user-community', onClick: () => setOpenDropdown('') },
32
+ ], containerTestId: "basic-dropdown1", hasArrow: true, tooltip: "This is a normal dropdown aligned to the end", tooltipDelay: 0, tooltipPlacement: "top" })),
33
+ React.createElement("div", { className: "tw-p-5 " },
34
+ React.createElement("div", { className: "dark:tw-text-white tw-text-xs" }, "Dropdown aligned at center"),
35
+ React.createElement(ButtonWithDropdown, { triggerIcon: React.createElement(Icon, { icon: "fc-more", type: "text", extraClassNames: "tw-text-sq-text-color dark:tw-text-sq-white tw-w-[18px]" }), onOpenChange: (isOpen) => setOpenDropdown(isOpen ? `dropdown-4-${color}-${isDark ? 'dark' : 'light'}` : ''), isOpen: openDropdown === `dropdown-4-${color}-${isDark ? 'dark' : 'light'}`, dropdownItems: [
36
+ { label: 'Orange', icon: 'fc-data-file', onClick: () => setOpenDropdown(''), hasDivider: true },
37
+ { label: 'Mango', icon: 'fc-user-community', onClick: () => setOpenDropdown('') },
38
+ { label: 'Guava', icon: 'fc-user-community', onClick: () => setOpenDropdown(''), hasDivider: true },
39
+ { label: 'Banana', icon: 'fc-user-community', onClick: () => setOpenDropdown('') },
40
+ ], containerTestId: "basic-dropdown1", hasArrow: true, tooltip: "This is a normal dropdown aligned to the center", align: "center", tooltipDelay: 0, tooltipPlacement: "top" })),
41
+ React.createElement("div", { className: "tw-p-5 " },
42
+ React.createElement("div", { className: "dark:tw-text-white tw-text-xs" }, "Dropdown aligned at start"),
43
+ React.createElement(ButtonWithDropdown, { triggerIcon: React.createElement(Icon, { icon: "fc-more", type: "text", extraClassNames: "tw-text-sq-text-color dark:tw-text-sq-white tw-w-[18px]" }), onOpenChange: (isOpen) => setOpenDropdown(isOpen ? `dropdown-5-${color}-${isDark ? 'dark' : 'light'}` : ''), isOpen: openDropdown === `dropdown-5-${color}-${isDark ? 'dark' : 'light'}`, dropdownItems: [
44
+ { label: 'Orange', icon: 'fc-data-file', onClick: () => setOpenDropdown(''), hasDivider: true },
45
+ { label: 'Mango', icon: 'fc-user-community', onClick: () => setOpenDropdown('') },
46
+ { label: 'Guava', icon: 'fc-user-community', onClick: () => setOpenDropdown(''), hasDivider: true },
47
+ { label: 'Banana', icon: 'fc-user-community', onClick: () => setOpenDropdown('') },
48
+ ], containerTestId: "basic-dropdown1", hasArrow: true, tooltip: "This is a normal dropdown aligned to the center", align: "start", tooltipDelay: 0, tooltipPlacement: "top" })),
49
+ React.createElement("div", { className: "tw-p-5 " },
50
+ React.createElement(ButtonWithDropdown, { triggerIcon: React.createElement(Icon, { icon: "fc-gears-2", type: "text", extraClassNames: "tw-text-sq-text-color dark:tw-text-sq-white tw-w-[18px]" }), dropdownItems: [], onOpenChange: (isOpen) => setOpenDropdown(isOpen ? `dropdown-6-${color}-${isDark ? 'dark' : 'light'}` : ''), isOpen: openDropdown === `dropdown-6-${color}-${isDark ? 'dark' : 'light'}`, containerTestId: "basic-dropdown2", tooltip: "This is a disabled dropdown.", tooltipDelay: 0, tooltipPlacement: "top", disabled: true }))));
51
+ const renderAllVariations = (color) => (React.createElement("div", { className: "tw-grid tw-grid-cols-2 tw-gap-4 tw-p-4" },
52
+ allButtonWithDropdowns(color),
53
+ allButtonWithDropdowns(color, true)));
54
+ return (React.createElement("div", { className: "tw-grid tw-grid-cols-3 tw-gap-4" },
55
+ React.createElement(QTip, null),
56
+ React.createElement("div", { className: "color_topic" },
57
+ React.createElement("b", null, "Topic Colors"),
58
+ renderAllVariations('topic')),
59
+ React.createElement("div", { className: "color_analysis" },
60
+ React.createElement("b", null, "Analysis Colors"),
61
+ renderAllVariations('analysis')),
62
+ React.createElement("div", { className: "color_datalab" },
63
+ React.createElement("b", null, "Datalab Colors"),
64
+ renderAllVariations('datalab'))));
65
+ };
66
+ //# sourceMappingURL=ButtonWithDropdown.stories.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ButtonWithDropdown.stories.js","sourceRoot":"","sources":["../../src/ButtonWithDropdown/ButtonWithDropdown.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,kBAAkB,MAAM,sBAAsB,CAAC;AACtD,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAEvC,eAAe;IACb,KAAK,EAAE,sBAAsB;CAC9B,CAAC;AAEF,MAAM,CAAC,MAAM,6BAA6B,GAAG,GAAG,EAAE;IAChD,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IAC3D,MAAM,sBAAsB,GAAG,CAAC,KAAa,EAAE,MAAgB,EAAE,EAAE,CAAC,CAClE,6BAAK,SAAS,EAAE,MAAM,CAAC,CAAC,CAAC,kCAAkC,CAAC,CAAC,CAAC,EAAE;QAC9D,6BAAK,SAAS,EAAC,SAAS;YACtB,oBAAC,kBAAkB,IACjB,YAAY,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC,CAAC,cAAc,KAAK,IAAI,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAC3G,MAAM,EAAE,YAAY,KAAK,cAAc,KAAK,IAAI,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,EAAE,EAC3E,WAAW,EACT,oBAAC,IAAI,IACH,IAAI,EAAC,SAAS,EACd,IAAI,EAAC,MAAM,EACX,eAAe,EAAC,yDAAyD,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B,CAAC,KAAK,CAAC;QAC7B,sBAAsB,CAAC,KAAK,EAAE,IAAI,CAAC,CAChC,CACP,CAAC;IACF,OAAO,CACL,6BAAK,SAAS,EAAC,iCAAiC;QAC9C,oBAAC,IAAI,OAAG;QACR,6BAAK,SAAS,EAAC,aAAa;YAC1B,8CAAmB;YAClB,mBAAmB,CAAC,OAAO,CAAC,CACzB;QAEN,6BAAK,SAAS,EAAC,gBAAgB;YAC7B,iDAAsB;YACrB,mBAAmB,CAAC,UAAU,CAAC,CAC5B;QAEN,6BAAK,SAAS,EAAC,eAAe;YAC5B,gDAAqB;YACpB,mBAAmB,CAAC,SAAS,CAAC,CAC3B,CACF,CACP,CAAC;AACJ,CAAC,CAAC"}
@@ -0,0 +1,72 @@
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 ButtonWithDropdown from './ButtonWithDropdown';
6
+ import Icon from '../Icon';
7
+ describe('ButtonWithDropdown', () => {
8
+ const mockOnClick = jest.fn();
9
+ const testId = 'trigger-icon';
10
+ class Context {
11
+ props = {
12
+ triggerIcon: (React.createElement(Icon, { icon: "fc-more", type: "text", testId: testId, extraClassNames: "tw-text-sq-text-color dark:tw-text-sq-white tw-w-[18px]" })),
13
+ containerTestId: 'basic-dropdown1',
14
+ tooltip: 'This is a small dropdown.',
15
+ tooltipDelay: 0,
16
+ tooltipPlacement: 'top',
17
+ isHtmlTooltip: false,
18
+ dropdownItems: [
19
+ { label: 'Orange', icon: 'fc-data-file', onClick: mockOnClick },
20
+ { label: 'Mango', icon: 'fc-user-community', onClick: mockOnClick },
21
+ { label: 'Guava', icon: 'fc-user-community', onClick: mockOnClick },
22
+ { label: 'Banana', icon: 'fc-user-community', onClick: mockOnClick },
23
+ ],
24
+ };
25
+ }
26
+ let tc;
27
+ beforeEach(() => {
28
+ tc = new Context();
29
+ jest.clearAllMocks();
30
+ });
31
+ const renderButtonWithDropdown = (props) => render(React.createElement(ButtonWithDropdown, { ...props }));
32
+ const openDropdown = async () => {
33
+ const popover = screen.getByTestId(testId);
34
+ await userEvent.click(popover);
35
+ };
36
+ test('renders trigger and opens dropdown content on trigger click', async () => {
37
+ renderButtonWithDropdown(tc.props);
38
+ expect(screen.getByTestId('trigger-icon')).toBeInTheDocument();
39
+ await openDropdown();
40
+ expect(screen.getByText('Orange')).toBeInTheDocument();
41
+ });
42
+ test('renders dividers correctly', async () => {
43
+ tc.props.dropdownItems[1].hasDivider = true;
44
+ renderButtonWithDropdown(tc.props);
45
+ expect(screen.getByTestId('trigger-icon')).toBeInTheDocument();
46
+ await openDropdown();
47
+ expect(screen.getByText('Orange')).toBeInTheDocument();
48
+ expect(screen.getByTestId('dropdown-divider-1')).toBeInTheDocument();
49
+ });
50
+ test('calls onClick handler when dropdown item is selected', async () => {
51
+ renderButtonWithDropdown(tc.props);
52
+ await openDropdown();
53
+ const item1 = screen.getByText('Orange');
54
+ await userEvent.click(item1);
55
+ expect(mockOnClick).toHaveBeenCalledTimes(1);
56
+ });
57
+ test('closes dropdown when item is clicked', async () => {
58
+ renderButtonWithDropdown(tc.props);
59
+ await openDropdown();
60
+ const item1 = screen.getByText('Orange');
61
+ await userEvent.click(item1);
62
+ expect(mockOnClick).toHaveBeenCalledTimes(1);
63
+ expect(screen.queryByText('Orange')).not.toBeInTheDocument();
64
+ });
65
+ test('does not open when disabled', async () => {
66
+ tc.props.disabled = true;
67
+ renderButtonWithDropdown(tc.props);
68
+ await openDropdown();
69
+ expect(screen.queryByText('Orange')).not.toBeInTheDocument();
70
+ });
71
+ });
72
+ //# sourceMappingURL=ButtonWithDropdown.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ButtonWithDropdown.test.js","sourceRoot":"","sources":["../../src/ButtonWithDropdown/ButtonWithDropdown.test.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,2BAA2B,CAAC;AACnC,OAAO,EAA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,CAAC,QAAQ,CAAC,CAAC;QACzC,MAAM,SAAS,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAE7B,MAAM,CAAC,WAAW,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC;IAC/C,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,sCAAsC,EAAE,KAAK,IAAI,EAAE;QACtD,wBAAwB,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC;QACnC,MAAM,YAAY,EAAE,CAAC;QACrB,MAAM,KAAK,GAAG,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;QACzC,MAAM,SAAS,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAE7B,MAAM,CAAC,WAAW,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC;QAC7C,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,iBAAiB,EAAE,CAAC;IAC/D,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,6BAA6B,EAAE,KAAK,IAAI,EAAE;QAC7C,EAAE,CAAC,KAAK,CAAC,QAAQ,GAAG,IAAI,CAAC;QACzB,wBAAwB,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC;QACnC,MAAM,YAAY,EAAE,CAAC;QACrB,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,iBAAiB,EAAE,CAAC;IAC/D,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -1,9 +1,21 @@
1
- import { TooltipPosition } from '../Tooltip/Tooltip.types';
1
+ import { TooltipComponentProps } from '../Tooltip/Tooltip.types';
2
2
  interface DropdownSubItems {
3
3
  /** icon class to be used with the dropdown subitems - if available (i.e. 'fc-zoom') */
4
4
  icon?: string;
5
+ /** icon type to be used with the dropdown subitems - if available (i.e. 'fc') */
6
+ iconType?: string;
7
+ /** icon color to be used with the dropdown subitems - if available */
8
+ iconColor?: string;
9
+ /** custom id for the icon */
10
+ iconCustomId?: string;
11
+ /** icon extra class names */
12
+ iconExtraClassNames?: string;
5
13
  /** label for the dropdown subitems */
6
14
  label: string;
15
+ /** custom id for the dropdown label */
16
+ labelCustomId?: string;
17
+ /** is the dropdown subitem a label */
18
+ isLabel?: boolean;
7
19
  /** function called when the dropdown subitem is clicked on */
8
20
  onClick: (e: Event) => void;
9
21
  /** dropdown subitem container classes */
@@ -12,6 +24,8 @@ interface DropdownSubItems {
12
24
  labelClasses?: string;
13
25
  /** is item disabled */
14
26
  disabled?: boolean;
27
+ /** custom id for the subitem */
28
+ itemCustomId?: string;
15
29
  /** dropdown container extra class names */
16
30
  containerExtraClassNames?: string;
17
31
  /** test id for the dropdown subitem */
@@ -23,7 +37,7 @@ interface DropdownSubItems {
23
37
  /** test id for the dropdown subitem */
24
38
  testId?: string;
25
39
  }
26
- export interface ButtonWithDropdownProps {
40
+ export interface ButtonWithDropdownProps extends TooltipComponentProps {
27
41
  /** items for the dropdown content */
28
42
  dropdownItems: DropdownSubItems[];
29
43
  /** icon element to be used as the trigger */
@@ -34,16 +48,6 @@ export interface ButtonWithDropdownProps {
34
48
  extraClassNames?: string;
35
49
  /** id that will be used in the data-testid attribute on the container element */
36
50
  containerTestId?: string;
37
- /** the text to be displayed on the triggers's tooltip */
38
- tooltipText?: string;
39
- /** optional testId applied to the tooltip - useful for testing */
40
- tooltipTestId?: string;
41
- /** number of milliseconds to wait before showing a tooltip on-hover */
42
- tooltipDelay?: number;
43
- /** position of the tooltip */
44
- tooltipPlacement?: TooltipPosition;
45
- /** true if the provided tooltip text should be rendered as HTML */
46
- isHtmlTooltip?: boolean;
47
51
  /** is the button disabled */
48
52
  disabled?: boolean;
49
53
  /** function called when the trigger is clicked on, i.e. for tracking (does not open the popover) */
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=ButtonWithDropdown.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ButtonWithDropdown.types.js","sourceRoot":"","sources":["../../src/ButtonWithDropdown/ButtonWithDropdown.types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export { default } from './ButtonWithDropdown';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/ButtonWithDropdown/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC"}
@@ -0,0 +1,27 @@
1
+ import * as React from 'react';
2
+ import * as PopoverPrimitive from '@radix-ui/react-popover';
3
+ import { getQTipData } from '../Tooltip/qTip.utilities';
4
+ const bgStyles = ['tw-bg-sq-white', 'dark:tw-bg-sq-dark-background'].join(' ');
5
+ const borderStyles = [
6
+ 'tw-border-solid',
7
+ 'tw-border',
8
+ 'tw-rounded-sm',
9
+ 'tw-border-sq-disabled-gray',
10
+ 'dark:tw-border-gray-700',
11
+ ].join(' ');
12
+ const disabledClasses = ['tw-opacity-50', 'tw-cursor-not-allowed'].join(' ');
13
+ const ButtonWithPopover = ({ children, trigger, id, hasArrow, extraTriggerClassNames, extraPopoverClassNames, containerTestId, disabled = false, align = 'end', alignOffset = -5, placement = 'bottom', placementOffset = 2, onOpenChange, isOpen, isCloseOnContentClick = false, setFocusOnTriggerOnClose = true, ...tooltipProps }) => {
14
+ const tooltipData = getQTipData(tooltipProps);
15
+ return (React.createElement(PopoverPrimitive.Root, { open: isOpen, defaultOpen: false, onOpenChange: onOpenChange },
16
+ React.createElement(PopoverPrimitive.Trigger, { id: id, className: `tw-border-none`, disabled: disabled },
17
+ React.createElement("div", { ...tooltipData, className: `tw-bg-transparent tw-flex tw-flex-col tw-items-center tw-justify-center ${disabled ? disabledClasses : ''} ${extraTriggerClassNames || ''}` }, trigger)),
18
+ React.createElement(PopoverPrimitive.Content, { sideOffset: placementOffset, align: align, side: placement, alignOffset: alignOffset, onCloseAutoFocus: (e) => !setFocusOnTriggerOnClose && e.preventDefault(), asChild: true, onClick: () => isCloseOnContentClick && onOpenChange && onOpenChange(false), className: "focus-visible:tw-outline-none tw-outline-none" },
19
+ React.createElement("div", { "data-testid": containerTestId, className: `${bgStyles} ${borderStyles} tw-relative tw-z-[1000] tw-min-w-6 tw-p-[0.5rem] focus-visible:tw-outline-none tw-outline-none data-[state=open]:tw-animate-in data-[state=closed]:tw-animate-out
20
+ data-[side=top]:tw-animate-slideDownAndFade data-[side=right]:tw-animate-slideLeftAndFade data-[side=bottom]:tw-animate-slideUpAndFade data-[side=left]:tw-animate-slideRightAndFade
21
+ ${extraPopoverClassNames || ''}` },
22
+ hasArrow && (React.createElement(PopoverPrimitive.Arrow, { asChild: true },
23
+ React.createElement("div", { className: " tw-fill-transparent tw-bg-white tw-w-[6px] tw-h-[6px] tw-rotate-45 dark:tw-bg-sq-dark-background tw-border-b tw-border-r tw-border-sq-disabled-gray dark:tw-border-gray-700 tw-mt-[-2px]" }))),
24
+ children))));
25
+ };
26
+ export default ButtonWithPopover;
27
+ //# sourceMappingURL=ButtonWithPopover.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ButtonWithPopover.js","sourceRoot":"","sources":["../../src/ButtonWithPopover/ButtonWithPopover.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,gBAAgB,MAAM,yBAAyB,CAAC;AAE5D,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAExD,MAAM,QAAQ,GAAG,CAAC,gBAAgB,EAAE,+BAA+B,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAE/E,MAAM,YAAY,GAAG;IACnB,iBAAiB;IACjB,WAAW;IACX,eAAe;IACf,4BAA4B;IAC5B,yBAAyB;CAC1B,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAEZ,MAAM,eAAe,GAAG,CAAC,eAAe,EAAE,uBAAuB,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,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sB,IAAI,EAAE,EAAE;gBACjC,QAAQ,IAAI,CACX,oBAAC,gBAAgB,CAAC,KAAK,IAAC,OAAO;oBAC7B,6BAAK,SAAS,EAAC,4LAA4L,GAAG,CACvL,CAC1B;gBACA,QAAQ,CACL,CACmB,CACL,CACzB,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
@@ -0,0 +1,50 @@
1
+ import React from 'react';
2
+ import ButtonWithPopover from './ButtonWithPopover';
3
+ import Icon from '../Icon';
4
+ import { QTip } from '../Tooltip/Qtip';
5
+ export default {
6
+ title: 'Button with Popover',
7
+ };
8
+ export const AllButtonWithPopoverVariants = () => {
9
+ const options = ['Chocolate', 'Strawberry', 'Vanilla', 'Rocky Road', 'Crazy Cow', 'Almond Joy'];
10
+ const renderFlavours = () => (React.createElement("div", { className: "tw-text-sm dark:tw-text-white tw-w-72" },
11
+ React.createElement("p", { className: "tw-bg-gray-200 dark:tw-bg-gray-700 tw-p-2" }, "Flavors"),
12
+ React.createElement("div", { className: "tw-w-full tw-flex tw-flex-wrap tw-gap-1" }, options.map((option) => (React.createElement("div", { key: option, className: "tw-flex tw-items-center tw-px-2 tw-py-1 tw-mt-2 tw tw-rounded-full tw-border-sq-color-dark-dark tw-border" },
13
+ React.createElement(Icon, { type: "color", color: "rgb(var(--sq-color-dark-dark))", icon: "fc-check", extraClassNames: "tw-mr-2" }),
14
+ React.createElement("span", null, option)))))));
15
+ const [openPopver, setOpenPopover] = React.useState('');
16
+ const allButtonWithPopovers = (isDark = false, topic) => (React.createElement("div", { className: isDark ? 'tw-dark tw-bg-sq-dark-background ' : '' },
17
+ React.createElement("div", { className: "tw-p-5 " },
18
+ React.createElement(ButtonWithPopover, { trigger: React.createElement(Icon, { type: "color", color: "rgb(var(--sq-color-dark-dark))", icon: "fc-more" }), containerTestId: `basic-popover-${isDark ? 'dark' : 'light'}-${topic}-1`, isOpen: openPopver === `basic-popover-${isDark ? 'dark' : 'light'}-${topic}-1`, onOpenChange: (isOpen) => setOpenPopover(isOpen ? `basic-popover-${isDark ? 'dark' : 'light'}-${topic}-1` : ''), tooltip: "This is a small popover.", tooltipDelay: 0, tooltipPlacement: "top", isHtmlTooltip: false }, renderFlavours())),
19
+ React.createElement("div", { className: "tw-p-5 " },
20
+ React.createElement(ButtonWithPopover, { trigger: React.createElement(Icon, { type: "color", color: "rgb(var(--sq-color-dark-dark))", icon: "fc-more" }), containerTestId: `basic-popover-${isDark ? 'dark' : 'light'}-${topic}-2`, isOpen: openPopver === `basic-popover-${isDark ? 'dark' : 'light'}-${topic}-2`, onOpenChange: (isOpen) => setOpenPopover(isOpen ? `basic-popover-${isDark ? 'dark' : 'light'}-${topic}-2` : ''), tooltip: "This is a normal popover.", tooltipDelay: 0, tooltipPlacement: "top", isHtmlTooltip: false }, renderFlavours())),
21
+ React.createElement("div", { className: "tw-p-5 " },
22
+ React.createElement("p", { className: "dark:tw-text-sq-white tw-text-sm tw-mb-4" }, "Close popover on content click"),
23
+ React.createElement(ButtonWithPopover, { trigger: React.createElement(Icon, { type: "color", color: "rgb(var(--sq-color-dark-dark))", icon: "fc-more" }), containerTestId: `basic-popover-${isDark ? 'dark' : 'light'}-${topic}-3`, isOpen: openPopver === `basic-popover-${isDark ? 'dark' : 'light'}-${topic}-3`, onOpenChange: (isOpen) => setOpenPopover(isOpen ? `basic-popover-${isDark ? 'dark' : 'light'}-${topic}-3` : ''), tooltip: "This is a normal popover.", tooltipDelay: 0, tooltipPlacement: "top", isCloseOnContentClick: true, isHtmlTooltip: false }, renderFlavours())),
24
+ React.createElement("div", { className: "tw-p-5 " },
25
+ React.createElement(ButtonWithPopover, { trigger: React.createElement(Icon, { type: "color", color: "rgb(var(--sq-color-dark-dark))", icon: "fc-more" }), containerTestId: `basic-popover-${isDark ? 'dark' : 'light'}-${topic}-4`, isOpen: openPopver === `basic-popover-${isDark ? 'dark' : 'light'}-${topic}-4`, onOpenChange: (isOpen) => setOpenPopover(isOpen ? `basic-popover-${isDark ? 'dark' : 'light'}-${topic}-4` : ''), tooltip: "This is a disabled popover.", tooltipDelay: 0, tooltipPlacement: "top", isHtmlTooltip: false, disabled: true }, renderFlavours())),
26
+ React.createElement("div", { className: "tw-p-5 " },
27
+ React.createElement("div", { className: "dark:tw-text-white tw-text-xs" }, "Popover with arrow"),
28
+ React.createElement(ButtonWithPopover, { trigger: React.createElement(Icon, { type: "color", color: "rgb(var(--sq-color-dark-dark))", icon: "fc-more" }), containerTestId: `basic-popover-${isDark ? 'dark' : 'light'}-${topic}-5`, isOpen: openPopver === `basic-popover-${isDark ? 'dark' : 'light'}-${topic}-5`, onOpenChange: (isOpen) => setOpenPopover(isOpen ? `basic-popover-${isDark ? 'dark' : 'light'}-${topic}-5` : ''), tooltip: "This is a normal popover with arrow.", tooltipDelay: 0, tooltipPlacement: "top", hasArrow: true, isHtmlTooltip: false }, renderFlavours())),
29
+ React.createElement("div", { className: "tw-p-5 " },
30
+ React.createElement("div", { className: "dark:tw-text-white tw-text-xs" }, "Popover aligned at center"),
31
+ React.createElement(ButtonWithPopover, { trigger: React.createElement(Icon, { type: "color", color: "rgb(var(--sq-color-dark-dark))", icon: "fc-more" }), containerTestId: `basic-popover-${isDark ? 'dark' : 'light'}-${topic}-6`, isOpen: openPopver === `basic-popover-${isDark ? 'dark' : 'light'}-${topic}-6`, onOpenChange: (isOpen) => setOpenPopover(isOpen ? `basic-popover-${isDark ? 'dark' : 'light'}-${topic}-6` : ''), tooltip: "This is a normal popover with arrow.", tooltipDelay: 0, tooltipPlacement: "top", align: "center", hasArrow: true, isHtmlTooltip: false }, renderFlavours())),
32
+ React.createElement("div", { className: "tw-p-5 " },
33
+ React.createElement("div", { className: "dark:tw-text-white tw-text-xs" }, "Popover aligned at start"),
34
+ React.createElement(ButtonWithPopover, { trigger: React.createElement(Icon, { type: "color", color: "rgb(var(--sq-color-dark-dark))", icon: "fc-more" }), containerTestId: `basic-popover-${isDark ? 'dark' : 'light'}-${topic}-7`, isOpen: openPopver === `basic-popover-${isDark ? 'dark' : 'light'}-${topic}-7`, onOpenChange: (isOpen) => setOpenPopover(isOpen ? `basic-popover-${isDark ? 'dark' : 'light'}-${topic}-7` : ''), tooltip: "This is a normal popover with arrow.", tooltipDelay: 0, align: "start", tooltipPlacement: "top", hasArrow: true, isHtmlTooltip: false }, renderFlavours()))));
35
+ const renderAllVariations = (color) => (React.createElement("div", { className: "tw-grid tw-grid-cols-2 tw-gap-4 tw-p-4" },
36
+ allButtonWithPopovers(false, color),
37
+ allButtonWithPopovers(true, color)));
38
+ return (React.createElement("div", { className: "tw-grid tw-grid-cols-3 tw-gap-4" },
39
+ React.createElement(QTip, null),
40
+ React.createElement("div", { className: "color_topic" },
41
+ React.createElement("b", null, "Topic Colors"),
42
+ renderAllVariations('topic')),
43
+ React.createElement("div", { className: "color_analysis" },
44
+ React.createElement("b", null, "Analysis Colors"),
45
+ renderAllVariations('analysis')),
46
+ React.createElement("div", { className: "color_datalab" },
47
+ React.createElement("b", null, "Datalab Colors"),
48
+ renderAllVariations('datalab'))));
49
+ };
50
+ //# sourceMappingURL=ButtonWithPopover.stories.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ButtonWithPopover.stories.js","sourceRoot":"","sources":["../../src/ButtonWithPopover/ButtonWithPopover.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,iBAAiB,MAAM,qBAAqB,CAAC;AACpD,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAEvC,eAAe;IACb,KAAK,EAAE,qBAAqB;CAC7B,CAAC;AAEF,MAAM,CAAC,MAAM,4BAA4B,GAAG,GAAG,EAAE;IAC/C,MAAM,OAAO,GAAG,CAAC,WAAW,EAAE,YAAY,EAAE,SAAS,EAAE,YAAY,EAAE,WAAW,EAAE,YAAY,CAAC,CAAC;IAEhG,MAAM,cAAc,GAAG,GAAG,EAAE,CAAC,CAC3B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,8CAAmB;YAClB,mBAAmB,CAAC,OAAO,CAAC,CACzB;QAEN,6BAAK,SAAS,EAAC,gBAAgB;YAC7B,iDAAsB;YACrB,mBAAmB,CAAC,UAAU,CAAC,CAC5B;QAEN,6BAAK,SAAS,EAAC,eAAe;YAC5B,gDAAqB;YACpB,mBAAmB,CAAC,SAAS,CAAC,CAC3B,CACF,CACP,CAAC;AACJ,CAAC,CAAC"}
@@ -0,0 +1,61 @@
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 ButtonWithPopover from './ButtonWithPopover';
6
+ import Icon from '../Icon';
7
+ describe('ButtonWithPopover', () => {
8
+ const mockOnClick = jest.fn();
9
+ const testId = 'trigger-icon';
10
+ class Context {
11
+ props = {
12
+ trigger: (React.createElement(Icon, { icon: "fc-more", type: "text", testId: testId, extraClassNames: "tw-text-sq-text-color dark:tw-text-sq-white tw-w-[18px]" })),
13
+ onOpenChange: mockOnClick,
14
+ containerTestId: 'basic-Popover1',
15
+ tooltip: 'This is a small Popover.',
16
+ tooltipDelay: 0,
17
+ tooltipPlacement: 'top',
18
+ isHtmlTooltip: false,
19
+ children: React.createElement("div", null, "Popover content"),
20
+ };
21
+ }
22
+ let tc;
23
+ beforeEach(() => {
24
+ tc = new Context();
25
+ jest.clearAllMocks();
26
+ });
27
+ const renderButtonWithPopover = (props) => render(React.createElement(ButtonWithPopover, { ...props }));
28
+ const openPopover = async () => {
29
+ const popover = screen.getByTestId(testId);
30
+ await userEvent.click(popover);
31
+ };
32
+ test('renders trigger and opens Popover content on trigger click', async () => {
33
+ renderButtonWithPopover(tc.props);
34
+ expect(screen.getByTestId('trigger-icon')).toBeInTheDocument();
35
+ await openPopover();
36
+ expect(screen.getByText('Popover content')).toBeInTheDocument();
37
+ });
38
+ test('closes popover when content is clicked and is set in props', async () => {
39
+ tc.props.isCloseOnContentClick = true;
40
+ renderButtonWithPopover(tc.props);
41
+ await openPopover();
42
+ const item1 = screen.getByText('Popover content');
43
+ await userEvent.click(item1);
44
+ expect(mockOnClick).toHaveBeenCalledTimes(2);
45
+ });
46
+ test('leaves popover open when content is clicked and is set in props', async () => {
47
+ tc.props.isCloseOnContentClick = false;
48
+ renderButtonWithPopover(tc.props);
49
+ await openPopover();
50
+ const item1 = screen.getByText('Popover content');
51
+ await userEvent.click(item1);
52
+ expect(mockOnClick).toHaveBeenCalledTimes(1);
53
+ });
54
+ test('does not open when disabled', async () => {
55
+ tc.props.disabled = true;
56
+ renderButtonWithPopover(tc.props);
57
+ await openPopover();
58
+ expect(screen.queryByText('Popover content')).not.toBeInTheDocument();
59
+ });
60
+ });
61
+ //# sourceMappingURL=ButtonWithPopover.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ButtonWithPopover.test.js","sourceRoot":"","sources":["../../src/ButtonWithPopover/ButtonWithPopover.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;AACpD,OAAO,iBAAiB,MAAM,qBAAqB,CAAC;AAEpD,OAAO,IAAI,MAAM,SAAS,CAAC;AAE3B,QAAQ,CAAC,mBAAmB,EAAE,GAAG,EAAE;IACjC,MAAM,WAAW,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;IAE9B,MAAM,MAAM,GAAG,cAAc,CAAC;IAC9B,MAAM,OAAO;QACX,KAAK,GAA2B;YAC9B,OAAO,EAAE,CACP,oBAAC,IAAI,IACH,IAAI,EAAC,SAAS,EACd,IAAI,EAAC,MAAM,EACX,MAAM,EAAE,MAAM,EACd,eAAe,EAAC,yDAAyD,GACzE,CACH;YACD,YAAY,EAAE,WAAW;YACzB,eAAe,EAAE,gBAAgB;YACjC,OAAO,EAAE,0BAA0B;YACnC,YAAY,EA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,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC;IAC/C,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,iEAAiE,EAAE,KAAK,IAAI,EAAE;QACjF,EAAE,CAAC,KAAK,CAAC,qBAAqB,GAAG,KAAK,CAAC;QACvC,uBAAuB,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC;QAClC,MAAM,WAAW,EAAE,CAAC;QACpB,MAAM,KAAK,GAAG,MAAM,CAAC,SAAS,CAAC,iBAAiB,CAAC,CAAC;QAClD,MAAM,SAAS,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAE7B,MAAM,CAAC,WAAW,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC;IAC/C,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,6BAA6B,EAAE,KAAK,IAAI,EAAE;QAC7C,EAAE,CAAC,KAAK,CAAC,QAAQ,GAAG,IAAI,CAAC;QACzB,uBAAuB,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC;QAClC,MAAM,WAAW,EAAE,CAAC;QACpB,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,iBAAiB,CAAC,CAAC,CAAC,GAAG,CAAC,iBAAiB,EAAE,CAAC;IACxE,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
- import { TooltipPosition } from '../Tooltip/Tooltip.types';
3
- export interface ButtonWithPopoverProps {
2
+ import { TooltipComponentProps } from '../Tooltip/Tooltip.types';
3
+ export interface ButtonWithPopoverProps extends TooltipComponentProps {
4
4
  /** icon class to be used with the toolbar (i.e. 'fc-zoom') */
5
5
  trigger: React.ReactNode;
6
6
  /** items for the popover content */
@@ -10,16 +10,6 @@ export interface ButtonWithPopoverProps {
10
10
  extraClassNames?: string;
11
11
  /** id that will be used in the data-testid attribute on the container element */
12
12
  containerTestId?: string;
13
- /** the text to be displayed on the icon's tooltip */
14
- tooltipText?: string;
15
- /** optional testId applied to the tooltip - useful for testing */
16
- tooltipTestId?: string;
17
- /** number of milliseconds to wait before showing a tooltip on-hover */
18
- tooltipDelay?: number;
19
- /** position of the tooltip */
20
- tooltipPlacement?: TooltipPosition;
21
- /** true if the provided tooltip text should be rendered as HTML */
22
- isHtmlTooltip?: boolean;
23
13
  disabled?: boolean;
24
14
  /** function called when the toolbar is clicked on, i.e. for tracking (does not open the popover) */
25
15
  onClick?: (isOpen: boolean) => void;
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=ButtonWithPopover.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ButtonWithPopover.types.js","sourceRoot":"","sources":["../../src/ButtonWithPopover/ButtonWithPopover.types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export { default } from './ButtonWithPopover';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/ButtonWithPopover/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC"}
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
2
  import '../styles.css';
3
+ import { getQTipData } from '../Tooltip/qTip.utilities';
3
4
  const alignment = 'tw-flex';
4
5
  const labelClasses = 'tw-ml-1.5 tw-text-sm tw--mt-0.5';
5
6
  const baseClasses = 'tw-border-1 tw-h-3.5 tw-w-3.5 focus:tw-ring-0 focus:tw-ring-offset-0 tw-outline-none focus:tw-outline-none' +
@@ -13,10 +14,11 @@ const radioClasses = `tw-form-radio ${baseClasses}`;
13
14
  * Checkbox and Radio Box Component.
14
15
  */
15
16
  export const Checkbox = (props) => {
16
- const { type = 'checkbox', value, disabled = false, label, onChange, onClick, onKeyDown, checked, defaultChecked, id, name, extraClassNames, extraLabelClassNames, testId, } = props;
17
+ const { type = 'checkbox', value, disabled = false, label, onChange, onClick, onKeyDown, checked, defaultChecked, id, name, extraClassNames, extraLabelClassNames, testId, ...tooltipProps } = props;
17
18
  const assignedId = id ?? 'checkbox_' + Math.random();
19
+ const tooltipData = getQTipData(tooltipProps);
18
20
  return (React.createElement("span", { className: `${alignment} ${extraClassNames}` },
19
- React.createElement("input", { value: value, type: type, "data-testid": testId, name: name, id: assignedId, checked: checked, defaultChecked: defaultChecked, className: `${type === 'checkbox' ? checkboxClasses : radioClasses} ${disabled ? 'tw-cursor-not-allowed' : 'tw-cursor-pointer'}`, disabled: disabled, onClick: onClick, onChange: onChange, onKeyDown: onKeyDown }),
21
+ React.createElement("input", { value: value, type: type, "data-testid": testId, name: name, id: assignedId, checked: checked, defaultChecked: defaultChecked, className: `${type === 'checkbox' ? checkboxClasses : radioClasses} ${disabled ? 'tw-cursor-not-allowed' : 'tw-cursor-pointer'}`, disabled: disabled, onClick: onClick, onChange: onChange, onKeyDown: onKeyDown, ...tooltipData }),
20
22
  React.createElement("label", { htmlFor: assignedId, className: `${labelClasses} ${extraLabelClassNames} ${disabled
21
23
  ? 'tw-cursor-not-allowed dark:tw-text-sq-fairly-dark-gray tw-text-sq-fairly-dark-gray'
22
24
  : 'tw-cursor-pointer tw-text-sq-text-color dark:tw-text-sq-dark-text'}` }, label)));
@@ -1 +1 @@
1
- {"version":3,"file":"Checkbox.js","sourceRoot":"","sources":["../../src/Checkbox/Checkbox.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,eAAe,CAAC;AAEvB,MAAM,SAAS,GAAG,SAAS,CAAC;AAC5B,MAAM,YAAY,GAAG,iCAAiC,CAAC;AAEvD,MAAM,WAAW,GACf,4GAA4G;IAC5G,iGAAiG;IACjG,8FAA8F;IAC9F,mHAAmH;IACnH,0FAA0F,CAAC;AAE7F,MAAM,eAAe,GAAG,+BAA+B,WAAW,EAAE,CAAC;AAErE,MAAM,YAAY,GAAG,iBAAiB,WAAW,EAAE,CAAC;AAEpD;;GAEG;AACH,MAAM,CAAC,MAAM,QAAQ,GAA2C,CAAC,KAA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AAS,EAAE,GAAG,YAAY,IAAI,oBAAoB,IAChD,QAAQ;gBACN,CAAC,CAAC,oFAAoF;gBACtF,CAAC,CAAC,mEACN,EAAE,IACD,KAAK,CACA,CACH,CACR,CAAC;AACJ,CAAC,CAAC"}
@@ -1,23 +1,25 @@
1
1
  import React from 'react';
2
2
  import { Checkbox } from './Checkbox';
3
+ import { QTip } from '../Tooltip';
3
4
  export default {
4
5
  title: 'Checkbox',
5
6
  };
6
7
  export const AllCheckboxes = () => {
7
8
  const getDisplay = (type) => (React.createElement(React.Fragment, null,
9
+ React.createElement(QTip, null),
8
10
  React.createElement("div", { className: "tw-p-4" },
9
- React.createElement(Checkbox, { value: "a", type: type, checked: true, label: 'with Label' })),
11
+ React.createElement(Checkbox, { value: "a", type: type, checked: true, label: 'with Label', tooltip: "Checkbox Tooltip" })),
10
12
  React.createElement("div", { className: "tw-p-4" },
11
13
  React.createElement(Checkbox, { value: "d", type: type, checked: false, disabled: true, label: React.createElement("div", null,
12
14
  "Disabled",
13
15
  React.createElement("br", null),
14
- "multi-Line") })),
16
+ "multi-Line"), tooltip: "Checkbox Tooltip" })),
15
17
  React.createElement("div", { className: "tw-p-4" },
16
- React.createElement(Checkbox, { value: "d", type: type, checked: true, disabled: true, label: "Disabled" })),
18
+ React.createElement(Checkbox, { value: "d", type: type, checked: true, disabled: true, label: "Disabled", tooltip: "Checkbox Tooltip" })),
17
19
  React.createElement("div", { className: "tw-p-4" },
18
- React.createElement(Checkbox, { value: "b", type: type, checked: true })),
20
+ React.createElement(Checkbox, { value: "b", type: type, checked: true, tooltip: "Checkbox Tooltip" })),
19
21
  React.createElement("div", { className: "tw-p-4" },
20
- React.createElement(Checkbox, { value: "c", type: type, checked: false }))));
22
+ React.createElement(Checkbox, { value: "c", type: type, checked: false, tooltip: "Checkbox Tooltip" }))));
21
23
  const renderAllVariations = (type) => (React.createElement(React.Fragment, null,
22
24
  React.createElement("div", { className: "tw-p-4 light" }, getDisplay(type)),
23
25
  React.createElement("div", { className: "tw-p-4 tw-dark tw-bg-sq-dark-background" }, getDisplay(type))));
@@ -1 +1 @@
1
- {"version":3,"file":"Checkbox.stories.js","sourceRoot":"","sources":["../../src/Checkbox/Checkbox.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,eAAe;IACb,KAAK,EAAE,UAAU;CAClB,CAAC;AAEF,MAAM,CAAC,MAAM,aAAa,GAAG,GAAG,EAAE;IAChC,MAAM,UAAU,GAAG,CAAC,IAA0B,EAAE,EAAE,CAAC,CACjD;QACE,6BAAK,SAAS,EAAC,QAAQ;YACrB,oBAAC,QAAQ,IAAC,KAAK,EAAC,GAAG,EAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,YAAY,GAAI,CAClE;QACN,6BAAK,SAAS,EAAC,QAAQ;YACrB,oBAAC,QAAQ,IAAC,KAAK,EAAC,GAAG,EAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE;;oBAAa,+BAAM;iCAAgB,GAAI,CAC1G;QACN,6BAAK,SAAS,EAAC,QAAQ;YACrB,oBAAC,QAAQ,IAAC,KAAK,EAAC,GAAG,EAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAC,UAAU,GAAG,CAC9E;QACN,6BAAK,SAAS,EAAC,QAAQ;YACrB,oBAAC,QAAQ,IAAC,KAAK,EAAC,GAAG,EAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,GAAI,CAC7C;QACN,6BAAK,SAAS,EAAC,QAAQ;YACrB,oBAAC,QAAQ,IAAC,KAAK,EAAC,GAAG,EAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,GAAI,CAC9C,CACL,CACJ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QACN,6BAAK,SAAS,EAAC,QAAQ;YACrB,oBAAC,QAAQ,IAAC,KAAK,EAAC,GAAG,EAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAC,UAAU,EAAC,OAAO,EAAC,kBAAkB,GAAG,CACzG;QACN,6BAAK,SAAS,EAAC,QAAQ;YACrB,oBAAC,QAAQ,IAAC,KAAK,EAAC,GAAG,EAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAC,kBAAkB,GAAG,CACxE;QACN,6BAAK,SAAS,EAAC,QAAQ;YACrB,oBAAC,QAAQ,IAAC,KAAK,EAAC,GAAG,EAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAC,kBAAkB,GAAG,CACzE,CACL,CACJ,CAAC;IACF,MAAM,mBAAmB,GAAG,CAAC,IAA0B,EAAE,EAAE,CAAC,CAC1D;QACE,6BAAK,SAAS,EAAC,cAAc,IAAE,UAAU,CAAC,IAAI,CAAC,CAAO;QACtD,6BAAK,SAAS,EAAC,yCAAyC,IAAE,UAAU,CAAC,IAAI,CAAC,CAAO,CAChF,CACJ,CAAC;IAEF,OAAO,CACL,6BAAK,SAAS,EAAC,iCAAiC;QAC9C;YACE,0CAAe;YACd,mBAAmB,CAAC,UAAU,CAAC,CAC5B;QAEN;YACE,wCAAa;YACZ,mBAAmB,CAAC,OAAO,CAAC,CACzB,CACF,CACP,CAAC;AACJ,CAAC,CAAC"}
@@ -1,5 +1,6 @@
1
+ import { TooltipComponentProps } from '../Tooltip/Tooltip.types';
1
2
  type FormControlElement = HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement;
2
- export interface CheckboxProps {
3
+ export interface CheckboxProps extends TooltipComponentProps {
3
4
  extraClassNames?: string;
4
5
  extraLabelClassNames?: string;
5
6
  type?: 'radio' | 'checkbox';