@seeqdev/qomponents 0.0.0 → 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Button/Button.d.ts +5 -0
- package/dist/Button/Button.js +44 -0
- package/dist/Button/Button.js.map +1 -0
- package/dist/Button/Button.stories.d.ts +3 -5
- package/dist/Button/Button.stories.js +49 -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.d.ts +19 -4
- package/dist/Button/Button.types.js +4 -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/FontCustom.woff +0 -0
- package/dist/FontCustom.woff2 +0 -0
- package/dist/Icon/Icon.d.ts +10 -0
- package/dist/Icon/Icon.js +38 -0
- package/dist/Icon/Icon.js.map +1 -0
- package/dist/Icon/Icon.stories.d.ts +5 -0
- package/dist/Icon/Icon.stories.js +35 -0
- package/dist/Icon/Icon.stories.js.map +1 -0
- package/dist/Icon/Icon.test.d.ts +1 -0
- package/dist/Icon/Icon.test.js +55 -0
- package/dist/Icon/Icon.test.js.map +1 -0
- package/dist/Icon/Icon.types.d.ts +38 -0
- package/dist/Icon/Icon.types.js +16 -0
- package/dist/Icon/Icon.types.js.map +1 -0
- package/dist/Icon/index.d.ts +1 -0
- package/dist/Icon/index.js +2 -0
- package/dist/Icon/index.js.map +1 -0
- package/dist/TextField/TextField.d.ts +7 -0
- package/dist/TextField/TextField.js +45 -0
- package/dist/TextField/TextField.js.map +1 -0
- package/dist/TextField/TextField.stories.d.ts +5 -0
- package/dist/TextField/TextField.stories.js +25 -0
- package/dist/TextField/TextField.stories.js.map +1 -0
- package/dist/TextField/TextField.test.d.ts +1 -0
- package/dist/TextField/TextField.test.js +35 -0
- package/dist/TextField/TextField.test.js.map +1 -0
- package/dist/TextField/TextField.types.d.ts +16 -0
- package/dist/TextField/TextField.types.js +2 -0
- package/dist/TextField/TextField.types.js.map +1 -0
- package/dist/TextField/index.d.ts +1 -0
- package/dist/TextField/index.js +2 -0
- package/dist/TextField/index.js.map +1 -0
- package/dist/Tooltip/Tooltip.d.ts +7 -0
- package/dist/Tooltip/Tooltip.js +30 -0
- package/dist/Tooltip/Tooltip.js.map +1 -0
- package/dist/Tooltip/Tooltip.stories.d.ts +5 -0
- package/dist/Tooltip/Tooltip.stories.js +32 -0
- package/dist/Tooltip/Tooltip.stories.js.map +1 -0
- package/dist/Tooltip/Tooltip.types.d.ts +9 -0
- package/dist/Tooltip/Tooltip.types.js +3 -0
- package/dist/Tooltip/Tooltip.types.js.map +1 -0
- package/dist/Tooltip/index.d.ts +1 -0
- package/dist/Tooltip/index.js +2 -0
- package/dist/Tooltip/index.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.esm.js +137 -15
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +137 -13
- package/dist/index.js.map +1 -1
- package/dist/styles.css +1621 -181
- package/dist/utils/browserId.js +29 -0
- package/dist/utils/browserId.js.map +1 -0
- package/package.json +3 -1
package/dist/Button/Button.d.ts
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { ButtonProps } from './Button.types';
|
|
3
3
|
import '../styles.css';
|
|
4
|
+
/**
|
|
5
|
+
* All-in-one Button:
|
|
6
|
+
* - use "variant" to achieve the desired style
|
|
7
|
+
* - include tooltips and/or icons
|
|
8
|
+
*/
|
|
4
9
|
declare const Button: React.FunctionComponent<ButtonProps>;
|
|
5
10
|
export default Button;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import '../styles.css';
|
|
3
|
+
import { browserIsFirefox } from '../utils/browserId';
|
|
4
|
+
import Tooltip from '../Tooltip';
|
|
5
|
+
import Icon from '../Icon';
|
|
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, }) => {
|
|
12
|
+
const baseClasses = 'tw-py-1 tw-px-2.5 tw-rounded-sm focus:tw-ring-0 disabled:tw-pointer-events-none';
|
|
13
|
+
const textClassesByVariant = {
|
|
14
|
+
'outline': 'tw-text-sq-text-color',
|
|
15
|
+
'theme': 'tw-text-white',
|
|
16
|
+
'theme-light': 'tw-text-white',
|
|
17
|
+
'danger': 'tw-text-white',
|
|
18
|
+
'no-border': 'tw-text-sq-text-color',
|
|
19
|
+
'warning': 'tw-text-white',
|
|
20
|
+
};
|
|
21
|
+
const classesByVariant = {
|
|
22
|
+
'outline': 'tw-border-sq-disabled-gray tw-border-solid tw-border hover:tw-bg-sq-light-gray' +
|
|
23
|
+
' focus:tw-bg-sq-dark-gray active:tw-bg-sq-dark-gray focus:tw-border-sq-color-dark active:tw-border-sq-color-dark',
|
|
24
|
+
'theme': 'tw-bg-sq-color-dark hover:tw-bg-sq-color-highlight disabled:tw-bg-opacity-50',
|
|
25
|
+
'danger': 'tw-bg-sq-danger-color hover:tw-bg-sq-danger-color-hover disabled:tw-bg-opacity-50',
|
|
26
|
+
'theme-light': 'tw-bg-sq-icon hover:tw-bg-sq-link disabled:tw-bg-opacity-50',
|
|
27
|
+
'no-border': '',
|
|
28
|
+
'warning': 'tw-bg-sq-warning-color',
|
|
29
|
+
};
|
|
30
|
+
const sizeClasses = {
|
|
31
|
+
sm: 'tw-text-sm',
|
|
32
|
+
lg: 'tw-text-xl',
|
|
33
|
+
};
|
|
34
|
+
const appliedClasses = `${baseClasses} ${sizeClasses[size]} ${classesByVariant[variant]} ${textClassesByVariant[variant]} ${extraClassNames}`;
|
|
35
|
+
const button = (React.createElement("button", { id: id, disabled: disabled, "data-testid": testId, type: type === 'link' || (type === 'submit' && browserIsFirefox) ? 'button' : type, onClick: (e) => {
|
|
36
|
+
stopPropagation && e.stopPropagation();
|
|
37
|
+
onClick && onClick();
|
|
38
|
+
}, className: appliedClasses },
|
|
39
|
+
icon && (React.createElement(Icon, { icon: icon, type: iconStyle, color: iconColor, extraClassNames: label ? `tw-mr-1 ${textClassesByVariant[variant]}` : '', testId: `${id}_spinner` })),
|
|
40
|
+
label));
|
|
41
|
+
return tooltip ? (React.createElement(Tooltip, { text: tooltip, ...tooltipOptions }, button)) : (button);
|
|
42
|
+
};
|
|
43
|
+
export default Button;
|
|
44
|
+
//# 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;AACvB,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,OAAO,MAAM,YAAY,CAAC;AACjC,OAAO,IAAI,MAAM,SAAS,CAAC;AAE3B;;;;GAIG;AACH,MAAM,MAAM,GAAyC,CAAC,EACpD,OAAO,EACP,KAAK,EACL,OAAO,GAAG,SAAS,EACnB,IAAI,GAAG,QAAQ,EACf,IAAI,GAAG,IAAI,EACX,QAAQ,EACR,eAAe,EACf,EAAE,EACF,MAAM,EACN,eAAe,GAAG,IAAI,EACtB,OAAO,EACP,cAAc,EACd,SAAS,GAAG,MAAM,EAClB,IAAI,EACJ,SAAS,GACV,EAAE,EAAE;IACH,MAAM,WAAW,GAAG,iFAAiF,CAAC;IACtG,MAAM,oBAAoB,GAAG;QAC3B,SAAS,EAAE,uBAAuB;QAClC,OAAO,EAAE,eAAe;QACxB,aAAa,EAAE,eAAe;QAC9B,QAAQ,EAAE,eAAe;QACzB,WAAW,EAAE,uBAAuB;QACpC,SAAS,EAAE,eAAe;KAC3B,CAAC;IACF,MAAM,gBA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,CACF,MAAM,CACP,CAAC;AACJ,CAAC,CAAC;AACF,eAAe,MAAM,CAAC"}
|
|
@@ -2,8 +2,6 @@ declare const _default: {
|
|
|
2
2
|
title: string;
|
|
3
3
|
};
|
|
4
4
|
export default _default;
|
|
5
|
-
export declare const
|
|
6
|
-
export declare const
|
|
7
|
-
export declare const
|
|
8
|
-
export declare const InTopic: () => JSX.Element;
|
|
9
|
-
export declare const InAnalysis: () => JSX.Element;
|
|
5
|
+
export declare const AllButtonVariants: () => JSX.Element;
|
|
6
|
+
export declare const ButtonWithTooltip: () => JSX.Element;
|
|
7
|
+
export declare const ButtonWithIcon: () => JSX.Element;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import Button from './Button';
|
|
3
|
+
import { buttonVariants } from './Button.types';
|
|
4
|
+
export default {
|
|
5
|
+
title: 'Button',
|
|
6
|
+
};
|
|
7
|
+
export const AllButtonVariants = () => {
|
|
8
|
+
const renderAllVariations = () => (React.createElement(React.Fragment, null, buttonVariants.map((variant) => (React.createElement("div", { key: `{variant_${variant}`, className: "tw-p-4" },
|
|
9
|
+
React.createElement(Button, { label: `Variant: ${variant}`, onClick: () => { }, variant: variant }))))));
|
|
10
|
+
return (React.createElement("div", { className: "tw-grid tw-grid-cols-3 tw-gap-4" },
|
|
11
|
+
React.createElement("div", { className: "color_topic" },
|
|
12
|
+
React.createElement("b", null, "Topic Colors"),
|
|
13
|
+
renderAllVariations()),
|
|
14
|
+
React.createElement("div", { className: "color_analysis" },
|
|
15
|
+
React.createElement("b", null, "Analysis Colors"),
|
|
16
|
+
renderAllVariations()),
|
|
17
|
+
React.createElement("div", { className: "color_datalab" },
|
|
18
|
+
React.createElement("b", null, "Datalab Colors"),
|
|
19
|
+
renderAllVariations())));
|
|
20
|
+
};
|
|
21
|
+
export const ButtonWithTooltip = () => {
|
|
22
|
+
const renderButtonWithTooltip = () => (React.createElement("div", { className: "tw-p-4" },
|
|
23
|
+
React.createElement(Button, { tooltip: "Helpful tooltip", variant: "theme", label: "Hover me" })));
|
|
24
|
+
return (React.createElement("div", { className: "tw-grid tw-grid-cols-3 tw-gap-4" },
|
|
25
|
+
React.createElement("div", { className: "color_topic" },
|
|
26
|
+
React.createElement("b", null, "Topic Colors"),
|
|
27
|
+
renderButtonWithTooltip()),
|
|
28
|
+
React.createElement("div", { className: "color_analysis" },
|
|
29
|
+
React.createElement("b", null, "Analysis Colors"),
|
|
30
|
+
renderButtonWithTooltip()),
|
|
31
|
+
React.createElement("div", { className: "color_datalab" },
|
|
32
|
+
React.createElement("b", null, "Datalab Colors"),
|
|
33
|
+
renderButtonWithTooltip())));
|
|
34
|
+
};
|
|
35
|
+
export const ButtonWithIcon = () => {
|
|
36
|
+
const renderButtonWithIcon = () => (React.createElement("div", { className: "tw-p-4" },
|
|
37
|
+
React.createElement(Button, { icon: "fc-search-power", variant: "theme", label: "With Icon" })));
|
|
38
|
+
return (React.createElement("div", { className: "tw-grid tw-grid-cols-3 tw-gap-4" },
|
|
39
|
+
React.createElement("div", { className: "color_topic" },
|
|
40
|
+
React.createElement("b", null, "Topic Colors"),
|
|
41
|
+
renderButtonWithIcon()),
|
|
42
|
+
React.createElement("div", { className: "color_analysis" },
|
|
43
|
+
React.createElement("b", null, "Analysis Colors"),
|
|
44
|
+
renderButtonWithIcon()),
|
|
45
|
+
React.createElement("div", { className: "color_datalab" },
|
|
46
|
+
React.createElement("b", null, "Datalab Colors"),
|
|
47
|
+
renderButtonWithIcon())));
|
|
48
|
+
};
|
|
49
|
+
//# 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;AAEhD,eAAe;IACb,KA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,CACF,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,cAAc,GAAG,GAAG,EAAE;IACjC,MAAM,oBAAoB,GAAG,GAAG,EAAE,CAAC,CACjC,6BAAK,SAAS,EAAC,QAAQ;QACrB,oBAAC,MAAM,IAAC,IAAI,EAAC,iBAAiB,EAAC,OAAO,EAAC,OAAO,EAAC,KAAK,EAAC,WAAW,GAAG,CAC/D,CACP,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,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,MAAM,6BAA6B,CAAC;AAEpD,OAAO,MAAM,MAAM,UAAU,CAAC;AAG9B,QAAQ,CAAC,QAAQ,EAAE,GAAG,EAAE;IACtB,MAAM,OAAO;QACX,MAAM,GAAG,cAAc,CAAC;QACxB,KAAK,GAAG,cAAc,CAAC;QACvB,KAAK,GAAgB;YACnB,KAAK,EAA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C,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"}
|
|
@@ -1,11 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export
|
|
1
|
+
import { TooltipProps } from '../Tooltip/Tooltip.types';
|
|
2
|
+
import { IconType } from '../Icon/Icon.types';
|
|
3
|
+
export declare const buttonTypes: readonly ["button", "reset", "submit", "link"];
|
|
4
|
+
export declare const buttonSizes: readonly ["sm", "lg"];
|
|
5
|
+
export declare const buttonVariants: readonly ["outline", "theme", "theme-light", "warning", "danger", "no-border"];
|
|
6
|
+
export type ButtonType = typeof buttonTypes[number];
|
|
7
|
+
export type ButtonSize = typeof buttonSizes[number];
|
|
8
|
+
export type ButtonVariant = typeof buttonVariants[number];
|
|
4
9
|
export interface ButtonProps {
|
|
5
10
|
/** function to call when clicking the button (takes no parameters) */
|
|
6
11
|
onClick?: () => any;
|
|
7
12
|
/** label translation key on the button (i.e. SUBMIT) */
|
|
8
|
-
label?: string;
|
|
13
|
+
label?: string | JSX.Element | React.ReactNode;
|
|
9
14
|
variant?: ButtonVariant;
|
|
10
15
|
/** type of button (i.e button/submit/reset, default is button) */
|
|
11
16
|
type?: ButtonType;
|
|
@@ -15,10 +20,20 @@ export interface ButtonProps {
|
|
|
15
20
|
disabled?: boolean;
|
|
16
21
|
/** extra class names to be placed on the Icon component */
|
|
17
22
|
extraClassNames?: string;
|
|
23
|
+
/** icon class to be used if an icon should go before the text (i.e. fc-zoom) */
|
|
24
|
+
icon?: string;
|
|
25
|
+
/** icon color option (text, white, theme, color, default is "text") */
|
|
26
|
+
iconStyle?: IconType;
|
|
27
|
+
/** color of the icon if it is custom (required if iconStyle is "color") */
|
|
28
|
+
iconColor?: string;
|
|
18
29
|
/** id to place on the button element */
|
|
19
30
|
id?: string;
|
|
20
31
|
/** id that will be used in the data-testid attribute on the button element */
|
|
21
32
|
testId?: string;
|
|
22
33
|
/** if false, will not stopPropagation onClick **/
|
|
23
34
|
stopPropagation?: boolean;
|
|
35
|
+
/** a tooltip for the button */
|
|
36
|
+
tooltip?: string;
|
|
37
|
+
/** options for the tooltip */
|
|
38
|
+
tooltipOptions?: Omit<TooltipProps, 'text'>;
|
|
24
39
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Button.types.js","sourceRoot":"","sources":["../../src/Button/Button.types.ts"],"names":[],"mappings":"AAGA,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"}
|
|
@@ -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"}
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import '../styles.css';
|
|
3
|
+
import { IconProps } from './Icon.types';
|
|
4
|
+
/**
|
|
5
|
+
* Icon:
|
|
6
|
+
* - access to Seeq custom icons by providing the desired icon
|
|
7
|
+
* - leverage "type" to style your icon
|
|
8
|
+
*/
|
|
9
|
+
declare const Icon: React.FunctionComponent<IconProps>;
|
|
10
|
+
export default Icon;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import '../styles.css';
|
|
3
|
+
import Tooltip from '../Tooltip';
|
|
4
|
+
/**
|
|
5
|
+
* Icon:
|
|
6
|
+
* - access to Seeq custom icons by providing the desired icon
|
|
7
|
+
* - leverage "type" to style your icon
|
|
8
|
+
*/
|
|
9
|
+
const Icon = ({ onClick, icon, type = 'theme', extraClassNames, id, large, small, color, testId, customId, tooltip, tooltipDelay, tooltipPlacement, number, hasExternalTooltipHandler = false, }) => {
|
|
10
|
+
if ((type === 'color' && (color === undefined || color === '')) || (color && type !== 'color')) {
|
|
11
|
+
const errorMessage = color === undefined || color === ''
|
|
12
|
+
? 'Icon with type="color" must have prop color specified.'
|
|
13
|
+
: 'Icon with prop color must have type="color".';
|
|
14
|
+
return React.createElement("div", { className: "tw-text-sq-danger-color" }, errorMessage);
|
|
15
|
+
}
|
|
16
|
+
const colorClasses = {
|
|
17
|
+
'theme': 'tw-text-sq-color-dark',
|
|
18
|
+
'white': 'tw-text-white',
|
|
19
|
+
'dark-gray': 'tw-text-sq-fairly-dark-gray',
|
|
20
|
+
'warning': 'tw-text-sq-warning-color',
|
|
21
|
+
'darkish-gray': 'tw-text-sq-darkish-gray',
|
|
22
|
+
'gray': 'tw-text-sq-disabled-gray',
|
|
23
|
+
'color': '',
|
|
24
|
+
'info': 'tw-text-sq-link',
|
|
25
|
+
'text': 'tw-text-sq-text-color',
|
|
26
|
+
'inherit': '',
|
|
27
|
+
'danger': 'tw-text-sq-danger-color',
|
|
28
|
+
'theme-light': 'tw-text-sq-color-light',
|
|
29
|
+
'success': 'tw-text-sq-success-color',
|
|
30
|
+
};
|
|
31
|
+
const iconPrefix = icon.startsWith('fc') ? 'fc' : 'fa';
|
|
32
|
+
const style = type === 'color' && color ? { color } : {};
|
|
33
|
+
const appliedClassNames = `${iconPrefix} ${icon} ${small ? 'fa-sm' : ''} ${large ? 'fa-lg' : ''} ${colorClasses[type]} ${onClick ? 'cursor-pointer' : ''} ${extraClassNames}`;
|
|
34
|
+
const iconTag = (React.createElement("i", { className: appliedClassNames, style: style, onClick: onClick, "data-testid": testId, "data-customid": customId, id: id, "data-number": number }));
|
|
35
|
+
return !hasExternalTooltipHandler && tooltip && tooltip !== '' ? (React.createElement(Tooltip, { text: tooltip, delay: tooltipDelay, position: tooltipPlacement }, iconTag)) : (iconTag);
|
|
36
|
+
};
|
|
37
|
+
export default Icon;
|
|
38
|
+
//# sourceMappingURL=Icon.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Icon.js","sourceRoot":"","sources":["../../src/Icon/Icon.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,eAAe,CAAC;AAEvB,OAAO,OAAO,MAAM,YAAY,CAAC;AAEjC;;;;GAIG;AACH,MAAM,IAAI,GAAuC,CAAC,EAChD,OAAO,EACP,IAAI,EACJ,IAAI,GAAG,OAAO,EACd,eAAe,EACf,EAAE,EACF,KAAK,EACL,KAAK,EACL,KAAK,EACL,MAAM,EACN,QAAQ,EACR,OAAO,EACP,YAAY,EACZ,gBAAgB,EAChB,MAAM,EACN,yBAAyB,GAAG,KAAK,G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AC,EAAE,IAAI,eAAe,EAAE,CAAC;IAEzD,MAAM,OAAO,GAAG,CACd,2BACE,SAAS,EAAE,iBAAiB,EAC5B,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,OAAO,iBACH,MAAM,mBACJ,QAAQ,EACvB,EAAE,EAAE,EAAE,iBACO,MAAM,GACnB,CACH,CAAC;IAEF,OAAO,CAAC,yBAAyB,IAAI,OAAO,IAAI,OAAO,KAAK,EAAE,CAAC,CAAC,CAAC,CAC/D,oBAAC,OAAO,IAAC,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,gBAAgB,IACpE,OAAO,CACA,CACX,CAAC,CAAC,CAAC,CACF,OAAO,CACR,CAAC;AACJ,CAAC,CAAC;AACF,eAAe,IAAI,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import Icon from './Icon';
|
|
3
|
+
import { iconTypes } from './Icon.types';
|
|
4
|
+
export default {
|
|
5
|
+
title: 'Icons',
|
|
6
|
+
};
|
|
7
|
+
export const AllIcons = () => {
|
|
8
|
+
const renderAllVariations = () => {
|
|
9
|
+
return (React.createElement(React.Fragment, null,
|
|
10
|
+
React.createElement("br", null),
|
|
11
|
+
React.createElement("br", null),
|
|
12
|
+
iconTypes.map((iconType) => {
|
|
13
|
+
return (React.createElement("div", { key: `${iconType}` },
|
|
14
|
+
React.createElement("b", null,
|
|
15
|
+
"type=",
|
|
16
|
+
iconType),
|
|
17
|
+
React.createElement("br", null),
|
|
18
|
+
React.createElement(Icon, { icon: 'fc-announcements', small: true, extraClassNames: 'tw-p-2', type: iconType, color: iconType === 'color' ? 'purple' : undefined }),
|
|
19
|
+
React.createElement(Icon, { icon: 'fc-announcements', extraClassNames: 'tw-p-2', type: iconType, color: iconType === 'color' ? '#928378' : undefined }),
|
|
20
|
+
React.createElement(Icon, { icon: 'fc-announcements', large: true, extraClassNames: 'tw-p-2', type: iconType, color: iconType === 'color' ? 'pink' : undefined }),
|
|
21
|
+
React.createElement("br", null)));
|
|
22
|
+
})));
|
|
23
|
+
};
|
|
24
|
+
return (React.createElement("div", { className: "tw-grid tw-grid-cols-3 tw-gap-4" },
|
|
25
|
+
React.createElement("div", { className: "color_topic" },
|
|
26
|
+
React.createElement("b", null, "Topic Colors"),
|
|
27
|
+
renderAllVariations()),
|
|
28
|
+
React.createElement("div", { className: "color_analysis" },
|
|
29
|
+
React.createElement("b", null, "Analysis Colors"),
|
|
30
|
+
renderAllVariations()),
|
|
31
|
+
React.createElement("div", { className: "color_datalab" },
|
|
32
|
+
React.createElement("b", null, "Datalab Colors"),
|
|
33
|
+
renderAllVariations())));
|
|
34
|
+
};
|
|
35
|
+
//# sourceMappingURL=Icon.stories.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Icon.stories.js","sourceRoot":"","sources":["../../src/Icon/Icon.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,IAAI,MAAM,QAAQ,CAAC;AAC1B,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,eAAe;IACb,KAAK,EAAE,OAAO;CACf,CAAC;AAEF,MAAM,CAAC,MAAM,QAAQ,GAAG,GAAG,EAAE;IAC3B,MAAM,mBAAmB,GAAG,GAAG,EAAE;QAC/B,OAAO,CACL;YACE,+BAAM;YACN,+BAAM;YACL,SAAS,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE;gBAC1B,OAAO,CACL,6BAAK,GAAG,EAAE,GAAG,QAAQ,EAAE;oBACrB;;wBAAS,QAAQ,CAAK;oBACtB,+BAAM;oBACN,oBAAC,IAAI,IACH,IAAI,EAAE,kBAAkB,EACxB,KAAK,EAAE,IAAI,EACX,eAAe,EAAE,QAAQ,EACzB,IAAI,EAAE,QAAQ,EACd,KAAK,EAAE,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,GAClD;oBACF,oBAAC,IAAI,IACH,IAAI,EAAE,kBAAkB,EACxB,eAAe,EAAE,QAAQ,EACzB,IAAI,EAAE,QAAQ,EACd,KAAK,EAAE,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,GACnD;oBACF,oBAAC,IAAI,IACH,IAAI,EAAE,kBAAkB,EACxB,KAAK,EAAE,IAAI,EACX,eAAe,EAAE,QAAQ,EACzB,IAAI,EAAE,QAAQ,EACd,KAAK,EAAE,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,GAChD;oBACF,+BAAM,CACF,CACP,CAAC;YACJ,CAAC,CAAC,CACD,CACJ,CAAC;IACJ,CAAC,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,CACF,CACP,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '@testing-library/jest-dom';
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import '@testing-library/jest-dom';
|
|
3
|
+
import { render, screen } from '@testing-library/react';
|
|
4
|
+
import Icon from './Icon';
|
|
5
|
+
describe('Icon', () => {
|
|
6
|
+
class Context {
|
|
7
|
+
testId = 'iconTestId';
|
|
8
|
+
icon = 'testIcon';
|
|
9
|
+
props = {
|
|
10
|
+
icon: this.icon,
|
|
11
|
+
onClick: jest.fn(),
|
|
12
|
+
testId: this.testId,
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
let tc;
|
|
16
|
+
beforeEach(() => {
|
|
17
|
+
tc = new Context();
|
|
18
|
+
});
|
|
19
|
+
const renderIcon = (props) => render(React.createElement(Icon, { ...props }));
|
|
20
|
+
it('renders icon', () => {
|
|
21
|
+
renderIcon(tc.props);
|
|
22
|
+
expect(screen.getByTestId(tc.testId)).toHaveClass(tc.icon);
|
|
23
|
+
});
|
|
24
|
+
it('renders large icon', () => {
|
|
25
|
+
renderIcon({ ...tc.props, large: true });
|
|
26
|
+
expect(screen.getByTestId(tc.testId)).toHaveClass('fa-lg');
|
|
27
|
+
});
|
|
28
|
+
it('renders small icon', () => {
|
|
29
|
+
renderIcon({ ...tc.props, small: true });
|
|
30
|
+
expect(screen.getByTestId(tc.testId)).toHaveClass('fa-sm');
|
|
31
|
+
});
|
|
32
|
+
describe('icon types', () => {
|
|
33
|
+
it('renders the theme type by default', () => {
|
|
34
|
+
renderIcon(tc.props);
|
|
35
|
+
expect(screen.getByTestId(tc.testId)).toHaveClass('tw-text-sq-color-dark');
|
|
36
|
+
});
|
|
37
|
+
it('renders the white icon', () => {
|
|
38
|
+
renderIcon({ ...tc.props, type: 'white' });
|
|
39
|
+
expect(screen.getByTestId(tc.testId)).toHaveClass('tw-text-white');
|
|
40
|
+
});
|
|
41
|
+
it('renders the text-type icon', () => {
|
|
42
|
+
renderIcon({ ...tc.props, type: 'text' });
|
|
43
|
+
expect(screen.getByTestId(tc.testId)).toHaveClass('tw-text-sq-text-color');
|
|
44
|
+
});
|
|
45
|
+
it('renders the color-type icon', () => {
|
|
46
|
+
renderIcon({ ...tc.props, type: 'color', color: '#AABBFF' });
|
|
47
|
+
expect(screen.getByTestId(tc.testId)).toHaveStyle('color: #AABBFF');
|
|
48
|
+
});
|
|
49
|
+
it('renders a warning if type=color and no color is provided', () => {
|
|
50
|
+
renderIcon({ ...tc.props, type: 'color' });
|
|
51
|
+
expect(screen.getByText('Icon with type="color" must have prop color specified.')).toBeInTheDocument();
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+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EAAE,GAAG,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;YAC7D,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,WAAW,CAAC,gBAAgB,CAAC,CAAC;QACtE,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,0DAA0D,EAAE,GAAG,EAAE;YAClE,UAAU,CAAC,EAAE,GAAG,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC;YAC3C,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,wDAAwD,CAAC,CAAC,CAAC,iBAAiB,EAAE,CAAC;QACzG,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { TooltipPosition } from '../Tooltip/Tooltip.types';
|
|
2
|
+
export declare const iconTypes: readonly ["theme", "white", "dark-gray", "darkish-gray", "gray", "color", "info", "text", "warning", "inherit", "danger", "theme-light", "success"];
|
|
3
|
+
export type IconType = typeof iconTypes[number];
|
|
4
|
+
export interface IconProps {
|
|
5
|
+
/** icon class to be used (i.e. fc-zoom) */
|
|
6
|
+
icon: string;
|
|
7
|
+
/** icon color option (text, white, theme, color, inherit; default is "theme") */
|
|
8
|
+
type?: IconType;
|
|
9
|
+
/** used to add a custom color to the icon (required if type="color") */
|
|
10
|
+
color?: string;
|
|
11
|
+
/** function to call when clicking the icon (takes no parameters) */
|
|
12
|
+
onClick?: (e?: React.MouseEvent<HTMLElement, MouseEvent>) => any;
|
|
13
|
+
/** extra class names to be placed on the Icon component */
|
|
14
|
+
extraClassNames?: string;
|
|
15
|
+
/** id that can be placed on the Icon component */
|
|
16
|
+
id?: string;
|
|
17
|
+
/** true to add the 'fa-lg' class to the icon */
|
|
18
|
+
large?: boolean;
|
|
19
|
+
/** true to add the 'fa-sm' class to the icon */
|
|
20
|
+
small?: boolean;
|
|
21
|
+
/** id that will be used in the data-testid attribute on the icon */
|
|
22
|
+
testId?: string;
|
|
23
|
+
/** id that will be used in the data-customid attribute on the icon.
|
|
24
|
+
* Can be used to identify the icon as the click event target in an event handler */
|
|
25
|
+
customId?: string;
|
|
26
|
+
/** text to display on icon tooltip */
|
|
27
|
+
tooltip?: string;
|
|
28
|
+
/** formatted text to display on icon tooltip */
|
|
29
|
+
formattedTooltip?: any;
|
|
30
|
+
/** number of milliseconds to wait before showing a tooltip on-hover */
|
|
31
|
+
tooltipDelay?: number;
|
|
32
|
+
tooltipPlacement?: TooltipPosition;
|
|
33
|
+
number?: number;
|
|
34
|
+
/** set this to true if the icon is inside a <SingletonTooltip> element. In this case the tooltip and placement
|
|
35
|
+
* information will be passed on as data attributes and a singleton tooltip element will be reused for this icon.
|
|
36
|
+
* This is recommended for improved performance when there are many icons with tooltips. */
|
|
37
|
+
hasExternalTooltipHandler?: boolean;
|
|
38
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Icon.types.js","sourceRoot":"","sources":["../../src/Icon/Icon.types.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB,OAAO;IACP,OAAO;IACP,WAAW;IACX,cAAc;IACd,MAAM;IACN,OAAO;IACP,MAAM;IACN,MAAM;IACN,SAAS;IACT,SAAS;IACT,QAAQ;IACR,aAAa;IACb,SAAS;CACD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './Icon';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/Icon/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import React, { useEffect, useRef, useState } from 'react';
|
|
2
|
+
import '../styles.css';
|
|
3
|
+
/**
|
|
4
|
+
* Textfield.
|
|
5
|
+
*/
|
|
6
|
+
export const TextField = React.forwardRef((props, ref) => {
|
|
7
|
+
const { readonly = false, onChange, onKeyUp, id, name, size = 'sm', value, placeholder, extraClassNames, testId, type = 'text', } = props;
|
|
8
|
+
const internalRef = useRef(null);
|
|
9
|
+
const [cursor, setCursor] = useState(null);
|
|
10
|
+
const setAllRefs = (receivedRef) => {
|
|
11
|
+
if (ref)
|
|
12
|
+
ref.current = receivedRef;
|
|
13
|
+
internalRef.current = receivedRef;
|
|
14
|
+
};
|
|
15
|
+
useEffect(() => {
|
|
16
|
+
const input = internalRef.current;
|
|
17
|
+
if (input)
|
|
18
|
+
input.setSelectionRange(cursor, cursor);
|
|
19
|
+
}, [ref, cursor, value]);
|
|
20
|
+
const handleChange = (e) => {
|
|
21
|
+
setCursor(e.target.selectionStart);
|
|
22
|
+
onChange && onChange(e);
|
|
23
|
+
};
|
|
24
|
+
useEffect(() => {
|
|
25
|
+
/**
|
|
26
|
+
* we need to change the value only if it's different since the internal state of "input" will change it anyway
|
|
27
|
+
* this will only be the case when the value has been changed externally via store (undo / redo)
|
|
28
|
+
*/
|
|
29
|
+
if (value !== null && value !== undefined && value !== internalRef.current?.value && internalRef.current) {
|
|
30
|
+
// we need to use this method because using the value props directly will switch the input to a "controlled"
|
|
31
|
+
// component
|
|
32
|
+
internalRef.current.value = `${value}`;
|
|
33
|
+
}
|
|
34
|
+
}, [value]);
|
|
35
|
+
const baseClasses = 'tw-height-34 tw-leading-normal tw-outline-none tw-py-1 tw-px-3 tw-rounded-sm disabled:tw-pointer-events-none' +
|
|
36
|
+
' disabled:tw-cursor-not-allowed tw-p-1 tw-border-sq-disabled-gray tw-border-solid tw-border' +
|
|
37
|
+
' tw-text-sq-text-color focus:tw-border-sq-color-dark active:tw-border-sq-color-dark';
|
|
38
|
+
const sizeClasses = {
|
|
39
|
+
sm: 'tw-text-sm',
|
|
40
|
+
lg: 'tw-text-xl',
|
|
41
|
+
};
|
|
42
|
+
const appliedClasses = `${baseClasses} ${sizeClasses[size]} ${extraClassNames}`;
|
|
43
|
+
return (React.createElement("input", { ref: setAllRefs, "data-testid": testId, name: name, id: id, type: type, value: value, className: appliedClasses, placeholder: placeholder, disabled: readonly, autoComplete: "none", onChange: handleChange, onKeyUp: onKeyUp }));
|
|
44
|
+
});
|
|
45
|
+
//# sourceMappingURL=TextField.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TextField.js","sourceRoot":"","sources":["../../src/TextField/TextField.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE3D,OAAO,eAAe,CAAC;AAEvB;;GAEG;AACH,MAAM,CAAC,MAAM,SAAS,GAA4C,KAAK,CAAC,UAAU,CAChF,CAAC,KAAK,EAAE,GAAQ,EAAE,EAAE;IAClB,MAAM,EACJ,QAAQ,GAAG,KAAK,EAChB,QAAQ,EACR,OAAO,EACP,EAAE,EACF,IAAI,EACJ,IAAI,GAAG,IAAI,EACX,KAAK,EACL,WAAW,EACX,eAAe,EACf,MAAM,EACN,IAAI,GAAG,MAAM,GACd,GAAG,KAAK,CAAC;IAEV,MAAM,WAAW,GAAG,MAAM,CAA0B,IAAI,CAAC,CAAC;IAC1D,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC;IAE3C,MAAM,UAAU,GAAG,CAAC,WAAgB,EAAE,EAAE;QACtC,IAAI,GAAG;YAAE,GAAG,CAAC,OAAO,GAAG,WAAW,CAAC;QACnC,WAAW,CAAC,OAAO,GAAG,WAAW,CAAC;IACpC,CAAC,CAAC;IAEF,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,KAAK,GAAG,WAAW,CAAC,OAAuC,CAAC;QAClE,IAAI,KAAK;YAAE,KAAK,CAAC,iBAAiB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACrD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
|
+
export default {
|
|
4
|
+
title: 'TextField',
|
|
5
|
+
};
|
|
6
|
+
export const AllTextFields = () => {
|
|
7
|
+
const renderAllVariations = () => (React.createElement("div", { className: "tw-p-4" },
|
|
8
|
+
React.createElement("div", { className: "tw-p-4" },
|
|
9
|
+
React.createElement(TextField, { value: "value provided" })),
|
|
10
|
+
React.createElement("div", { className: "tw-p-4" },
|
|
11
|
+
React.createElement(TextField, { placeholder: "placeholder text" })),
|
|
12
|
+
React.createElement("div", { className: "tw-p-4" },
|
|
13
|
+
React.createElement(TextField, { value: "read-only", readonly: true }))));
|
|
14
|
+
return (React.createElement("div", { className: "tw-grid tw-grid-cols-3 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
|
+
};
|
|
25
|
+
//# sourceMappingURL=TextField.stories.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TextField.stories.js","sourceRoot":"","sources":["../../src/TextField/TextField.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,eAAe;IACb,KAAK,EAAE,WAAW;CACnB,CAAC;AAEF,MAAM,CAAC,MAAM,aAAa,GAAG,GAAG,EAAE;IAChC,MAAM,mBAAmB,GAAG,GAAG,EAAE,CAAC,CAChC,6BAAK,SAAS,EAAC,QAAQ;QACrB,6BAAK,SAAS,EAAC,QAAQ;YACrB,oBAAC,SAAS,IAAC,KAAK,EAAC,gBAAgB,GAAG,CAChC;QACN,6BAAK,SAAS,EAAC,QAAQ;YACrB,oBAAC,SAAS,IAAC,WAAW,EAAC,kBAAkB,GAAG,CACxC;QACN,6BAAK,SAAS,EAAC,QAAQ;YACrB,oBAAC,SAAS,IAAC,KAAK,EAAC,WAAW,EAAC,QAAQ,EAAE,IAAI,GAAI,CAC3C,CACF,CACP,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,CACF,CACP,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '@testing-library/jest-dom';
|