@seeqdev/qomponents 0.0.115 → 0.0.117
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/README.md +135 -135
- package/dist/Accordion/Accordion.js +9 -0
- package/dist/Accordion/Accordion.js.map +1 -0
- package/dist/Accordion/Accordion.stories.js +115 -0
- package/dist/Accordion/Accordion.stories.js.map +1 -0
- package/dist/Accordion/Accordion.test.js +55 -0
- package/dist/Accordion/Accordion.test.js.map +1 -0
- package/dist/Accordion/Accordion.types.js +2 -0
- package/dist/Accordion/Accordion.types.js.map +1 -0
- package/dist/Accordion/index.js +2 -0
- package/dist/Accordion/index.js.map +1 -0
- package/dist/Alert/Alert.js +34 -0
- package/dist/Alert/Alert.js.map +1 -0
- package/dist/Alert/Alert.stories.js +52 -0
- package/dist/Alert/Alert.stories.js.map +1 -0
- package/dist/Alert/Alert.test.js +51 -0
- package/dist/Alert/Alert.test.js.map +1 -0
- package/dist/Alert/Alert.types.js +2 -0
- package/dist/Alert/Alert.types.js.map +1 -0
- package/dist/Alert/index.js +2 -0
- package/dist/Alert/index.js.map +1 -0
- package/dist/Button/Button.js +92 -0
- package/dist/Button/Button.js.map +1 -0
- package/dist/Button/Button.stories.js +100 -0
- package/dist/Button/Button.stories.js.map +1 -0
- package/dist/Button/Button.test.js +49 -0
- package/dist/Button/Button.test.js.map +1 -0
- package/dist/Button/Button.types.js +5 -0
- package/dist/Button/Button.types.js.map +1 -0
- package/dist/Button/index.js +2 -0
- package/dist/Button/index.js.map +1 -0
- package/dist/ButtonWithDropdown/ButtonWithDropdown.js +67 -0
- package/dist/ButtonWithDropdown/ButtonWithDropdown.js.map +1 -0
- package/dist/ButtonWithDropdown/ButtonWithDropdown.stories.js +98 -0
- package/dist/ButtonWithDropdown/ButtonWithDropdown.stories.js.map +1 -0
- package/dist/ButtonWithDropdown/ButtonWithDropdown.test.js +85 -0
- package/dist/ButtonWithDropdown/ButtonWithDropdown.test.js.map +1 -0
- package/dist/ButtonWithDropdown/ButtonWithDropdown.types.js +2 -0
- package/dist/ButtonWithDropdown/ButtonWithDropdown.types.js.map +1 -0
- package/dist/ButtonWithDropdown/index.js +2 -0
- package/dist/ButtonWithDropdown/index.js.map +1 -0
- package/dist/ButtonWithPopover/ButtonWithPopover.js +53 -0
- package/dist/ButtonWithPopover/ButtonWithPopover.js.map +1 -0
- package/dist/ButtonWithPopover/ButtonWithPopover.stories.js +75 -0
- package/dist/ButtonWithPopover/ButtonWithPopover.stories.js.map +1 -0
- package/dist/ButtonWithPopover/ButtonWithPopover.test.js +82 -0
- package/dist/ButtonWithPopover/ButtonWithPopover.test.js.map +1 -0
- package/dist/ButtonWithPopover/ButtonWithPopover.types.js +2 -0
- package/dist/ButtonWithPopover/ButtonWithPopover.types.js.map +1 -0
- package/dist/ButtonWithPopover/index.js +2 -0
- package/dist/ButtonWithPopover/index.js.map +1 -0
- package/dist/Checkbox/Checkbox.js +26 -0
- package/dist/Checkbox/Checkbox.js.map +1 -0
- package/dist/Checkbox/Checkbox.stories.js +34 -0
- package/dist/Checkbox/Checkbox.stories.js.map +1 -0
- package/dist/Checkbox/Checkbox.test.js +94 -0
- package/dist/Checkbox/Checkbox.test.js.map +1 -0
- package/dist/Checkbox/Checkbox.types.js +2 -0
- package/dist/Checkbox/Checkbox.types.js.map +1 -0
- package/dist/Checkbox/index.js +2 -0
- package/dist/Checkbox/index.js.map +1 -0
- package/dist/Collapse/Collapse.d.ts +4 -0
- package/dist/Collapse/Collapse.js +18 -0
- package/dist/Collapse/Collapse.js.map +1 -0
- package/dist/Collapse/Collapse.stories.d.ts +5 -0
- package/dist/Collapse/Collapse.stories.js +37 -0
- package/dist/Collapse/Collapse.stories.js.map +1 -0
- package/dist/Collapse/Collapse.test.d.ts +1 -0
- package/dist/Collapse/Collapse.test.js +19 -0
- package/dist/Collapse/Collapse.test.js.map +1 -0
- package/dist/Collapse/Collapse.types.d.ts +4 -0
- package/dist/Collapse/Collapse.types.js +2 -0
- package/dist/Collapse/Collapse.types.js.map +1 -0
- package/dist/Collapse/index.d.ts +1 -0
- package/dist/Collapse/index.js +2 -0
- package/dist/Collapse/index.js.map +1 -0
- package/dist/Icon/Icon.js +55 -0
- package/dist/Icon/Icon.js.map +1 -0
- package/dist/Icon/Icon.stories.js +50 -0
- package/dist/Icon/Icon.stories.js.map +1 -0
- package/dist/Icon/Icon.test.js +55 -0
- package/dist/Icon/Icon.test.js.map +1 -0
- package/dist/Icon/Icon.types.js +16 -0
- package/dist/Icon/Icon.types.js.map +1 -0
- package/dist/Icon/index.js +2 -0
- package/dist/Icon/index.js.map +1 -0
- package/dist/InputGroup/InputGroup.js +32 -0
- package/dist/InputGroup/InputGroup.js.map +1 -0
- package/dist/InputGroup/InputGroup.stories.js +168 -0
- package/dist/InputGroup/InputGroup.stories.js.map +1 -0
- package/dist/InputGroup/InputGroup.test.js +43 -0
- package/dist/InputGroup/InputGroup.test.js.map +1 -0
- package/dist/InputGroup/InputGroup.types.js +2 -0
- package/dist/InputGroup/InputGroup.types.js.map +1 -0
- package/dist/InputGroup/index.js +2 -0
- package/dist/InputGroup/index.js.map +1 -0
- package/dist/Modal/Modal.js +100 -0
- package/dist/Modal/Modal.js.map +1 -0
- package/dist/Modal/Modal.stories.js +127 -0
- package/dist/Modal/Modal.stories.js.map +1 -0
- package/dist/Modal/Modal.test.js +108 -0
- package/dist/Modal/Modal.test.js.map +1 -0
- package/dist/Modal/Modal.types.js +2 -0
- package/dist/Modal/Modal.types.js.map +1 -0
- package/dist/Modal/index.js +2 -0
- package/dist/Modal/index.js.map +1 -0
- package/dist/ProgressBar/ProgressBar.js +30 -0
- package/dist/ProgressBar/ProgressBar.js.map +1 -0
- package/dist/ProgressBar/ProgressBar.stories.js +73 -0
- package/dist/ProgressBar/ProgressBar.stories.js.map +1 -0
- package/dist/ProgressBar/ProgressBar.test.js +38 -0
- package/dist/ProgressBar/ProgressBar.test.js.map +1 -0
- package/dist/ProgressBar/ProgressBar.types.d.ts +22 -6
- package/dist/ProgressBar/ProgressBar.types.js +2 -0
- package/dist/ProgressBar/ProgressBar.types.js.map +1 -0
- package/dist/ProgressBar/index.js +2 -0
- package/dist/ProgressBar/index.js.map +1 -0
- package/dist/SeeqActionDropdown/SeeqActionDropdown.js +48 -0
- package/dist/SeeqActionDropdown/SeeqActionDropdown.js.map +1 -0
- package/dist/SeeqActionDropdown/SeeqActionDropdown.stories.js +80 -0
- package/dist/SeeqActionDropdown/SeeqActionDropdown.stories.js.map +1 -0
- package/dist/SeeqActionDropdown/SeeqActionDropdown.test.js +73 -0
- package/dist/SeeqActionDropdown/SeeqActionDropdown.test.js.map +1 -0
- package/dist/SeeqActionDropdown/SeeqActionDropdown.types.js +2 -0
- package/dist/SeeqActionDropdown/SeeqActionDropdown.types.js.map +1 -0
- package/dist/SeeqActionDropdown/index.js +2 -0
- package/dist/SeeqActionDropdown/index.js.map +1 -0
- package/dist/SeeqActionDropdown/variants.js +23 -0
- package/dist/SeeqActionDropdown/variants.js.map +1 -0
- package/dist/Select/Select.js +174 -0
- package/dist/Select/Select.js.map +1 -0
- package/dist/Select/Select.stories.js +80 -0
- package/dist/Select/Select.stories.js.map +1 -0
- package/dist/Select/Select.test.js +182 -0
- package/dist/Select/Select.test.js.map +1 -0
- package/dist/Select/Select.types.js +2 -0
- package/dist/Select/Select.types.js.map +1 -0
- package/dist/Select/index.js +3 -0
- package/dist/Select/index.js.map +1 -0
- package/dist/Slider/Slider.js +13 -0
- package/dist/Slider/Slider.js.map +1 -0
- package/dist/Slider/Slider.stories.js +58 -0
- package/dist/Slider/Slider.stories.js.map +1 -0
- package/dist/Slider/Slider.test.js +33 -0
- package/dist/Slider/Slider.test.js.map +1 -0
- package/dist/Slider/Slider.types.js +2 -0
- package/dist/Slider/Slider.types.js.map +1 -0
- package/dist/Slider/index.js +2 -0
- package/dist/Slider/index.js.map +1 -0
- package/dist/Tabs/Tabs.js +22 -0
- package/dist/Tabs/Tabs.js.map +1 -0
- package/dist/Tabs/Tabs.stories.js +91 -0
- package/dist/Tabs/Tabs.stories.js.map +1 -0
- package/dist/Tabs/Tabs.test.js +91 -0
- package/dist/Tabs/Tabs.test.js.map +1 -0
- package/dist/Tabs/Tabs.types.js +2 -0
- package/dist/Tabs/Tabs.types.js.map +1 -0
- package/dist/Tabs/index.js +2 -0
- package/dist/Tabs/index.js.map +1 -0
- package/dist/TextArea/TextArea.js +25 -0
- package/dist/TextArea/TextArea.js.map +1 -0
- package/dist/TextArea/TextArea.stories.js +46 -0
- package/dist/TextArea/TextArea.stories.js.map +1 -0
- package/dist/TextArea/TextArea.test.js +68 -0
- package/dist/TextArea/TextArea.test.js.map +1 -0
- package/dist/TextArea/TextArea.types.js +2 -0
- package/dist/TextArea/TextArea.types.js.map +1 -0
- package/dist/TextArea/index.js +2 -0
- package/dist/TextArea/index.js.map +1 -0
- package/dist/TextField/TextField.js +79 -0
- package/dist/TextField/TextField.js.map +1 -0
- package/dist/TextField/TextField.stories.js +70 -0
- package/dist/TextField/TextField.stories.js.map +1 -0
- package/dist/TextField/TextField.test.js +39 -0
- package/dist/TextField/TextField.test.js.map +1 -0
- package/dist/TextField/TextField.types.js +2 -0
- package/dist/TextField/TextField.types.js.map +1 -0
- package/dist/TextField/index.js +2 -0
- package/dist/TextField/index.js.map +1 -0
- package/dist/ToolbarButton/ToolbarButton.js +75 -0
- package/dist/ToolbarButton/ToolbarButton.js.map +1 -0
- package/dist/ToolbarButton/ToolbarButton.stories.js +94 -0
- package/dist/ToolbarButton/ToolbarButton.stories.js.map +1 -0
- package/dist/ToolbarButton/ToolbarButton.test.js +93 -0
- package/dist/ToolbarButton/ToolbarButton.test.js.map +1 -0
- package/dist/ToolbarButton/ToolbarButton.types.js +2 -0
- package/dist/ToolbarButton/ToolbarButton.types.js.map +1 -0
- package/dist/ToolbarButton/index.js +2 -0
- package/dist/ToolbarButton/index.js.map +1 -0
- package/dist/Tooltip/QTip.stories.js +45 -0
- package/dist/Tooltip/QTip.stories.js.map +1 -0
- package/dist/Tooltip/QTip.types.js +2 -0
- package/dist/Tooltip/QTip.types.js.map +1 -0
- package/dist/Tooltip/QTipPerformance.stories.js +30 -0
- package/dist/Tooltip/QTipPerformance.stories.js.map +1 -0
- package/dist/Tooltip/Qtip.js +168 -0
- package/dist/Tooltip/Qtip.js.map +1 -0
- package/dist/Tooltip/Tooltip.js +36 -0
- package/dist/Tooltip/Tooltip.js.map +1 -0
- package/dist/Tooltip/Tooltip.stories.js +32 -0
- package/dist/Tooltip/Tooltip.stories.js.map +1 -0
- package/dist/Tooltip/Tooltip.types.js +3 -0
- package/dist/Tooltip/Tooltip.types.js.map +1 -0
- package/dist/Tooltip/TooltipPerformance.stories.js +30 -0
- package/dist/Tooltip/TooltipPerformance.stories.js.map +1 -0
- package/dist/Tooltip/index.js +3 -0
- package/dist/Tooltip/index.js.map +1 -0
- package/dist/Tooltip/qTip.utilities.js +11 -0
- package/dist/Tooltip/qTip.utilities.js.map +1 -0
- package/dist/example/.eslintrc.cjs +14 -14
- package/dist/example/README.md +33 -33
- package/dist/example/index.html +13 -13
- package/dist/example/package.json +30 -30
- package/dist/example/src/ComplexSelectExample.tsx +81 -81
- package/dist/example/src/Example.tsx +408 -408
- package/dist/example/src/index.css +102 -102
- package/dist/example/src/main.tsx +10 -10
- package/dist/example/src/vite-env.d.ts +1 -1
- package/dist/example/tsconfig.json +33 -33
- package/dist/example/tsconfig.node.json +12 -12
- package/dist/example/vite.config.ts +12 -12
- package/dist/index.d.ts +2 -0
- package/dist/index.esm.js +3566 -52
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +3563 -48
- package/dist/index.js.map +1 -1
- package/dist/styles.css +3629 -3631
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/browserId.js +29 -0
- package/dist/utils/browserId.js.map +1 -0
- package/dist/utils/svg.js +20 -0
- package/dist/utils/svg.js.map +1 -0
- package/dist/utils/validateStyleDimension.js +14 -0
- package/dist/utils/validateStyleDimension.js.map +1 -0
- package/dist/utils/validateStyleDimension.test.js +20 -0
- package/dist/utils/validateStyleDimension.test.js.map +1 -0
- package/package.json +86 -85
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { fireEvent, render, screen } from '@testing-library/react';
|
|
3
|
+
import '@testing-library/jest-dom/extend-expect';
|
|
4
|
+
import { Alert } from './Alert';
|
|
5
|
+
describe('Alert Component', () => {
|
|
6
|
+
const defaultProps = {
|
|
7
|
+
children: 'Test Alert',
|
|
8
|
+
dismissible: true,
|
|
9
|
+
onClose: jest.fn(),
|
|
10
|
+
show: true,
|
|
11
|
+
variant: 'theme',
|
|
12
|
+
testId: 'alert-test-id',
|
|
13
|
+
id: 'alert-id',
|
|
14
|
+
extraClassNames: '',
|
|
15
|
+
};
|
|
16
|
+
it('should render the Alert component', () => {
|
|
17
|
+
render(React.createElement(Alert, { ...defaultProps }));
|
|
18
|
+
const alertElement = screen.getByTestId('alert-test-id');
|
|
19
|
+
expect(alertElement).toBeInTheDocument();
|
|
20
|
+
});
|
|
21
|
+
it('should render children correctly', () => {
|
|
22
|
+
render(React.createElement(Alert, { ...defaultProps }));
|
|
23
|
+
const alertElement = screen.getByTestId('alert-test-id');
|
|
24
|
+
expect(alertElement).toHaveTextContent('Test Alert');
|
|
25
|
+
});
|
|
26
|
+
it('should apply the correct classes based on variant', () => {
|
|
27
|
+
const { rerender } = render(React.createElement(Alert, { ...defaultProps, variant: "danger" }));
|
|
28
|
+
let alertElement = screen.getByTestId('alert-test-id');
|
|
29
|
+
expect(alertElement).toHaveClass('tw-text-sq-text-color tw-bg-sq-danger-color');
|
|
30
|
+
rerender(React.createElement(Alert, { ...defaultProps, variant: "warning" }));
|
|
31
|
+
alertElement = screen.getByTestId('alert-test-id');
|
|
32
|
+
expect(alertElement).toHaveClass('tw-bg-sq-bg-warning-color tw-text-sq-text-color');
|
|
33
|
+
});
|
|
34
|
+
it('should call onClose when dismissible icon is clicked', () => {
|
|
35
|
+
render(React.createElement(Alert, { ...defaultProps }));
|
|
36
|
+
const closeButton = screen.getByTestId('alert-test-id-close-btn');
|
|
37
|
+
fireEvent.click(closeButton);
|
|
38
|
+
expect(defaultProps.onClose).toHaveBeenCalled();
|
|
39
|
+
});
|
|
40
|
+
it('should not render when show is false', () => {
|
|
41
|
+
render(React.createElement(Alert, { ...defaultProps, show: false }));
|
|
42
|
+
const alertElement = screen.queryByTestId('alert-test-id');
|
|
43
|
+
expect(alertElement).not.toBeInTheDocument();
|
|
44
|
+
});
|
|
45
|
+
it('should apply extra class names', () => {
|
|
46
|
+
render(React.createElement(Alert, { ...defaultProps, extraClassNames: "extra-class" }));
|
|
47
|
+
const alertElement = screen.getByTestId('alert-test-id');
|
|
48
|
+
expect(alertElement).toHaveClass('extra-class');
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
//# sourceMappingURL=Alert.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Alert.test.js","sourceRoot":"","sources":["../../src/Alert/Alert.test.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AACnE,OAAO,yCAAyC,CAAC;AACjD,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAGhC,QAAQ,CAAC,iBAAiB,EAAE,GAAG,EAAE;IAC/B,MAAM,YAAY,GAAe;QAC/B,QAAQ,EAAE,YAAY;QACtB,WAAW,EAAE,IAAI;QACjB,OAAO,EAAE,IAAI,CAAC,EAAE,EAAE;QAClB,IAAI,EAAE,IAAI;QACV,OAAO,EAAE,OAAO;QAChB,MAAM,EAAE,eAAe;QACvB,EAAE,EAAE,UAAU;QACd,eAAe,EAAE,EAAE;KACpB,CAAC;IAEF,EAAE,CAAC,mCAAmC,EAAE,GAAG,EAAE;QAC3C,MAAM,CAAC,oBAAC,KAAK,OAAK,YAAY,GAAI,CAAC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C,gBAAgB,EAAE,CAAC;IAClD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,sCAAsC,EAAE,GAAG,EAAE;QAC9C,MAAM,CAAC,oBAAC,KAAK,OAAK,YAAY,EAAE,IAAI,EAAE,KAAK,GAAI,CAAC,CAAC;QACjD,MAAM,YAAY,GAAG,MAAM,CAAC,aAAa,CAAC,eAAe,CAAC,CAAC;QAC3D,MAAM,CAAC,YAAY,CAAC,CAAC,GAAG,CAAC,iBAAiB,EAAE,CAAC;IAC/C,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,gCAAgC,EAAE,GAAG,EAAE;QACxC,MAAM,CAAC,oBAAC,KAAK,OAAK,YAAY,EAAE,eAAe,EAAC,aAAa,GAAG,CAAC,CAAC;QAClE,MAAM,YAAY,GAAG,MAAM,CAAC,WAAW,CAAC,eAAe,CAAC,CAAC;QACzD,MAAM,CAAC,YAAY,CAAC,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC;IAClD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Alert.types.js","sourceRoot":"","sources":["../../src/Alert/Alert.types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/Alert/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,IAAI,OAAO,EAAE,MAAM,SAAS,CAAC"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import '../styles.css';
|
|
3
|
+
import { browserIsFirefox } from '../utils/browserId';
|
|
4
|
+
import Icon from '../Icon';
|
|
5
|
+
import { DEFAULT_TOOL_TIP_DELAY } from '../Tooltip/Tooltip.types';
|
|
6
|
+
/**
|
|
7
|
+
* All-in-one Button:
|
|
8
|
+
* - use "variant" to achieve the desired style
|
|
9
|
+
* - include tooltips and/or icons
|
|
10
|
+
*/
|
|
11
|
+
const Button = ({ onClick, label, variant = 'outline', type = 'button', size = 'sm', disabled, extraClassNames, id, testId, stopPropagation = true, tooltip, tooltipOptions, iconStyle = 'text', icon, iconColor, iconPosition = 'left', iconPrefix = undefined, preventBlur = false, isHtmlTooltip = false, tooltipTestId, }) => {
|
|
12
|
+
const baseClasses = 'tw-py-1 tw-px-2.5 tw-rounded-sm focus:tw-ring-0 focus-visible:tw-outline-none disabled:tw-pointer-events-none';
|
|
13
|
+
const baseClassesByVariant = {
|
|
14
|
+
'outline': 'disabled:tw-opacity-50 tw-border-solid tw-border',
|
|
15
|
+
'theme': 'disabled:tw-opacity-50 tw-border-solid tw-border',
|
|
16
|
+
'danger': 'tw-bg-sq-danger-color hover:tw-bg-sq-danger-color-hover disabled:tw-opacity-50 tw-border-solid tw-border ' +
|
|
17
|
+
'tw-border-sq-danger-color hover:tw-border-sq-danger-color-hover',
|
|
18
|
+
'theme-light': 'disabled:tw-opacity-50 tw-border-solid tw-border',
|
|
19
|
+
'no-border': 'disabled:tw-opacity-50',
|
|
20
|
+
'warning': 'tw-bg-sq-warning-color tw-border-solid tw-border tw-border-sq-warning-color',
|
|
21
|
+
};
|
|
22
|
+
const textClassesByVariantLightTheme = {
|
|
23
|
+
'outline': 'tw-text-sq-text-color',
|
|
24
|
+
'theme': 'tw-text-white',
|
|
25
|
+
'theme-light': 'tw-text-white',
|
|
26
|
+
'danger': 'tw-text-white',
|
|
27
|
+
'no-border': 'tw-text-sq-text-color',
|
|
28
|
+
'warning': 'tw-text-white',
|
|
29
|
+
};
|
|
30
|
+
const textClassesByVariantDarkTheme = {
|
|
31
|
+
'outline': 'dark:tw-text-sq-dark-text',
|
|
32
|
+
'theme': 'dark:tw-text-white',
|
|
33
|
+
'theme-light': 'dark:tw-text-white',
|
|
34
|
+
'danger': 'dark:tw-text-white',
|
|
35
|
+
'no-border': 'dark:tw-text-sq-dark-text',
|
|
36
|
+
'warning': 'dark:tw-text-white',
|
|
37
|
+
};
|
|
38
|
+
const classesByVariantLightTheme = {
|
|
39
|
+
'outline': 'tw-bg-white dark:tw-bg-sq-dark-background tw-border-sq-disabled-gray hover:tw-bg-sq-light-gray' +
|
|
40
|
+
' focus:tw-bg-sq-dark-gray active:tw-bg-sq-dark-gray focus:tw-border-sq-color-dark active:tw-border-sq-color-dark',
|
|
41
|
+
'theme': 'tw-bg-sq-color-dark hover:tw-bg-sq-color-highlight tw-border-sq-color-dark' +
|
|
42
|
+
' hover:tw-border-sq-color-highlight',
|
|
43
|
+
'danger': '',
|
|
44
|
+
'theme-light': 'tw-bg-sq-icon hover:tw-bg-sq-link tw-border-sq-icon hover:tw-border-sq-link',
|
|
45
|
+
'no-border': '',
|
|
46
|
+
'warning': '',
|
|
47
|
+
};
|
|
48
|
+
const classesByVariantDarkTheme = {
|
|
49
|
+
'outline': 'dark:tw-border-sq-dark-disabled-gray dark:hover:tw-bg-sq-highlight-color-dark' +
|
|
50
|
+
' dark:focus:tw-bg-sq-multi-gray-dark dark:active:tw-bg-sq-multi-gray-dark dark:focus:tw-border-sq-color-dark' +
|
|
51
|
+
' dark:active:tw-border-sq-color-dark',
|
|
52
|
+
'theme': 'dark:tw-bg-sq-color-dark dark:hover:tw-bg-sq-color-highlight dark:tw-border-sq-color-dark' +
|
|
53
|
+
' dark:hover:tw-border-sq-color-highlight',
|
|
54
|
+
'danger': '',
|
|
55
|
+
'theme-light': 'dark:tw-bg-sq-icon-dark dark:hover:tw-bg-sq-link-dark dark:tw-border-sq-icon-dark' +
|
|
56
|
+
' dark:hover:tw-border-sq-link-dark',
|
|
57
|
+
'no-border': '',
|
|
58
|
+
'warning': '',
|
|
59
|
+
};
|
|
60
|
+
const sizeClasses = {
|
|
61
|
+
sm: 'tw-text-sm',
|
|
62
|
+
lg: 'tw-text-xl',
|
|
63
|
+
};
|
|
64
|
+
const appliedClasses = `${baseClasses} ${baseClassesByVariant[variant]} ${sizeClasses[size]} ${classesByVariantLightTheme[variant]} ${classesByVariantDarkTheme[variant]} ${textClassesByVariantLightTheme[variant]} ${textClassesByVariantDarkTheme[variant]} ${extraClassNames}`;
|
|
65
|
+
let tooltipData = undefined;
|
|
66
|
+
if (tooltip) {
|
|
67
|
+
tooltipData = {
|
|
68
|
+
'data-qtip-text': tooltip,
|
|
69
|
+
'data-qtip-placement': tooltipOptions?.position,
|
|
70
|
+
'data-qtip-is-html': isHtmlTooltip,
|
|
71
|
+
'data-qtip-testid': tooltipTestId,
|
|
72
|
+
'data-qtip-delay': tooltipOptions?.delay ?? DEFAULT_TOOL_TIP_DELAY,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
const iconClass = iconPosition === 'left' ? 'tw-mr-1' : 'tw-ml-1';
|
|
76
|
+
const iconElement = icon && (React.createElement(Icon, { icon: icon, iconPrefix: iconPrefix, type: iconStyle, color: iconColor, extraClassNames: label
|
|
77
|
+
? `${iconClass} ${textClassesByVariantLightTheme[variant]} ${textClassesByVariantDarkTheme[variant]}`
|
|
78
|
+
: '', testId: `${id}_spinner` }));
|
|
79
|
+
return (React.createElement("button", { id: id, ...tooltipData, disabled: disabled, "data-testid": testId, type: type === 'link' || (type === 'submit' && browserIsFirefox) ? 'button' : type, onClick: (e) => {
|
|
80
|
+
stopPropagation && e.stopPropagation();
|
|
81
|
+
onClick && onClick(e);
|
|
82
|
+
}, onMouseDown: (e) => {
|
|
83
|
+
if (preventBlur) {
|
|
84
|
+
e.preventDefault();
|
|
85
|
+
}
|
|
86
|
+
}, className: appliedClasses },
|
|
87
|
+
iconPosition === 'left' && iconElement,
|
|
88
|
+
label,
|
|
89
|
+
iconPosition === 'right' && iconElement));
|
|
90
|
+
};
|
|
91
|
+
export default Button;
|
|
92
|
+
//# sourceMappingURL=Button.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Button.js","sourceRoot":"","sources":["../../src/Button/Button.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,eAAe,CAAC;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,EAAE,SAAS,EACf,KAAK,EAAE,SAAS,EAChB,eAAe,EACb,KAAK;YACH,CAAC,CAAC,GAAG,SAAS,IAAI,8BAA8B,CAAC,OAAO,CAAC,KAAK,6BAA6B,CAAC,OAAO,CAAC,EAAE;YACtG,CAAC,CAAC,EAAE,EAER,MAAM,EAAE,GAAG,EAAE,UAAU,GACvB,CACH,CAAC;IAEF,OAAO,CACL,gCACE,EAAE,EAAE,EAAE,KACF,WAAW,EACf,QAAQ,EAAE,QAAQ,iBACL,MAAM,EACnB,IAAI,EAAE,IAAI,KAAK,MAAM,IAAI,CAAC,IAAI,KAAK,QAAQ,IAAI,gBAAgB,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,EAClF,OAAO,EAAE,CAAC,CAAmB,EAAE,EAAE;YAC/B,eAAe,IAAI,CAAC,CAAC,eAAe,EAAE,CAAC;YACvC,OAAO,IAAI,OAAO,CAAC,CAAC,CAAC,CAAC;QACxB,CAAC,EACD,WAAW,EAAE,CAAC,CAAC,EAAE,EAAE;YACjB,IAAI,WAAW,EAAE;gBACf,CAAC,CAAC,cAAc,EAAE,CAAC;aACpB;QACH,CAAC,EACD,SAAS,EAAE,cAAc;QACxB,YAAY,KAAK,MAAM,IAAI,WAAW;QACtC,KAAK;QACL,YAAY,KAAK,OAAO,IAAI,WAAW,CACjC,CACV,CAAC;AACJ,CAAC,CAAC;AACF,eAAe,MAAM,CAAC"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import Button from './Button';
|
|
3
|
+
import { buttonVariants } from './Button.types';
|
|
4
|
+
import { QTip } from '../Tooltip';
|
|
5
|
+
export default {
|
|
6
|
+
title: 'Button',
|
|
7
|
+
};
|
|
8
|
+
export const AllButtonVariants = () => {
|
|
9
|
+
const renderAllVariations = () => (React.createElement(React.Fragment, null, buttonVariants.map((variant) => (React.createElement("div", { key: `{variant_${variant}`, className: "tw-grid tw-grid-cols-2 tw-gap-4" },
|
|
10
|
+
React.createElement("div", { className: "tw-p-4" },
|
|
11
|
+
React.createElement(Button, { label: `Variant: ${variant}`, onClick: () => { }, variant: variant })),
|
|
12
|
+
React.createElement("div", { className: "tw-p-4 tw-dark tw-bg-sq-dark-background" },
|
|
13
|
+
React.createElement(Button, { label: `Variant: ${variant}`, onClick: () => { }, variant: variant })))))));
|
|
14
|
+
return (React.createElement("div", { className: "tw-grid tw-grid-cols-4 tw-gap-4" },
|
|
15
|
+
React.createElement("div", { className: "color_topic" },
|
|
16
|
+
React.createElement("b", null, "Topic Colors"),
|
|
17
|
+
renderAllVariations()),
|
|
18
|
+
React.createElement("div", { className: "color_analysis" },
|
|
19
|
+
React.createElement("b", null, "Analysis Colors"),
|
|
20
|
+
renderAllVariations()),
|
|
21
|
+
React.createElement("div", { className: "color_datalab" },
|
|
22
|
+
React.createElement("b", null, "Datalab Colors"),
|
|
23
|
+
renderAllVariations()),
|
|
24
|
+
React.createElement("div", { className: "color_vantage" },
|
|
25
|
+
React.createElement("b", null, "Vantage Colors"),
|
|
26
|
+
renderAllVariations())));
|
|
27
|
+
};
|
|
28
|
+
export const ButtonWithTooltip = () => {
|
|
29
|
+
const renderButtonWithTooltip = () => (React.createElement(React.Fragment, null,
|
|
30
|
+
React.createElement("div", { className: "tw-p-4" },
|
|
31
|
+
React.createElement(Button, { tooltip: "Helpful tooltip", variant: "theme", label: "Hover me" })),
|
|
32
|
+
React.createElement("div", { className: "tw-p-4 tw-dark tw-bg-sq-dark-background" },
|
|
33
|
+
React.createElement(Button, { tooltip: "Helpful tooltip", variant: "theme", label: "Hover me" }))));
|
|
34
|
+
return (React.createElement("div", { className: "tw-grid tw-grid-cols-4 tw-gap-4" },
|
|
35
|
+
React.createElement(QTip, null),
|
|
36
|
+
React.createElement("div", { className: "color_topic" },
|
|
37
|
+
React.createElement("b", null, "Topic Colors"),
|
|
38
|
+
renderButtonWithTooltip()),
|
|
39
|
+
React.createElement("div", { className: "color_analysis" },
|
|
40
|
+
React.createElement("b", null, "Analysis Colors"),
|
|
41
|
+
renderButtonWithTooltip()),
|
|
42
|
+
React.createElement("div", { className: "color_datalab" },
|
|
43
|
+
React.createElement("b", null, "Datalab Colors"),
|
|
44
|
+
renderButtonWithTooltip()),
|
|
45
|
+
React.createElement("div", { className: "color_vantage" },
|
|
46
|
+
React.createElement("b", null, "Vantage Colors"),
|
|
47
|
+
renderButtonWithTooltip())));
|
|
48
|
+
};
|
|
49
|
+
export const ButtonWithIcon = () => {
|
|
50
|
+
const renderButtonWithIcon = () => (React.createElement(React.Fragment, null,
|
|
51
|
+
React.createElement("div", { className: "tw-p-4" },
|
|
52
|
+
React.createElement(Button, { icon: "fc-search-power", variant: "theme", label: "With Icon" })),
|
|
53
|
+
React.createElement("div", { className: "tw-p-4 tw-dark tw-bg-sq-dark-background" },
|
|
54
|
+
React.createElement(Button, { icon: "fc-search-power", variant: "theme", label: "With Icon" }))));
|
|
55
|
+
const renderButtonWithIconOnRight = () => (React.createElement(React.Fragment, null,
|
|
56
|
+
React.createElement("div", { className: "tw-p-4" },
|
|
57
|
+
React.createElement(Button, { icon: "fc-search-power", iconPosition: "right", variant: "theme", label: "With Icon On Right" })),
|
|
58
|
+
React.createElement("div", { className: "tw-p-4 tw-dark tw-bg-sq-dark-background" },
|
|
59
|
+
React.createElement(Button, { icon: "fc-search-power", iconPosition: "right", variant: "theme", label: "With Icon On Right" }))));
|
|
60
|
+
return (React.createElement("div", { className: "tw-grid tw-grid-cols-4 tw-gap-4" },
|
|
61
|
+
React.createElement("div", { className: "color_topic" },
|
|
62
|
+
React.createElement("b", null, "Topic Colors"),
|
|
63
|
+
renderButtonWithIcon()),
|
|
64
|
+
React.createElement("div", { className: "color_analysis" },
|
|
65
|
+
React.createElement("b", null, "Analysis Colors"),
|
|
66
|
+
renderButtonWithIcon()),
|
|
67
|
+
React.createElement("div", { className: "color_datalab" },
|
|
68
|
+
React.createElement("b", null, "Datalab Colors"),
|
|
69
|
+
renderButtonWithIcon()),
|
|
70
|
+
React.createElement("div", { className: "color_vantage" },
|
|
71
|
+
React.createElement("b", null, "Vantage Colors"),
|
|
72
|
+
renderButtonWithIcon()),
|
|
73
|
+
React.createElement("div", { className: "color_topic" }, renderButtonWithIconOnRight()),
|
|
74
|
+
React.createElement("div", { className: "color_analysis" }, renderButtonWithIconOnRight()),
|
|
75
|
+
React.createElement("div", { className: "color_datalab" }, renderButtonWithIconOnRight()),
|
|
76
|
+
React.createElement("div", { className: "color_vantage" }, renderButtonWithIconOnRight())));
|
|
77
|
+
};
|
|
78
|
+
export const DisabledButton = () => {
|
|
79
|
+
const renderDisabledButton = () => (React.createElement(React.Fragment, null,
|
|
80
|
+
React.createElement("div", { className: "tw-p-4" },
|
|
81
|
+
React.createElement(Button, { disabled: true, variant: "theme", label: "Disabled Button" }),
|
|
82
|
+
React.createElement(Button, { extraClassNames: "tw-m-5", disabled: true, label: "Disabled Button" })),
|
|
83
|
+
React.createElement("div", { className: "tw-p-4 tw-dark tw-bg-sq-dark-background" },
|
|
84
|
+
React.createElement(Button, { disabled: true, variant: "theme", label: "Disabled Button" }),
|
|
85
|
+
React.createElement(Button, { extraClassNames: "tw-m-5", disabled: true, label: "Disabled Button" }))));
|
|
86
|
+
return (React.createElement("div", { className: "tw-grid tw-grid-cols-4 tw-gap-4" },
|
|
87
|
+
React.createElement("div", { className: "color_topic" },
|
|
88
|
+
React.createElement("b", null, "Topic Colors"),
|
|
89
|
+
renderDisabledButton()),
|
|
90
|
+
React.createElement("div", { className: "color_analysis" },
|
|
91
|
+
React.createElement("b", null, "Analysis Colors"),
|
|
92
|
+
renderDisabledButton()),
|
|
93
|
+
React.createElement("div", { className: "color_datalab" },
|
|
94
|
+
React.createElement("b", null, "Datalab Colors"),
|
|
95
|
+
renderDisabledButton()),
|
|
96
|
+
React.createElement("div", { className: "color_vantage" },
|
|
97
|
+
React.createElement("b", null, "Vantage Colors"),
|
|
98
|
+
renderDisabledButton())));
|
|
99
|
+
};
|
|
100
|
+
//# sourceMappingURL=Button.stories.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Button.stories.js","sourceRoot":"","sources":["../../src/Button/Button.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,MAAM,MAAM,UAAU,CAAC;AAC9B,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAElC,eAAe;IACb,KAAK,EAAE,QAAQ;CAChB,CAAC;AAEF,MAAM,CAAC,MAAM,iBAAiB,GAAG,GAAG,EAAE;IACpC,MAAM,mBAAmB,GAAG,GAAG,EAAE,CAAC,CAChC,0CACG,cAAc,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAC/B,6BAAK,GAAG,EAAE,YAAY,OAAO,EAAE,EAAE,SAAS,EAAC,iCAAiC;QAC1E,6BAAK,SAAS,EAAC,QAAQ;YACrB,oBAAC,MAAM,IAAC,KAAK,EAAE,YAAY,OAAO,EAAE,EAAE,OAAO,EAAE,GAAG,EAAE,GAAE,CAAC,EAAE,OAAO,EAAE,OAAO,GAAI,CACzE;QACN,6BAAK,SAAS,EAAC,yCAAyC;YACtD,oBAAC,MAAM,IAAC,KAAK,EAAE,YAAY,OAAO,EAAE,EAAE,OAAO,EAAE,GAAG,EAAE,GAAE,CAAC,EAAE,OAAO,EAAE,OAAO,GAAI,CACzE,CACF,CACP,CAAC,CACD,CACJ,CAAC;IACF,OAAO,CACL,6BAAK,SAAS,EAAC,iCAAiC;QAC9C,6BAAK,SAAS,EAAC,aAAa;YAC1B,8CAAmB;YAClB,mBAAmB,EAAE,CAClB;QAEN,6BAAK,SAAS,EAAC,gBAAgB;YAC7B,iDAAsB;YACrB,mBAAmB,EAAE,CAClB;QAEN,6BAAK,SAAS,EAAC,eAAe;YAC5B,gDAAqB;YACpB,mBAAmB,EAAE,CAClB;QAEN,6BAAK,S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OAAO,EAAC,OAAO,EAAC,KAAK,EAAC,iBAAiB,GAAG;YAClE,oBAAC,MAAM,IAAC,eAAe,EAAC,QAAQ,EAAC,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAC,iBAAiB,GAAG,CACvE;QACN,6BAAK,SAAS,EAAC,yCAAyC;YACtD,oBAAC,MAAM,IAAC,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAC,OAAO,EAAC,KAAK,EAAC,iBAAiB,GAAG;YAClE,oBAAC,MAAM,IAAC,eAAe,EAAC,QAAQ,EAAC,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAC,iBAAiB,GAAG,CACvE,CACL,CACJ,CAAC;IACF,OAAO,CACL,6BAAK,SAAS,EAAC,iCAAiC;QAC9C,6BAAK,SAAS,EAAC,aAAa;YAC1B,8CAAmB;YAClB,oBAAoB,EAAE,CACnB;QAEN,6BAAK,SAAS,EAAC,gBAAgB;YAC7B,iDAAsB;YACrB,oBAAoB,EAAE,CACnB;QAEN,6BAAK,SAAS,EAAC,eAAe;YAC5B,gDAAqB;YACpB,oBAAoB,EAAE,CACnB;QAEN,6BAAK,SAAS,EAAC,eAAe;YAC5B,gDAAqB;YACpB,oBAAoB,EAAE,CACnB,CACF,CACP,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
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 Button from './Button';
|
|
6
|
+
describe('Button', () => {
|
|
7
|
+
class Context {
|
|
8
|
+
testId = 'buttonTestId';
|
|
9
|
+
label = 'button label';
|
|
10
|
+
props = {
|
|
11
|
+
label: this.label,
|
|
12
|
+
onClick: jest.fn(),
|
|
13
|
+
testId: this.testId,
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
let tc;
|
|
17
|
+
beforeEach(() => {
|
|
18
|
+
tc = new Context();
|
|
19
|
+
});
|
|
20
|
+
const renderButton = (props) => render(React.createElement(Button, { ...props }));
|
|
21
|
+
it('renders button label', () => {
|
|
22
|
+
renderButton(tc.props);
|
|
23
|
+
expect(screen.getByText(tc.label)).toBeInTheDocument();
|
|
24
|
+
});
|
|
25
|
+
it('calls on click', async () => {
|
|
26
|
+
renderButton(tc.props);
|
|
27
|
+
await userEvent.click(screen.getByTestId(tc.testId));
|
|
28
|
+
expect(tc.props.onClick).toHaveBeenCalled();
|
|
29
|
+
});
|
|
30
|
+
it('renders disabled button', () => {
|
|
31
|
+
renderButton({ ...tc.props, disabled: true });
|
|
32
|
+
expect(screen.getByText(tc.label)).toBeDisabled();
|
|
33
|
+
});
|
|
34
|
+
it('respects stopPropagation default', async () => {
|
|
35
|
+
const callOnPropagation = jest.fn();
|
|
36
|
+
render(React.createElement("div", { onClick: callOnPropagation },
|
|
37
|
+
React.createElement(Button, { ...tc.props })));
|
|
38
|
+
await userEvent.click(screen.getByTestId(tc.testId));
|
|
39
|
+
expect(callOnPropagation).not.toHaveBeenCalled();
|
|
40
|
+
});
|
|
41
|
+
it('propagates click event if not told not to', async () => {
|
|
42
|
+
const callOnPropagation = jest.fn();
|
|
43
|
+
render(React.createElement("div", { onClick: callOnPropagation },
|
|
44
|
+
React.createElement(Button, { ...{ ...tc.props, stopPropagation: false } })));
|
|
45
|
+
await userEvent.click(screen.getByTestId(tc.testId));
|
|
46
|
+
expect(callOnPropagation).toHaveBeenCalled();
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
//# sourceMappingURL=Button.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Button.test.js","sourceRoot":"","sources":["../../src/Button/Button.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,MA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MAAM,CAAC,SAAS,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,YAAY,EAAE,CAAC;IACpD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,kCAAkC,EAAE,KAAK,IAAI,EAAE;QAChD,MAAM,iBAAiB,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;QACpC,MAAM,CACJ,6BAAK,OAAO,EAAE,iBAAiB;YAC7B,oBAAC,MAAM,OAAK,EAAE,CAAC,KAAK,GAAI,CACpB,CACP,CAAC;QACF,MAAM,SAAS,CAAC,KAAK,CAAC,MAAM,CAAC,WAAW,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;QACrD,MAAM,CAAC,iBAAiB,CAAC,CAAC,GAAG,CAAC,gBAAgB,EAAE,CAAC;IACnD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,2CAA2C,EAAE,KAAK,IAAI,EAAE;QACzD,MAAM,iBAAiB,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;QACpC,MAAM,CACJ,6BAAK,OAAO,EAAE,iBAAiB;YAC7B,oBAAC,MAAM,OAAK,EAAE,GAAG,EAAE,CAAC,KAAK,EAAE,eAAe,EAAE,KAAK,EAAE,GAAI,CACnD,CACP,CAAC;QACF,MAAM,SAAS,CAAC,KAAK,CAAC,MAAM,CAAC,WAAW,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;QACrD,MAAM,CAAC,iBAAiB,CAAC,CAAC,gBAAgB,EAAE,CAAC;IAC/C,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export const buttonTypes = ['button', 'reset', 'submit', 'link'];
|
|
2
|
+
export const buttonSizes = ['sm', 'lg'];
|
|
3
|
+
export const buttonVariants = ['outline', 'theme', 'theme-light', 'warning', 'danger', 'no-border'];
|
|
4
|
+
export const iconPositions = ['left', 'right'];
|
|
5
|
+
//# sourceMappingURL=Button.types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Button.types.js","sourceRoot":"","sources":["../../src/Button/Button.types.ts"],"names":[],"mappings":"AAIA,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,CAAU,CAAC;AAC1E,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,IAAI,EAAE,IAAI,CAAU,CAAC;AACjD,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,SAAS,EAAE,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,QAAQ,EAAE,WAAW,CAAU,CAAC;AAC7G,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/Button/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC"}
|
|
@@ -0,0 +1,67 @@
|
|
|
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-500',
|
|
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 = 5, alignOffset = -35, hasArrow = false, onOpenChange, isOpen, setFocusOnTriggerOnClose = true, keepFocusInsideDropdown = true, onContainerClick, ...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.Portal, null,
|
|
20
|
+
React.createElement(DropdownMenu.Content, { onClick: onContainerClick, sideOffset: placementOffset, side: placement, align: align, alignOffset: alignOffset, asChild: true, onCloseAutoFocus: (e) => !setFocusOnTriggerOnClose && e.preventDefault(), className: "focus-visible:tw-outline-none tw-outline-none" },
|
|
21
|
+
React.createElement("div", { "data-testid": containerTestId, className: bgStyles +
|
|
22
|
+
' tw-relative tw-z-[1200] tw-min-w-6 tw-py-2 focus-visible:tw-outline-none tw-outline-none' +
|
|
23
|
+
' data-[state=open]:tw-animate-in data-[state=closed]:tw-animate-out' +
|
|
24
|
+
' 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 ' +
|
|
25
|
+
borderStyles },
|
|
26
|
+
hasArrow && (React.createElement(DropdownMenu.Arrow, { asChild: true },
|
|
27
|
+
React.createElement("div", { className: " tw-fill-transparent tw-bg-white tw-w-[15px] tw-h-[15px] tw-rotate-45 dark:tw-bg-sq-dark-background tw-border-b tw-border-r tw-border-sq-disabled-gray dark:tw-border-gray-500 tw-mt-[-7px]" }))),
|
|
28
|
+
dropdownItems.map((item, index) => {
|
|
29
|
+
const tooltipData = getQTipData(item);
|
|
30
|
+
if (item.isLabel) {
|
|
31
|
+
return (React.createElement(DropdownMenu.Label, { key: (item.label || '') + index, className: item.containerExtraClassNames, ...tooltipData },
|
|
32
|
+
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]" })),
|
|
33
|
+
React.createElement("div", { "data-testid": item.labelTestId, className: `tw-text-[13px] tw-ml-1 ${item.disabled ? 'tw-text-sq-disabled-gray' : 'tw-text-sq-text-color dark:tw-text-sq-white'} tw-not-italic tw-font-normal ${item.labelClasses}` }, item.label)));
|
|
34
|
+
}
|
|
35
|
+
if (Array.isArray(item.subMenuItems) && item.subMenuItems.length > 0) {
|
|
36
|
+
return (React.createElement(DropdownMenu.Sub, { key: item.label + index },
|
|
37
|
+
React.createElement(DropdownMenu.SubTrigger, { id: id, className: `tw-cursor-pointer tw-flex tw-justify-between dark:tw-text-sq-white hover:tw-bg-sq-gray-highlight dark:hover:tw-bg-sq-gray-highlight-dark tw-leading-none tw-items-center tw-h-[27px] tw-pl-[19px] tw-relative tw-select-none tw-outline-none data-[disabled]:tw-pointer-events-none ${item.containerExtraClassNames || ''}`, "data-testid": item.testId, disabled: item.disabled, ...tooltipData },
|
|
38
|
+
React.createElement("div", { className: "tw-flex" },
|
|
39
|
+
item.icon && (React.createElement(Icon, { icon: item.icon, extraClassNames: `tw-w-[18px] ${item.disabled
|
|
40
|
+
? '!tw-text-sq-disabled-gray'
|
|
41
|
+
: 'tw-text-sq-text-color dark:tw-text-sq-white'} ${item.iconExtraClassNames || ''}` })),
|
|
42
|
+
React.createElement("div", { "data-testid": item.labelTestId, "data-customid": item.labelCustomId, className: `tw-text-[13px] tw-ml-1 ${item.disabled && '!tw-opacity-30'} tw-not-italic tw-font-semibold ${item.labelClasses}` }, item.label)),
|
|
43
|
+
React.createElement(Icon, { small: true, icon: "fc-arrow-dropdown -tw-rotate-90", extraClassNames: `${item.disabled ? 'tw-text-sq-disabled-gray' : 'tw-text-sq-text-color dark:tw-text-sq-white'} tw-w-[18px] tw-ml-4 tw-text-[8px] tw-justify-center tw-flex` })),
|
|
44
|
+
React.createElement(DropdownMenu.Portal, null,
|
|
45
|
+
React.createElement(DropdownMenu.SubContent, { className: "focus-visible:tw-outline-none tw-outline-none" },
|
|
46
|
+
React.createElement("div", { "data-testid": containerTestId, className: bgStyles +
|
|
47
|
+
' tw-relative tw-z-[1000] tw-min-w-6 tw-py-2 focus-visible:tw-outline-none tw-outline-none data-[state=open]:tw-animate-in data-[state=closed]:tw-animate-out' +
|
|
48
|
+
' 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 ' +
|
|
49
|
+
borderStyles }, item.subMenuItems.map((subItem, subIndex) => {
|
|
50
|
+
return (React.createElement(DropdownMenu.Item, { key: subItem.label + subIndex, onSelect: subItem.onClick, "data-qtip-text": subItem.tooltip, className: "tw-cursor-pointer tw-flex dark:tw-text-sq-white hover:tw-bg-sq-gray-highlight dark:hover:tw-bg-sq-gray-highlight-dark tw-leading-none tw-items-center tw-h-[27px] tw-px-[19px] tw-relative tw-select-none tw-outline-none data-[disabled]:tw-pointer-events-none", disabled: subItem.disabled },
|
|
51
|
+
subItem.iconClass && (React.createElement(Icon, { icon: subItem.iconClass, extraClassNames: `tw-w-[18px] ${item.disabled && '!tw-opacity-30'}` })),
|
|
52
|
+
React.createElement("div", { className: `tw-text-[13px] tw-ml-1 ${subItem.disabled
|
|
53
|
+
? 'tw-text-sq-disabled-gray'
|
|
54
|
+
: 'tw-text-sq-text-color dark:tw-text-sq-white'} tw-not-italic tw-font-normal ${item.labelClasses}` }, subItem.label)));
|
|
55
|
+
}))))));
|
|
56
|
+
}
|
|
57
|
+
return (React.createElement("div", { key: item.label + index, ...tooltipData },
|
|
58
|
+
React.createElement(DropdownMenu.Item, { key: item.label + index, "data-customid": item.itemCustomId, onSelect: (e) => {
|
|
59
|
+
item.onClick(e);
|
|
60
|
+
}, className: `tw-cursor-pointer tw-flex dark:tw-text-sq-white hover:tw-bg-sq-gray-highlight dark:hover:tw-bg-sq-gray-highlight-dark tw-leading-none tw-items-center tw-h-[27px] tw-px-[19px] tw-relative tw-select-none tw-outline-none data-[disabled]:tw-pointer-events-none ${item.containerExtraClassNames || ''}`, "data-testid": item.testId, disabled: item.disabled },
|
|
61
|
+
item.icon && (React.createElement(Icon, { icon: item.icon, testId: item.iconTestId, type: (item.iconType || 'text'), color: item.iconColor, customId: item.iconCustomId, extraClassNames: `tw-w-[18px] ${item.disabled && '!tw-opacity-30'} ${item.iconExtraClassNames || ''}` })),
|
|
62
|
+
React.createElement("div", { "data-testid": item.labelTestId, "data-customid": item.labelCustomId, className: `tw-text-[13px] tw-ml-1 ${item.disabled ? 'tw-text-sq-disabled-gray' : 'tw-text-sq-text-color dark:tw-text-sq-white'} tw-not-italic tw-font-normal ${item.labelClasses || ''}` }, item.label)),
|
|
63
|
+
item.hasDivider && (React.createElement(DropdownMenu.Separator, { "data-testid": `dropdown-divider-${index}`, className: "tw-h-[1px] tw-bg-sq-disabled-gray dark:tw-bg-gray-500 tw-my-[8px]" }))));
|
|
64
|
+
}))))));
|
|
65
|
+
};
|
|
66
|
+
export default ButtonWithDropdown;
|
|
67
|
+
//# 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;A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AAI,MAAM,CAAa,EAC3C,KAAK,EAAE,IAAI,CAAC,SAAS,EACrB,QAAQ,EAAE,IAAI,CAAC,YAAY,EAC3B,eAAe,EAAE,eAAe,IAAI,CAAC,QAAQ,IAAI,gBAAgB,IAAI,IAAI,CAAC,mBAAmB,IAAI,EAAE,EAAE,GACrG,CACH;gCACD,4CACe,IAAI,CAAC,WAAW,mBACd,IAAI,CAAC,aAAa,EACjC,SAAS,EAAE,0BACT,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,0BAA0B,CAAC,CAAC,CAAC,6CAC/C,iCAAiC,IAAI,CAAC,YAAY,IAAI,EAAE,EAAE,IACzD,IAAI,CAAC,KAAK,CACP,CACY;4BACnB,IAAI,CAAC,UAAU,IAAI,CAClB,oBAAC,YAAY,CAAC,SAAS,mBACR,oBAAoB,KAAK,EAAE,EACxC,SAAS,EAAC,mEAAmE,GAC7E,CACH,CACG,CACP,CAAC;oBACJ,CAAC,CAAC,CACE,CACe,CACH,CACJ,CACrB,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,98 @@
|
|
|
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(''), tooltipDelay: 0, tooltip: 'This is a banana' },
|
|
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
|
+
React.createElement("div", { className: "tw-p-5 " },
|
|
52
|
+
React.createElement(ButtonWithDropdown, { onOpenChange: (isOpen) => setOpenDropdown(isOpen ? `dropdown-7-${color}-${isDark ? 'dark' : 'light'}` : ''), isOpen: openDropdown === `dropdown-7-${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-dropdown7", tooltip: "This is a dropdown with submenu", tooltipDelay: 0, tooltipPlacement: "top", dropdownItems: [
|
|
53
|
+
{ label: 'Orange', icon: 'fc-data-file', onClick: () => setOpenDropdown('') },
|
|
54
|
+
{ label: 'Mango', icon: 'fc-user-community', onClick: () => setOpenDropdown('') },
|
|
55
|
+
{
|
|
56
|
+
label: 'Guava',
|
|
57
|
+
icon: 'fc-user-community',
|
|
58
|
+
onClick: () => setOpenDropdown(''),
|
|
59
|
+
tooltipDelay: 0,
|
|
60
|
+
tooltip: 'This is a guava',
|
|
61
|
+
subMenuItems: [
|
|
62
|
+
{ label: 'Orange', iconClass: 'fc-data-file', onClick: () => setOpenDropdown('') },
|
|
63
|
+
{ label: 'Mango', iconClass: 'fc-user-community', onClick: () => setOpenDropdown('') },
|
|
64
|
+
{ label: 'Apple', iconClass: 'fc-user-community', onClick: () => setOpenDropdown(''), disabled: true },
|
|
65
|
+
],
|
|
66
|
+
},
|
|
67
|
+
{ label: 'Banana', icon: 'fc-user-community', onClick: () => setOpenDropdown(''), disabled: true },
|
|
68
|
+
{
|
|
69
|
+
label: 'Cashew',
|
|
70
|
+
icon: 'fc-user-community',
|
|
71
|
+
disabled: true,
|
|
72
|
+
onClick: () => setOpenDropdown(''),
|
|
73
|
+
subMenuItems: [
|
|
74
|
+
{ label: 'Orange', iconClass: 'fc-data-file', onClick: () => setOpenDropdown('') },
|
|
75
|
+
{ label: 'Mango', iconClass: 'fc-user-community', onClick: () => setOpenDropdown('') },
|
|
76
|
+
{ label: 'Apple', iconClass: 'fc-user-community', onClick: () => setOpenDropdown(''), disabled: true },
|
|
77
|
+
],
|
|
78
|
+
},
|
|
79
|
+
] }))));
|
|
80
|
+
const renderAllVariations = (color) => (React.createElement("div", { className: "tw-grid tw-grid-cols-2 tw-gap-4 tw-p-4" },
|
|
81
|
+
allButtonWithDropdowns(color),
|
|
82
|
+
allButtonWithDropdowns(color, true)));
|
|
83
|
+
return (React.createElement("div", { className: "tw-grid tw-grid-cols-4 tw-gap-4" },
|
|
84
|
+
React.createElement(QTip, null),
|
|
85
|
+
React.createElement("div", { className: "color_topic" },
|
|
86
|
+
React.createElement("b", null, "Topic Colors"),
|
|
87
|
+
renderAllVariations('topic')),
|
|
88
|
+
React.createElement("div", { className: "color_analysis" },
|
|
89
|
+
React.createElement("b", null, "Analysis Colors"),
|
|
90
|
+
renderAllVariations('analysis')),
|
|
91
|
+
React.createElement("div", { className: "color_datalab" },
|
|
92
|
+
React.createElement("b", null, "Datalab Colors"),
|
|
93
|
+
renderAllVariations('datalab')),
|
|
94
|
+
React.createElement("div", { className: "color_vantage" },
|
|
95
|
+
React.createElement("b", null, "Vantage Colors"),
|
|
96
|
+
renderAllVariations('vantage'))));
|
|
97
|
+
};
|
|
98
|
+
//# 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,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