@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.
Files changed (66) hide show
  1. package/dist/Button/Button.d.ts +5 -0
  2. package/dist/Button/Button.js +44 -0
  3. package/dist/Button/Button.js.map +1 -0
  4. package/dist/Button/Button.stories.d.ts +3 -5
  5. package/dist/Button/Button.stories.js +49 -0
  6. package/dist/Button/Button.stories.js.map +1 -0
  7. package/dist/Button/Button.test.js +49 -0
  8. package/dist/Button/Button.test.js.map +1 -0
  9. package/dist/Button/Button.types.d.ts +19 -4
  10. package/dist/Button/Button.types.js +4 -0
  11. package/dist/Button/Button.types.js.map +1 -0
  12. package/dist/Button/index.js +2 -0
  13. package/dist/Button/index.js.map +1 -0
  14. package/dist/FontCustom.woff +0 -0
  15. package/dist/FontCustom.woff2 +0 -0
  16. package/dist/Icon/Icon.d.ts +10 -0
  17. package/dist/Icon/Icon.js +38 -0
  18. package/dist/Icon/Icon.js.map +1 -0
  19. package/dist/Icon/Icon.stories.d.ts +5 -0
  20. package/dist/Icon/Icon.stories.js +35 -0
  21. package/dist/Icon/Icon.stories.js.map +1 -0
  22. package/dist/Icon/Icon.test.d.ts +1 -0
  23. package/dist/Icon/Icon.test.js +55 -0
  24. package/dist/Icon/Icon.test.js.map +1 -0
  25. package/dist/Icon/Icon.types.d.ts +38 -0
  26. package/dist/Icon/Icon.types.js +16 -0
  27. package/dist/Icon/Icon.types.js.map +1 -0
  28. package/dist/Icon/index.d.ts +1 -0
  29. package/dist/Icon/index.js +2 -0
  30. package/dist/Icon/index.js.map +1 -0
  31. package/dist/TextField/TextField.d.ts +7 -0
  32. package/dist/TextField/TextField.js +45 -0
  33. package/dist/TextField/TextField.js.map +1 -0
  34. package/dist/TextField/TextField.stories.d.ts +5 -0
  35. package/dist/TextField/TextField.stories.js +25 -0
  36. package/dist/TextField/TextField.stories.js.map +1 -0
  37. package/dist/TextField/TextField.test.d.ts +1 -0
  38. package/dist/TextField/TextField.test.js +35 -0
  39. package/dist/TextField/TextField.test.js.map +1 -0
  40. package/dist/TextField/TextField.types.d.ts +16 -0
  41. package/dist/TextField/TextField.types.js +2 -0
  42. package/dist/TextField/TextField.types.js.map +1 -0
  43. package/dist/TextField/index.d.ts +1 -0
  44. package/dist/TextField/index.js +2 -0
  45. package/dist/TextField/index.js.map +1 -0
  46. package/dist/Tooltip/Tooltip.d.ts +7 -0
  47. package/dist/Tooltip/Tooltip.js +30 -0
  48. package/dist/Tooltip/Tooltip.js.map +1 -0
  49. package/dist/Tooltip/Tooltip.stories.d.ts +5 -0
  50. package/dist/Tooltip/Tooltip.stories.js +32 -0
  51. package/dist/Tooltip/Tooltip.stories.js.map +1 -0
  52. package/dist/Tooltip/Tooltip.types.d.ts +9 -0
  53. package/dist/Tooltip/Tooltip.types.js +3 -0
  54. package/dist/Tooltip/Tooltip.types.js.map +1 -0
  55. package/dist/Tooltip/index.d.ts +1 -0
  56. package/dist/Tooltip/index.js +2 -0
  57. package/dist/Tooltip/index.js.map +1 -0
  58. package/dist/index.d.ts +4 -0
  59. package/dist/index.esm.js +137 -15
  60. package/dist/index.esm.js.map +1 -1
  61. package/dist/index.js +137 -13
  62. package/dist/index.js.map +1 -1
  63. package/dist/styles.css +1621 -181
  64. package/dist/utils/browserId.js +29 -0
  65. package/dist/utils/browserId.js.map +1 -0
  66. package/package.json +3 -1
