@seeqdev/qomponents 0.0.17 → 0.0.19

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 (83) hide show
  1. package/README.md +3 -0
  2. package/dist/Button/Button.js +74 -0
  3. package/dist/Button/Button.js.map +1 -0
  4. package/dist/Button/Button.stories.js +77 -0
  5. package/dist/Button/Button.stories.js.map +1 -0
  6. package/dist/Button/Button.test.js +49 -0
  7. package/dist/Button/Button.test.js.map +1 -0
  8. package/dist/Button/Button.types.js +4 -0
  9. package/dist/Button/Button.types.js.map +1 -0
  10. package/dist/Button/index.js +2 -0
  11. package/dist/Button/index.js.map +1 -0
  12. package/dist/Checkbox/Checkbox.js +23 -0
  13. package/dist/Checkbox/Checkbox.js.map +1 -0
  14. package/dist/Checkbox/Checkbox.stories.js +29 -0
  15. package/dist/Checkbox/Checkbox.stories.js.map +1 -0
  16. package/dist/Checkbox/Checkbox.test.js +94 -0
  17. package/dist/Checkbox/Checkbox.test.js.map +1 -0
  18. package/dist/Checkbox/Checkbox.types.js +2 -0
  19. package/dist/Checkbox/Checkbox.types.js.map +1 -0
  20. package/dist/Checkbox/index.js +2 -0
  21. package/dist/Checkbox/index.js.map +1 -0
  22. package/dist/FontCustom.woff +0 -0
  23. package/dist/FontCustom.woff2 +0 -0
  24. package/dist/Icon/Icon.js +54 -0
  25. package/dist/Icon/Icon.js.map +1 -0
  26. package/dist/Icon/Icon.stories.js +40 -0
  27. package/dist/Icon/Icon.stories.js.map +1 -0
  28. package/dist/Icon/Icon.test.js +55 -0
  29. package/dist/Icon/Icon.test.js.map +1 -0
  30. package/dist/Icon/Icon.types.js +16 -0
  31. package/dist/Icon/Icon.types.js.map +1 -0
  32. package/dist/Icon/index.js +2 -0
  33. package/dist/Icon/index.js.map +1 -0
  34. package/dist/Select/Select.js +168 -0
  35. package/dist/Select/Select.js.map +1 -0
  36. package/dist/Select/Select.stories.js +72 -0
  37. package/dist/Select/Select.stories.js.map +1 -0
  38. package/dist/Select/Select.test.js +161 -0
  39. package/dist/Select/Select.test.js.map +1 -0
  40. package/dist/Select/Select.types.js +2 -0
  41. package/dist/Select/Select.types.js.map +1 -0
  42. package/dist/Select/index.js +2 -0
  43. package/dist/Select/index.js.map +1 -0
  44. package/dist/TextArea/TextArea.js +17 -0
  45. package/dist/TextArea/TextArea.js.map +1 -0
  46. package/dist/TextArea/TextArea.stories.js +39 -0
  47. package/dist/TextArea/TextArea.stories.js.map +1 -0
  48. package/dist/TextArea/TextArea.test.js +68 -0
  49. package/dist/TextArea/TextArea.test.js.map +1 -0
  50. package/dist/TextArea/TextArea.types.d.ts +2 -0
  51. package/dist/TextArea/TextArea.types.js +2 -0
  52. package/dist/TextArea/TextArea.types.js.map +1 -0
  53. package/dist/TextArea/index.js +2 -0
  54. package/dist/TextArea/index.js.map +1 -0
  55. package/dist/TextField/TextField.js +58 -0
  56. package/dist/TextField/TextField.js.map +1 -0
  57. package/dist/TextField/TextField.stories.js +41 -0
  58. package/dist/TextField/TextField.stories.js.map +1 -0
  59. package/dist/TextField/TextField.test.js +35 -0
  60. package/dist/TextField/TextField.test.js.map +1 -0
  61. package/dist/TextField/TextField.types.d.ts +2 -0
  62. package/dist/TextField/TextField.types.js +2 -0
  63. package/dist/TextField/TextField.types.js.map +1 -0
  64. package/dist/TextField/index.js +2 -0
  65. package/dist/TextField/index.js.map +1 -0
  66. package/dist/Tooltip/Tooltip.js +30 -0
  67. package/dist/Tooltip/Tooltip.js.map +1 -0
  68. package/dist/Tooltip/Tooltip.stories.js +32 -0
  69. package/dist/Tooltip/Tooltip.stories.js.map +1 -0
  70. package/dist/Tooltip/Tooltip.types.js +3 -0
  71. package/dist/Tooltip/Tooltip.types.js.map +1 -0
  72. package/dist/Tooltip/index.js +2 -0
  73. package/dist/Tooltip/index.js.map +1 -0
  74. package/dist/index.esm.js +21 -17
  75. package/dist/index.esm.js.map +1 -1
  76. package/dist/index.js +21 -17
  77. package/dist/index.js.map +1 -1
  78. package/dist/styles.css +248 -244
  79. package/dist/types.js +2 -0
  80. package/dist/types.js.map +1 -0
  81. package/dist/utils/browserId.js +29 -0
  82. package/dist/utils/browserId.js.map +1 -0
  83. package/package.json +1 -1
