chem-generic-ui 0.1.43 → 0.1.46

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,8 +5,8 @@
5
5
  /* eslint-disable no-restricted-globals */
6
6
 
7
7
  import React from 'react';
8
- import { Button, FormGroup, FormControl,
9
- InputGroup, ListGroup, ListGroupItem, OverlayTrigger, Tooltip } from 'react-bootstrap';
8
+ import { Button, Checkbox, FormGroup, FormControl,
9
+ InputGroup, ListGroup, ListGroupItem, OverlayTrigger, Radio, Tooltip } from 'react-bootstrap';
10
10
  import Select from 'react-select';
11
11
  import Dropzone from 'react-dropzone';
12
12
  import { v4 as uuid } from 'uuid';
@@ -51,12 +51,53 @@ const GenPropertiesCalculate = (opt) => {
51
51
 
52
52
  const fieldHeader = opt.label === '' ? null : (<FieldLabel label={opt.label} desc={opt.description} />);
53
53
  return (
54
- <div>GenPropertiesCalculate</div>
54
+ <FormGroup>
55
+ {fieldHeader}
56
+ <InputGroup>
57
+ <FormControl
58
+ type="text"
59
+ value={showTxt}
60
+ onChange={opt.onChange}
61
+ className="readonly"
62
+ readOnly="readonly"
63
+ required={false}
64
+ placeholder={opt.placeholder}
65
+ min={0}
66
+ />
67
+ <InputGroup.Button>
68
+ <OverlayTrigger
69
+ placement="bottom"
70
+ overlay={<Tooltip id="update_calculation_field">adjust</Tooltip>}
71
+ >
72
+ <Button active className="clipboardBtn" onClick={() => opt.onChange(showTxt)}>
73
+ <i className="fa fa-arrow-right" aria-hidden="true" />
74
+ </Button>
75
+ </OverlayTrigger>
76
+ </InputGroup.Button>
77
+ <FormControl
78
+ type="text"
79
+ value={opt.value}
80
+ onChange={opt.onChange}
81
+ required={false}
82
+ placeholder={opt.placeholder}
83
+ min={0}
84
+ />
85
+ </InputGroup>
86
+ </FormGroup>
55
87
  );
56
88
  };
57
89
 
58
90
  const GenPropertiesCheckbox = opt => (
59
- <div>GenPropertiesCheckbox</div>
91
+ <FormGroup>
92
+ <Checkbox
93
+ name={opt.field}
94
+ checked={opt.value}
95
+ onChange={opt.onChange}
96
+ disabled={opt.readOnly}
97
+ >
98
+ <FormControl.Static>{opt.label}</FormControl.Static>
99
+ </Checkbox>
100
+ </FormGroup>
60
101
  );
61
102
 