@@ -0,0 +1,35 @@
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 { TextField } from './TextField';
6
+ describe('TextField', () => {
7
+ class Context {
8
+ testId = 'textFieldTestId';
9
+ props = {
10
+ onChange: jest.fn(),
11
+ testId: this.testId,
12
+ };
13
+ }
14
+ let tc;
15
+ beforeEach(() => {
16
+ tc = new Context();
17
+ });
18
+ const renderTextField = (props) => render(React.createElement(TextField, { ...props }));
19
+ it('renders the provided value', () => {
20
+ const value = 'hello';
21
+ renderTextField({ ...tc.props, value });
22
+ expect(screen.getByDisplayValue(value)).toBeInTheDocument();
23
+ });
24
+ it('renders the provided placeholder', () => {
25
+ const placeholder = 'Prompt to enter';
26
+ renderTextField({ ...tc.props, placeholder });
27
+ expect(screen.getByPlaceholderText(placeholder)).toBeInTheDocument();
28
+ });
29
+ it('calls onChange handler', async () => {
30
+ renderTextField({ ...tc.props });
31
+ await userEvent.type(screen.getByTestId(tc.testId), 'trigger');
32
+ expect(tc.props.onChange).toHaveBeenCalled();
33
+ });
34
+ });
35
+ //# sourceMappingURL=TextField.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TextField.test.js","sourceRoot":"","sources":["../../src/TextField/TextField.test.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,2BAA2B,CAAC;AACnC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,SAAS,MAAM,6BAA6B,CAAC;AAEpD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAGxC,QAAQ,CAAC,WAAW,EAAE,GAAG,EAAE;IACzB,MAAM,OAAO;QACX,MAAM,GAAG,iBAAiB,CAAC;QAC3B,KAAK,GAAmB;YACtB,QAAQ,EAAE,IAAI,CAAC,EAAE,EAAE;YACnB,MAAM,EAAE,IAAI,CAAC,MAAM;SACpB,CAAC;KACH;IAED,IAAI,EAAW,CAAC;IAChB,UAAU,CAAC,GAAG,EAAE;QACd,EAAE,GAAG,IAAI,OAAO,EAAE,CAAC;IACrB,CAAC,CAAC,CAAC;IACH,MAAM,eAAe,GAAG,CAAC,KAAqB,EAAE,EAAE,CAAC,MAAM,CAAC,oBAAC,SAAS,OAAK,KAAK,GAAI,CAAC,CAAC;IAEpF,EAAE,CAAC,4BAA4B,EAAE,GAAG,EAAE;QACpC,MAAM,KAAK,GAAG,OAAO,CAAC;QACtB,eAAe,CAAC,EAAE,GAAG,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;QACxC,MAAM,CAAC,MAAM,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC,CAAC,iBAAiB,EAAE,CAAC;IAC9D,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,kCAAkC,EAAE,GAAG,EAAE;QAC1C,MAAM,WAAW,GAAG,iBAAiB,CAAC;QACtC,eAAe,CAAC,EAAE,GAAG,EAAE,CAAC,KAAK,EAAE,WAAW,EAAE,CAAC,CAAC;QAC9C,MAAM,CAAC,MAAM,CAAC,oBAAoB,CAAC,WAAW,CAAC,CAAC,CAAC,iBAAiB,EAAE,CAAC;IACvE,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,wBAAwB,EAAE,KAAK,IAAI,EAAE;QACtC,eAAe,CAAC,EAAE,GAAG,EAAE,CAAC,KAAK,EAAE,CAAC,CAAC;QACjC,MAAM,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,EAAE,CAAC,MAAM,CAAC,EAAE,SAAS,CAAC,CAAC;QAC/D,MAAM,CAAC,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,gBAAgB,EAAE,CAAC;IAC/C,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,16 @@
1
+ declare type FormControlElement = HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement;
2
+ export interface TextFieldProps {
3
+ readonly?: boolean;
4
+ onChange?: React.ChangeEventHandler<FormControlElement>;
5
+ onKeyUp?: React.KeyboardEventHandler<FormControlElement>;
6
+ id?: string;
7
+ name?: string;
8
+ size?: 'sm' | 'lg';
9
+ value?: string | string[] | number;
10
+ placeholder?: string;
11
+ extraClassNames?: string;
12
+ type?: 'text' | 'password';
13
+ testId?: string;
14
+ ref?: any;
15
+ }
16
+ export {};
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=TextField.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TextField.types.js","sourceRoot":"","sources":["../../src/TextField/TextField.types.ts"],"names":[],"mappings":""}
@@ -0,0 +1 @@
1
+ export { TextField as default } from './TextField';
@@ -0,0 +1,2 @@
1
+ export { TextField as default } from './TextField';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/TextField/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,IAAI,OAAO,EAAE,MAAM,aAAa,CAAC"}
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+ import '../styles.css';
3
+ import { TooltipProps } from './Tooltip.types';
4
+ /**
5
+ * This component displays a Tooltip for the provided children.
6
+ */
7
+ export declare const Tooltip: React.FunctionComponent<TooltipProps>;
@@ -0,0 +1,30 @@
1
+ import React from 'react';
2
+ import '../styles.css';
3
+ import { DEFAULT_TOOL_TIP_DELAY } from './Tooltip.types';
4
+ /**
5
+ * This component displays a Tooltip for the provided children.
6
+ */
7
+ export const Tooltip = ({ position = 'bottom', children, text, delay = DEFAULT_TOOL_TIP_DELAY, }) => {
8
+ const arrowBaseClasses = "before:tw-content-[''] before:tw-absolute before:tw-border-8";
9
+ const centerArrowVertically = 'before:tw-top-1/2 before:-tw-translate-y-1/2';
10
+ const centerArrowHorizontally = 'before:tw-left-1/2 before:-tw-translate-x-1/2';
11
+ const arrowRight = `${arrowBaseClasses} ${centerArrowVertically} before:tw-right-[100%] before:tw-border-y-transparent
12
+ before:tw-border-l-transparent before:tw-border-r-black`;
13
+ const arrowLeft = `${arrowBaseClasses} ${centerArrowVertically} before:tw-left-[100%] before:tw-border-y-transparent
14
+ before:tw-border-l-black before:tw-border-r-transparent`;
15
+ const arrowBottom = `${arrowBaseClasses} ${centerArrowHorizontally} before:-tw-top-4 before:tw-border-b-black
16
+ before:tw-border-r-transparent before:tw-border-l-transparent before:tw-border-t-transparent`;
17
+ const arrowTop = `${arrowBaseClasses} ${centerArrowHorizontally} before:-tw-bottom-4 before:tw-border-b-transparent
18
+ before:tw-border-t-black before:tw-border-l-transparent before:tw-border-r-transparent`;
19
+ const placements = {
20
+ top: `-tw-top-2 -tw-translate-y-full tw-left-1/2 -tw-translate-x-1/2 ${arrowTop}`,
21
+ left: `-tw-translate-x-full -tw-left-3 -tw-translate-y-1/2 tw-top-1/2 ${arrowLeft}`,
22
+ right: `tw-translate-x-full -tw-right-3 -tw-translate-y-1/2 tw-top-1/2 ${arrowRight}`,
23
+ bottom: `-tw-bottom-2 tw-translate-y-full tw-left-1/2 -tw-translate-x-1/2 ${arrowBottom}`,
24
+ };
25
+ return (React.createElement("div", { className: "tw-group tw-relative tw-inline-block" },
26
+ children,
27
+ React.createElement("div", { className: `tw-z-50 tw-whitespace-nowrap tw-hidden group-hover:tw-inline-block group-hover:tw-delay-[${delay}ms]
28
+ tw-absolute tw-opacity-0 group-hover:tw-opacity-100 tw-rounded tw-bg-black tw-p-2 tw-text-xs tw-text-white ${placements[position]}` }, text)));
29
+ };
30
+ //# sourceMappingURL=Tooltip.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Tooltip.js","sourceRoot":"","sources":["../../src/Tooltip/Tooltip.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,eAAe,CAAC;AACvB,OAAO,EAAE,sBAAsB,EAAgB,MAAM,iBAAiB,CAAC;AAEvE;;GAEG;AACH,MAAM,CAAC,MAAM,OAAO,GAA0C,CAAC,EAC7D,QAAQ,GAAG,QAAQ,EACnB,QAAQ,EACR,IAAI,EACJ,KAAK,GAAG,sBAAsB,GAC/B,EAAE,EAAE;IACH,MAAM,gBAAgB,GAAG,8DAA8D,CAAC;IACxF,MAAM,qBAAqB,GAAG,8CAA8C,CAAC;IAC7E,MAAM,uBAAuB,GAAG,+CAA+C,CAAC;IAChF,MAAM,UAAU,GAAG,GAAG,gBAAgB,IAAI,qBAAqB;0DACP,CAAC;IAEzD,MAAM,SAAS,GAAG,GAAG,gBAAgB,IAAI,qBAAqB;2DACL,CAAC;IAE1D,MAAM,WAAW,GAAG,GAAG,gBAAgB,IAAI,uBAAuB;+FAC2B,CAAC;IAC9F,MAAM,QAAQ,GAAG,GAAG,gBAAgB,IAAI,uBAAuB;yFACwB,CAAC;IAExF,MAAM,UAAU,GAAG;QACjB,GAAG,EAAE,kEAAkE,QAAQ,EAAE;QACjF,IAAI,EAAE,kEAAkE,SAAS,EAAE;QACnF,KAAK,EAAE,kEAAkE,UAAU,EAAE;QACrF,MAAM,EAAE,oEAAoE,WAAW,EAAE;KAC1F,CAAC;IAEF,OAAO,CACL,6BAAK,SAAS,EAAC,sCAAsC;QAClD,QAAQ;QACT,6BACE,SAAS,EAAE,4FAA4F,KAAK;qHACC,UAAU,CAAC,QAAQ,CAAC,EAAE,IAClI,IAAI,CACD,CACF,CACP,CAAC;AACJ,CAAC,CAAC"}
@@ -0,0 +1,5 @@
1
+ declare const _default: {
2
+ title: string;
3
+ };
4
+ export default _default;
5
+ export declare const AllTooltips: () => JSX.Element;
@@ -0,0 +1,32 @@
1
+ import React from 'react';
2
+ import { Tooltip } from './Tooltip';
3
+ import Icon from '../Icon';
4
+ import Button from '../Button';
5
+ import { tooltipPositions } from './Tooltip.types';
6
+ export default {
7
+ title: 'Tooltip',
8
+ };
9
+ export const AllTooltips = () => {
10
+ const renderButtonsWithTooltip = () => tooltipPositions.map((position) => (React.createElement("div", { key: `${position}_button` },
11
+ React.createElement(Tooltip, { text: `Tooltip on the ${position}`, position: position },
12
+ React.createElement(Button, { label: position })))));
13
+ const renderIconsWithHtmlTooltip = () => tooltipPositions.map((position) => (React.createElement("div", { key: `${position}_icon` },
14
+ React.createElement(Tooltip, { text: React.createElement("div", null,
15
+ React.createElement("h2", null, "Fancy Tooltip"),
16
+ " This is a special tooltip. Why?",
17
+ React.createElement("br", null),
18
+ "Because it supports ",
19
+ React.createElement("b", null, "HTML!")), position: position },
20
+ React.createElement(Icon, { icon: "fc-sun" })))));
21
+ const renderTextTooltipOnText = () => tooltipPositions.map((position) => (React.createElement("div", { key: `${position}_text` },
22
+ React.createElement(Tooltip, { text: "Helpful information provided here", position: position },
23
+ React.createElement("span", null,
24
+ "Hover for Tooltip (on the ",
25
+ position,
26
+ ")")))));
27
+ return (React.createElement("div", { className: "tw-grid tw-grid-cols-4 tw-gap-4 tw-text-center" },
28
+ renderButtonsWithTooltip(),
29
+ renderIconsWithHtmlTooltip(),
30
+ renderTextTooltipOnText()));
31
+ };
32
+ //# sourceMappingURL=Tooltip.stories.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Tooltip.stories.js","sourceRoot":"","sources":["../../src/Tooltip/Tooltip.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,MAAM,MAAM,WAAW,CAAC;AAC/B,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAEnD,eAAe;IACb,KAAK,EAAE,SAAS;CACjB,CAAC;AAEF,MAAM,CAAC,MAAM,WAAW,GAAG,GAAG,EAAE;IAC9B,MAAM,wBAAwB,GAAG,GAAG,EAAE,CACpC,gBAAgB,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,CACjC,6BAAK,GAAG,EAAE,GAAG,QAAQ,SAAS;QAC5B,oBAAC,OAAO,IAAC,IAAI,EAAE,kBAAkB,QAAQ,EAAE,EAAE,QAAQ,EAAE,QAAQ;YAC7D,oBAAC,MAAM,IAAC,KAAK,EAAE,QAAQ,GAAI,CACnB,CACN,CACP,CAAC,CAAC;IAEL,MAAM,0BAA0B,GAAG,GAAG,EAAE,CACtC,gBAAgB,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,CACjC,6BAAK,GAAG,EAAE,GAAG,QAAQ,OAAO;QAC1B,oBAAC,OAAO,IACN,IAAI,EACF;gBACE,gDAAsB;;gBACtB,+BAAM;;gBACc,uCAAY,CAC5B,EAER,QAAQ,EAAE,QAAQ;YAClB,oBAAC,IAAI,IAAC,IAAI,EAAC,QAAQ,GAAG,CACd,CACN,CACP,CAAC,CAAC;IAEL,MAAM,uBAAuB,GAAG,GAAG,EAAE,CACnC,gBAAgB,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,CACjC,6BAAK,GAAG,EAAE,GAAG,QAAQ,OAAO;QAC1B,oBAAC,OAAO,IAAC,IAAI,EAAC,mCAAmC,EAAC,QAAQ,EAAE,QAAQ;YAClE;;gBAAiC,QAAQ;oBAAS,CAC1C,CACN,CACP,CAAC,CAAC;IAEL,OAAO,CACL,6BAAK,SAAS,EAAC,gDAAgD;QAC5D,wBAAwB,EAAE;QAC1B,0BAA0B,EAAE;QAC5B,uBAAuB,EAAE,CACtB,CACP,CAAC;AACJ,CAAC,CAAC"}
@@ -0,0 +1,9 @@
1
+ export declare const DEFAULT_TOOL_TIP_DELAY = 1000;
2
+ export declare const tooltipPositions: readonly ["top", "left", "right", "bottom"];
3
+ export type TooltipPosition = typeof tooltipPositions[number];
4
+ export interface TooltipProps {
5
+ position?: TooltipPosition;
6
+ children?: JSX.Element | string;
7
+ text: JSX.Element | string;
8
+ delay?: number;
9
+ }
@@ -0,0 +1,3 @@
1
+ export const DEFAULT_TOOL_TIP_DELAY = 1000;
2
+ export const tooltipPositions = ['top', 'left', 'right', 'bottom'];
3
+ //# sourceMappingURL=Tooltip.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Tooltip.types.js","sourceRoot":"","sources":["../../src/Tooltip/Tooltip.types.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,sBAAsB,GAAG,IAAI,CAAC;AAC3C,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,CAAU,CAAC"}
@@ -0,0 +1 @@
1
+ export { Tooltip as default } from './Tooltip';
@@ -0,0 +1,2 @@
1
+ export { Tooltip as default } from './Tooltip';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/Tooltip/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,WAAW,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,2 +1,6 @@
1
1
  import Button from './Button';
