@seeqdev/qomponents 0.0.94 → 0.0.95
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/Accordion/Accordion.js +9 -0
- package/dist/Accordion/Accordion.js.map +1 -0
- package/dist/Accordion/Accordion.stories.js +115 -0
- package/dist/Accordion/Accordion.stories.js.map +1 -0
- package/dist/Accordion/Accordion.test.js +55 -0
- package/dist/Accordion/Accordion.test.js.map +1 -0
- package/dist/Accordion/Accordion.types.js +2 -0
- package/dist/Accordion/Accordion.types.js.map +1 -0
- package/dist/Accordion/index.js +2 -0
- package/dist/Accordion/index.js.map +1 -0
- package/dist/Button/Button.js +90 -0
- package/dist/Button/Button.js.map +1 -0
- package/dist/Button/Button.stories.js +98 -0
- package/dist/Button/Button.stories.js.map +1 -0
- package/dist/Button/Button.test.js +49 -0
- package/dist/Button/Button.test.js.map +1 -0
- package/dist/Button/Button.types.js +5 -0
- package/dist/Button/Button.types.js.map +1 -0
- package/dist/Button/index.js +2 -0
- package/dist/Button/index.js.map +1 -0
- package/dist/ButtonWithDropdown/ButtonWithDropdown.js +66 -0
- package/dist/ButtonWithDropdown/ButtonWithDropdown.js.map +1 -0
- package/dist/ButtonWithDropdown/ButtonWithDropdown.stories.js +96 -0
- package/dist/ButtonWithDropdown/ButtonWithDropdown.stories.js.map +1 -0
- package/dist/ButtonWithDropdown/ButtonWithDropdown.test.js +72 -0
- package/dist/ButtonWithDropdown/ButtonWithDropdown.test.js.map +1 -0
- package/dist/ButtonWithDropdown/ButtonWithDropdown.types.js +2 -0
- package/dist/ButtonWithDropdown/ButtonWithDropdown.types.js.map +1 -0
- package/dist/ButtonWithDropdown/index.js +2 -0
- package/dist/ButtonWithDropdown/index.js.map +1 -0
- package/dist/ButtonWithPopover/ButtonWithPopover.js +53 -0
- package/dist/ButtonWithPopover/ButtonWithPopover.js.map +1 -0
- package/dist/ButtonWithPopover/ButtonWithPopover.stories.js +75 -0
- package/dist/ButtonWithPopover/ButtonWithPopover.stories.js.map +1 -0
- package/dist/ButtonWithPopover/ButtonWithPopover.test.js +82 -0
- package/dist/ButtonWithPopover/ButtonWithPopover.test.js.map +1 -0
- package/dist/ButtonWithPopover/ButtonWithPopover.types.js +2 -0
- package/dist/ButtonWithPopover/ButtonWithPopover.types.js.map +1 -0
- package/dist/ButtonWithPopover/index.js +2 -0
- package/dist/ButtonWithPopover/index.js.map +1 -0
- package/dist/Checkbox/Checkbox.js +26 -0
- package/dist/Checkbox/Checkbox.js.map +1 -0
- package/dist/Checkbox/Checkbox.stories.js +34 -0
- package/dist/Checkbox/Checkbox.stories.js.map +1 -0
- package/dist/Checkbox/Checkbox.test.js +94 -0
- package/dist/Checkbox/Checkbox.test.js.map +1 -0
- package/dist/Checkbox/Checkbox.types.js +2 -0
- package/dist/Checkbox/Checkbox.types.js.map +1 -0
- package/dist/Checkbox/index.js +2 -0
- package/dist/Checkbox/index.js.map +1 -0
- package/dist/Icon/Icon.js +55 -0
- package/dist/Icon/Icon.js.map +1 -0
- package/dist/Icon/Icon.stories.js +45 -0
- package/dist/Icon/Icon.stories.js.map +1 -0
- package/dist/Icon/Icon.test.js +55 -0
- package/dist/Icon/Icon.test.js.map +1 -0
- package/dist/Icon/Icon.types.js +16 -0
- package/dist/Icon/Icon.types.js.map +1 -0
- package/dist/Icon/index.js +2 -0
- package/dist/Icon/index.js.map +1 -0
- package/dist/Modal/Modal.js +100 -0
- package/dist/Modal/Modal.js.map +1 -0
- package/dist/Modal/Modal.stories.js +127 -0
- package/dist/Modal/Modal.stories.js.map +1 -0
- package/dist/Modal/Modal.test.js +108 -0
- package/dist/Modal/Modal.test.js.map +1 -0
- package/dist/Modal/Modal.types.js +2 -0
- package/dist/Modal/Modal.types.js.map +1 -0
- package/dist/Modal/index.js +2 -0
- package/dist/Modal/index.js.map +1 -0
- package/dist/Select/Select.js +174 -0
- package/dist/Select/Select.js.map +1 -0
- package/dist/Select/Select.stories.js +80 -0
- package/dist/Select/Select.stories.js.map +1 -0
- package/dist/Select/Select.test.js +182 -0
- package/dist/Select/Select.test.js.map +1 -0
- package/dist/Select/Select.types.js +2 -0
- package/dist/Select/Select.types.js.map +1 -0
- package/dist/Select/index.js +3 -0
- package/dist/Select/index.js.map +1 -0
- package/dist/Tabs/Tabs.js +22 -0
- package/dist/Tabs/Tabs.js.map +1 -0
- package/dist/Tabs/Tabs.stories.js +91 -0
- package/dist/Tabs/Tabs.stories.js.map +1 -0
- package/dist/Tabs/Tabs.test.js +91 -0
- package/dist/Tabs/Tabs.test.js.map +1 -0
- package/dist/Tabs/Tabs.types.js +2 -0
- package/dist/Tabs/Tabs.types.js.map +1 -0
- package/dist/Tabs/index.js +2 -0
- package/dist/Tabs/index.js.map +1 -0
- package/dist/TextArea/TextArea.js +25 -0
- package/dist/TextArea/TextArea.js.map +1 -0
- package/dist/TextArea/TextArea.stories.js +42 -0
- package/dist/TextArea/TextArea.stories.js.map +1 -0
- package/dist/TextArea/TextArea.test.js +68 -0
- package/dist/TextArea/TextArea.test.js.map +1 -0
- package/dist/TextArea/TextArea.types.d.ts +4 -1
- package/dist/TextArea/TextArea.types.js +2 -0
- package/dist/TextArea/TextArea.types.js.map +1 -0
- package/dist/TextArea/index.js +2 -0
- package/dist/TextArea/index.js.map +1 -0
- package/dist/TextField/TextField.d.ts +2 -2
- package/dist/TextField/TextField.js +77 -0
- package/dist/TextField/TextField.js.map +1 -0
- package/dist/TextField/TextField.stories.js +48 -0
- package/dist/TextField/TextField.stories.js.map +1 -0
- package/dist/TextField/TextField.test.js +39 -0
- package/dist/TextField/TextField.test.js.map +1 -0
- package/dist/TextField/TextField.types.d.ts +5 -1
- package/dist/TextField/TextField.types.js +2 -0
- package/dist/TextField/TextField.types.js.map +1 -0
- package/dist/TextField/index.js +2 -0
- package/dist/TextField/index.js.map +1 -0
- package/dist/ToolbarButton/ToolbarButton.js +75 -0
- package/dist/ToolbarButton/ToolbarButton.js.map +1 -0
- package/dist/ToolbarButton/ToolbarButton.stories.js +94 -0
- package/dist/ToolbarButton/ToolbarButton.stories.js.map +1 -0
- package/dist/ToolbarButton/ToolbarButton.test.js +93 -0
- package/dist/ToolbarButton/ToolbarButton.test.js.map +1 -0
- package/dist/ToolbarButton/ToolbarButton.types.js +2 -0
- package/dist/ToolbarButton/ToolbarButton.types.js.map +1 -0
- package/dist/ToolbarButton/index.js +2 -0
- package/dist/ToolbarButton/index.js.map +1 -0
- package/dist/Tooltip/QTip.stories.js +45 -0
- package/dist/Tooltip/QTip.stories.js.map +1 -0
- package/dist/Tooltip/QTip.types.js +2 -0
- package/dist/Tooltip/QTip.types.js.map +1 -0
- package/dist/Tooltip/QTipPerformance.stories.js +30 -0
- package/dist/Tooltip/QTipPerformance.stories.js.map +1 -0
- package/dist/Tooltip/Qtip.js +155 -0
- package/dist/Tooltip/Qtip.js.map +1 -0
- package/dist/Tooltip/Tooltip.js +36 -0
- package/dist/Tooltip/Tooltip.js.map +1 -0
- package/dist/Tooltip/Tooltip.stories.js +32 -0
- package/dist/Tooltip/Tooltip.stories.js.map +1 -0
- package/dist/Tooltip/Tooltip.types.js +3 -0
- package/dist/Tooltip/Tooltip.types.js.map +1 -0
- package/dist/Tooltip/TooltipPerformance.stories.js +30 -0
- package/dist/Tooltip/TooltipPerformance.stories.js.map +1 -0
- package/dist/Tooltip/index.js +3 -0
- package/dist/Tooltip/index.js.map +1 -0
- package/dist/Tooltip/qTip.utilities.js +11 -0
- package/dist/Tooltip/qTip.utilities.js.map +1 -0
- package/dist/index.esm.js +18 -11
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +18 -11
- package/dist/index.js.map +1 -1
- package/dist/styles.css +20 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/browserId.js +29 -0
- package/dist/utils/browserId.js.map +1 -0
- package/dist/utils/svg.js +20 -0
- package/dist/utils/svg.js.map +1 -0
- package/dist/utils/validateStyleDimension.js +14 -0
- package/dist/utils/validateStyleDimension.js.map +1 -0
- package/dist/utils/validateStyleDimension.test.js +20 -0
- package/dist/utils/validateStyleDimension.test.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import DOMPurify from 'dompurify';
|
|
2
|
+
import React, { useEffect, useRef, useState } from 'react';
|
|
3
|
+
import { arrow, computePosition, offset } from '@floating-ui/dom';
|
|
4
|
+
import { useIntervalWhen } from 'rooks';
|
|
5
|
+
import { DEFAULT_TOOL_TIP_DELAY } from './Tooltip.types';
|
|
6
|
+
const getArrowStyle = (position, x, arrowWidth, tooltipHeight, tooltipWidth) => {
|
|
7
|
+
switch (position) {
|
|
8
|
+
case 'bottom':
|
|
9
|
+
return {
|
|
10
|
+
left: `${x}px`,
|
|
11
|
+
top: `${-arrowWidth}px`,
|
|
12
|
+
};
|
|
13
|
+
case 'left':
|
|
14
|
+
return {
|
|
15
|
+
left: `${tooltipWidth - arrowWidth}px`,
|
|
16
|
+
top: `${tooltipHeight / 2 - arrowWidth}px`,
|
|
17
|
+
};
|
|
18
|
+
case 'right':
|
|
19
|
+
return {
|
|
20
|
+
left: `${-arrowWidth}px`,
|
|
21
|
+
top: `${tooltipHeight / 2 - arrowWidth}px`,
|
|
22
|
+
};
|
|
23
|
+
default: // 'top':
|
|
24
|
+
return {
|
|
25
|
+
left: `${x}px`,
|
|
26
|
+
top: `${tooltipHeight - 10 + arrowWidth}px`,
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
const HTMLTip = ({ text }) => {
|
|
31
|
+
return React.createElement('div', {
|
|
32
|
+
dangerouslySetInnerHTML: { __html: DOMPurify.sanitize(text) },
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
|
+
/** Tooltips can cause SystemTests to be flaky, so we suppress them in Playwright and Protractor */
|
|
36
|
+
const suppressTooltip = () => {
|
|
37
|
+
return window.navigator.userAgent === 'Playwright' || window.navigator.userAgent.includes('Protractor');
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* QTip
|
|
41
|
+
*
|
|
42
|
+
* QTip is a Singleton Tooltip component that guarantees high-performance and reduces component wrappers!
|
|
43
|
+
*
|
|
44
|
+
* QTip is used by all qomponents that support the display of tooltips.
|
|
45
|
+
* If you want to add a Tooltip to your application you can do so by adding the following html data-attributes:
|
|
46
|
+
*
|
|
47
|
+
* 'data-qtip-text': the tooltip text to display; this can also be a string containing valid HTML
|
|
48
|
+
* 'data-qtip-placement': one of TooltipPosition (top, bottom, right, or left)
|
|
49
|
+
* 'data-qtip-is-html': set this to true if you provided a text that contains HTML,
|
|
50
|
+
* 'data-qtip-delay': this can be used to delay the showing of the tooltip. this should be a number representing
|
|
51
|
+
* the # of milliseconds you want to delay the tooltip for. If no delay is provided the DEFAULT_TOOL_TIP_DELAY is
|
|
52
|
+
* applied!
|
|
53
|
+
* 'data-qtip-testid': use this attribute to provide a value for a data-testid of your tooltip; this is useful
|
|
54
|
+
* for tests
|
|
55
|
+
*
|
|
56
|
+
* In order for QTip to be able to display Tooltips you must add the QTip component to your top-most component
|
|
57
|
+
* (often that's App or Application) - simply add:
|
|
58
|
+
*
|
|
59
|
+
* <QTip />
|
|
60
|
+
*
|
|
61
|
+
* and enjoy beautiful & performant tooltips!
|
|
62
|
+
*/
|
|
63
|
+
export const QTip = () => {
|
|
64
|
+
const tooltipRef = useRef(null);
|
|
65
|
+
const tooltipTarget = useRef(null);
|
|
66
|
+
const tooltipArrowRef = useRef(null);
|
|
67
|
+
const [tooltipText, setTooltipText] = useState('');
|
|
68
|
+
const [tooltipTargetOriginalPosition, setTooltipTargetOriginalPosition] = useState(null);
|
|
69
|
+
const [show, setShow] = useState(false);
|
|
70
|
+
const [html, setHtml] = useState(false);
|
|
71
|
+
const [tooltipTestId, setTooltipTestId] = useState('');
|
|
72
|
+
const [overTooltip, setOverTooltip] = useState(false);
|
|
73
|
+
// Check every 300ms if the tooltip target position has changed and hide the tooltip if this happens.
|
|
74
|
+
useIntervalWhen(() => {
|
|
75
|
+
const currentPosition = tooltipTarget?.current?.getBoundingClientRect();
|
|
76
|
+
if (overTooltip) {
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
if (tooltipTargetOriginalPosition?.y !== currentPosition?.y ||
|
|
80
|
+
tooltipTargetOriginalPosition?.x !== currentPosition?.x) {
|
|
81
|
+
setShow(false);
|
|
82
|
+
}
|
|
83
|
+
}, 300, show);
|
|
84
|
+
useEffect(() => {
|
|
85
|
+
!suppressTooltip() && document.body.addEventListener('mousemove', onMouseMove);
|
|
86
|
+
return () => {
|
|
87
|
+
!suppressTooltip() && document.removeEventListener('mousemove', onMouseMove);
|
|
88
|
+
};
|
|
89
|
+
}, []);
|
|
90
|
+
const ttTimeout = useRef();
|
|
91
|
+
const onMouseMove = (e) => {
|
|
92
|
+
clearTimeout(ttTimeout.current);
|
|
93
|
+
tooltipTarget.current = e.target;
|
|
94
|
+
let dataset = e.target?.dataset;
|
|
95
|
+
let text = dataset?.qtipText;
|
|
96
|
+
// Buttons support React.Nodes as children, the tooltip however is applied to the actual button component.
|
|
97
|
+
// we only check two levels up - alternatively the tooltip can also be provided on the React.Node
|
|
98
|
+
if (!text || text === '') {
|
|
99
|
+
let currentTooltipTarget = e.target?.parentElement;
|
|
100
|
+
dataset = currentTooltipTarget?.dataset;
|
|
101
|
+
text = dataset?.qtipText;
|
|
102
|
+
if (!text || text === '') {
|
|
103
|
+
currentTooltipTarget = e.target?.parentElement?.parentElement || null;
|
|
104
|
+
dataset = currentTooltipTarget?.dataset;
|
|
105
|
+
text = dataset?.qtipText;
|
|
106
|
+
}
|
|
107
|
+
tooltipTarget.current = currentTooltipTarget;
|
|
108
|
+
}
|
|
109
|
+
if (text) {
|
|
110
|
+
const delay = parseInt(dataset?.qtipDelay ?? DEFAULT_TOOL_TIP_DELAY + '');
|
|
111
|
+
ttTimeout.current = setTimeout(() => makeTooltip(text, dataset?.qtipPlacement, dataset?.qtipIsHtml === 'true', dataset?.qtipTestid, delay), delay);
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
const makeTooltip = (tooltipText, position = 'top', isHtml, dataTestId, delay) => {
|
|
115
|
+
if (tooltipText && tooltipTarget.current) {
|
|
116
|
+
setHtml(isHtml);
|
|
117
|
+
setTooltipText(tooltipText);
|
|
118
|
+
setTooltipTestId(dataTestId);
|
|
119
|
+
setTooltipTargetOriginalPosition(tooltipTarget.current.getBoundingClientRect());
|
|
120
|
+
const positionTooltip = () => {
|
|
121
|
+
if (tooltipRef.current && tooltipTarget.current) {
|
|
122
|
+
computePosition(tooltipTarget.current, tooltipRef.current, {
|
|
123
|
+
placement: position,
|
|
124
|
+
middleware: [offset(10), arrow({ element: tooltipArrowRef.current })],
|
|
125
|
+
}).then(({ x, y, middlewareData }) => {
|
|
126
|
+
Object.assign(tooltipRef.current?.style, {
|
|
127
|
+
left: `${x}px`,
|
|
128
|
+
top: `${y}px`,
|
|
129
|
+
});
|
|
130
|
+
if (middlewareData.arrow) {
|
|
131
|
+
const { x, y } = middlewareData.arrow;
|
|
132
|
+
const arrowWidth = tooltipArrowRef.current?.offsetHeight / 2;
|
|
133
|
+
const tooltipHeight = tooltipRef.current?.offsetHeight;
|
|
134
|
+
const tooltipWidth = tooltipRef.current?.offsetWidth;
|
|
135
|
+
const style = getArrowStyle(position, x || y, arrowWidth, tooltipHeight, tooltipWidth);
|
|
136
|
+
Object.assign(tooltipArrowRef.current.style, style);
|
|
137
|
+
}
|
|
138
|
+
setShow(true);
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
delay > 0
|
|
143
|
+
? requestAnimationFrame(() => {
|
|
144
|
+
positionTooltip();
|
|
145
|
+
})
|
|
146
|
+
: positionTooltip();
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
return (React.createElement(React.Fragment, null,
|
|
150
|
+
React.createElement("div", { onMouseEnter: () => setOverTooltip(true), onMouseLeave: () => setOverTooltip(false), "data-testid": tooltipTestId, ref: tooltipRef, className: 'tw-absolute tw-rounded tw-bg-black tw-p-2 tw-text-xs tw-text-white tw-z-[9999] fade-in ' +
|
|
151
|
+
(show ? 'tw-visible' : 'tw-invisible tw-pointer-events-none') },
|
|
152
|
+
html ? React.createElement(HTMLTip, { text: tooltipText }) : tooltipText,
|
|
153
|
+
React.createElement("div", { className: "tw-absolute tw-w-[10px] tw-h-[10px] tw-rotate-45 tw-bg-black", ref: tooltipArrowRef }))));
|
|
154
|
+
};
|
|
155
|
+
//# sourceMappingURL=Qtip.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Qtip.js","sourceRoot":"","sources":["../../src/Tooltip/Qtip.tsx"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,WAAW,CAAC;AAClC,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC3D,OAAO,EAAE,KAAK,EAAE,eAAe,EAAE,MAAM,EAAa,MAAM,kBAAkB,CAAC;AAC7E,OAAO,EAAE,eAAe,EAAE,MAAM,OAAO,CAAC;AACxC,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAEzD,MAAM,aAAa,GAAG,CACpB,QAAgB,EAChB,CAAqB,EACrB,UAAkB,EAClB,aAAqB,EACrB,YAAoB,EACpB,EAAE;IACF,QAAQ,QAAQ,EAAE;QAChB,KAAK,QAAQ;YACX,OAAO;gBACL,IAAI,EAAE,GAAG,CAAC,IAAI;gBACd,GAAG,EAAE,GAAG,CAAC,UAAU,IAAI;aACxB,CAAC;QAEJ,KAAK,MAAM;YACT,OAAO;gBACL,IAAI,EAAE,GAAG,YAAY,GAAG,UAAU,IAAI;gBACtC,GAAG,EAAE,GAAG,aAAa,GAAG,CAAC,GAAG,UAAU,IAAI;aAC3C,CAAC;QACJ,KAAK,OAAO;YACV,OAAO;gBACL,IAAI,EAAE,GAAG,CAAC,UAAU,IAAI;gBACxB,GAAG,EAAE,GAAG,aAAa,GAAG,CAAC,GAAG,UAAU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CAAC,EACxC,YAAY,EAAE,GAAG,EAAE,CAAC,cAAc,CAAC,KAAK,CAAC,iBAC5B,aAAa,EAC1B,GAAG,EAAE,UAAU,EACf,SAAS,EACP,yFAAyF;gBACzF,CAAC,IAAI,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,qCAAqC,CAAC;YAE9D,IAAI,CAAC,CAAC,CAAC,oBAAC,OAAO,IAAC,IAAI,EAAE,WAAW,GAAI,CAAC,CAAC,CAAC,WAAW;YACpD,6BAAK,SAAS,EAAC,8DAA8D,EAAC,GAAG,EAAE,eAAe,GAAQ,CACtG,CACL,CACJ,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import '../styles.css';
|
|
3
|
+
import { DEFAULT_TOOL_TIP_DELAY } from './Tooltip.types';
|
|
4
|
+
/**
|
|
5
|
+
* @deprecated
|
|
6
|
+
* Note: Tooltip has been replaced by QTip - a singleton JS tooltip that behaves well even with overflow settings :)
|
|
7
|
+
* See @QTip for more info!
|
|
8
|
+
*
|
|
9
|
+
* This component displays a Tooltip for the provided children. It is a CSS only tooltip that will not display
|
|
10
|
+
* correctly if a parent element has an overflow CSS property assigned. Please use QTip to ensure your tooltips
|
|
11
|
+
* display correctly.
|
|
12
|
+
*/
|
|
13
|
+
export const Tooltip = ({ position = 'bottom', children, text, delay = DEFAULT_TOOL_TIP_DELAY, }) => {
|
|
14
|
+
const arrowBaseClasses = 'before:tw-content-[\'\'] before:tw-absolute before:tw-border-8';
|
|
15
|
+
const centerArrowVertically = 'before:tw-top-1/2 before:-tw-translate-y-1/2';
|
|
16
|
+
const centerArrowHorizontally = 'before:tw-left-1/2 before:-tw-translate-x-1/2';
|
|
17
|
+
const arrowRight = `${arrowBaseClasses} ${centerArrowVertically} before:tw-right-[100%] before:tw-border-y-transparent
|
|
18
|
+
before:tw-border-l-transparent before:tw-border-r-black`;
|
|
19
|
+
const arrowLeft = `${arrowBaseClasses} ${centerArrowVertically} before:tw-left-[100%] before:tw-border-y-transparent
|
|
20
|
+
before:tw-border-l-black before:tw-border-r-transparent`;
|
|
21
|
+
const arrowBottom = `${arrowBaseClasses} ${centerArrowHorizontally} before:-tw-top-4 before:tw-border-b-black
|
|
22
|
+
before:tw-border-r-transparent before:tw-border-l-transparent before:tw-border-t-transparent`;
|
|
23
|
+
const arrowTop = `${arrowBaseClasses} ${centerArrowHorizontally} before:-tw-bottom-4 before:tw-border-b-transparent
|
|
24
|
+
before:tw-border-t-black before:tw-border-l-transparent before:tw-border-r-transparent`;
|
|
25
|
+
const placements = {
|
|
26
|
+
top: `-tw-top-2 -tw-translate-y-full tw-left-1/2 -tw-translate-x-1/2 ${arrowTop}`,
|
|
27
|
+
left: `-tw-translate-x-full -tw-left-3 -tw-translate-y-1/2 tw-top-1/2 ${arrowLeft}`,
|
|
28
|
+
right: `tw-translate-x-full -tw-right-3 -tw-translate-y-1/2 tw-top-1/2 ${arrowRight}`,
|
|
29
|
+
bottom: `-tw-bottom-2 tw-translate-y-full tw-left-1/2 -tw-translate-x-1/2 ${arrowBottom}`,
|
|
30
|
+
};
|
|
31
|
+
return (React.createElement("div", { className: "tw-group tw-relative tw-inline-block" },
|
|
32
|
+
children,
|
|
33
|
+
React.createElement("div", { className: `tw-z-50 tw-whitespace-nowrap tw-hidden group-hover:tw-inline-block group-hover:tw-delay-[${delay}ms]
|
|
34
|
+
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)));
|
|
35
|
+
};
|
|
36
|
+
//# 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;;;;;;;;GAQG;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,gEAAgE,CAAC;IAC1F,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;AAC/B,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAEnD,eAAe;IACb,KA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/Tooltip/Tooltip.types.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,sBAAsB,GAAG,GAAG,CAAC;AAC1C,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,CAAU,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Tooltip } from './Tooltip';
|
|
3
|
+
import Icon from '../Icon';
|
|
4
|
+
export default {
|
|
5
|
+
title: 'Tooltip',
|
|
6
|
+
};
|
|
7
|
+
const renderManyTooltips = () => {
|
|
8
|
+
const colsCount = 100;
|
|
9
|
+
const rowCount = 100;
|
|
10
|
+
const rows = [];
|
|
11
|
+
const getCols = (rowId) => {
|
|
12
|
+
const cols = [];
|
|
13
|
+
for (let i = 0; i < colsCount; i++) {
|
|
14
|
+
cols.push(React.createElement("td", { key: 'col_' + i + '_row_' + rowId },
|
|
15
|
+
React.createElement(Tooltip, { text: `hello there ${i}` },
|
|
16
|
+
React.createElement(Icon, { icon: "fc-sun" }))));
|
|
17
|
+
}
|
|
18
|
+
return cols;
|
|
19
|
+
};
|
|
20
|
+
for (let i = 0; i < rowCount; i++) {
|
|
21
|
+
rows.push(React.createElement("tr", { key: 'row_' + i }, ...getCols(i)));
|
|
22
|
+
}
|
|
23
|
+
return (React.createElement("table", null,
|
|
24
|
+
React.createElement("tbody", null, rows.map((row) => row))));
|
|
25
|
+
};
|
|
26
|
+
export const TooltipPerformance = () => {
|
|
27
|
+
return (React.createElement(React.Fragment, null,
|
|
28
|
+
React.createElement("div", { className: "tw-grid tw-grid-cols-4 tw-gap-4 tw-text-center" }, renderManyTooltips())));
|
|
29
|
+
};
|
|
30
|
+
//# sourceMappingURL=TooltipPerformance.stories.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TooltipPerformance.stories.js","sourceRoot":"","sources":["../../src/Tooltip/TooltipPerformance.stories.tsx"],"names":[],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C3F,CACJ,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/Tooltip/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { DEFAULT_TOOL_TIP_DELAY } from './Tooltip.types';
|
|
2
|
+
export const getQTipData = ({ tooltip, tooltipPlacement, isHtmlTooltip, tooltipTestId, tooltipDelay = DEFAULT_TOOL_TIP_DELAY, }) => tooltip
|
|
3
|
+
? {
|
|
4
|
+
'data-qtip-text': tooltip,
|
|
5
|
+
'data-qtip-placement': tooltipPlacement,
|
|
6
|
+
'data-qtip-is-html': isHtmlTooltip,
|
|
7
|
+
'data-qtip-testid': tooltipTestId,
|
|
8
|
+
'data-qtip-delay': tooltipDelay,
|
|
9
|
+
}
|
|
10
|
+
: undefined;
|
|
11
|
+
//# sourceMappingURL=qTip.utilities.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"qTip.utilities.js","sourceRoot":"","sources":["../../src/Tooltip/qTip.utilities.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAAyB,MAAM,iBAAiB,CAAC;AAEhF,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,EAC1B,OAAO,EACP,gBAAgB,EAChB,aAAa,EACb,aAAa,EACb,YAAY,GAAG,sBAAsB,GACf,EAAkC,EAAE,CAC1D,OAAO;IACL,CAAC,CAAC;QACE,gBAAgB,EAAE,OAAO;QACzB,qBAAqB,EAAE,gBAAgB;QACvC,mBAAmB,EAAE,aAAa;QAClC,kBAAkB,EAAE,aAAa;QACjC,iBAAiB,EAAE,YAAY;KAChC;IACH,CAAC,CAAC,SAAS,CAAC"}
|
package/dist/index.esm.js
CHANGED
|
@@ -4675,11 +4675,11 @@ const borderColorClasses$2 = [
|
|
|
4675
4675
|
'active:tw-border-sq-color-dark',
|
|
4676
4676
|
].join(' ');
|
|
4677
4677
|
const baseClasses$3 = 'tw-h-inputs tw-leading-normal tw-outline-none tw-py-1 tw-px-3' +
|
|
4678
|
-
' disabled:tw-pointer-events-none' +
|
|
4678
|
+
' disabled:tw-pointer-events-none disabled:tw-bg-sq-light-gray disabled:dark:tw-bg-sq-dark-disabled-gray' +
|
|
4679
4679
|
' disabled:tw-cursor-not-allowed tw-p-1 tw-border-solid tw-border tw-placeholder-gray-400' +
|
|
4680
4680
|
' dark:tw-placeholder-sq-dark-text-lighter specTextField';
|
|
4681
|
-
const darkTheme$1 = 'dark:tw-bg-sq-dark-background dark:tw-text-sq-dark-text';
|
|
4682
|
-
const lightTheme$1 = 'tw-text-sq-text-color';
|
|
4681
|
+
const darkTheme$1 = 'dark:tw-bg-sq-dark-background dark:tw-text-sq-dark-text disabled:dark:tw-text-sq-dark-text-lighter';
|
|
4682
|
+
const lightTheme$1 = 'tw-text-sq-text-color disabled:tw-text-sq-darkish-gray';
|
|
4683
4683
|
const sizeClasses = {
|
|
4684
4684
|
sm: 'tw-text-sm',
|
|
4685
4685
|
lg: 'tw-text-xl',
|
|
@@ -4688,7 +4688,7 @@ const sizeClasses = {
|
|
|
4688
4688
|
* Textfield.
|
|
4689
4689
|
*/
|
|
4690
4690
|
const TextField = React__default.forwardRef((props, ref) => {
|
|
4691
|
-
const { readonly = false, onChange, onKeyUp, onFocus, onBlur, onKeyDown, id, name, size = 'sm', value, placeholder, extraClassNames, testId, type = 'text', inputGroup, step, showError, errorText, required = false, autoComplete = 'off', inputWidth = undefined, inputHeight = undefined, } = props;
|
|
4691
|
+
const { readonly = false, onChange, onKeyUp, onFocus, onBlur, onKeyDown, id, name, size = 'sm', value, placeholder, extraClassNames, testId, type = 'text', inputGroup, step, showError, errorText, maxLength, minLength, required = false, autoComplete = 'off', inputWidth = undefined, inputHeight = undefined, autoFocus = false, } = props;
|
|
4692
4692
|
const internalRef = useRef(null);
|
|
4693
4693
|
const [cursor, setCursor] = useState(null);
|
|
4694
4694
|
const setAllRefs = (receivedRef) => {
|
|
@@ -4698,7 +4698,7 @@ const TextField = React__default.forwardRef((props, ref) => {
|
|
|
4698
4698
|
};
|
|
4699
4699
|
useEffect(() => {
|
|
4700
4700
|
const input = internalRef.current;
|
|
4701
|
-
if (input && type !== 'number')
|
|
4701
|
+
if (input && type !== 'number' && type !== 'email')
|
|
4702
4702
|
input.setSelectionRange(cursor, cursor);
|
|
4703
4703
|
}, [ref, cursor, value]);
|
|
4704
4704
|
const handleChange = (e) => {
|
|
@@ -4724,13 +4724,18 @@ const TextField = React__default.forwardRef((props, ref) => {
|
|
|
4724
4724
|
borderRadius = 'tw-rounded-r-sm tw-border-l-0 focus:tw-border-l active:tw-border-l';
|
|
4725
4725
|
}
|
|
4726
4726
|
const appliedClasses = `${baseClasses$3} ${sizeClasses[size]} ${extraClassNames} ${lightTheme$1} ${darkTheme$1} ${borderRadius} ${showError ? errorClasses$2 : borderColorClasses$2} `;
|
|
4727
|
-
const
|
|
4727
|
+
const inputProp = setValidInputDimension(inputWidth, inputHeight)
|
|
4728
4728
|
? {
|
|
4729
4729
|
style: setValidInputDimension(inputWidth, inputHeight),
|
|
4730
4730
|
}
|
|
4731
4731
|
: {};
|
|
4732
|
+
const inputLenghtProp = {};
|
|
4733
|
+
if (maxLength)
|
|
4734
|
+
inputLenghtProp.maxLength = maxLength;
|
|
4735
|
+
if (minLength)
|
|
4736
|
+
inputLenghtProp.minLength = minLength;
|
|
4732
4737
|
return (React__default.createElement(React__default.Fragment, null,
|
|
4733
|
-
React__default.createElement("input", { ref: setAllRefs, "data-testid": testId, name: name, id: id, type: type, value: value, className: appliedClasses, placeholder: placeholder, disabled: readonly, autoComplete: autoComplete, onChange: handleChange, onFocus: onFocus, onBlur: onBlur, onKeyDown: onKeyDown, onKeyUp: onKeyUp, step: step, required: required, ...
|
|
4738
|
+
React__default.createElement("input", { ref: setAllRefs, "data-testid": testId, name: name, id: id, type: type, value: value, className: appliedClasses, placeholder: placeholder, disabled: readonly, autoComplete: autoComplete, onChange: handleChange, onFocus: onFocus, onBlur: onBlur, onKeyDown: onKeyDown, onKeyUp: onKeyUp, step: step, required: required, autoFocus: autoFocus, ...inputLenghtProp, ...inputProp }),
|
|
4734
4739
|
errorText && showError && React__default.createElement("div", { className: "tw-text-sq-danger-color tw-text-xs tw-mt-1" }, errorText)));
|
|
4735
4740
|
});
|
|
4736
4741
|
|
|
@@ -4758,9 +4763,11 @@ const Checkbox = (props) => {
|
|
|
4758
4763
|
};
|
|
4759
4764
|
|
|
4760
4765
|
const baseClasses$1 = 'tw-leading-normal tw-outline-none tw-py-1 tw-px-3 tw-rounded-sm' +
|
|
4766
|
+
' disabled:tw-pointer-events-none disabled:tw-bg-sq-light-gray disabled:dark:tw-bg-sq-dark-disabled-gray' +
|
|
4761
4767
|
' disabled:tw-cursor-not-allowed tw-p-1 tw-border-solid tw-border tw-text-sm';
|
|
4762
|
-
const darkTheme = 'dark:tw-bg-sq-dark-background dark:tw-text-sq-dark-text ' +
|
|
4763
|
-
|
|
4768
|
+
const darkTheme = 'dark:tw-bg-sq-dark-background dark:tw-text-sq-dark-text ' +
|
|
4769
|
+
'dark:tw-placeholder-sq-dark-text-lighter disabled:dark:tw-text-sq-dark-text-lighter';
|
|
4770
|
+
const lightTheme = 'tw-text-sq-text-color tw-placeholder-gray-400 disabled:tw-text-sq-darkish-gray';
|
|
4764
4771
|
const errorClasses$1 = 'tw-border-sq-danger-color';
|
|
4765
4772
|
const borderColorClasses$1 = [
|
|
4766
4773
|
'tw-border-sq-disabled-gray',
|
|
@@ -4773,9 +4780,9 @@ const borderColorClasses$1 = [
|
|
|
4773
4780
|
/**
|
|
4774
4781
|
* TextArea.
|
|
4775
4782
|
*/
|
|
4776
|
-
const TextArea = ({ readonly = false, onChange, onKeyUp, id, name, rows = 3, cols = undefined, value, placeholder, extraClassNames, testId,
|
|
4783
|
+
const TextArea = ({ readonly = false, onChange, onKeyUp, onFocus, onBlur, onKeyDown, id, name, rows = 3, cols = undefined, value, placeholder, showError, extraClassNames, testId, autoFocus = false, }) => {
|
|
4777
4784
|
const appliedClasses = `${baseClasses$1} ${extraClassNames} ${lightTheme} ${darkTheme} ${showError ? errorClasses$1 : borderColorClasses$1}`;
|
|
4778
|
-
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:
|
|
4785
|
+
return (React__default.createElement("textarea", { "data-testid": testId, name: name, id: id, value: value, className: appliedClasses, placeholder: placeholder, disabled: readonly, onChange: onChange, onFocus: onFocus, onBlur: onBlur, onKeyDown: onKeyDown, onKeyUp: onKeyUp, rows: rows, cols: cols, autoFocus: autoFocus }));
|
|
4779
4786
|
};
|
|
4780
4787
|
|
|
4781
4788
|
/**
|