62
103
  const GenPropertiesDrop = (opt) => {
@@ -67,13 +108,13 @@ const GenPropertiesDrop = (opt) => {
67
108
  createOpt = (
68
109
  <div className="sample_radios">
69
110
  <OverlayTrigger placement="top" overlay={<Tooltip id={uuid()}>associate with this sample</Tooltip>}>
70
- <InputGroup.Radio name={`dropS_${opt.value.el_id}`} disabled={opt.value.isAssoc === true} checked={opt.value.cr_opt === 0} onChange={() => opt.onChange({ ...opt.value, cr_opt: 0 })} inline>Current</InputGroup.Radio>
111
+ <Radio name={`dropS_${opt.value.el_id}`} disabled={opt.value.isAssoc === true} checked={opt.value.cr_opt === 0} onChange={() => opt.onChange({ ...opt.value, cr_opt: 0 })} inline>Current</Radio>
71
112
  </OverlayTrigger>
72
113
  <OverlayTrigger placement="top" overlay={<Tooltip id={uuid()}>split from the sample first and then associate with it</Tooltip>}>
73
- <InputGroup.Radio name={`dropS_${opt.value.el_id}`} checked={opt.value.cr_opt === 1} onChange={() => opt.onChange({ ...opt.value, cr_opt: 1 })} inline>Split</InputGroup.Radio>
114
+ <Radio name={`dropS_${opt.value.el_id}`} checked={opt.value.cr_opt === 1} onChange={() => opt.onChange({ ...opt.value, cr_opt: 1 })} inline>Split</Radio>
74
115
  </OverlayTrigger>
75
116
  <OverlayTrigger placement="top" overlay={<Tooltip id={uuid()}>duplicate the sample first and then associate with it</Tooltip>}>
76
- <InputGroup.Radio name={`dropS_${opt.value.el_id}`} checked={opt.value.cr_opt === 2} onChange={() => opt.onChange({ ...opt.value, cr_opt: 2 })} inline>Copy</InputGroup.Radio>
117
+ <Radio name={`dropS_${opt.value.el_id}`} checked={opt.value.cr_opt === 2} onChange={() => opt.onChange({ ...opt.value, cr_opt: 2 })} inline>Copy</Radio>
77
118
  </OverlayTrigger>
78
119
  </div>
79
120
  );
@@ -83,7 +124,20 @@ const GenPropertiesDrop = (opt) => {
83
124
  const dragTarget = opt.isPreview === true ? <div className="target">{defaultIcon}</div> : <GenericElDropTarget opt={opt} onDrop={opt.onChange} />;
84
125
 
85
126
  return (
86
- <div>GenPropertiesDrop</div>
127
+ <FormGroup>
128
+ {fieldHeader}
129
+ <FormControl.Static style={{ paddingBottom: '0px' }}>
130
+ <div className={className}>
131
+ {dragTarget}
132
+ {createOpt}
133
+ <div>
134
+ <OverlayTrigger placement="top" overlay={<Tooltip id={uuid()}>remove</Tooltip>}>
135
+ <Button className="btn_del" bsStyle="danger" bsSize="xsmall" onClick={() => opt.onChange({})} ><i className="fa fa-trash-o" aria-hidden="true" /></Button>
136
+ </OverlayTrigger>
137
+ </div>
138
+ </div>
139
+ </FormControl.Static>
140
+ </FormGroup>
87
141
  );
88
142
  };
89
143
 
@@ -101,7 +155,7 @@ const GenPropertiesInputGroup = (opt) => {
101
155
  <span key={`${e.id}_GenPropertiesInputGroup`} className="input-group" style={{ width: '100%' }}>
102
156
  <FormControl key={e.id} type="number" name={e.id} value={e.value} onChange={o => opt.onSubChange(o, e.id, opt.f_obj)} min={1} />
103
157
  <InputGroup.Button>
104
- <Button active onClick={() => opt.onSubChange(e, e.id, opt.f_obj)} variant="success">
158
+ <Button active onClick={() => opt.onSubChange(e, e.id, opt.f_obj)} bsStyle="success">
105
159
  {genUnitSup(genUnit(e.option_layers, e.value_system).label) || ''}
106
160
  </Button>
107
161
  </InputGroup.Button>
@@ -111,7 +165,12 @@ const GenPropertiesInputGroup = (opt) => {
111
165
  if (e.type === 'label') { return fLab(e); } if (e.type === 'system-defined') { return fUnit(e); } return fTxt(e);
112
166
  });
113
167
  return (
114
- <div>GenPropertiesInputGroup</div>
168
+ <FormGroup>
169
+ {fieldHeader}
170
+ <InputGroup style={{ display: 'flex' }}>
171
+ {subs}
172
+ </InputGroup>
173
+ </FormGroup>
115
174
  );
116
175
  };
117
176
 
@@ -179,9 +238,11 @@ const GenPropertiesSystemDefined = (opt) => {
179
238
  placeholder={opt.placeholder}
180
239
  min={1}
181
240
  />
182
- <Button disabled={opt.readOnly} active onClick={opt.onClick} variant="success">
241
+ <InputGroup.Button>
242
+ <Button disabled={opt.readOnly} active onClick={opt.onClick} bsStyle="success">
183
243
  {genUnitSup(genUnit(opt.option_layers, opt.value_system).label) || ''}
184
244
  </Button>
245
+ </InputGroup.Button>
185
246
  </InputGroup>
186
247
  </FormGroup>
187
248
  );
@@ -190,7 +251,10 @@ const GenPropertiesSystemDefined = (opt) => {
190
251
  const GenPropertiesTable = (opt) => {
191
252
  const fieldHeader = opt.label === '' ? null : <FieldLabel label={opt.label} desc={opt.description} />;
192
253
  return (
193
- <div>GenPropertiesTable</div>
254
+ <FormGroup>
255
+ {fieldHeader}
256
+ <TableRecord key={`grid_${opt.f_obj.field}`} opt={opt} />
257
+ </FormGroup>
194
258
  );
195
259
  };
196
260
 
@@ -219,7 +283,18 @@ const GenPropertiesTextArea = (opt) => {
219
283
  className = opt.isRequired && opt.isEditable ? 'required' : className;
220
284
  const fieldHeader = opt.label === '' ? null : <FieldLabel label={opt.label} desc={opt.description} />;
221
285
  return (
222
- <div>GenPropertiesTextArea</div>
286
+ <FormGroup className="text_generic_properties">
287
+ {fieldHeader}
288
+ <FormControl
289
+ componentClass="textarea"
290
+ value={opt.value}
291
+ onChange={opt.onChange}
292
+ className={className}
293
+ readOnly={opt.readOnly}
294
+ required={opt.isRequired}
295
+ placeholder={opt.placeholder}
296
+ />
297
+ </FormGroup>
223
298
  );
224
299
  };
225
300
 
@@ -246,20 +321,45 @@ const GenTextFormula = (opt) => {
246
321
  return true;
247
322
  });
248
323
  return (
249
- <div>GenTextFormula</div>
324
+ <FormGroup className="text_generic_properties">
325
+ {fieldHeader}
326
+ <FormControl
327
+ type="text"
328
+ value={subs.join('')}
329
+ className="readonly"
330
+ readOnly
331
+ required={false}
332
+ />
333
+ </FormGroup>
250
334
  );
251
335
  };