2
+ import TextField from './TextField';
3
+ import Tooltip from './Tooltip';
2
4
  export { Button };
5
+ export { TextField };
6
+ export { Tooltip };
package/dist/index.esm.js CHANGED
@@ -1,4 +1,4 @@
1
- import React from 'react';
1
+ import React, { useRef, useState, useEffect } from 'react';
2
2
 
3
3
  /**
4
4
  * @exports the browser id (i.e., 'IE 11' 'Chrome 90')
@@ -28,27 +28,149 @@ const browserName = browserId && browserId.split(' ', 2)[0];
28
28
  browserId && parseInt(browserId.split(' ', 2)[1], 10);
29
29
  const browserIsFirefox = browserId && browserName === 'Firefox';
30
30
 
31
- const Button = ({ onClick, label, variant = 'outline', type = 'button', size = 'sm', disabled, extraClassNames, id, testId, stopPropagation = true, }) => {
32
- const baseClasses = 'py-1 px-3 rounded-sm focus:ring-0 disabled:pointer-events-none';
31
+ const DEFAULT_TOOL_TIP_DELAY = 1000;
32
+
33
+ /**
34
+ * This component displays a Tooltip for the provided children.
35
+ */
36
+ const Tooltip = ({ position = 'bottom', children, text, delay = DEFAULT_TOOL_TIP_DELAY, }) => {
37
+ const arrowBaseClasses = "before:tw-content-[''] before:tw-absolute before:tw-border-8";
38
+ const centerArrowVertically = 'before:tw-top-1/2 before:-tw-translate-y-1/2';
39
+ const centerArrowHorizontally = 'before:tw-left-1/2 before:-tw-translate-x-1/2';
40
+ const arrowRight = `${arrowBaseClasses} ${centerArrowVertically} before:tw-right-[100%] before:tw-border-y-transparent
41
+ before:tw-border-l-transparent before:tw-border-r-black`;
42
+ const arrowLeft = `${arrowBaseClasses} ${centerArrowVertically} before:tw-left-[100%] before:tw-border-y-transparent
43
+ before:tw-border-l-black before:tw-border-r-transparent`;
44
+ const arrowBottom = `${arrowBaseClasses} ${centerArrowHorizontally} before:-tw-top-4 before:tw-border-b-black
45
+ before:tw-border-r-transparent before:tw-border-l-transparent before:tw-border-t-transparent`;
46
+ const arrowTop = `${arrowBaseClasses} ${centerArrowHorizontally} before:-tw-bottom-4 before:tw-border-b-transparent
47
+ before:tw-border-t-black before:tw-border-l-transparent before:tw-border-r-transparent`;
48
+ const placements = {
49
+ top: `-tw-top-2 -tw-translate-y-full tw-left-1/2 -tw-translate-x-1/2 ${arrowTop}`,
50
+ left: `-tw-translate-x-full -tw-left-3 -tw-translate-y-1/2 tw-top-1/2 ${arrowLeft}`,
51
+ right: `tw-translate-x-full -tw-right-3 -tw-translate-y-1/2 tw-top-1/2 ${arrowRight}`,
52
+ bottom: `-tw-bottom-2 tw-translate-y-full tw-left-1/2 -tw-translate-x-1/2 ${arrowBottom}`,
53
+ };
54
+ return (React.createElement("div", { className: "tw-group tw-relative tw-inline-block" },
55
+ children,
56
+ React.createElement("div", { className: `tw-z-50 tw-whitespace-nowrap tw-hidden group-hover:tw-inline-block group-hover:tw-delay-[${delay}ms]
57
+ tw-absolute tw-opacity-0 group-hover:tw-opacity-100 tw-rounded tw-bg-black tw-p-2 tw-text-xs tw-text-white ${placements[position]}` }, text)));
58
+ };
59
+
60
+ /**
61
+ * Icon:
62
+ * - access to Seeq custom icons by providing the desired icon
63
+ * - leverage "type" to style your icon
64
+ */
65
+ const Icon = ({ onClick, icon, type = 'theme', extraClassNames, id, large, small, color, testId, customId, tooltip, tooltipDelay, tooltipPlacement, number, hasExternalTooltipHandler = false, }) => {
66
+ if ((type === 'color' && (color === undefined || color === '')) || (color && type !== 'color')) {
67
+ const errorMessage = color === undefined || color === ''
68
+ ? 'Icon with type="color" must have prop color specified.'
69
+ : 'Icon with prop color must have type="color".';
70
+ return React.createElement("div", { className: "tw-text-sq-danger-color" }, errorMessage);
71
+ }
72
+ const colorClasses = {
73
+ 'theme': 'tw-text-sq-color-dark',
74
+ 'white': 'tw-text-white',
75
+ 'dark-gray': 'tw-text-sq-fairly-dark-gray',
76
+ 'warning': 'tw-text-sq-warning-color',
77
+ 'darkish-gray': 'tw-text-sq-darkish-gray',
78
+ 'gray': 'tw-text-sq-disabled-gray',
79
+ 'color': '',
80
+ 'info': 'tw-text-sq-link',
81
+ 'text': 'tw-text-sq-text-color',
82
+ 'inherit': '',
83
+ 'danger': 'tw-text-sq-danger-color',
84
+ 'theme-light': 'tw-text-sq-color-light',
85
+ 'success': 'tw-text-sq-success-color',
86
+ };
87
+ const iconPrefix = icon.startsWith('fc') ? 'fc' : 'fa';
88
+ const style = type === 'color' && color ? { color } : {};
89
+ const appliedClassNames = `${iconPrefix} ${icon} ${small ? 'fa-sm' : ''} ${large ? 'fa-lg' : ''} ${colorClasses[type]} ${onClick ? 'cursor-pointer' : ''} ${extraClassNames}`;
90
+ const iconTag = (React.createElement("i", { className: appliedClassNames, style: style, onClick: onClick, "data-testid": testId, "data-customid": customId, id: id, "data-number": number }));
91
+ return !hasExternalTooltipHandler && tooltip && tooltip !== '' ? (React.createElement(Tooltip, { text: tooltip, delay: tooltipDelay, position: tooltipPlacement }, iconTag)) : (iconTag);
92
+ };
93
+
94
+ /**
95
+ * All-in-one Button:
96
+ * - use "variant" to achieve the desired style
97
+ * - include tooltips and/or icons
98
+ */
99
+ const Button = ({ onClick, label, variant = 'outline', type = 'button', size = 'sm', disabled, extraClassNames, id, testId, stopPropagation = true, tooltip, tooltipOptions, iconStyle = 'text', icon, iconColor, }) => {
100
+ const baseClasses = 'tw-py-1 tw-px-2.5 tw-rounded-sm focus:tw-ring-0 disabled:tw-pointer-events-none';
101
+ const textClassesByVariant = {
102
+ 'outline': 'tw-text-sq-text-color',
103
+ 'theme': 'tw-text-white',
104
+ 'theme-light': 'tw-text-white',
105
+ 'danger': 'tw-text-white',
106
+ 'no-border': 'tw-text-sq-text-color',
107
+ 'warning': 'tw-text-white',
108
+ };
33
109
  const classesByVariant = {
34
- outline: 'text-sq-text-color border-sq-disabled-gray border-solid border hover:bg-sq-light-gray' +
35
- ' focus:bg-sq-dark-gray active:bg-sq-dark-gray focus:border-sq-color-dark active:border-sq-color-dark',
36
- theme: 'bg-sq-color-dark hover:bg-sq-color-highlight text-white disabled:bg-opacity-50',
37
- danger: 'bg-sq-danger-color text-white hover:bg-sq-danger-color-hover disabled:bg-opacity-50',
38
- 'theme-light': 'bg-sq-icon text-white hover:bg-sq-link disabled:bg-opacity-50',
110
+ 'outline': 'tw-border-sq-disabled-gray tw-border-solid tw-border hover:tw-bg-sq-light-gray' +
111
+ ' focus:tw-bg-sq-dark-gray active:tw-bg-sq-dark-gray focus:tw-border-sq-color-dark active:tw-border-sq-color-dark',
112
+ 'theme': 'tw-bg-sq-color-dark hover:tw-bg-sq-color-highlight disabled:tw-bg-opacity-50',
113
+ 'danger': 'tw-bg-sq-danger-color hover:tw-bg-sq-danger-color-hover disabled:tw-bg-opacity-50',
114
+ 'theme-light': 'tw-bg-sq-icon hover:tw-bg-sq-link disabled:tw-bg-opacity-50',
39
115
  'no-border': '',
40
- 'warning': '',
116
+ 'warning': 'tw-bg-sq-warning-color',
41
117
  };
42
118
  const sizeClasses = {
43
- sm: 'text-xs',
44
- lg: 'text-xl',
119
+ sm: 'tw-text-sm',
120
+ lg: 'tw-text-xl',
45
121
  };
46
- const appliedClasses = baseClasses + ' ' + sizeClasses[size] + ' ' + classesByVariant[variant] + ' ' + extraClassNames;
47
- return (React.createElement("button", { id: id, disabled: disabled, "data-testid": testId, type: type === 'link' || (type === 'submit' && browserIsFirefox) ? 'button' : type, onClick: (e) => {
122
+ const appliedClasses = `${baseClasses} ${sizeClasses[size]} ${classesByVariant[variant]} ${textClassesByVariant[variant]} ${extraClassNames}`;
123
+ const button = (React.createElement("button", { id: id, disabled: disabled, "data-testid": testId, type: type === 'link' || (type === 'submit' && browserIsFirefox) ? 'button' : type, onClick: (e) => {
48
124
  stopPropagation && e.stopPropagation();
49
125
  onClick && onClick();
50
- }, className: appliedClasses }, label));
126
+ }, className: appliedClasses },
127
+ icon && (React.createElement(Icon, { icon: icon, type: iconStyle, color: iconColor, extraClassNames: label ? `tw-mr-1 ${textClassesByVariant[variant]}` : '', testId: `${id}_spinner` })),
128
+ label));
129
+ return tooltip ? (React.createElement(Tooltip, { text: tooltip, ...tooltipOptions }, button)) : (button);
51
130
  };
