@bento-core/query-bar 1.0.1-icdc.26 → 1.0.1-icdc.28
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/components/QueryUrl.js +98 -26
- package/package.json +1 -1
- package/src/components/QueryUrl.js +115 -27
|
@@ -16,15 +16,61 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
16
16
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
17
17
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
18
18
|
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
19
|
-
const
|
|
19
|
+
const ViewFullLinkComponent = _ref => {
|
|
20
|
+
let {
|
|
21
|
+
classes,
|
|
22
|
+
url,
|
|
23
|
+
maxWidth = 1200
|
|
24
|
+
} = _ref;
|
|
25
|
+
const linkRef = (0, _react.useRef)(null);
|
|
26
|
+
const [collapseLink, setCollapseLink] = (0, _react.useState)(false);
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Compute url link width based on the windowsize
|
|
30
|
+
*/
|
|
31
|
+
(0, _react.useEffect)(() => {
|
|
32
|
+
var _linkRef$current;
|
|
33
|
+
const urlWidth = linkRef === null || linkRef === void 0 ? void 0 : (_linkRef$current = linkRef.current) === null || _linkRef$current === void 0 ? void 0 : _linkRef$current.offsetWidth;
|
|
34
|
+
if (urlWidth > maxWidth / 2) {
|
|
35
|
+
setCollapseLink(true);
|
|
36
|
+
}
|
|
37
|
+
}, []);
|
|
38
|
+
const expandUrl = () => {
|
|
39
|
+
setCollapseLink(false);
|
|
40
|
+
};
|
|
41
|
+
const collapseUrl = () => {
|
|
42
|
+
setCollapseLink(true);
|
|
43
|
+
};
|
|
44
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("span", {
|
|
45
|
+
ref: linkRef,
|
|
46
|
+
className: classes.link
|
|
47
|
+
}, /*#__PURE__*/_react.default.createElement("span", {
|
|
48
|
+
className: (0, _clsx.default)(classes.viewLink, {
|
|
49
|
+
[classes.collapseLink]: collapseLink
|
|
50
|
+
})
|
|
51
|
+
}, /*#__PURE__*/_react.default.createElement("span", {
|
|
52
|
+
className: (0, _clsx.default)(classes.urlView, {
|
|
53
|
+
[classes.urlViewBtn]: !collapseLink
|
|
54
|
+
}),
|
|
55
|
+
type: "button",
|
|
56
|
+
onClick: collapseUrl
|
|
57
|
+
}, url), collapseLink && /*#__PURE__*/_react.default.createElement("span", {
|
|
58
|
+
className: classes.expandLinkBtn,
|
|
59
|
+
type: "button",
|
|
60
|
+
onClick: expandUrl
|
|
61
|
+
}, "..."))));
|
|
62
|
+
};
|
|
63
|
+
const QueryUrl = _ref2 => {
|
|
64
|
+
var _queryRef$current;
|
|
20
65
|
let {
|
|
21
66
|
classes,
|
|
22
67
|
filterItems,
|
|
23
68
|
localFind = {},
|
|
24
69
|
rootPath
|
|
25
|
-
} =
|
|
70
|
+
} = _ref2;
|
|
26
71
|
const [display, setDisplay] = (0, _react.useState)(false);
|
|
27
72
|
const toggleDisplay = () => setDisplay(!display);
|
|
73
|
+
const [expand, setExpand] = (0, _react.useState)(false);
|
|
28
74
|
const [open, toggleOpen] = (0, _react.useState)(false);
|
|
29
75
|
const pathFilterParams = filterItems.reduce((acc, item) => {
|
|
30
76
|
const {
|
|
@@ -47,10 +93,15 @@ const QueryUrl = _ref => {
|
|
|
47
93
|
}, /*#__PURE__*/_react.default.createElement(_core.Button, {
|
|
48
94
|
onClick: toggleDisplay,
|
|
49
95
|
className: classes.viewLinkToggleBtn
|
|
50
|
-
}, display ? 'Hide Query URL' : 'Show Query URL'), display && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("
|
|
96
|
+
}, display ? 'Hide Query URL' : 'Show Query URL'), display && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, expand ? /*#__PURE__*/_react.default.createElement("span", {
|
|
51
97
|
type: "button",
|
|
52
|
-
|
|
53
|
-
|
|
98
|
+
onClick: () => setExpand(!expand),
|
|
99
|
+
className: (0, _clsx.default)(classes.link, classes.viewLink, classes.expandLink)
|
|
100
|
+
}, url) : /*#__PURE__*/_react.default.createElement(ViewFullLinkComponent, {
|
|
101
|
+
url: url,
|
|
102
|
+
classes: classes,
|
|
103
|
+
maxWidth: queryRef === null || queryRef === void 0 ? void 0 : (_queryRef$current = queryRef.current) === null || _queryRef$current === void 0 ? void 0 : _queryRef$current.offsetWidth
|
|
104
|
+
}), /*#__PURE__*/_react.default.createElement(_core.Tooltip, {
|
|
54
105
|
arrow: true,
|
|
55
106
|
title: "Copy to Clipboard"
|
|
56
107
|
}, /*#__PURE__*/_react.default.createElement(_core.IconButton, {
|
|
@@ -76,43 +127,48 @@ const QueryUrl = _ref => {
|
|
|
76
127
|
const styles = () => ({
|
|
77
128
|
urlContainer: {
|
|
78
129
|
display: 'flex',
|
|
79
|
-
marginTop: '
|
|
130
|
+
marginTop: '10px',
|
|
80
131
|
minHeight: '10px'
|
|
81
132
|
},
|
|
82
|
-
|
|
133
|
+
link: {
|
|
134
|
+
lineBreak: 'anywhere',
|
|
83
135
|
overflow: 'hidden',
|
|
84
|
-
textOverflow: 'ellipsis',
|
|
85
136
|
fontFamily: 'Nunito',
|
|
86
137
|
fontSize: '12px',
|
|
87
138
|
fontWeight: '500',
|
|
88
139
|
lineHeight: '16px',
|
|
89
140
|
letterSpacing: '0em',
|
|
90
|
-
padding: '
|
|
141
|
+
padding: '5px',
|
|
91
142
|
borderRadius: '5px',
|
|
92
143
|
float: 'left',
|
|
93
144
|
color: '#1D79A8',
|
|
94
145
|
backgroundColor: '#fff',
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
maxWidth: '1800px'
|
|
100
|
-
},
|
|
101
|
-
'@media (max-width: 2000px)': {
|
|
102
|
-
maxWidth: '1500px'
|
|
103
|
-
},
|
|
104
|
-
'@media (max-width: 1600px)': {
|
|
105
|
-
maxWidth: '1100px'
|
|
106
|
-
},
|
|
107
|
-
'@media (max-width: 1300px)': {
|
|
108
|
-
maxWidth: '900px'
|
|
109
|
-
}
|
|
146
|
+
maxWidth: '80%'
|
|
147
|
+
},
|
|
148
|
+
viewLink: {
|
|
149
|
+
margin: '0'
|
|
110
150
|
},
|
|
111
151
|
urlViewBtn: {
|
|
112
152
|
cursor: 'pointer'
|
|
113
153
|
},
|
|
154
|
+
collapseLink: {
|
|
155
|
+
maxHeight: '1em',
|
|
156
|
+
display: 'block',
|
|
157
|
+
// display: '-webkit-box',
|
|
158
|
+
'-webkit-box-orient': 'vertical',
|
|
159
|
+
'-webkit-line-clamp': '1',
|
|
160
|
+
overflow: 'hidden'
|
|
161
|
+
},
|
|
162
|
+
expandLink: {
|
|
163
|
+
cursor: 'pointer'
|
|
164
|
+
},
|
|
165
|
+
expandLinkBtn: {
|
|
166
|
+
float: 'left',
|
|
167
|
+
'&:hover': {
|
|
168
|
+
cursor: 'pointer'
|
|
169
|
+
}
|
|
170
|
+
},
|
|
114
171
|
viewLinkToggleBtn: {
|
|
115
|
-
padding: '5px 10px 5px 10px',
|
|
116
172
|
height: '20px',
|
|
117
173
|
fontFamily: 'Nunito',
|
|
118
174
|
fontSize: '12px',
|
|
@@ -125,12 +181,28 @@ const styles = () => ({
|
|
|
125
181
|
color: '#fff',
|
|
126
182
|
float: 'left',
|
|
127
183
|
margin: '0px 10px 0px 0px',
|
|
128
|
-
whiteSpace: 'nowrap',
|
|
129
184
|
'&:hover': {
|
|
130
185
|
backgroundColor: '#1D79A8',
|
|
131
186
|
color: '#fff'
|
|
132
187
|
}
|
|
133
188
|
},
|
|
189
|
+
urlView: {
|
|
190
|
+
float: 'left',
|
|
191
|
+
width: 'calc(100% - 13px)',
|
|
192
|
+
minWidth: '840px',
|
|
193
|
+
'@media (max-width: 2560px)': {
|
|
194
|
+
maxWidth: '1800px'
|
|
195
|
+
},
|
|
196
|
+
'@media (max-width: 2000px)': {
|
|
197
|
+
maxWidth: '1400px'
|
|
198
|
+
},
|
|
199
|
+
'@media (max-width: 1600px)': {
|
|
200
|
+
maxWidth: '1200px'
|
|
201
|
+
},
|
|
202
|
+
'@media (max-width: 1300px)': {
|
|
203
|
+
maxWidth: '1050px'
|
|
204
|
+
}
|
|
205
|
+
},
|
|
134
206
|
copyIconBtn: {
|
|
135
207
|
padding: '0px',
|
|
136
208
|
height: '20px',
|
package/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useState, useRef } from 'react';
|
|
1
|
+
import React, { useState, useEffect, useRef } from 'react';
|
|
2
2
|
import clsx from 'clsx';
|
|
3
3
|
import {
|
|
4
4
|
Button,
|
|
@@ -12,6 +12,62 @@ import {
|
|
|
12
12
|
} from '@material-ui/core';
|
|
13
13
|
import CopyIcon from '../assets/CopyIcon.svg';
|
|
14
14
|
|
|
15
|
+
const ViewFullLinkComponent = ({
|
|
16
|
+
classes,
|
|
17
|
+
url,
|
|
18
|
+
maxWidth = 1200,
|
|
19
|
+
}) => {
|
|
20
|
+
const linkRef = useRef(null);
|
|
21
|
+
const [collapseLink, setCollapseLink] = useState(false);
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Compute url link width based on the windowsize
|
|
25
|
+
*/
|
|
26
|
+
useEffect(() => {
|
|
27
|
+
const urlWidth = linkRef?.current?.offsetWidth;
|
|
28
|
+
if (urlWidth > maxWidth / 2) {
|
|
29
|
+
setCollapseLink(true);
|
|
30
|
+
}
|
|
31
|
+
}, []);
|
|
32
|
+
|
|
33
|
+
const expandUrl = () => {
|
|
34
|
+
setCollapseLink(false);
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const collapseUrl = () => {
|
|
38
|
+
setCollapseLink(true);
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
return (
|
|
42
|
+
<>
|
|
43
|
+
<span ref={linkRef} className={classes.link}>
|
|
44
|
+
<span
|
|
45
|
+
className={clsx(classes.viewLink,
|
|
46
|
+
{ [classes.collapseLink]: collapseLink })}
|
|
47
|
+
>
|
|
48
|
+
<span
|
|
49
|
+
className={clsx(classes.urlView,
|
|
50
|
+
{ [classes.urlViewBtn]: !collapseLink })}
|
|
51
|
+
type="button"
|
|
52
|
+
onClick={collapseUrl}
|
|
53
|
+
>
|
|
54
|
+
{url}
|
|
55
|
+
</span>
|
|
56
|
+
{(collapseLink) && (
|
|
57
|
+
<span
|
|
58
|
+
className={classes.expandLinkBtn}
|
|
59
|
+
type="button"
|
|
60
|
+
onClick={expandUrl}
|
|
61
|
+
>
|
|
62
|
+
...
|
|
63
|
+
</span>
|
|
64
|
+
)}
|
|
65
|
+
</span>
|
|
66
|
+
</span>
|
|
67
|
+
</>
|
|
68
|
+
);
|
|
69
|
+
};
|
|
70
|
+
|
|
15
71
|
const QueryUrl = ({
|
|
16
72
|
classes,
|
|
17
73
|
filterItems,
|
|
@@ -21,6 +77,8 @@ const QueryUrl = ({
|
|
|
21
77
|
const [display, setDisplay] = useState(false);
|
|
22
78
|
const toggleDisplay = () => setDisplay(!display);
|
|
23
79
|
|
|
80
|
+
const [expand, setExpand] = useState(false);
|
|
81
|
+
|
|
24
82
|
const [open, toggleOpen] = useState(false);
|
|
25
83
|
|
|
26
84
|
const pathFilterParams = filterItems.reduce((acc, item) => {
|
|
@@ -55,12 +113,21 @@ const QueryUrl = ({
|
|
|
55
113
|
{
|
|
56
114
|
(display) && (
|
|
57
115
|
<>
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
116
|
+
{(expand) ? (
|
|
117
|
+
<span
|
|
118
|
+
type="button"
|
|
119
|
+
onClick={() => setExpand(!expand)}
|
|
120
|
+
className={clsx(classes.link, classes.viewLink, classes.expandLink)}
|
|
121
|
+
>
|
|
122
|
+
{url}
|
|
123
|
+
</span>
|
|
124
|
+
) : (
|
|
125
|
+
<ViewFullLinkComponent
|
|
126
|
+
url={url}
|
|
127
|
+
classes={classes}
|
|
128
|
+
maxWidth={queryRef?.current?.offsetWidth}
|
|
129
|
+
/>
|
|
130
|
+
)}
|
|
64
131
|
<Tooltip
|
|
65
132
|
arrow
|
|
66
133
|
title="Copy to Clipboard"
|
|
@@ -98,43 +165,48 @@ const QueryUrl = ({
|
|
|
98
165
|
const styles = () => ({
|
|
99
166
|
urlContainer: {
|
|
100
167
|
display: 'flex',
|
|
101
|
-
marginTop: '
|
|
168
|
+
marginTop: '10px',
|
|
102
169
|
minHeight: '10px',
|
|
103
170
|
},
|
|
104
|
-
|
|
171
|
+
link: {
|
|
172
|
+
lineBreak: 'anywhere',
|
|
105
173
|
overflow: 'hidden',
|
|
106
|
-
textOverflow: 'ellipsis',
|
|
107
174
|
fontFamily: 'Nunito',
|
|
108
175
|
fontSize: '12px',
|
|
109
176
|
fontWeight: '500',
|
|
110
177
|
lineHeight: '16px',
|
|
111
178
|
letterSpacing: '0em',
|
|
112
|
-
padding: '
|
|
179
|
+
padding: '5px',
|
|
113
180
|
borderRadius: '5px',
|
|
114
181
|
float: 'left',
|
|
115
182
|
color: '#1D79A8',
|
|
116
183
|
backgroundColor: '#fff',
|
|
184
|
+
maxWidth: '80%',
|
|
185
|
+
},
|
|
186
|
+
viewLink: {
|
|
117
187
|
margin: '0',
|
|
118
|
-
whiteSpace: 'nowrap',
|
|
119
|
-
wordBreak: 'break-all',
|
|
120
|
-
'@media (max-width: 2560px)': {
|
|
121
|
-
maxWidth: '1800px',
|
|
122
|
-
},
|
|
123
|
-
'@media (max-width: 2000px)': {
|
|
124
|
-
maxWidth: '1500px',
|
|
125
|
-
},
|
|
126
|
-
'@media (max-width: 1600px)': {
|
|
127
|
-
maxWidth: '1100px',
|
|
128
|
-
},
|
|
129
|
-
'@media (max-width: 1300px)': {
|
|
130
|
-
maxWidth: '900px',
|
|
131
|
-
},
|
|
132
188
|
},
|
|
133
189
|
urlViewBtn: {
|
|
134
190
|
cursor: 'pointer',
|
|
135
191
|
},
|
|
192
|
+
collapseLink: {
|
|
193
|
+
maxHeight: '1em',
|
|
194
|
+
display: 'block',
|
|
195
|
+
// display: '-webkit-box',
|
|
196
|
+
'-webkit-box-orient': 'vertical',
|
|
197
|
+
'-webkit-line-clamp': '1',
|
|
198
|
+
overflow: 'hidden',
|
|
199
|
+
},
|
|
200
|
+
expandLink: {
|
|
201
|
+
cursor: 'pointer',
|
|
202
|
+
},
|
|
203
|
+
expandLinkBtn: {
|
|
204
|
+
float: 'left',
|
|
205
|
+
'&:hover': {
|
|
206
|
+
cursor: 'pointer',
|
|
207
|
+
},
|
|
208
|
+
},
|
|
136
209
|
viewLinkToggleBtn: {
|
|
137
|
-
padding: '5px 10px 5px 10px',
|
|
138
210
|
height: '20px',
|
|
139
211
|
fontFamily: 'Nunito',
|
|
140
212
|
fontSize: '12px',
|
|
@@ -147,12 +219,28 @@ const styles = () => ({
|
|
|
147
219
|
color: '#fff',
|
|
148
220
|
float: 'left',
|
|
149
221
|
margin: '0px 10px 0px 0px',
|
|
150
|
-
whiteSpace: 'nowrap',
|
|
151
222
|
'&:hover': {
|
|
152
223
|
backgroundColor: '#1D79A8',
|
|
153
224
|
color: '#fff',
|
|
154
225
|
},
|
|
155
226
|
},
|
|
227
|
+
urlView: {
|
|
228
|
+
float: 'left',
|
|
229
|
+
width: 'calc(100% - 13px)',
|
|
230
|
+
minWidth: '840px',
|
|
231
|
+
'@media (max-width: 2560px)': {
|
|
232
|
+
maxWidth: '1800px',
|
|
233
|
+
},
|
|
234
|
+
'@media (max-width: 2000px)': {
|
|
235
|
+
maxWidth: '1400px',
|
|
236
|
+
},
|
|
237
|
+
'@media (max-width: 1600px)': {
|
|
238
|
+
maxWidth: '1200px',
|
|
239
|
+
},
|
|
240
|
+
'@media (max-width: 1300px)': {
|
|
241
|
+
maxWidth: '1050px',
|
|
242
|
+
},
|
|
243
|
+
},
|
|
156
244
|
copyIconBtn: {
|
|
157
245
|
padding: '0px',
|
|
158
246
|
height: '20px',
|