@bento-core/query-bar 1.0.1-icdc.8 → 1.0.1-icdc.9

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.
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
  var _react = _interopRequireWildcard(require("react"));
8
+ var _clsx = _interopRequireDefault(require("clsx"));
8
9
  var _core = require("@material-ui/core");
9
10
  var _CopyIcon = _interopRequireDefault(require("../assets/CopyIcon.svg"));
10
11
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -15,15 +16,55 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
15
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; }
16
17
  function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
17
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); }
18
- const QueryUrl = _ref => {
19
+ const ViewFullLinkComponent = _ref => {
20
+ let {
21
+ classes,
22
+ url,
23
+ maxWidth = 1200
24
+ } = _ref;
25
+ const linkRef = (0, _react.useRef)(null);
26
+ const [expandLink, setExpand] = (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
+ setExpand(true);
36
+ }
37
+ }, []);
38
+ const expandUrl = () => {
39
+ setExpand(!expandLink);
40
+ };
41
+ return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("span", {
42
+ ref: linkRef,
43
+ className: classes.link
44
+ }, /*#__PURE__*/_react.default.createElement("span", {
45
+ className: (0, _clsx.default)(classes.viewLink, {
46
+ [classes.collapseLink]: expandLink
47
+ })
48
+ }, /*#__PURE__*/_react.default.createElement("span", {
49
+ className: classes.urlView
50
+ }, url), expandLink && /*#__PURE__*/_react.default.createElement("span", {
51
+ className: classes.expandLinkBtn,
52
+ type: "button",
53
+ onClick: expandUrl
54
+ }, "..."))));
55
+ };
56
+ const QueryUrl = _ref2 => {
57
+ var _queryRef$current;
19
58
  let {
20
59
  classes,
21
60
  filterItems,
22
61
  localFind,
23
62
  rootPath
24
- } = _ref;
63
+ } = _ref2;
64
+ const [display, setDisplay] = (0, _react.useState)(false);
65
+ const toggleDisplay = () => setDisplay(!display);
25
66
  const [expand, setExpand] = (0, _react.useState)(false);
26
- const toggleExpand = () => setExpand(!expand);
67
+ const [open, toggleOpen] = (0, _react.useState)(false);
27
68
  const {
28
69
  autocomplete = [],
29
70
  upload
@@ -42,20 +83,25 @@ const QueryUrl = _ref => {
42
83
  }));
43
84
  const url = encodeURI(rootPath.concat(query));
44
85
  const copyUrl = async () => {
86
+ toggleOpen(!open);
45
87
  await navigator.clipboard.writeText(url);
46
88
  };
47
- return /*#__PURE__*/_react.default.createElement("div", {
89
+ const queryRef = (0, _react.useRef)(null);
90
+ return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
91
+ ref: queryRef,
48
92
  className: classes.urlContainer
49
93
  }, /*#__PURE__*/_react.default.createElement(_core.Button, {
50
- onClick: toggleExpand,
94
+ onClick: toggleDisplay,
51
95
  className: classes.viewLinkToggleBtn
52
- }, expand ? 'Hide Query URL' : 'Show Query URL'), expand && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_core.Link, {
53
- target: "_blank",
54
- href: url,
55
- className: classes.link
56
- }, /*#__PURE__*/_react.default.createElement("p", {
57
- className: classes.viewLink
58
- }, url)), /*#__PURE__*/_react.default.createElement(_core.Tooltip, {
96
+ }, display ? 'Hide Query URL' : 'Show Query URL'), display && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, expand ? /*#__PURE__*/_react.default.createElement("span", {
97
+ type: "button",
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, {
59
105
  arrow: true,
60
106
  title: "Copy to Clipboard"
61
107
  }, /*#__PURE__*/_react.default.createElement(_core.IconButton, {
@@ -64,7 +110,18 @@ const QueryUrl = _ref => {
64
110
  }, /*#__PURE__*/_react.default.createElement("img", {
65
111
  src: _CopyIcon.default,
66
112
  alt: "copy icon"
67
- })))));
113
+ }))))), /*#__PURE__*/_react.default.createElement(_core.Dialog, {
114
+ open: open,
115
+ "aria-labelledby": "alert-dialog-title",
116
+ "aria-describedby": "alert-dialog-description",
117
+ className: classes.dialogBox
118
+ }, /*#__PURE__*/_react.default.createElement(_core.DialogContent, {
119
+ className: classes.okText
120
+ }, /*#__PURE__*/_react.default.createElement(_core.DialogContentText, {
121
+ id: "alert-dialog-description"
122
+ }, "Your query URL has been copied!")), /*#__PURE__*/_react.default.createElement(_core.DialogActions, null, /*#__PURE__*/_react.default.createElement(_core.Button, {
123
+ onClick: () => toggleOpen(!open)
124
+ }, "OK"))));
68
125
  };