52
131
 
53
- export { Button };
132
+ /**
133
+ * Textfield.
134
+ */
135
+ const TextField = React.forwardRef((props, ref) => {
136
+ const { readonly = false, onChange, onKeyUp, id, name, size = 'sm', value, placeholder, extraClassNames, testId, type = 'text', } = props;
137
+ const internalRef = useRef(null);
138
+ const [cursor, setCursor] = useState(null);
139
+ const setAllRefs = (receivedRef) => {
140
+ if (ref)
141
+ ref.current = receivedRef;
142
+ internalRef.current = receivedRef;
143
+ };
144
+ useEffect(() => {
145
+ const input = internalRef.current;
146
+ if (input)
147
+ input.setSelectionRange(cursor, cursor);
148
+ }, [ref, cursor, value]);
149
+ const handleChange = (e) => {
150
+ setCursor(e.target.selectionStart);
151
+ onChange && onChange(e);
152
+ };
153
+ useEffect(() => {
154
+ /**
155
+ * we need to change the value only if it's different since the internal state of "input" will change it anyway
156
+ * this will only be the case when the value has been changed externally via store (undo / redo)
157
+ */
158
+ if (value !== null && value !== undefined && value !== internalRef.current?.value && internalRef.current) {
159
+ // we need to use this method because using the value props directly will switch the input to a "controlled"
160
+ // component
161
+ internalRef.current.value = `${value}`;
162
+ }
163
+ }, [value]);
164
+ 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' +
165
+ ' disabled:tw-cursor-not-allowed tw-p-1 tw-border-sq-disabled-gray tw-border-solid tw-border' +
166
+ ' tw-text-sq-text-color focus:tw-border-sq-color-dark active:tw-border-sq-color-dark';
167
+ const sizeClasses = {
168
+ sm: 'tw-text-sm',
169
+ lg: 'tw-text-xl',
170
+ };
171
+ const appliedClasses = `${baseClasses} ${sizeClasses[size]} ${extraClassNames}`;
172
+ 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 }));
173
+ });
174
+
175
+ export { Button, TextField, Tooltip };
54
176
  //# sourceMappingURL=index.esm.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.esm.js","sources":["../src/utils/browserId.ts","../src/Button/Button.tsx"],"sourcesContent":["/**\n * @exports the browser id (i.e., 'IE 11' 'Chrome 90')\n * @see http://stackoverflow.com/questions/2400935/browser-detection-in-javascript\n */\nexport const browserId: string = (function () {\n let tem;\n const ua = navigator.userAgent;\n let M = ua.match(/(opera|chrome|safari|firefox|msie|trident(?=\\/))\\/?\\s*(\\d+)/i) || [];\n if (/trident/i.test(M[1])) {\n tem = /\\brv[ :]+(\\d+)/g.exec(ua) || [];\n return `IE ${tem[1] || ''}`;\n }\n\n if (M[1] === 'Chrome') {\n tem = ua.match(/\\b(OPR|Edge?)\\/(\\d+)/);\n if (tem !== null) {\n return tem.slice(1).join(' ').replace('OPR', 'Opera').replace('Edg ', 'Edge ');\n }\n }\n\n M = M[2] ? [M[1], M[2]] : [navigator.appName, navigator.appVersion, '-?'];\n if ((tem = ua.match(/version\\/(\\d+)/i)) !== null) {\n M.splice(1, 1, tem[1]);\n }\n\n return M.join(' ');\n})();\nexport const browserName = browserId && browserId.split(' ', 2)[0];\nexport const browserVersion = browserId && parseInt(browserId.split(' ', 2)[1], 10);\nexport const browserIsFirefox = browserId && browserName === 'Firefox';\nexport const browserIsEdgeBeforeChromium =\n browserName && browserVersion && browserName === 'Edge' && browserVersion < 70;\n","import React from 'react';\nimport { ButtonProps } from './Button.types';\nimport '../styles.css';\nimport { browserIsFirefox } from '../utils/browserId';\n\nconst Button: React.FunctionComponent<ButtonProps> =\n ({\n onClick,\n label,\n variant = 'outline',\n type = 'button',\n size = 'sm',\n disabled,\n extraClassNames,\n id,\n testId,\n stopPropagation = true,\n }) => {\n const baseClasses = 'py-1 px-3 rounded-sm focus:ring-0 disabled:pointer-events-none';\n const classesByVariant = {\n outline: 'text-sq-text-color border-sq-disabled-gray border-solid border hover:bg-sq-light-gray' +\n ' focus:bg-sq-dark-gray active:bg-sq-dark-gray focus:border-sq-color-dark active:border-sq-color-dark',\n theme: 'bg-sq-color-dark hover:bg-sq-color-highlight text-white disabled:bg-opacity-50',\n danger: 'bg-sq-danger-color text-white hover:bg-sq-danger-color-hover disabled:bg-opacity-50',\n 'theme-light': 'bg-sq-icon text-white hover:bg-sq-link disabled:bg-opacity-50',\n 'no-border': '',\n 'warning': '',\n };\n const sizeClasses = {\n sm: 'text-xs',\n lg: 'text-xl',\n };\n const appliedClasses = baseClasses + ' ' + sizeClasses[size] + ' ' + classesByVariant[variant] + ' ' + extraClassNames;\n\n return (\n <button\n id={id}\n disabled={disabled}\n data-testid={testId}\n type={type === 'link' || (type === 'submit' && browserIsFirefox) ? 'button' : type}\n onClick={(e) => {\n stopPropagation && e.stopPropagation();\n onClick && onClick();\n }}\n className={appliedClasses}>\n {label}\n </button>\n );\n };\nexport default Button;\n\n"],"names":[],"mappings":";;AAAA;;;AAGG;AACI,MAAM,SAAS,GAAW,CAAC,YAAA;AAChC,IAAA,IAAI,GAAG,CAAC;AACR,IAAA,MAAM,EAAE,GAAG,SAAS,CAAC,SAAS,CAAC;IAC/B,IAAI,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,8DAA8D,CAAC,IAAI,EAAE,CAAC;IACvF,IAAI,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE;QACzB,GAAG,GAAG,iBAAiB,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC;QACvC,OAAO,CAAA,GAAA,EAAM,GAAG,CAAC,CAAC,CAAC,IAA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nB,IAAI,GAAG,QAAQ,EACf,IAAI,GAAG,IAAI,EACX,QAAQ,EACR,eAAe,EACf,EAAE,EACF,MAAM,EACN,eAAe,GAAG,IAAI,GACvB,KAAI;IACH,MAAM,WAAW,GAAG,gEAAgE,CAAC;AACrF,IAAA,MAAM,gBAAgB,GAAG;AACvB,QAAA,OAAO,EAAE,uFAAuF;YAC9F,sGAAsG;AACxG,QAAA,KAAK,EAAE,gFAAgF;AACvF,QAAA,MAAM,EAAE,qFAAqF;AAC7F,QAAA,aAAa,EAAE,+DAA+D;AAC9E,QAAA,WAAW,EAAE,EAAE;AACf,QAAA,SAAS,EAAE,EAAE;KACd,CAAC;AACF,IAAA,MAAM,WAAW,GAAG;AAClB,QAAA,EAAE,EAAE,SAAS;AACb,QAAA,EAAE,EAAE,SAAS;KACd,CAAC;IACF,MAAM,cAAc,GAAG,WAAW,GAAG,GAAG,GAAG,WAAW,CAAC,IAAI,CAAC,GAAG,GAAG,GAAG,gBAAgB,CAAC,OAAO,CAAC,GAAG,GAAG,GAAG,eAAe,CAAC;AAEvH,IAAA,QACE,KACE,CAAA,aAAA,CAAA,QAAA,EAAA,EAAA,EAAE,EAAE,EAAE,EACN,QAAQ,EAAE,QAAQ,EAAA,aAAA,EACL,MAAM,EACnB,IAAI,EAAE,IAAI,KAAK,MAAM,KAAK,IAAI,KAAK,QAAQ,IAAI,gBAAgB,CAAC,GAAG,QAAQ,GAAG,IAAI,EAClF,OAAO,EAAE,CAAC,CAAC,KAAI;AACb,YAAA,eAAe,IAAI,CAAC,CAAC,eAAe,EAAE,CAAC;YACvC,OAAO,IAAI,OAAO,EAAE,CAAC;SACtB,EACD,SAAS,EAAE,cAAc,IACxB,KAAK,CACC,EACT;AACJ;;;;"}