252
336
 
253
337
  const renderListGroupItem = (opt, attachment) => {
254
338
  const delBtn = (
255
- <Button size="xsmall" id={attachment.uid} className="button-right" onClick={() => opt.onChange({ ...opt.value, action: 'd', uid: attachment.uid })}>
339
+ <Button bsSize="xsmall" id={attachment.uid} className="button-right" onClick={() => opt.onChange({ ...opt.value, action: 'd', uid: attachment.uid })}>
256
340
  <i className="fa fa-times" aria-hidden="true" />
257
341
  </Button>
258
342
  );
259
343
  const filename = attachment.aid ?
260
344
  (<a onClick={() => downloadFile({ contents: `/api/v1/attachments/${attachment.aid}`, name: attachment.filename })} style={{ cursor: 'pointer' }}>{attachment.filename}</a>) : attachment.filename;
261
345
  return (
262
- <div>renderListGroupItem</div>
346
+ <div className="generic_grid">
347
+ <div>
348
+ <div>{delBtn}</div>
349
+ <div className="generic_grid_row">{filename}</div>
350
+ <div className="generic_grid_row">
351
+ <FormGroup bsSize="small">
352
+ <FormControl
353
+ type="text"
354
+ value={attachment.label || ''}
355
+ onChange={e => opt.onChange({
356
+ ...opt.value, action: 'l', uid: attachment.uid, val: e
357
+ })}
358
+ />
359
+ </FormGroup>
360
+ </div>
361
+ </div>
362
+ </div>
263
363
  );
264
364
  };
265
365
 