@@ -24,4 +24,6 @@ export interface TextAreaProps {
24
24
  testId?: string;
25
25
  /** value of the TextArea */
26
26
  value?: string | string[] | number;
27
+ /** if true error formatting will be displayed */
28
+ showError?: boolean;
27
29
  }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=TextArea.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TextArea.types.js","sourceRoot":"","sources":["../../src/TextArea/TextArea.types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export { TextArea as default } from './TextArea';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/TextArea/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,IAAI,OAAO,EAAE,MAAM,YAAY,CAAC"}
@@ -0,0 +1,58 @@
1
+ import React, { useEffect, useRef, useState } from 'react';
2
+ import '../styles.css';
3
+ const errorClasses = 'tw-border-sq-danger-color';
4
+ const borderColorClasses = ['tw-border-sq-disabled-gray', 'dark:tw-border-sq-dark-disabled-gray'].join(' ');
5
+ const baseClasses = 'tw-h-inputs tw-leading-normal tw-outline-none tw-py-1 tw-px-3' +
6
+ ' disabled:tw-pointer-events-none' +
7
+ ' disabled:tw-cursor-not-allowed tw-p-1 tw-border-solid tw-border tw-placeholder-gray-400' +
8
+ ' dark:tw-placeholder-sq-dark-text-lighter specTextField';
9
+ const darkTheme = 'dark:tw-bg-sq-dark-background dark:tw-text-sq-dark-text' +
10
+ ' dark:focus:tw-border-sq-color-dark-dark dark:active:tw-border-sq-color-dark-dark';
11
+ const lightTheme = 'tw-text-sq-text-color focus:tw-border-sq-color-dark active:tw-border-sq-color-dark';
12
+ const sizeClasses = {
13
+ sm: 'tw-text-sm',
14
+ lg: 'tw-text-xl',
15
+ };
16
+ /**
17
+ * Textfield.
18
+ */
19
+ export const TextField = React.forwardRef((props, ref) => {
20
+ const { readonly = false, onChange, onKeyUp, id, name, size = 'sm', value, placeholder, extraClassNames, testId, type = 'text', inputGroup, step, showError, } = props;
21
+ const internalRef = useRef(null);
22
+ const [cursor, setCursor] = useState(null);
23
+ const setAllRefs = (receivedRef) => {
24
+ if (ref)
25
+ ref.current = receivedRef;
26
+ internalRef.current = receivedRef;
27
+ };
28
+ useEffect(() => {
29
+ const input = internalRef.current;
30
+ if (input && type !== 'number')
31
+ input.setSelectionRange(cursor, cursor);
32
+ }, [ref, cursor, value]);
33
+ const handleChange = (e) => {
34
+ setCursor(e.target.selectionStart);
35
+ onChange && onChange(e);
36
+ };
37
+ useEffect(() => {
38
+ /**
39
+ * we need to change the value only if it's different since the internal state of "input" will change it anyway
40
+ * this will only be the case when the value has been changed externally via store (undo / redo)
41
+ */
42
+ if (value !== null && value !== undefined && value !== internalRef.current?.value && internalRef.current) {
43
+ // we need to use this method because using the value props directly will switch the input to a "controlled"
44
+ // component
45
+ internalRef.current.value = `${value}`;
46
+ }
47
+ }, [value]);
48
+ let borderRadius = 'tw-rounded-sm';
49
+ if (inputGroup === 'left') {
50
+ borderRadius = 'tw-rounded-l-sm tw-border-r-0 focus:tw-border-r' + ' active:tw-border-r';
51
+ }
52
+ else if (inputGroup === 'right') {
53
+ borderRadius = 'tw-rounded-r-sm tw-border-l-0 focus:tw-border-l active:tw-border-l';
54
+ }
55
+ const appliedClasses = `${baseClasses} ${sizeClasses[size]} ${extraClassNames} ${lightTheme} ${darkTheme} ${borderRadius} ${showError ? errorClasses : borderColorClasses} `;
56
+ 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, step: step }));
57
+ });
58
+ //# sourceMappingURL=TextField.js.map
@@ -0,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,EACV,EAAE,EAAE,EAAE,EACN,IAAI,EAAE,IAAI,EACV,KAAK,EAAE,KAAK,EACZ,SAAS,EAAE,cAAc,EACzB,WAAW,EAAE,WAAW,EACxB,QAAQ,EAAE,QAAQ,EAClB,YAAY,EAAC,MAAM,EACnB,QAAQ,EAAE,YAAY,EACtB,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,IAAI,GACV,CACH,CAAC;AACJ,CAAC,CACF,CAAC"}
@@ -0,0 +1,41 @@
1
+ import React from 'react';
2
+ import { TextField } from './TextField';
3
+ export default {
4
+ title: 'TextField',
5
+ };
6
+ export const AllTextFields = () => {
7
+ const renderAllVariations = () => (React.createElement(React.Fragment, null,
8
+ React.createElement("div", { className: "tw-p-4 light" },
9
+ React.createElement("div", { className: "tw-p-4" },
10
+ React.createElement(TextField, { value: "value provided" })),
11
+ React.createElement("div", { className: "tw-p-4" },
12
+ React.createElement(TextField, { placeholder: "placeholder text" })),
13
+ React.createElement("div", { className: "tw-p-4" },
14
+ React.createElement(TextField, { placeholder: "with error", showError: true })),
15
+ React.createElement("div", { className: "tw-p-4" },
16
+ React.createElement(TextField, { value: "read-only", readonly: true })),
17
+ React.createElement("div", { className: "tw-p-4" },
18
+ React.createElement(TextField, { value: "large", size: "lg" }))),
19
+ React.createElement("div", { className: "tw-p-4 tw-dark tw-bg-sq-dark-background" },
20
+ React.createElement("div", { className: "tw-p-4" },
21
+ React.createElement(TextField, { value: "value provided" })),
22
+ React.createElement("div", { className: "tw-p-4" },
23
+ React.createElement(TextField, { placeholder: "placeholder text" })),
24
+ React.createElement("div", { className: "tw-p-4" },
25
+ React.createElement(TextField, { placeholder: "with error", showError: true })),
26
+ React.createElement("div", { className: "tw-p-4" },
27
+ React.createElement(TextField, { value: "read-only", readonly: true })),
28
+ React.createElement("div", { className: "tw-p-4" },
29
+ React.createElement(TextField, { value: "large", size: "lg" })))));
30
+ return (React.createElement("div", { className: "tw-grid tw-grid-cols-3 tw-gap-4" },
31
+ React.createElement("div", { className: "color_topic" },
32
+ React.createElement("b", null, "Topic Colors"),
33
+ renderAllVariations()),
34
+ React.createElement("div", { className: "color_analysis" },
35
+ React.createElement("b", null, "Analysis Colors"),
36
+ renderAllVariations()),
37
+ React.createElement("div", { className: "color_datalab" },
38
+ React.createElement("b", null, "Datalab Colors"),
39
+ renderAllVariations())));
40
+ };
41
+ //# 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;QACE,6BAAK,SAAS,EAAC,cAAc;YAC3B,6BAAK,SAAS,EAAC,QAAQ;gBACrB,oBAAC,SAAS,IAAC,KAAK,EAAC,gBAAgB,GAAG,CAChC;YACN,6BAAK,SAAS,EAAC,QAAQ;gBACrB,oBAAC,SAAS,IAAC,WAAW,EAAC,kBAAkB,GAAG,CACxC;YACN,6BAAK,SAAS,EAAC,QAAQ;gBACrB,oBAAC,SAAS,IAAC,WAAW,EAAC,YAAY,EAAC,SAAS,EAAE,IAAI,GAAI,CACnD;YACN,6BAAK,SAAS,EAAC,QAAQ;gBACrB,oBAAC,SAAS,IAAC,KAAK,EAAC,WAAW,EAAC,QAAQ,EAAE,IAAI,GAAI,CAC3C;YACN,6BAAK,SAAS,EAAC,QAAQ;gBACrB,oBAAC,SAAS,IAAC,KAAK,EAAC,OAAO,EAAC,IAAI,EAAC,IAAI,GAAG,CACjC,CACF;QAEN,6BAAK,SAAS,EAAC,yCAAyC;YACtD,6BAAK,SAAS,EAAC,QAAQ;gBACrB,oBAAC,SAAS,IAAC,KAAK,EAAC,gBAAgB,GAAG,CAChC;YACN,6BAAK,SAAS,EAAC,QAAQ;gBACrB,oBAAC,SAAS,IAAC,WAAW,EAAC,kBAAkB,GAAG,CACxC;YACN,6BAAK,SAAS,EAAC,QAAQ;gBACrB,oBAAC,SAAS,IAAC,WAAW,EAAC,YAAY,EAAC,SAAS,EAAE,IAAI,GAAI,CACnD;YACN,6BAAK,SAAS,EAAC,QAAQ;gBACrB,oBAAC,SAAS,IAAC,KAAK,EAAC,WAAW,EAAC,QAAQ,EAAE,IAAI,GAAI,CAC3C;YACN,6BAAK,SAAS,EAAC,QAAQ;gBACrB,oBAAC,SAAS,IAAC,KAAK,EAAC,OAAO,EAAC,IAAI,EAAC,IAAI,GAAG,CACjC,CACF,CACL,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,CACF,CACP,CAAC;AACJ,CAAC,CAAC"}
@@ -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"}
@@ -14,4 +14,6 @@ export interface TextFieldProps {
14
14
  ref?: any;
15
15
  inputGroup?: InputGroupPlacement;
16
16
  step?: number | string;
17
+ /** if true error formatting will be displayed */
18
+ showError?: boolean;
17
19
  }