1
+ {"version":3,"file":"index.esm.js","sources":["../src/utils/browserId.ts","../src/Tooltip/Tooltip.types.ts","../src/Tooltip/Tooltip.tsx","../src/Icon/Icon.tsx","../src/Button/Button.tsx","../src/TextField/TextField.tsx"],"sourcesContent":["/**\n * @exports the browser id (i.e., 'IE 11' 'Chrome 90')\n * @see http://stackoverflow.com/questions/2400935/browser-detection-in-javascript\n */\nexport const browserId: string = (function () {\n let tem;\n const ua = navigator.userAgent;\n let M = ua.match(/(opera|chrome|safari|firefox|msie|trident(?=\\/))\\/?\\s*(\\d+)/i) || [];\n if (/trident/i.test(M[1])) {\n tem = /\\brv[ :]+(\\d+)/g.exec(ua) || [];\n return `IE ${tem[1] || ''}`;\n }\n\n if (M[1] === 'Chrome') {\n tem = ua.match(/\\b(OPR|Edge?)\\/(\\d+)/);\n if (tem !== null) {\n return tem.slice(1).join(' ').replace('OPR', 'Opera').replace('Edg ', 'Edge ');\n }\n }\n\n M = M[2] ? [M[1], M[2]] : [navigator.appName, navigator.appVersion, '-?'];\n if ((tem = ua.match(/version\\/(\\d+)/i)) !== null) {\n M.splice(1, 1, tem[1]);\n }\n\n return M.join(' ');\n})();\nexport const browserName = browserId && browserId.split(' ', 2)[0];\nexport const browserVersion = browserId && parseInt(browserId.split(' ', 2)[1], 10);\nexport const browserIsFirefox = browserId && browserName === 'Firefox';\nexport const browserIsEdgeBeforeChromium =\n browserName && browserVersion && browserName === 'Edge' && browserVersion < 70;\n","export const DEFAULT_TOOL_TIP_DELAY = 1000;\nexport const tooltipPositions = ['top', 'left', 'right', 'bottom'] as const;\n\nexport type TooltipPosition = typeof tooltipPositions[number];\n\nexport interface TooltipProps {\n position?: TooltipPosition;\n children?: JSX.Element | string;\n text: JSX.Element | string;\n delay?: number;\n}\n","import React from 'react';\nimport '../styles.css';\nimport { DEFAULT_TOOL_TIP_DELAY, TooltipProps } from './Tooltip.types';\n\n/**\n * This component displays a Tooltip for the provided children.\n */\nexport const Tooltip: React.FunctionComponent<TooltipProps> = ({\n position = 'bottom',\n children,\n text,\n delay = DEFAULT_TOOL_TIP_DELAY,\n}) => {\n const arrowBaseClasses = \"before:tw-content-[''] before:tw-absolute before:tw-border-8\";\n const centerArrowVertically = 'before:tw-top-1/2 before:-tw-translate-y-1/2';\n const centerArrowHorizontally = 'before:tw-left-1/2 before:-tw-translate-x-1/2';\n const arrowRight = `${arrowBaseClasses} ${centerArrowVertically} before:tw-right-[100%] before:tw-border-y-transparent \n before:tw-border-l-transparent before:tw-border-r-black`;\n\n const arrowLeft = `${arrowBaseClasses} ${centerArrowVertically} before:tw-left-[100%] before:tw-border-y-transparent\n before:tw-border-l-black before:tw-border-r-transparent`;\n\n const arrowBottom = `${arrowBaseClasses} ${centerArrowHorizontally} before:-tw-top-4 before:tw-border-b-black \n before:tw-border-r-transparent before:tw-border-l-transparent before:tw-border-t-transparent`;\n const arrowTop = `${arrowBaseClasses} ${centerArrowHorizontally} before:-tw-bottom-4 before:tw-border-b-transparent \n before:tw-border-t-black before:tw-border-l-transparent before:tw-border-r-transparent`;\n\n const placements = {\n top: `-tw-top-2 -tw-translate-y-full tw-left-1/2 -tw-translate-x-1/2 ${arrowTop}`,\n left: `-tw-translate-x-full -tw-left-3 -tw-translate-y-1/2 tw-top-1/2 ${arrowLeft}`,\n right: `tw-translate-x-full -tw-right-3 -tw-translate-y-1/2 tw-top-1/2 ${arrowRight}`,\n bottom: `-tw-bottom-2 tw-translate-y-full tw-left-1/2 -tw-translate-x-1/2 ${arrowBottom}`,\n };\n\n return (\n <div className=\"tw-group tw-relative tw-inline-block\">\n {children}\n <div\n className={`tw-z-50 tw-whitespace-nowrap tw-hidden group-hover:tw-inline-block group-hover:tw-delay-[${delay}ms] \n tw-absolute tw-opacity-0 group-hover:tw-opacity-100 tw-rounded tw-bg-black tw-p-2 tw-text-xs tw-text-white ${placements[position]}`}>\n {text}\n </div>\n </div>\n );\n};\n","import React from 'react';\nimport '../styles.css';\nimport { IconProps } from './Icon.types';\nimport Tooltip from '../Tooltip';\n\n/**\n * Icon:\n * - access to Seeq custom icons by providing the desired icon\n * - leverage \"type\" to style your icon\n */\nconst Icon: React.FunctionComponent<IconProps> = ({\n onClick,\n icon,\n type = 'theme',\n extraClassNames,\n id,\n large,\n small,\n color,\n testId,\n customId,\n tooltip,\n tooltipDelay,\n tooltipPlacement,\n number,\n hasExternalTooltipHandler = false,\n}) => {\n if ((type === 'color' && (color === undefined || color === '')) || (color && type !== 'color')) {\n const errorMessage =\n color === undefined || color === ''\n ? 'Icon with type=\"color\" must have prop color specified.'\n : 'Icon with prop color must have type=\"color\".';\n return <div className=\"tw-text-sq-danger-color\">{errorMessage}</div>;\n }\n\n const colorClasses = {\n 'theme': 'tw-text-sq-color-dark',\n 'white': 'tw-text-white',\n 'dark-gray': 'tw-text-sq-fairly-dark-gray',\n 'warning': 'tw-text-sq-warning-color',\n 'darkish-gray': 'tw-text-sq-darkish-gray',\n 'gray': 'tw-text-sq-disabled-gray',\n 'color': '',\n 'info': 'tw-text-sq-link',\n 'text': 'tw-text-sq-text-color',\n 'inherit': '',\n 'danger': 'tw-text-sq-danger-color',\n 'theme-light': 'tw-text-sq-color-light',\n 'success': 'tw-text-sq-success-color',\n };\n\n const iconPrefix = icon.startsWith('fc') ? 'fc' : 'fa';\n const style = type === 'color' && color ? { color } : {};\n const appliedClassNames = `${iconPrefix} ${icon} ${small ? 'fa-sm' : ''} ${large ? 'fa-lg' : ''} ${\n colorClasses[type]\n } ${onClick ? 'cursor-pointer' : ''} ${extraClassNames}`;\n\n const iconTag = (\n <i\n className={appliedClassNames}\n style={style}\n onClick={onClick}\n data-testid={testId}\n data-customid={customId}\n id={id}\n data-number={number}\n />\n );\n\n return !hasExternalTooltipHandler && tooltip && tooltip !== '' ? (\n <Tooltip text={tooltip} delay={tooltipDelay} position={tooltipPlacement}>\n {iconTag}\n </Tooltip>\n ) : (\n iconTag\n );\n};\nexport default Icon;\n","import React from 'react';\nimport { ButtonProps } from './Button.types';\nimport '../styles.css';\nimport { browserIsFirefox } from '../utils/browserId';\nimport Tooltip from '../Tooltip';\nimport Icon from '../Icon';\n\n/**\n * All-in-one Button:\n * - use \"variant\" to achieve the desired style\n * - include tooltips and/or icons\n */\nconst Button: React.FunctionComponent<ButtonProps> = ({\n onClick,\n label,\n variant = 'outline',\n type = 'button',\n size = 'sm',\n disabled,\n extraClassNames,\n id,\n testId,\n stopPropagation = true,\n tooltip,\n tooltipOptions,\n iconStyle = 'text',\n icon,\n iconColor,\n}) => {\n const baseClasses = 'tw-py-1 tw-px-2.5 tw-rounded-sm focus:tw-ring-0 disabled:tw-pointer-events-none';\n const textClassesByVariant = {\n 'outline': 'tw-text-sq-text-color',\n 'theme': 'tw-text-white',\n 'theme-light': 'tw-text-white',\n 'danger': 'tw-text-white',\n 'no-border': 'tw-text-sq-text-color',\n 'warning': 'tw-text-white',\n };\n const classesByVariant = {\n 'outline':\n 'tw-border-sq-disabled-gray tw-border-solid tw-border hover:tw-bg-sq-light-gray' +\n ' focus:tw-bg-sq-dark-gray active:tw-bg-sq-dark-gray focus:tw-border-sq-color-dark active:tw-border-sq-color-dark',\n 'theme': 'tw-bg-sq-color-dark hover:tw-bg-sq-color-highlight disabled:tw-bg-opacity-50',\n 'danger': 'tw-bg-sq-danger-color hover:tw-bg-sq-danger-color-hover disabled:tw-bg-opacity-50',\n 'theme-light': 'tw-bg-sq-icon hover:tw-bg-sq-link disabled:tw-bg-opacity-50',\n 'no-border': '',\n 'warning': 'tw-bg-sq-warning-color',\n };\n const sizeClasses = {\n sm: 'tw-text-sm',\n lg: 'tw-text-xl',\n };\n const appliedClasses = `${baseClasses} ${sizeClasses[size]} ${classesByVariant[variant]} ${textClassesByVariant[variant]} ${extraClassNames}`;\n\n const button = (\n <button\n id={id}\n disabled={disabled}\n data-testid={testId}\n type={type === 'link' || (type === 'submit' && browserIsFirefox) ? 'button' : type}\n onClick={(e) => {\n stopPropagation && e.stopPropagation();\n onClick && onClick();\n }}\n className={appliedClasses}>\n {icon && (\n <Icon\n icon={icon}\n type={iconStyle}\n color={iconColor}\n extraClassNames={label ? `tw-mr-1 ${textClassesByVariant[variant]}` : ''}\n testId={`${id}_spinner`}\n />\n )}\n {label}\n </button>\n );\n\n return tooltip ? (\n <Tooltip text={tooltip} {...tooltipOptions}>\n {button}\n </Tooltip>\n ) : (\n button\n );\n};\nexport default Button;\n","import React, { useEffect, useRef, useState } from 'react';\nimport { TextFieldProps } from './TextField.types';\nimport '../styles.css';\n\n/**\n * Textfield.\n */\nexport const TextField: React.FunctionComponent<TextFieldProps> = React.forwardRef<HTMLInputElement, TextFieldProps>(\n (props, ref: any) => {\n const {\n readonly = false,\n onChange,\n onKeyUp,\n id,\n name,\n size = 'sm',\n value,\n placeholder,\n extraClassNames,\n testId,\n type = 'text',\n } = props;\n\n const internalRef = useRef<HTMLInputElement | null>(null);\n const [cursor, setCursor] = useState(null);\n\n const setAllRefs = (receivedRef: any) => {\n if (ref) ref.current = receivedRef;\n internalRef.current = receivedRef;\n };\n\n useEffect(() => {\n const input = internalRef.current! as unknown as HTMLInputElement;\n if (input) input.setSelectionRange(cursor, cursor);\n }, [ref, cursor, value]);\n\n const handleChange = (e: any) => {\n setCursor(e.target.selectionStart);\n onChange && onChange(e);\n };\n\n useEffect(() => {\n /**\n * we need to change the value only if it's different since the internal state of \"input\" will change it anyway\n * this will only be the case when the value has been changed externally via store (undo / redo)\n */\n if (value !== null && value !== undefined && value !== internalRef.current?.value && internalRef.current) {\n // we need to use this method because using the value props directly will switch the input to a \"controlled\"\n // component\n internalRef.current.value = `${value}`;\n }\n }, [value]);\n\n const baseClasses =\n 'tw-height-34 tw-leading-normal tw-outline-none tw-py-1 tw-px-3 tw-rounded-sm disabled:tw-pointer-events-none' +\n ' disabled:tw-cursor-not-allowed tw-p-1 tw-border-sq-disabled-gray tw-border-solid tw-border' +\n ' tw-text-sq-text-color focus:tw-border-sq-color-dark active:tw-border-sq-color-dark';\n\n const sizeClasses = {\n sm: 'tw-text-sm',\n lg: 'tw-text-xl',\n };\n\n const appliedClasses = `${baseClasses} ${sizeClasses[size]} ${extraClassNames}`;\n\n return (\n <input\n ref={setAllRefs}\n data-testid={testId}\n name={name}\n id={id}\n type={type}\n value={value}\n className={appliedClasses}\n placeholder={placeholder}\n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WAAW,EACxB,QAAQ,EAAE,QAAQ,EAClB,YAAY,EAAC,MAAM,EACnB,QAAQ,EAAE,YAAY,EACtB,OAAO,EAAE,OAAO,EAChB,CAAA,EACF;AACJ,CAAC;;;;"}
package/dist/index.js CHANGED
@@ -30,27 +30,151 @@ const browserName = browserId && browserId.split(' ', 2)[0];
30
30
  browserId && parseInt(browserId.split(' ', 2)[1], 10);
31
31
  const browserIsFirefox = browserId && browserName === 'Firefox';
32
32
 
33
- const Button = ({ onClick, label, variant = 'outline', type = 'button', size = 'sm', disabled, extraClassNames, id, testId, stopPropagation = true, }) => {
34
- const baseClasses = 'py-1 px-3 rounded-sm focus:ring-0 disabled:pointer-events-none';
33
+ const DEFAULT_TOOL_TIP_DELAY = 1000;
34
+
35
+ /**
36
+ * This component displays a Tooltip for the provided children.
37
+ */
38
+ const Tooltip = ({ position = 'bottom', children, text, delay = DEFAULT_TOOL_TIP_DELAY, }) => {
39
+ const arrowBaseClasses = "before:tw-content-[''] before:tw-absolute before:tw-border-8";
40
+ const centerArrowVertically = 'before:tw-top-1/2 before:-tw-translate-y-1/2';
41
+ const centerArrowHorizontally = 'before:tw-left-1/2 before:-tw-translate-x-1/2';
42
+ const arrowRight = `${arrowBaseClasses} ${centerArrowVertically} before:tw-right-[100%] before:tw-border-y-transparent
43
+ before:tw-border-l-transparent before:tw-border-r-black`;
44
+ const arrowLeft = `${arrowBaseClasses} ${centerArrowVertically} before:tw-left-[100%] before:tw-border-y-transparent
45
+ before:tw-border-l-black before:tw-border-r-transparent`;
46
+ const arrowBottom = `${arrowBaseClasses} ${centerArrowHorizontally} before:-tw-top-4 before:tw-border-b-black
47
+ before:tw-border-r-transparent before:tw-border-l-transparent before:tw-border-t-transparent`;
48
+ const arrowTop = `${arrowBaseClasses} ${centerArrowHorizontally} before:-tw-bottom-4 before:tw-border-b-transparent
49
+ before:tw-border-t-black before:tw-border-l-transparent before:tw-border-r-transparent`;
50
+ const placements = {
51
+ top: `-tw-top-2 -tw-translate-y-full tw-left-1/2 -tw-translate-x-1/2 ${arrowTop}`,
52
+ left: `-tw-translate-x-full -tw-left-3 -tw-translate-y-1/2 tw-top-1/2 ${arrowLeft}`,
53
+ right: `tw-translate-x-full -tw-right-3 -tw-translate-y-1/2 tw-top-1/2 ${arrowRight}`,
54
+ bottom: `-tw-bottom-2 tw-translate-y-full tw-left-1/2 -tw-translate-x-1/2 ${arrowBottom}`,
55
+ };
56
+ return (React.createElement("div", { className: "tw-group tw-relative tw-inline-block" },
57
+ children,
58
+ React.createElement("div", { className: `tw-z-50 tw-whitespace-nowrap tw-hidden group-hover:tw-inline-block group-hover:tw-delay-[${delay}ms]
59
+ tw-absolute tw-opacity-0 group-hover:tw-opacity-100 tw-rounded tw-bg-black tw-p-2 tw-text-xs tw-text-white ${placements[position]}` }, text)));
60
+ };
61
+
62
+ /**
63
+ * Icon:
64
+ * - access to Seeq custom icons by providing the desired icon
65
+ * - leverage "type" to style your icon
66
+ */
67
+ const Icon = ({ onClick, icon, type = 'theme', extraClassNames, id, large, small, color, testId, customId, tooltip, tooltipDelay, tooltipPlacement, number, hasExternalTooltipHandler = false, }) => {
68
+ if ((type === 'color' && (color === undefined || color === '')) || (color && type !== 'color')) {
69
+ const errorMessage = color === undefined || color === ''
70
+ ? 'Icon with type="color" must have prop color specified.'
71
+ : 'Icon with prop color must have type="color".';
72
+ return React.createElement("div", { className: "tw-text-sq-danger-color" }, errorMessage);
73
+ }
74
+ const colorClasses = {
75
+ 'theme': 'tw-text-sq-color-dark',
76
+ 'white': 'tw-text-white',
77
+ 'dark-gray': 'tw-text-sq-fairly-dark-gray',
78
+ 'warning': 'tw-text-sq-warning-color',
79
+ 'darkish-gray': 'tw-text-sq-darkish-gray',
80
+ 'gray': 'tw-text-sq-disabled-gray',
81
+ 'color': '',
82
+ 'info': 'tw-text-sq-link',
83
+ 'text': 'tw-text-sq-text-color',
84
+ 'inherit': '',
85
+ 'danger': 'tw-text-sq-danger-color',
86
+ 'theme-light': 'tw-text-sq-color-light',
87
+ 'success': 'tw-text-sq-success-color',
88
+ };
89
+ const iconPrefix = icon.startsWith('fc') ? 'fc' : 'fa';
90
+ const style = type === 'color' && color ? { color } : {};
91
+ const appliedClassNames = `${iconPrefix} ${icon} ${small ? 'fa-sm' : ''} ${large ? 'fa-lg' : ''} ${colorClasses[type]} ${onClick ? 'cursor-pointer' : ''} ${extraClassNames}`;
92
+ const iconTag = (React.createElement("i", { className: appliedClassNames, style: style, onClick: onClick, "data-testid": testId, "data-customid": customId, id: id, "data-number": number }));
93
+ return !hasExternalTooltipHandler && tooltip && tooltip !== '' ? (React.createElement(Tooltip, { text: tooltip, delay: tooltipDelay, position: tooltipPlacement }, iconTag)) : (iconTag);
94
+ };
95
+
96
+ /**
97
+ * All-in-one Button:
98
+ * - use "variant" to achieve the desired style
99
+ * - include tooltips and/or icons
100
+ */
101
+ const Button = ({ onClick, label, variant = 'outline', type = 'button', size = 'sm', disabled, extraClassNames, id, testId, stopPropagation = true, tooltip, tooltipOptions, iconStyle = 'text', icon, iconColor, }) => {
102
+ const baseClasses = 'tw-py-1 tw-px-2.5 tw-rounded-sm focus:tw-ring-0 disabled:tw-pointer-events-none';
103
+ const textClassesByVariant = {
104
+ 'outline': 'tw-text-sq-text-color',
105
+ 'theme': 'tw-text-white',
106
+ 'theme-light': 'tw-text-white',
107
+ 'danger': 'tw-text-white',
108
+ 'no-border': 'tw-text-sq-text-color',
109
+ 'warning': 'tw-text-white',
110
+ };
35
111
  const classesByVariant = {
36
- outline: 'text-sq-text-color border-sq-disabled-gray border-solid border hover:bg-sq-light-gray' +
37
- ' focus:bg-sq-dark-gray active:bg-sq-dark-gray focus:border-sq-color-dark active:border-sq-color-dark',
38
- theme: 'bg-sq-color-dark hover:bg-sq-color-highlight text-white disabled:bg-opacity-50',
39
- danger: 'bg-sq-danger-color text-white hover:bg-sq-danger-color-hover disabled:bg-opacity-50',
40
- 'theme-light': 'bg-sq-icon text-white hover:bg-sq-link disabled:bg-opacity-50',
112
+ 'outline': 'tw-border-sq-disabled-gray tw-border-solid tw-border hover:tw-bg-sq-light-gray' +
113
+ ' focus:tw-bg-sq-dark-gray active:tw-bg-sq-dark-gray focus:tw-border-sq-color-dark active:tw-border-sq-color-dark',
114
+ 'theme': 'tw-bg-sq-color-dark hover:tw-bg-sq-color-highlight disabled:tw-bg-opacity-50',
115
+ 'danger': 'tw-bg-sq-danger-color hover:tw-bg-sq-danger-color-hover disabled:tw-bg-opacity-50',
116
+ 'theme-light': 'tw-bg-sq-icon hover:tw-bg-sq-link disabled:tw-bg-opacity-50',
41
117
  'no-border': '',
42
- 'warning': '',
118
+ 'warning': 'tw-bg-sq-warning-color',
43
119
  };
44
120
  const sizeClasses = {
45
- sm: 'text-xs',
46
- lg: 'text-xl',
121
+ sm: 'tw-text-sm',
122
+ lg: 'tw-text-xl',
47
123
  };
48
- const appliedClasses = baseClasses + ' ' + sizeClasses[size] + ' ' + classesByVariant[variant] + ' ' + extraClassNames;
49
- return (React.createElement("button", { id: id, disabled: disabled, "data-testid": testId, type: type === 'link' || (type === 'submit' && browserIsFirefox) ? 'button' : type, onClick: (e) => {
124
+ const appliedClasses = `${baseClasses} ${sizeClasses[size]} ${classesByVariant[variant]} ${textClassesByVariant[variant]} ${extraClassNames}`;
125
+ const button = (React.createElement("button", { id: id, disabled: disabled, "data-testid": testId, type: type === 'link' || (type === 'submit' && browserIsFirefox) ? 'button' : type, onClick: (e) => {
50
126
  stopPropagation && e.stopPropagation();
51
127
  onClick && onClick();
52
- }, className: appliedClasses }, label));
128
+ }, className: appliedClasses },
129
+ icon && (React.createElement(Icon, { icon: icon, type: iconStyle, color: iconColor, extraClassNames: label ? `tw-mr-1 ${textClassesByVariant[variant]}` : '', testId: `${id}_spinner` })),
130
+ label));
131
+ return tooltip ? (React.createElement(Tooltip, { text: tooltip, ...tooltipOptions }, button)) : (button);
53
132
  };
54
133
 
134
+ /**
135
+ * Textfield.
136
+ */
137
+ const TextField = React.forwardRef((props, ref) => {
138
+ const { readonly = false, onChange, onKeyUp, id, name, size = 'sm', value, placeholder, extraClassNames, testId, type = 'text', } = props;
139
+ const internalRef = React.useRef(null);
140
+ const [cursor, setCursor] = React.useState(null);
141
+ const setAllRefs = (receivedRef) => {
142
+ if (ref)
143
+ ref.current = receivedRef;
144
+ internalRef.current = receivedRef;
145
+ };
146
+ React.useEffect(() => {
147
+ const input = internalRef.current;
148
+ if (input)
149
+ input.setSelectionRange(cursor, cursor);
150
+ }, [ref, cursor, value]);
151
+ const handleChange = (e) => {
152
+ setCursor(e.target.selectionStart);
153
+ onChange && onChange(e);
154
+ };
155
+ React.useEffect(() => {
156
+ /**
157
+ * we need to change the value only if it's different since the internal state of "input" will change it anyway
158
+ * this will only be the case when the value has been changed externally via store (undo / redo)
159
+ */
160
+ if (value !== null && value !== undefined && value !== internalRef.current?.value && internalRef.current) {
161
+ // we need to use this method because using the value props directly will switch the input to a "controlled"
162
+ // component
163
+ internalRef.current.value = `${value}`;
164
+ }
165
+ }, [value]);
166
+ 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' +
167
+ ' disabled:tw-cursor-not-allowed tw-p-1 tw-border-sq-disabled-gray tw-border-solid tw-border' +
168
+ ' tw-text-sq-text-color focus:tw-border-sq-color-dark active:tw-border-sq-color-dark';
169
+ const sizeClasses = {
170
+ sm: 'tw-text-sm',
171
+ lg: 'tw-text-xl',
172
+ };
173
+ const appliedClasses = `${baseClasses} ${sizeClasses[size]} ${extraClassNames}`;
174
+ 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 }));
175
+ });
176
+
55
177
  exports.Button = Button;
178
+ exports.TextField = TextField;
179
+ exports.Tooltip = Tooltip;
56
180
  //# sourceMappingURL=index.js.map