react-core-ts 1.0.2 → 1.0.3
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/.babel.config.js +7 -0
- package/.npmingnore +3 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +5 -1
- package/dist/index.js.map +1 -1
- package/dist/styles/components/autocomplete.css +1 -1
- package/dist/utilities/tooltip.js +0 -10
- package/dist/utilities/tooltip.js.map +1 -1
- package/docs/App.tsx +214 -0
- package/docs/index.html +40 -0
- package/docs/index.tsx +12 -0
- package/docs/style.css +4 -0
- package/package.json +1 -5
- package/postcss.config.js +7 -0
- package/src/AutoComplete.tsx +489 -0
- package/src/commontypes.ts +38 -0
- package/src/index.html +1 -0
- package/src/index.tsx +7 -0
- package/src/utilities/autosuggestions.ts +83 -0
- package/src/utilities/debounce.ts +15 -0
- package/src/utilities/deepEqual.ts +54 -0
- package/src/utilities/filterSuggestions.ts +46 -0
- package/src/utilities/icons.tsx +84 -0
- package/src/utilities/tooltip.tsx +52 -0
- package/tsconfig.json +14 -0
- package/webpack.config.js +66 -0
- package/dist/bundle.js +0 -2
- package/dist/bundle.js.LICENSE.txt +0 -14
- package/dist/utilities/tootltip.d.ts +0 -3
- package/dist/utilities/tootltip.js +0 -74
- package/dist/utilities/tootltip.js.map +0 -1
- /package/{dist/styles → src}/styles/components/autocomplete.css +0 -0
- /package/{dist/styles → src}/styles/global.css +0 -0
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
interface Item {
|
|
2
|
+
[key: string]: string;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
export const filterSuggestions = (
|
|
6
|
+
data: Item[],
|
|
7
|
+
query: string,
|
|
8
|
+
type: string,
|
|
9
|
+
desc: string,
|
|
10
|
+
inputValue?: string,
|
|
11
|
+
async?: boolean
|
|
12
|
+
): Item[] => {
|
|
13
|
+
if (
|
|
14
|
+
(type === 'custom_search_select' ||
|
|
15
|
+
type === 'auto_complete' ||
|
|
16
|
+
type === 'auto_suggestion') &&
|
|
17
|
+
!async &&
|
|
18
|
+
query
|
|
19
|
+
) {
|
|
20
|
+
return data?.filter((item) =>
|
|
21
|
+
item[desc].toLowerCase().includes(query.toLowerCase())
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
return sortedArrayData(data, inputValue, desc);
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const sortedArrayData = (
|
|
28
|
+
filteredData: any[],
|
|
29
|
+
selectedItems: any[] | string,
|
|
30
|
+
desc: any
|
|
31
|
+
) => {
|
|
32
|
+
return [...filteredData].sort((a, b) => {
|
|
33
|
+
let aIsSelected: boolean;
|
|
34
|
+
let bIsSelected: boolean;
|
|
35
|
+
|
|
36
|
+
if (Array.isArray(selectedItems)) {
|
|
37
|
+
aIsSelected = selectedItems.some((item) => item[desc] === a[desc]);
|
|
38
|
+
bIsSelected = selectedItems.some((item) => item[desc] === b[desc]);
|
|
39
|
+
} else {
|
|
40
|
+
aIsSelected = a[desc] === selectedItems;
|
|
41
|
+
bIsSelected = b[desc] === selectedItems;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return (bIsSelected ? 1 : 0) - (aIsSelected ? 1 : 0);
|
|
45
|
+
});
|
|
46
|
+
};
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
export const DropArrow: React.FC<any> = ({ className = '', stroke = 1.5 }) => {
|
|
4
|
+
return (
|
|
5
|
+
<svg
|
|
6
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
7
|
+
fill="none"
|
|
8
|
+
viewBox="0 0 24 24"
|
|
9
|
+
strokeWidth="1.5"
|
|
10
|
+
stroke="currentColor"
|
|
11
|
+
style={{ width: 15 }}
|
|
12
|
+
>
|
|
13
|
+
<path
|
|
14
|
+
strokeLinecap="round"
|
|
15
|
+
strokeLinejoin="round"
|
|
16
|
+
d="M19.5 8.25l-7.5 7.5-7.5-7.5"
|
|
17
|
+
/>
|
|
18
|
+
</svg>
|
|
19
|
+
);
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export const Close: React.FC<any> = ({ className = '', stroke = 1.5 }) => {
|
|
23
|
+
return (
|
|
24
|
+
<svg
|
|
25
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
26
|
+
fill="none"
|
|
27
|
+
viewBox="0 0 24 24"
|
|
28
|
+
strokeWidth="1.5"
|
|
29
|
+
stroke="currentColor"
|
|
30
|
+
style={{ width: 15 }}
|
|
31
|
+
>
|
|
32
|
+
<path
|
|
33
|
+
strokeLinecap="round"
|
|
34
|
+
strokeLinejoin="round"
|
|
35
|
+
d="M6 18L18 6M6 6l12 12"
|
|
36
|
+
/>
|
|
37
|
+
</svg>
|
|
38
|
+
);
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export const Spinner: React.FC<any> = ({ className = '', stroke = 1.5 }) => {
|
|
42
|
+
return (
|
|
43
|
+
<div role="status">
|
|
44
|
+
<svg
|
|
45
|
+
aria-hidden="true"
|
|
46
|
+
className="custom-spinner "
|
|
47
|
+
viewBox="0 0 100 101"
|
|
48
|
+
fill="none"
|
|
49
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
50
|
+
>
|
|
51
|
+
<path
|
|
52
|
+
d="M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z"
|
|
53
|
+
fill="currentColor"
|
|
54
|
+
/>
|
|
55
|
+
<path
|
|
56
|
+
d="M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z"
|
|
57
|
+
fill="currentFill"
|
|
58
|
+
/>
|
|
59
|
+
</svg>
|
|
60
|
+
</div>
|
|
61
|
+
);
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
export const Search: React.FC<any> = ({ className = '', stroke = 1.5 }) => {
|
|
65
|
+
return (
|
|
66
|
+
<div role="status">
|
|
67
|
+
<svg
|
|
68
|
+
width="16"
|
|
69
|
+
height="16"
|
|
70
|
+
viewBox="0 0 16 16"
|
|
71
|
+
fill="none"
|
|
72
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
73
|
+
>
|
|
74
|
+
<path
|
|
75
|
+
d="M14 14.0027L10 10.0027M11.3333 6.66935C11.3333 9.24668 9.244 11.336 6.66667 11.336C4.08934 11.336 2 9.24668 2 6.66935C2 4.09202 4.08934 2.00269 6.66667 2.00269C9.244 2.00269 11.3333 4.09202 11.3333 6.66935Z"
|
|
76
|
+
stroke="#999696"
|
|
77
|
+
strokeWidth="1.5"
|
|
78
|
+
strokeLinecap="round"
|
|
79
|
+
strokeLinejoin="round"
|
|
80
|
+
/>
|
|
81
|
+
</svg>
|
|
82
|
+
</div>
|
|
83
|
+
);
|
|
84
|
+
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import React, { useRef, useState } from 'react';
|
|
2
|
+
|
|
3
|
+
const ToolTip: React.FC<any> = ({ title, children }) => {
|
|
4
|
+
const [dropdownPosition, setDropdownPosition] = useState('bottom-position');
|
|
5
|
+
const dropRef = useRef(null);
|
|
6
|
+
const menuButtonRef = useRef<HTMLElement>(null);
|
|
7
|
+
const adjustDropdownPosition = () => {
|
|
8
|
+
if (menuButtonRef.current && dropRef.current) {
|
|
9
|
+
const inputBoxRect = menuButtonRef.current?.getBoundingClientRect();
|
|
10
|
+
const viewportHeight = window.innerHeight;
|
|
11
|
+
|
|
12
|
+
const spaceAbove = inputBoxRect.top;
|
|
13
|
+
const spaceBelow = viewportHeight - inputBoxRect.bottom;
|
|
14
|
+
console.log(spaceAbove, spaceBelow);
|
|
15
|
+
if (spaceAbove > spaceBelow) {
|
|
16
|
+
if (spaceAbove > 90 && spaceBelow < 120) {
|
|
17
|
+
setDropdownPosition('top-position');
|
|
18
|
+
} else {
|
|
19
|
+
setDropdownPosition('bottom-position');
|
|
20
|
+
}
|
|
21
|
+
} else {
|
|
22
|
+
const diff: number = spaceBelow - spaceAbove;
|
|
23
|
+
if (spaceAbove > 90 && spaceBelow > 90 && diff < 90) {
|
|
24
|
+
setDropdownPosition('top-position');
|
|
25
|
+
} else {
|
|
26
|
+
setDropdownPosition('bottom-position');
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
return (
|
|
33
|
+
<div
|
|
34
|
+
className={`qbs-table-tooltip ${
|
|
35
|
+
dropdownPosition == 'bottom-position' ? 'down' : 'up'
|
|
36
|
+
} `}
|
|
37
|
+
>
|
|
38
|
+
<span
|
|
39
|
+
ref={menuButtonRef}
|
|
40
|
+
style={{ display: 'flex' }}
|
|
41
|
+
onMouseEnter={() => adjustDropdownPosition()}
|
|
42
|
+
>
|
|
43
|
+
{children}
|
|
44
|
+
</span>
|
|
45
|
+
<span ref={dropRef} className={`tooltiptext `}>
|
|
46
|
+
{title}
|
|
47
|
+
</span>
|
|
48
|
+
</div>
|
|
49
|
+
);
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export default ToolTip;
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
const path = require('path');
|
|
2
|
+
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
|
3
|
+
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
|
4
|
+
|
|
5
|
+
module.exports = {
|
|
6
|
+
//...
|
|
7
|
+
entry: './dist',
|
|
8
|
+
devtool: 'source-map',
|
|
9
|
+
devServer: {
|
|
10
|
+
contentBase: './docs',
|
|
11
|
+
hot: true,
|
|
12
|
+
port: 3001, // port to run the dev server on
|
|
13
|
+
// stats: 'errors-only', // only show errors in the output
|
|
14
|
+
clientLogLevel: 'silent',
|
|
15
|
+
},
|
|
16
|
+
module: {
|
|
17
|
+
rules: [
|
|
18
|
+
{
|
|
19
|
+
test: /\.css$/i,
|
|
20
|
+
use: [MiniCssExtractPlugin.loader, 'css-loader'],
|
|
21
|
+
},
|
|
22
|
+
|
|
23
|
+
{
|
|
24
|
+
test: /\.tsx?$/,
|
|
25
|
+
exclude: (file) =>
|
|
26
|
+
/node_modules/.test(file) && !/\.react-core-ts/.test(file),
|
|
27
|
+
use: 'ts-loader',
|
|
28
|
+
},
|
|
29
|
+
|
|
30
|
+
{
|
|
31
|
+
enforce: 'pre',
|
|
32
|
+
test: /\.js$/,
|
|
33
|
+
loader: 'source-map-loader',
|
|
34
|
+
exclude: /node_modules/,
|
|
35
|
+
},
|
|
36
|
+
|
|
37
|
+
{
|
|
38
|
+
test: /\.svg$/,
|
|
39
|
+
use: ['@svgr/webpack', 'file-loader'],
|
|
40
|
+
},
|
|
41
|
+
],
|
|
42
|
+
},
|
|
43
|
+
plugins: [
|
|
44
|
+
new MiniCssExtractPlugin({
|
|
45
|
+
filename: '[name].css',
|
|
46
|
+
chunkFilename: '[id].css',
|
|
47
|
+
}),
|
|
48
|
+
new HtmlWebpackPlugin({
|
|
49
|
+
template: './docs/index.html', // your html file
|
|
50
|
+
}),
|
|
51
|
+
],
|
|
52
|
+
cache: {
|
|
53
|
+
type: 'filesystem',
|
|
54
|
+
buildDependencies: {
|
|
55
|
+
config: [__filename], // invalidate cache on config change
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
resolve: {
|
|
59
|
+
extensions: ['.ts', '.tsx', '.js', '.jsx', '.css'],
|
|
60
|
+
},
|
|
61
|
+
output: {
|
|
62
|
+
filename: 'bundle.js',
|
|
63
|
+
path: path.resolve(__dirname, 'dist'),
|
|
64
|
+
},
|
|
65
|
+
//...
|
|
66
|
+
};
|
package/dist/bundle.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
/*! For license information please see bundle.js.LICENSE.txt */
|
|
2
|
-
(()=>{"use strict";var e={418:e=>{var t=Object.getOwnPropertySymbols,r=Object.prototype.hasOwnProperty,n=Object.prototype.propertyIsEnumerable;e.exports=function(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de","5"===Object.getOwnPropertyNames(e)[0])return!1;for(var t={},r=0;r<10;r++)t["_"+String.fromCharCode(r)]=r;if("0123456789"!==Object.getOwnPropertyNames(t).map((function(e){return t[e]})).join(""))return!1;var n={};return"abcdefghijklmnopqrst".split("").forEach((function(e){n[e]=e})),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},n)).join("")}catch(e){return!1}}()?Object.assign:function(e,o){for(var u,i,a=function(e){if(null==e)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}(e),c=1;c<arguments.length;c++){for(var f in u=Object(arguments[c]))r.call(u,f)&&(a[f]=u[f]);if(t){i=t(u);for(var l=0;l<i.length;l++)n.call(u,i[l])&&(a[i[l]]=u[i[l]])}}return a}},408:(e,t,r)=>{var n=r(418),o=60103,u=60106;t.Fragment=60107,t.StrictMode=60108,t.Profiler=60114;var i=60109,a=60110,c=60112;t.Suspense=60113;var f=60115,l=60116;if("function"==typeof Symbol&&Symbol.for){var s=Symbol.for;o=s("react.element"),u=s("react.portal"),t.Fragment=s("react.fragment"),t.StrictMode=s("react.strict_mode"),t.Profiler=s("react.profiler"),i=s("react.provider"),a=s("react.context"),c=s("react.forward_ref"),t.Suspense=s("react.suspense"),f=s("react.memo"),l=s("react.lazy")}var p="function"==typeof Symbol&&Symbol.iterator;function y(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,r=1;r<arguments.length;r++)t+="&args[]="+encodeURIComponent(arguments[r]);return"Minified React error #"+e+"; visit "+t+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var d={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},v={};function h(e,t,r){this.props=e,this.context=t,this.refs=v,this.updater=r||d}function _(){}function m(e,t,r){this.props=e,this.context=t,this.refs=v,this.updater=r||d}h.prototype.isReactComponent={},h.prototype.setState=function(e,t){if("object"!=typeof e&&"function"!=typeof e&&null!=e)throw Error(y(85));this.updater.enqueueSetState(this,e,t,"setState")},h.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")},_.prototype=h.prototype;var b=m.prototype=new _;b.constructor=m,n(b,h.prototype),b.isPureReactComponent=!0;var g={current:null},j=Object.prototype.hasOwnProperty,O={key:!0,ref:!0,__self:!0,__source:!0};function w(e,t,r){var n,u={},i=null,a=null;if(null!=t)for(n in void 0!==t.ref&&(a=t.ref),void 0!==t.key&&(i=""+t.key),t)j.call(t,n)&&!O.hasOwnProperty(n)&&(u[n]=t[n]);var c=arguments.length-2;if(1===c)u.children=r;else if(1<c){for(var f=Array(c),l=0;l<c;l++)f[l]=arguments[l+2];u.children=f}if(e&&e.defaultProps)for(n in c=e.defaultProps)void 0===u[n]&&(u[n]=c[n]);return{$$typeof:o,type:e,key:i,ref:a,props:u,_owner:g.current}}function S(e){return"object"==typeof e&&null!==e&&e.$$typeof===o}var C=/\/+/g;function E(e,t){return"object"==typeof e&&null!==e&&null!=e.key?function(e){var t={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,(function(e){return t[e]}))}(""+e.key):t.toString(36)}function P(e,t,r,n,i){var a=typeof e;"undefined"!==a&&"boolean"!==a||(e=null);var c=!1;if(null===e)c=!0;else switch(a){case"string":case"number":c=!0;break;case"object":switch(e.$$typeof){case o:case u:c=!0}}if(c)return i=i(c=e),e=""===n?"."+E(c,0):n,Array.isArray(i)?(r="",null!=e&&(r=e.replace(C,"$&/")+"/"),P(i,t,r,"",(function(e){return e}))):null!=i&&(S(i)&&(i=function(e,t){return{$$typeof:o,type:e.type,key:t,ref:e.ref,props:e.props,_owner:e._owner}}(i,r+(!i.key||c&&c.key===i.key?"":(""+i.key).replace(C,"$&/")+"/")+e)),t.push(i)),1;if(c=0,n=""===n?".":n+":",Array.isArray(e))for(var f=0;f<e.length;f++){var l=n+E(a=e[f],f);c+=P(a,t,r,l,i)}else if(l=function(e){return null===e||"object"!=typeof e?null:"function"==typeof(e=p&&e[p]||e["@@iterator"])?e:null}(e),"function"==typeof l)for(e=l.call(e),f=0;!(a=e.next()).done;)c+=P(a=a.value,t,r,l=n+E(a,f++),i);else if("object"===a)throw t=""+e,Error(y(31,"[object Object]"===t?"object with keys {"+Object.keys(e).join(", ")+"}":t));return c}function k(e,t,r){if(null==e)return e;var n=[],o=0;return P(e,n,"","",(function(e){return t.call(r,e,o++)})),n}function $(e){if(-1===e._status){var t=e._result;t=t(),e._status=0,e._result=t,t.then((function(t){0===e._status&&(t=t.default,e._status=1,e._result=t)}),(function(t){0===e._status&&(e._status=2,e._result=t)}))}if(1===e._status)return e._result;throw e._result}var R={current:null};function x(){var e=R.current;if(null===e)throw Error(y(321));return e}var A={ReactCurrentDispatcher:R,ReactCurrentBatchConfig:{transition:0},ReactCurrentOwner:g,IsSomeRendererActing:{current:!1},assign:n};t.Children={map:k,forEach:function(e,t,r){k(e,(function(){t.apply(this,arguments)}),r)},count:function(e){var t=0;return k(e,(function(){t++})),t},toArray:function(e){return k(e,(function(e){return e}))||[]},only:function(e){if(!S(e))throw Error(y(143));return e}},t.Component=h,t.PureComponent=m,t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=A,t.cloneElement=function(e,t,r){if(null==e)throw Error(y(267,e));var u=n({},e.props),i=e.key,a=e.ref,c=e._owner;if(null!=t){if(void 0!==t.ref&&(a=t.ref,c=g.current),void 0!==t.key&&(i=""+t.key),e.type&&e.type.defaultProps)var f=e.type.defaultProps;for(l in t)j.call(t,l)&&!O.hasOwnProperty(l)&&(u[l]=void 0===t[l]&&void 0!==f?f[l]:t[l])}var l=arguments.length-2;if(1===l)u.children=r;else if(1<l){f=Array(l);for(var s=0;s<l;s++)f[s]=arguments[s+2];u.children=f}return{$$typeof:o,type:e.type,key:i,ref:a,props:u,_owner:c}},t.createContext=function(e,t){return void 0===t&&(t=null),(e={$$typeof:a,_calculateChangedBits:t,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null}).Provider={$$typeof:i,_context:e},e.Consumer=e},t.createElement=w,t.createFactory=function(e){var t=w.bind(null,e);return t.type=e,t},t.createRef=function(){return{current:null}},t.forwardRef=function(e){return{$$typeof:c,render:e}},t.isValidElement=S,t.lazy=function(e){return{$$typeof:l,_payload:{_status:-1,_result:e},_init:$}},t.memo=function(e,t){return{$$typeof:f,type:e,compare:void 0===t?null:t}},t.useCallback=function(e,t){return x().useCallback(e,t)},t.useContext=function(e,t){return x().useContext(e,t)},t.useDebugValue=function(){},t.useEffect=function(e,t){return x().useEffect(e,t)},t.useImperativeHandle=function(e,t,r){return x().useImperativeHandle(e,t,r)},t.useLayoutEffect=function(e,t){return x().useLayoutEffect(e,t)},t.useMemo=function(e,t){return x().useMemo(e,t)},t.useReducer=function(e,t,r){return x().useReducer(e,t,r)},t.useRef=function(e){return x().useRef(e)},t.useState=function(e){return x().useState(e)},t.version="17.0.2"},294:(e,t,r)=>{e.exports=r(408)},20:function(e,t,r){var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),u=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&n(t,e,r);return o(t,e),t};Object.defineProperty(t,"__esModule",{value:!0});var i=u(r(294));t.default=function(e){return i.createElement(i.Fragment,null,i.createElement("input",{placeholder:"AutoComplete",name:null==e?void 0:e.name}))}},629:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.AutoComplete=void 0;var o=r(20);Object.defineProperty(t,"AutoComplete",{enumerable:!0,get:function(){return n(o).default}})}},t={};!function r(n){var o=t[n];if(void 0!==o)return o.exports;var u=t[n]={exports:{}};return e[n].call(u.exports,u,u.exports,r),u.exports}(629)})();
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
object-assign
|
|
3
|
-
(c) Sindre Sorhus
|
|
4
|
-
@license MIT
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
/** @license React v17.0.2
|
|
8
|
-
* react.production.min.js
|
|
9
|
-
*
|
|
10
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
11
|
-
*
|
|
12
|
-
* This source code is licensed under the MIT license found in the
|
|
13
|
-
* LICENSE file in the root directory of this source tree.
|
|
14
|
-
*/
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// import React from 'react';
|
|
3
|
-
// const Tooltip: React.FC<any> = ({ children, title }) => {
|
|
4
|
-
// return (
|
|
5
|
-
// <div className="tooltip-wrapper">
|
|
6
|
-
// {children}
|
|
7
|
-
// <div className="tooltip-content">{title}</div>
|
|
8
|
-
// </div>
|
|
9
|
-
// );
|
|
10
|
-
// };
|
|
11
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
12
|
-
if (k2 === undefined) k2 = k;
|
|
13
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
14
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
15
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
16
|
-
}
|
|
17
|
-
Object.defineProperty(o, k2, desc);
|
|
18
|
-
}) : (function(o, m, k, k2) {
|
|
19
|
-
if (k2 === undefined) k2 = k;
|
|
20
|
-
o[k2] = m[k];
|
|
21
|
-
}));
|
|
22
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
23
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
24
|
-
}) : function(o, v) {
|
|
25
|
-
o["default"] = v;
|
|
26
|
-
});
|
|
27
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
-
// export default Tooltip;
|
|
36
|
-
var react_1 = __importStar(require("react"));
|
|
37
|
-
var ToolTip = function (_a) {
|
|
38
|
-
var title = _a.title, children = _a.children;
|
|
39
|
-
var _b = (0, react_1.useState)('bottom-position'), dropdownPosition = _b[0], setDropdownPosition = _b[1];
|
|
40
|
-
var dropRef = (0, react_1.useRef)(null);
|
|
41
|
-
var menuButtonRef = (0, react_1.useRef)(null);
|
|
42
|
-
var adjustDropdownPosition = function () {
|
|
43
|
-
var _a;
|
|
44
|
-
if (menuButtonRef.current && dropRef.current) {
|
|
45
|
-
var inputBoxRect = (_a = menuButtonRef.current) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect();
|
|
46
|
-
var viewportHeight = window.innerHeight;
|
|
47
|
-
var spaceAbove = inputBoxRect.top;
|
|
48
|
-
var spaceBelow = viewportHeight - inputBoxRect.bottom;
|
|
49
|
-
console.log(spaceAbove, spaceBelow);
|
|
50
|
-
if (spaceAbove > spaceBelow) {
|
|
51
|
-
if (spaceAbove > 90 && spaceBelow < 120) {
|
|
52
|
-
setDropdownPosition('top-position');
|
|
53
|
-
}
|
|
54
|
-
else {
|
|
55
|
-
setDropdownPosition('bottom-position');
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
else {
|
|
59
|
-
var diff = spaceBelow - spaceAbove;
|
|
60
|
-
if (spaceAbove > 90 && spaceBelow > 90 && diff < 90) {
|
|
61
|
-
setDropdownPosition('top-position');
|
|
62
|
-
}
|
|
63
|
-
else {
|
|
64
|
-
setDropdownPosition('bottom-position');
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
};
|
|
69
|
-
return (react_1.default.createElement("div", { className: "qbs-table-tooltip ".concat(dropdownPosition == 'bottom-position' ? 'down' : 'up', " ") },
|
|
70
|
-
react_1.default.createElement("span", { ref: menuButtonRef, style: { display: 'flex' }, onMouseEnter: function () { return adjustDropdownPosition(); } }, children),
|
|
71
|
-
react_1.default.createElement("span", { ref: dropRef, className: "tooltiptext " }, title)));
|
|
72
|
-
};
|
|
73
|
-
exports.default = ToolTip;
|
|
74
|
-
//# sourceMappingURL=tootltip.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tootltip.js","sourceRoot":"","sources":["../../src/utilities/tootltip.tsx"],"names":[],"mappings":";AAAA,6BAA6B;AAC7B,4DAA4D;AAC5D,aAAa;AACb,wCAAwC;AACxC,mBAAmB;AACnB,uDAAuD;AACvD,aAAa;AACb,OAAO;AACP,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;AAEL,0BAA0B;AAC1B,6CAAgD;AAEhD,IAAM,OAAO,GAAkB,UAAC,EAAmB;QAAjB,KAAK,WAAA,EAAE,QAAQ,cAAA;IACzC,IAAA,KAA0C,IAAA,gBAAQ,EAAC,iBAAiB,CAAC,EAApE,gBAAgB,QAAA,EAAE,mBAAmB,QAA+B,CAAC;IAC5E,IAAM,OAAO,GAAG,IAAA,cAAM,EAAC,IAAI,CAAC,CAAC;IAC7B,IAAM,aAAa,GAAG,IAAA,cAAM,EAAc,IAAI,CAAC,CAAC;IAChD,IAAM,sBAAsB,GAAG;;QAC7B,IAAI,aAAa,CAAC,OAAO,IAAI,OAAO,CAAC,OAAO,EAAE;YAC5C,IAAM,YAAY,GAAG,MAAA,aAAa,CAAC,OAAO,0CAAE,qBAAqB,EAAE,CAAC;YACpE,IAAM,cAAc,GAAG,MAAM,CAAC,WAAW,CAAC;YAE1C,IAAM,UAAU,GAAG,YAAY,CAAC,GAAG,CAAC;YACpC,IAAM,UAAU,GAAG,cAAc,GAAG,YAAY,CAAC,MAAM,CAAC;YACxD,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;YACpC,IAAI,UAAU,GAAG,UAAU,EAAE;gBAC3B,IAAI,UAAU,GAAG,EAAE,IAAI,UAAU,GAAG,GAAG,EAAE;oBACvC,mBAAmB,CAAC,cAAc,CAAC,CAAC;iBACrC;qBAAM;oBACL,mBAAmB,CAAC,iBAAiB,CAAC,CAAC;iBACxC;aACF;iBAAM;gBACL,IAAM,IAAI,GAAW,UAAU,GAAG,UAAU,CAAC;gBAC7C,IAAI,UAAU,GAAG,EAAE,IAAI,UAAU,GAAG,EAAE,IAAI,IAAI,GAAG,EAAE,EAAE;oBACnD,mBAAmB,CAAC,cAAc,CAAC,CAAC;iBACrC;qBAAM;oBACL,mBAAmB,CAAC,iBAAiB,CAAC,CAAC;iBACxC;aACF;SACF;IACH,CAAC,CAAC;IAEF,OAAO,CACL,uCACE,SAAS,EAAE,4BACT,gBAAgB,IAAI,iBAAiB,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,MACpD;QAEH,wCACE,GAAG,EAAE,aAAa,EAClB,KAAK,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,EAC1B,YAAY,EAAE,cAAM,OAAA,sBAAsB,EAAE,EAAxB,CAAwB,IAE3C,QAAQ,CACJ;QACP,wCAAM,GAAG,EAAE,OAAO,EAAE,SAAS,EAAE,cAAc,IAC1C,KAAK,CACD,CACH,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,OAAO,CAAC"}
|
|
File without changes
|
|
File without changes
|