@@ -269,7 +369,29 @@ const GenPropertiesUpload = (opt) => {
269
369
  if (opt.isSearchCriteria) return (<div>(This is an upload)</div>);
270
370
 
271
371
  return (
272
- <div>GenPropertiesUpload</div>
372
+ <FormGroup className="text_generic_properties">
373
+ {fieldHeader}
374
+ <FormControl.Static style={{ paddingBottom: '0px' }}>
375
+ <Dropzone
376
+ id="dropzone"
377
+ onDrop={e => opt.onChange({
378
+ ...opt.value, action: 'f', val: e
379
+ })}
380
+ style={{ height: 30, width: '100%', border: '3px dashed lightgray' }}
381
+ >
382
+ <div style={{ textAlign: 'center', paddingTop: 6, color: 'gray' }}>
383
+ Drop File, or Click to Select.
384
+ </div>
385
+ </Dropzone>
386
+ </FormControl.Static>
387
+ <ListGroup>
388
+ {attachments.map(attachment => (
389
+ <ListGroupItem key={attachment.id} className="generic_files">
390
+ {renderListGroupItem(opt, attachment)}
391
+ </ListGroupItem>
392
+ ))}
393
+ </ListGroup>
394
+ </FormGroup>
273
395
  );
274
396
  };
275
397
 
@@ -3,7 +3,7 @@
3
3
  /* eslint-disable react/forbid-prop-types */
4
4
  import React, { Component } from 'react';
5
5
  import PropTypes from 'prop-types';
6
- import { Card, Col, CardGroup, Row } from 'react-bootstrap';
6
+ import { Panel, Col, PanelGroup, Row } from 'react-bootstrap';
7
7
  import GenProperties from '../fields/GenProperties';
8
8
  import { genUnits, showProperties, unitConversion } from '../tools/utils';
9
9
  import PanelDnD from '../dnd/PanelDnD';
@@ -138,19 +138,21 @@ export default class GenPropertiesLayer extends Component {
138
138
  bs={bs}
139
139
  />);
140
140
  const panelHeader = label === '' ? (<span />) : (
141
- <Card.Heading className={cl}>
142
- <Card.Title toggle>{label}</Card.Title>
143
- </Card.Heading>
141
+ <Panel.Heading className={cl}>
142
+ <Panel.Title toggle>{label}</Panel.Title>
143
+ </Panel.Heading>
144
144
  );
145
145
  const noneKlass = bs === 'none' ? 'generic_panel_none' : '';
146
146
  if (bs === 'none') bs = 'default';
147
147
  return (
148
- <CardGroup id="accordion_generic_layer" defaultActiveKey="1" style={{ marginBottom: '0px' }}>
149
- <Card bg={bs} className={`panel_generic_properties ${noneKlass}`}>
150
-
151
- <Card.Body className="panel_generic_properties_body">{this.views()}</Card.Body>
152
- </Card>
153
- </CardGroup>
148
+ <PanelGroup accordion id="accordion_generic_layer" defaultActiveKey="1" style={{ marginBottom: '0px' }}>
149
+ <Panel bsStyle={bs} className={`panel_generic_properties ${noneKlass}`} eventKey="1">
150
+ {activeWF ? panelDnD : panelHeader}
151
+ <Panel.Collapse>
152
+ <Panel.Body className="panel_generic_properties_body">{this.views()}</Panel.Body>
153
+ </Panel.Collapse>
154
+ </Panel>
155
+ </PanelGroup>
154
156
  );
155
157
  }
156
158
  }