69
126
  var _default = QueryUrl;
70
127
  exports.default = _default;
@@ -125,7 +125,7 @@ const QueryBarGenerator = function QueryBarGenerator() {
125
125
  }, "INPUT CASE SET") : null, autocomplete.length ? /*#__PURE__*/_react.default.createElement("span", null, ' ', /*#__PURE__*/_react.default.createElement("span", {
126
126
  className: (0, _clsx.default)(classes.filterName, classes.localFindBackground),
127
127
  onClick: clearAutocomplete
128
- }, "Case IDs"), ' ', ' ', /*#__PURE__*/_react.default.createElement("span", {
128
+ }, "Case ID"), ' ', ' ', /*#__PURE__*/_react.default.createElement("span", {
129
129
  className: classes.operators
130
130
  }, autocomplete.length === 1 && !upload.length ? 'IS ' : 'IN ')) : null, /*#__PURE__*/_react.default.createElement("span", null, (upload.length > 0 ? 1 : 0) + autocomplete.length > 1 ? /*#__PURE__*/_react.default.createElement("span", {
131
131
  className: classes.bracketsOpen
@@ -27,7 +27,7 @@ var _default = {
27
27
  * root path of bento app
28
28
  * @var {boolean}
29
29
  */
30
- rootPath: 'http://localhost:3000/',
30
+ rootPath: 'http://localhost:3010/',
31
31
  /**
32
32
  * display query URL
33
33
  * @var {boolean}
@@ -121,10 +121,13 @@ var _default = () => ({
121
121
  }
122
122
  },
123
123
  urlContainer: {
124
- marginTop: '10px'
124
+ marginTop: '10px',
125
+ minHeight: '10px',
126
+ marginBottom: '10px'
125
127
  },
126
128
  link: {
127
129
  lineBreak: 'anywhere',
130
+ overflow: 'hidden',
128
131
  fontFamily: 'Nunito',
129
132
  fontSize: '12px',
130
133
  fontWeight: '500',
@@ -132,22 +135,34 @@ var _default = () => ({
132
135
  letterSpacing: '0em',
133
136
  padding: '5px',
134
137
  borderRadius: '5px',
135
- marginLeft: '10px',
136
138
  float: 'left',
137
139
  color: '#1D79A8',
138
- backgroundColor: '#fff'
140
+ backgroundColor: '#fff',
141
+ maxWidth: '80%'
139
142
  },
140
143
  viewLink: {
141
- maxWidth: '800px',
144
+ margin: '0'
145
+ },
146
+ collapseLink: {
142
147
  maxHeight: '1em',
143
- display: '-webkit-box',
148
+ display: 'block',
149
+ // display: '-webkit-box',
144
150
  '-webkit-box-orient': 'vertical',
145
151
  '-webkit-line-clamp': '1',
146
- overflow: 'hidden',
147
- margin: '0'
152
+ overflow: 'hidden'
153
+ },
154
+ expandLink: {
155
+ cursor: 'pointer'
156
+ },
157
+ expandLinkBtn: {
158
+ float: 'left',
159
+ '&:hover': {
160
+ cursor: 'pointer'
161
+ }
148
162
  },
149
163
  viewLinkToggleBtn: {
150
164
  height: '20px',
165
+ marginRight: '10px',
151
166
  fontFamily: 'Nunito',
152
167
  fontSize: '12px',
153
168
  fontWeight: '500',
@@ -163,9 +178,64 @@ var _default = () => ({
163
178
  color: '#fff'
164
179
  }
165
180
  },
181
+ urlView: {
182
+ float: 'left',
183
+ width: 'calc(100% - 13px)',
184
+ minWidth: '840px',
185
+ '@media (max-width: 2560px)': {
186
+ maxWidth: '1800px'
187
+ },
188
+ '@media (max-width: 2000px)': {
189
+ maxWidth: '1400px'
190
+ },
191
+ '@media (max-width: 1600px)': {
192
+ maxWidth: '1200px'
193
+ },
194
+ '@media (max-width: 1300px)': {
195
+ maxWidth: '1050px'
196
+ }
197
+ },
166
198
  copyIconBtn: {
167
199
  padding: '0px',
168
- marginLeft: '10px'
200
+ marginLeft: '10px',
201
+ float: 'left'
202
+ },
203
+ dialogBox: {
204
+ '& div.MuiBackdrop-root': {
205
+ backgroundColor: 'rgba(0, 0, 0, 0.2)'
206
+ },
207
+ '& div.MuiPaper-root': {
208
+ borderRadius: '20px',
209
+ border: '2px solid #1D79A8',
210
+ width: '430px',
211
+ backgroundColor: '#E8EFEF',
212
+ padding: '20px 0px 30px 0px',
213
+ '& .MuiDialogContent-root': {
214
+ fontFamily: 'Nunito',
215
+ fontSize: '14px',
216
+ fontWeight: '600',
217
+ lineHeight: '20px',
218
+ textAlign: 'center',
219
+ '& .MuiTypography-colorTextSecondary': {
220
+ color: '#000000'
221
+ }
222
+ },
223
+ '& .MuiDialogActions-root': {
224
+ '& button': {
225
+ width: '125px',
226
+ height: '38px',
227
+ borderRadius: '8px',
228
+ border: '1px solid #1A8CCB',
229
+ backgroundColor: '#1A8CCB',
230
+ color: '#fff',
231
+ fontFamily: 'Lato',
232
+ fontSize: '16px',
233
+ fontWeight: '400',
234
+ lineHeight: '16px',
235
+ margin: 'auto'
236
+ }
237
+ }
238
+ }
169
239
  }
170
240
  });
171
241
  exports.default = _default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bento-core/query-bar",
3
- "version": "1.0.1-icdc.8",
3
+ "version": "1.0.1-icdc.9",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -1,20 +1,75 @@
1
- import React, { useState } from 'react';
1
+ import React, { useState, useEffect, useRef } from 'react';
2
+ import clsx from 'clsx';
2
3
  import {
3
4
  Button,
4
5
  IconButton,
5
- Link,
6
6
  Tooltip,
7
+ Dialog,
8
+ DialogActions,
9
+ DialogContent,
10
+ DialogContentText,
7
11
  } from '@material-ui/core';
8
12
  import CopyIcon from '../assets/CopyIcon.svg';
9
13
 
14
+ const ViewFullLinkComponent = ({
15
+ classes,
16
+ url,
17
+ maxWidth = 1200,
18
+ }) => {
19
+ const linkRef = useRef(null);
20
+ const [expandLink, setExpand] = useState(false);
21
+
22
+ /**
23
+ * Compute url link width based on the windowsize
24
+ */
25
+ useEffect(() => {
26
+ const urlWidth = linkRef?.current?.offsetWidth;
27
+ if (urlWidth > maxWidth / 2) {
28
+ setExpand(true);
29
+ }
30
+ }, []);
31
+
32
+ const expandUrl = () => {
33
+ setExpand(!expandLink);
34
+ };
35
+
36
+ return (
37
+ <>
38
+ <span ref={linkRef} className={classes.link}>
39
+ <span
40
+ className={clsx(classes.viewLink,
41
+ { [classes.collapseLink]: expandLink })}
42
+ >
43
+ <span className={classes.urlView}>
44
+ {url}
45
+ </span>
46
+ {(expandLink) && (
47
+ <span
48
+ className={classes.expandLinkBtn}
49
+ type="button"
50
+ onClick={expandUrl}
51
+ >
52
+ ...
53
+ </span>
54
+ )}
55
+ </span>
56
+ </span>
57
+ </>
58
+ );
59
+ };
60
+
10
61
  const QueryUrl = ({
11
62
  classes,
12
63
  filterItems,
13
64
  localFind,
14
65
  rootPath,
15
66
  }) => {
67
+ const [display, setDisplay] = useState(false);
68
+ const toggleDisplay = () => setDisplay(!display);
69
+
16
70
  const [expand, setExpand] = useState(false);
17
- const toggleExpand = () => setExpand(!expand);
71
+
72
+ const [open, toggleOpen] = useState(false);
18
73
 
19
74
  const { autocomplete = [], upload } = localFind;
20
75
 
@@ -32,41 +87,69 @@ const QueryUrl = ({
32
87
  const url = encodeURI(rootPath.concat(query));
33
88
 
34
89
  const copyUrl = async () => {
90
+ toggleOpen(!open);
35
91
  await navigator.clipboard.writeText(url);
36
92
  };
37
93
 
94
+ const queryRef = useRef(null);
95
+
38
96
  return (
39
- <div className={classes.urlContainer}>
40
- <Button
41
- onClick={toggleExpand}
42
- className={classes.viewLinkToggleBtn}
97
+ <>
98
+ <div ref={queryRef} className={classes.urlContainer}>
99
+ <Button
100
+ onClick={toggleDisplay}
101
+ className={classes.viewLinkToggleBtn}
102
+ >
103
+ { (display) ? 'Hide Query URL' : 'Show Query URL'}
104
+ </Button>
105
+ {
106
+ (display) && (
107
+ <>
108
+ {(expand) ? (
109
+ <span
110
+ type="button"
111
+ onClick={() => setExpand(!expand)}
112
+ className={clsx(classes.link, classes.viewLink, classes.expandLink)}
113
+ >
114
+ {url}
115
+ </span>
116
+ ) : (
117
+ <ViewFullLinkComponent
118
+ url={url}
119
+ classes={classes}
120
+ maxWidth={queryRef?.current?.offsetWidth}
121
+ />
122
+ )}
123
+ <Tooltip
124
+ arrow
125
+ title="Copy to Clipboard"
126
+ >
127
+ <IconButton onClick={copyUrl} className={classes.copyIconBtn}>
128
+ <img src={CopyIcon} alt="copy icon" />
129
+ </IconButton>
130
+ </Tooltip>
131
+ </>
132
+ )
133
+ }
134
+ </div>
135
+ <Dialog
136
+ open={open}
137
+ aria-labelledby="alert-dialog-title"
138
+ aria-describedby="alert-dialog-description"
139
+ className={classes.dialogBox}
43
140
  >
44
- { (expand) ? 'Hide Query URL' : 'Show Query URL'}
45
- </Button>
46
- {
47
- (expand) && (
48
- <>
49
- <Link
50
- target="_blank"
51
- href={url}
52
- className={classes.link}
53
- >
54
- <p className={classes.viewLink}>
55
- {url}
56
- </p>
57
- </Link>
58
- <Tooltip
59
- arrow
60
- title="Copy to Clipboard"
61
- >
62
- <IconButton onClick={copyUrl} className={classes.copyIconBtn}>
63
- <img src={CopyIcon} alt="copy icon" />
64
- </IconButton>
65
- </Tooltip>
66
- </>
67
- )
68
- }
69
- </div>
141
+ <DialogContent className={classes.okText}>
142
+ <DialogContentText id="alert-dialog-description">
143
+ Your query URL has been copied!
144
+ </DialogContentText>
145
+ </DialogContent>
146
+ <DialogActions>
147
+ <Button onClick={() => toggleOpen(!open)}>
148
+ OK
149
+ </Button>
150
+ </DialogActions>
151
+ </Dialog>
152
+ </>
70
153
  );
71
154
  };
72
155
 
@@ -149,7 +149,7 @@ export const QueryBarGenerator = (uiConfig = DEFAULT_CONFIG) => {
149
149
  className={clsx(classes.filterName, classes.localFindBackground)}
150
150
  onClick={clearAutocomplete}
151
151
  >
152
- Case IDs
152
+ Case ID
153
153
  </span>
154
154
  {' '}
155
155
  {' '}
@@ -21,7 +21,7 @@ export default {
21
21
  * root path of bento app
22
22
  * @var {boolean}
23
23
  */
24
- rootPath: 'http://localhost:3000/',
24
+ rootPath: 'http://localhost:3010/',
25
25
  /**
26
26
  * display query URL
27
27
  * @var {boolean}
@@ -116,9 +116,12 @@ export default () => ({
116
116
  },
117
117
  urlContainer: {
118
118
  marginTop: '10px',
119
+ minHeight: '10px',
120
+ marginBottom: '10px',
119
121
  },
120
122
  link: {
121
123
  lineBreak: 'anywhere',
124
+ overflow: 'hidden',
122
125
  fontFamily: 'Nunito',
123
126
  fontSize: '12px',
124
127
  fontWeight: '500',
@@ -126,22 +129,34 @@ export default () => ({
126
129
  letterSpacing: '0em',
127
130
  padding: '5px',
128
131
  borderRadius: '5px',
129
- marginLeft: '10px',
130
132
  float: 'left',
131
133
  color: '#1D79A8',
132
134
  backgroundColor: '#fff',
135
+ maxWidth: '80%',
133
136
  },
134
137
  viewLink: {
135
- maxWidth: '800px',
138
+ margin: '0',
139
+ },
140
+ collapseLink: {
136
141
  maxHeight: '1em',
137
- display: '-webkit-box',
142
+ display: 'block',
143
+ // display: '-webkit-box',
138
144
  '-webkit-box-orient': 'vertical',
139
145
  '-webkit-line-clamp': '1',
140
146
  overflow: 'hidden',
141
- margin: '0',
147
+ },
148
+ expandLink: {
149
+ cursor: 'pointer',
150
+ },
151
+ expandLinkBtn: {
152
+ float: 'left',
153
+ '&:hover': {
154
+ cursor: 'pointer',
155
+ },
142
156
  },
143
157
  viewLinkToggleBtn: {
144
158
  height: '20px',
159
+ marginRight: '10px',
145
160
  fontFamily: 'Nunito',
146
161
  fontSize: '12px',
147
162
  fontWeight: '500',
@@ -157,8 +172,63 @@ export default () => ({
157
172
  color: '#fff',
158
173
  },
159
174
  },
175
+ urlView: {
176
+ float: 'left',
177
+ width: 'calc(100% - 13px)',
178
+ minWidth: '840px',
179
+ '@media (max-width: 2560px)': {
180
+ maxWidth: '1800px',
181
+ },
182
+ '@media (max-width: 2000px)': {
183
+ maxWidth: '1400px',
184
+ },
185
+ '@media (max-width: 1600px)': {
186
+ maxWidth: '1200px',
187
+ },
188
+ '@media (max-width: 1300px)': {
189
+ maxWidth: '1050px',
190
+ },
191
+ },
160
192
  copyIconBtn: {
161
193
  padding: '0px',
162
194
  marginLeft: '10px',
195
+ float: 'left',
196
+ },
197
+ dialogBox: {
198
+ '& div.MuiBackdrop-root': {
199
+ backgroundColor: 'rgba(0, 0, 0, 0.2)',
200
+ },
201
+ '& div.MuiPaper-root': {
202
+ borderRadius: '20px',
203
+ border: '2px solid #1D79A8',
204
+ width: '430px',
205
+ backgroundColor: '#E8EFEF',
206
+ padding: '20px 0px 30px 0px',
207
+ '& .MuiDialogContent-root': {
208
+ fontFamily: 'Nunito',
209
+ fontSize: '14px',
210
+ fontWeight: '600',
211
+ lineHeight: '20px',
212
+ textAlign: 'center',
213
+ '& .MuiTypography-colorTextSecondary': {
214
+ color: '#000000',
215
+ },
216
+ },
217
+ '& .MuiDialogActions-root': {
218
+ '& button': {
219
+ width: '125px',
220
+ height: '38px',
221
+ borderRadius: '8px',
222
+ border: '1px solid #1A8CCB',
223
+ backgroundColor: '#1A8CCB',
224
+ color: '#fff',
225
+ fontFamily: 'Lato',
226
+ fontSize: '16px',
227
+ fontWeight: '400',
228
+ lineHeight: '16px',
229
+ margin: 'auto',
230
+ },
231
+ },
232
+ },
163
233
  },
164
234
  });