@@ -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,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,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,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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-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,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.esm.js CHANGED
@@ -177,11 +177,24 @@ const Button = ({ onClick, label, variant = 'outline', type = 'button', size = '
177
177
  return tooltip ? (React__default.createElement(Tooltip, { text: tooltip, ...tooltipOptions }, button)) : (button);
178
178
  };
179
179
 
180
+ const errorClasses$2 = 'tw-border-sq-danger-color';
181
+ const borderColorClasses$2 = ['tw-border-sq-disabled-gray', 'dark:tw-border-sq-dark-disabled-gray'].join(' ');
182
+ const baseClasses$3 = 'tw-h-inputs tw-leading-normal tw-outline-none tw-py-1 tw-px-3' +
183
+ ' disabled:tw-pointer-events-none' +
184
+ ' disabled:tw-cursor-not-allowed tw-p-1 tw-border-solid tw-border tw-placeholder-gray-400' +
185
+ ' dark:tw-placeholder-sq-dark-text-lighter specTextField';
186
+ const darkTheme$1 = 'dark:tw-bg-sq-dark-background dark:tw-text-sq-dark-text' +
187
+ ' dark:focus:tw-border-sq-color-dark-dark dark:active:tw-border-sq-color-dark-dark';
188
+ const lightTheme$1 = 'tw-text-sq-text-color focus:tw-border-sq-color-dark active:tw-border-sq-color-dark';
189
+ const sizeClasses = {
190
+ sm: 'tw-text-sm',
191
+ lg: 'tw-text-xl',
192
+ };
180
193
  /**
181
194
  * Textfield.
182
195
  */
183
196
  const TextField = React__default.forwardRef((props, ref) => {
184
- const { readonly = false, onChange, onKeyUp, id, name, size = 'sm', value, placeholder, extraClassNames, testId, type = 'text', inputGroup, step, } = props;
197
+ const { readonly = false, onChange, onKeyUp, id, name, size = 'sm', value, placeholder, extraClassNames, testId, type = 'text', inputGroup, step, showError, } = props;
185
198
  const internalRef = useRef(null);
186
199
  const [cursor, setCursor] = useState(null);
187
200
  const setAllRefs = (receivedRef) => {
@@ -209,17 +222,6 @@ const TextField = React__default.forwardRef((props, ref) => {
209
222
  internalRef.current.value = `${value}`;
210
223
  }
211
224
  }, [value]);
212
- const baseClasses = 'tw-h-inputs tw-leading-normal tw-outline-none tw-py-1 tw-px-3' +
213
- ' disabled:tw-pointer-events-none' +
214
- ' disabled:tw-cursor-not-allowed tw-p-1 tw-border-solid tw-border tw-placeholder-gray-400' +
215
- ' dark:tw-placeholder-sq-dark-text-lighter specTextField';
216
- const darkTheme = 'dark:tw-border-sq-dark-disabled-gray dark:tw-bg-sq-dark-background dark:tw-text-sq-dark-text' +
217
- ' dark:focus:tw-border-sq-color-dark-dark dark:active:tw-border-sq-color-dark-dark';
218
- const lightTheme = 'tw-border-sq-disabled-gray tw-text-sq-text-color focus:tw-border-sq-color-dark active:tw-border-sq-color-dark';
219
- const sizeClasses = {
220
- sm: 'tw-text-sm',
221
- lg: 'tw-text-xl',
222
- };
223
225
  let borderRadius = 'tw-rounded-sm';
224
226
  if (inputGroup === 'left') {
225
227
  borderRadius = 'tw-rounded-l-sm tw-border-r-0 focus:tw-border-r' + ' active:tw-border-r';
@@ -227,7 +229,7 @@ const TextField = React__default.forwardRef((props, ref) => {
227
229
  else if (inputGroup === 'right') {
228
230
  borderRadius = 'tw-rounded-r-sm tw-border-l-0 focus:tw-border-l active:tw-border-l';
229
231
  }
230
- const appliedClasses = `${baseClasses} ${sizeClasses[size]} ${extraClassNames} ${lightTheme} ${darkTheme} ${borderRadius}`;
232
+ const appliedClasses = `${baseClasses$3} ${sizeClasses[size]} ${extraClassNames} ${lightTheme$1} ${darkTheme$1} ${borderRadius} ${showError ? errorClasses$2 : borderColorClasses$2} `;
231
233
  return (React__default.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, step: step }));
232
234
  });
233
235
 
@@ -254,14 +256,16 @@ const Checkbox = (props) => {
254
256
 
255
257
  const baseClasses$1 = 'tw-leading-normal tw-outline-none tw-py-1 tw-px-3 tw-rounded-sm' +
256
258
  ' disabled:tw-cursor-not-allowed tw-p-1 tw-border-solid tw-border tw-text-sm';
257
- const darkTheme = 'dark:tw-border-sq-dark-disabled-gray dark:tw-bg-sq-dark-background dark:tw-text-sq-dark-text' +
259
+ const darkTheme = 'dark:tw-bg-sq-dark-background dark:tw-text-sq-dark-text' +
258
260
  ' dark:focus:tw-border-sq-color-dark-dark dark:active:tw-border-sq-color-dark-dark dark:tw-placeholder-sq-dark-text-lighter';
259
- const lightTheme = 'tw-border-sq-disabled-gray tw-text-sq-text-color focus:tw-border-sq-color-dark active:tw-border-sq-color-dark tw-placeholder-gray-400';
261
+ const lightTheme = 'tw-text-sq-text-color focus:tw-border-sq-color-dark active:tw-border-sq-color-dark tw-placeholder-gray-400';
262
+ const errorClasses$1 = 'tw-border-sq-danger-color';
263
+ const borderColorClasses$1 = ['tw-border-sq-disabled-gray', 'dark:tw-border-sq-dark-disabled-gray'].join(' ');
260
264
  /**
261
265
  * TextArea.
262
266
  */
263
- const TextArea = ({ readonly = false, onChange, onKeyUp, id, name, rows = 3, cols = undefined, value, placeholder, extraClassNames, testId, autofocus = false, }) => {
264
- const appliedClasses = `${baseClasses$1} ${extraClassNames} ${lightTheme} ${darkTheme}`;
267
+ const TextArea = ({ readonly = false, onChange, onKeyUp, id, name, rows = 3, cols = undefined, value, placeholder, extraClassNames, testId, autofocus = false, showError, }) => {
268
+ const appliedClasses = `${baseClasses$1} ${extraClassNames} ${lightTheme} ${darkTheme} ${showError ? errorClasses$1 : borderColorClasses$1}`;
265
269
  return (React__default.createElement("textarea", { "data-testid": testId, name: name, id: id, value: value, className: appliedClasses, placeholder: placeholder, disabled: readonly, onChange: onChange, onKeyUp: onKeyUp, rows: rows, cols: cols, autoFocus: autofocus }));
266
270
  };
267
271