@@ -10,7 +10,7 @@ const block = (layer, fnAdd) => (
10
10
  <div>
11
11
  <div><b>{layer.label}</b><br />({layer.key})</div>
12
12
  <OverlayTrigger delayShow={1000} placement="top" overlay={<Tooltip id="_tooltip_layers">click to add layer</Tooltip>}>
13
- <Button variant="primary" onClick={event => fnAdd(event, layer)}><FontAwesomeIcon icon="fas fa-plus" /></Button>
13
+ <Button bsStyle="primary" onClick={event => fnAdd(event, layer)}><FontAwesomeIcon icon="fas fa-plus" /></Button>
14
14
  </OverlayTrigger>
15
15
  </div>
16
16
  </div>
@@ -23,7 +23,7 @@ const base = (opt, iconClass, onDrop = () => {}, params = {}) => {
23
23
  </OverlayTrigger>
24
24
  <div className="del_btn">
25
25
  <OverlayTrigger delayShow={1000} placement="top" overlay={<Tooltip id={uuid()}>remove this molecule</Tooltip>}>
26
- <Button className="btn_del" size="xsmall" onClick={() => onDrop({}, params)} ><i className="fa fa-trash-o" aria-hidden="true" /></Button>
26
+ <Button className="btn_del" bsSize="xsmall" onClick={() => onDrop({}, params)} ><i className="fa fa-trash-o" aria-hidden="true" /></Button>
27
27
  </OverlayTrigger>
28
28
  </div>
29
29
  </div>
@@ -7,7 +7,7 @@ import GridDnD from '../dnd/GridDnD';
7
7
 
8
8
  const AddRowBtn = ({ addRow }) => (
9
9
  <OverlayTrigger delayShow={1000} placement="top" overlay={<Tooltip id={uuid()}>add entry</Tooltip>}>
10
- <Button onClick={() => addRow()} size="sm" variant="primary"><i className="fa fa-plus" aria-hidden="true" /></Button>
10
+ <Button onClick={() => addRow()} bsSize="xsmall" bsStyle="primary"><i className="fa fa-plus" aria-hidden="true" /></Button>
11
11
  </OverlayTrigger>
12
12
  );
13
13
 
@@ -17,7 +17,7 @@ const DelRowBtn = ({ delRow, node }) => {
17
17
  const { data } = node;
18
18
  return (
19
19
  <OverlayTrigger delayShow={1000} placement="top" overlay={<Tooltip id={uuid()}>remove</Tooltip>}>
20
- <Button onClick={() => delRow(data)} size="sm"><i className="fa fa-times" aria-hidden="true" /></Button>
20
+ <Button onClick={() => delRow(data)} bsSize="xsmall"><i className="fa fa-times" aria-hidden="true" /></Button>
21
21
  </OverlayTrigger>);
22
22
  };
23
23
 
@@ -2,7 +2,7 @@
2
2
  import React from 'react';
3
3
  import PropTypes from 'prop-types';
4
4
  import { v4 as uuid } from 'uuid';
5
- import { OverlayTrigger, InputGroup, Tooltip } from 'react-bootstrap';
5
+ import { OverlayTrigger, Radio, Tooltip } from 'react-bootstrap';
6
6
 
7
7
  const SamOption = (props) => {
8
8
  const { sField, node, onChange } = props;
@@ -13,32 +13,32 @@ const SamOption = (props) => {
13
13
  return (
14
14
  <div className="generic_sam_options">
15
15
  <OverlayTrigger delayShow={1000} placement="right" overlay={<Tooltip id={uuid()}>associate with this sample</Tooltip>}>
16
- <InputGroup.Radio
16
+ <Radio
17
17
  name={`dropS_${rUUID}`}
18
18
  disabled={fValue.isAssoc}
19
19
  checked={fValue.cr_opt === 0}
20
20
  onChange={() => onChange({ node, subField: sField, crOpt: 0 })}
21
21
  >
22
22
  Current
23
- </InputGroup.Radio>
23
+ </Radio>
24
24
  </OverlayTrigger>
25
25
  <OverlayTrigger delayShow={1000} placement="right" overlay={<Tooltip id={uuid()}>split from the sample first and then associate with it</Tooltip>}>
26
- <InputGroup.Radio
26
+ <Radio
27
27
  name={`dropS_${rUUID}`}
28
28
  checked={fValue.cr_opt === 1}
29
29
  onChange={() => onChange({ node, subField: sField, crOpt: 1 })}
30
30
  >
31
31
  Split
32
- </InputGroup.Radio>
32
+ </Radio>
33
33
  </OverlayTrigger>
34
34
  <OverlayTrigger delayShow={1000} placement="right" overlay={<Tooltip id={uuid()}>duplicate the sample first and then associate with it</Tooltip>}>
35
- <InputGroup.Radio
35
+ <Radio
36
36
  name={`dropS_${rUUID}`}
37
37
  checked={fValue.cr_opt === 2}
38
38
  onChange={() => onChange({ node, subField: sField, crOpt: 2 })}
39
39
  >
40
40
  Copy
41
- </InputGroup.Radio>
41
+ </Radio>
42
42
  </OverlayTrigger>
43
43
  </div>
44
44
  );
@@ -9,7 +9,7 @@ const UConverterRenderer = (props) => {
9
9
  if (sField.type !== 'system-defined') return null;
10
10
  const { data } = node;
11
11
  return (
12
- <Button key={`ucr_${data.id}`} active onClick={() => onChange(sField, node)} variant="success">
12
+ <Button key={`ucr_${data.id}`} active onClick={() => onChange(sField, node)} bsStyle="success">
13
13
  {genUnitSup(genUnit(sField.option_layers, data[sField.id].value_system).label) || ''}
14
14
  </Button>
15
15
  );
package/src/index.html CHANGED
@@ -1 +1 @@
1
- <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"/> <meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"/> <meta name="theme-color" content="#000000"/> <title>React with Webpack and Babel</title> </head> <body> <noscript> You need to enable JavaScript to run this app. </noscript> <div id="root"> </div> </body> </html>
1
+ <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"/> <meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"/> <meta name="theme-color" content="#000000"/> <title>React with Webpack and Babel</title> </head> <body> <noscript> You need to enable JavaScript to run this app. </noscript> <div id="generic"> </div> </body> </html>
package/src/index.js CHANGED
@@ -4,7 +4,7 @@ import ReactDOM from 'react-dom';
4
4
  // import 'bootstrap/dist/css/bootstrap.min.css';
5
5
  import './index.css';
6
6
  //import 'bootstrap/dist/css/bootstrap.min.css';
7
- import 'bootstrap/dist/css/bootstrap.css';
7
+ // import 'bootstrap/dist/css/bootstrap.css'; Paggy
8
8
 
9
9
 
10
10
  // import 'bootstrap/dist/css/bootstrap.css';
@@ -29,7 +29,7 @@ ReactDOM.render(
29
29
  <SimuSG />
30
30
  </div>
31
31
  ,
32
- document.getElementById('root')
32
+ document.getElementById('generic')
33
33
  );
34
34
 
35
35
  module.hot.accept();
@@ -11,9 +11,9 @@ class SimuDS extends Component {
11
11
  }
12
12
 
13
13
  componentDidMount() {
14
- fetch('public/ds_details.json', { headers: { 'Content-Type': 'application/json', Accept: 'application/json' } })
14
+ fetch('ds_details.json', { headers: { 'Content-Type': 'application/json', Accept: 'application/json' } })
15
15
  .then(response => response.json()).then((json) => {
16
- fetch('public/ds_klass.json', { headers: { 'Content-Type': 'application/json', Accept: 'application/json' } })
16
+ fetch('ds_klass.json', { headers: { 'Content-Type': 'application/json', Accept: 'application/json' } })
17
17
  .then(response => response.json()).then((kjson) => {
18
18
  this.setState({ genericDS: json, klass: kjson });
19
19
  })
@@ -13,10 +13,10 @@ class SimuSG extends Component {
13
13
  }
14
14
 
15
15
  componentDidMount() {
16
- fetch('public/sg_details.json', { headers: { 'Content-Type': 'application/json', Accept: 'application/json' } })
16
+ fetch('sg_details.json', { headers: { 'Content-Type': 'application/json', Accept: 'application/json' } })
17
17
  .then(response => response.json()).then((json) => {
18
18
  console.log(json);
19
- fetch('public/sg_klass.json', { headers: { 'Content-Type': 'application/json', Accept: 'application/json' } })
19
+ fetch('sg_klass.json', { headers: { 'Content-Type': 'application/json', Accept: 'application/json' } })
20
20
  .then(response => response.json()).then((kjson) => {
21
21
  this.setState({ segment: json, klass: kjson });
22
22
  })
package/webpack.config.js CHANGED
@@ -5,8 +5,9 @@ module.exports = {
5
5
  mode: 'production',
6
6
  entry: {
7
7
  index: [
8
- './src/index.js',
9
- 'bootstrap/dist/css/bootstrap.css'
8
+ './src/app.js',
9
+ // './asserts/bootstrap.min.css',
10
+ // './asserts/bootstrap-theme.min.css'
10
11
  ]
11
12
  },
12
13
  module: {