@performant-software/semantic-components 0.5.13 → 0.5.16-beta.0

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/build/main.css CHANGED
@@ -146,6 +146,10 @@
146
146
  color: rgba(95, 95, 95, 0.86);
147
147
  }
148
148
 
149
+ .audio-player.ui.modal > .content > audio {
150
+ width: 100%;
151
+ }
152
+
149
153
  .color-button.ui.button {
150
154
  border: 1px solid rgba(34, 36, 38, 0.15);
151
155
  vertical-align: middle;
@@ -418,7 +422,30 @@ div.react-calendar {
418
422
  left: 4px;
419
423
  }
420
424
 
425
+ .lazy-audio.ui.segment {
426
+ display: inline-block !important;
427
+ max-width: 100%;
428
+ padding: 0;
429
+ }
430
+ .lazy-audio.ui.segment .buttons {
431
+ display: flex;
432
+ flex-direction: column;
433
+ }
434
+ .lazy-audio.ui.segment .buttons .ui.button {
435
+ margin-top: 5px;
436
+ margin-bottom: 5px;
437
+ }
438
+ .lazy-audio .placeholder-image.ui.image {
439
+ background-color: #f9fafb;
440
+ box-shadow: 0 1px 3px 0 #d4d4d5, 0 0 0 1px #d4d4d5;
441
+ padding-top: 20%;
442
+ padding-bottom: 20%;
443
+ text-align: center;
444
+ }
445
+
421
446
  .lazy-document.ui.segment {
447
+ display: inline-block !important;
448
+ max-width: 100%;
422
449
  padding: 0;
423
450
  }
424
451
  .lazy-document.ui.segment .buttons {
@@ -446,6 +473,8 @@ div.react-calendar {
446
473
  }
447
474
 
448
475
  .lazy-image.ui.segment {
476
+ display: inline-block !important;
477
+ max-width: 100%;
449
478
  padding: 0;
450
479
  }
451
480
  .lazy-image.ui.segment .buttons {
@@ -469,6 +498,8 @@ div.react-calendar {
469
498
  }
470
499
 
471
500
  .lazy-video.ui.segment {
501
+ display: inline-block !important;
502
+ max-width: 100%;
472
503
  padding: 0;
473
504
  }
474
505
  .lazy-video.ui.segment .buttons {
@@ -486,6 +517,10 @@ div.react-calendar {
486
517
  padding-bottom: 20%;
487
518
  text-align: center;
488
519
  }
520
+ .lazy-video.ui.segment > .image > video {
521
+ display: table;
522
+ width: 100%;
523
+ }
489
524
 
490
525
  .listLoader.ui.segment {
491
526
  position: absolute;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@performant-software/semantic-components",
3
- "version": "0.5.13",
3
+ "version": "0.5.16-beta.0",
4
4
  "description": "A package of shared components based on the Semantic UI Framework.",
5
5
  "license": "MIT",
6
6
  "main": "./build/index.js",
@@ -9,10 +9,12 @@
9
9
  "./build/semantic-ui.css"
10
10
  ],
11
11
  "scripts": {
12
- "build": "webpack --mode production && flow-copy-source -v src types"
12
+ "build": "webpack --mode production && flow-copy-source -v src types",
13
+ "publish": "npm publish",
14
+ "publish-beta": "npm publish --tag beta"
13
15
  },
14
16
  "dependencies": {
15
- "@performant-software/shared-components": "^0.5.13",
17
+ "@performant-software/shared-components": "^0.5.16-beta.0",
16
18
  "@react-google-maps/api": "^2.8.1",
17
19
  "axios": "^0.26.1",
18
20
  "i18next": "^19.4.4",
@@ -33,7 +35,7 @@
33
35
  "react-dom": ">= 16.13.1 < 18.0.0"
34
36
  },
35
37
  "devDependencies": {
36
- "@performant-software/webpack-config": "^0.5.13",
38
+ "@performant-software/webpack-config": "^0.5.16-beta.0",
37
39
  "flow-copy-source": "^2.0.9",
38
40
  "less": "^4.1.2",
39
41
  "less-loader": "^11.0.0",
@@ -0,0 +1,3 @@
1
+ .audio-player.ui.modal > .content > audio {
2
+ width: 100%;
3
+ }
@@ -0,0 +1,36 @@
1
+ // @flow
2
+
3
+ import React from 'react';
4
+ import { Button, Modal } from 'semantic-ui-react';
5
+ import i18n from '../i18n/i18n';
6
+ import './AudioPlayer.css';
7
+
8
+ type Props = {
9
+ centered?: boolean,
10
+ onClose: () => void,
11
+ open: boolean,
12
+ src: string
13
+ };
14
+
15
+ const AudioPlayer = (props: Props) => (
16
+ <Modal
17
+ centered={props.centered}
18
+ className='audio-player'
19
+ open={props.open}
20
+ >
21
+ <Modal.Content>
22
+ <audio
23
+ controls
24
+ src={props.src}
25
+ />
26
+ </Modal.Content>
27
+ <Modal.Actions>
28
+ <Button
29
+ content={i18n.t('Common.buttons.close')}
30
+ onClick={props.onClose}
31
+ />
32
+ </Modal.Actions>
33
+ </Modal>
34
+ );
35
+
36
+ export default AudioPlayer;
@@ -0,0 +1,23 @@
1
+ .lazy-audio.ui.segment {
2
+ display: inline-block !important;
3
+ max-width: 100%;
4
+ padding: 0;
5
+ }
6
+
7
+ .lazy-audio.ui.segment .buttons {
8
+ display: flex;
9
+ flex-direction: column;
10
+ }
11
+
12
+ .lazy-audio.ui.segment .buttons .ui.button {
13
+ margin-top: 5px;
14
+ margin-bottom: 5px;
15
+ }
16
+
17
+ .lazy-audio .placeholder-image.ui.image {
18
+ background-color: #f9fafb;
19
+ box-shadow: 0 1px 3px 0 #d4d4d5, 0 0 0 1px #d4d4d5;
20
+ padding-top: 20%;
21
+ padding-bottom: 20%;
22
+ text-align: center;
23
+ }
@@ -0,0 +1,123 @@
1
+ // @flow
2
+
3
+ import React, { useState, type Node } from 'react';
4
+ import {
5
+ Button,
6
+ Dimmer,
7
+ Icon,
8
+ Image,
9
+ Loader,
10
+ Segment,
11
+ Transition,
12
+ Visibility
13
+ } from 'semantic-ui-react';
14
+ import i18n from '../i18n/i18n';
15
+ import AudioPlayer from './AudioPlayer';
16
+ import './LazyAudio.css';
17
+
18
+ type Props = {
19
+ children?: Node,
20
+ dimmable: boolean,
21
+ duration?: number,
22
+ image?: any,
23
+ preview?: string,
24
+ size?: string,
25
+ src?: string
26
+ };
27
+
28
+ const LazyAudio = (props: Props) => {
29
+ const [visible, setVisible] = useState(false);
30
+ const [modal, setModal] = useState(false);
31
+ const [dimmer, setDimmer] = useState(false);
32
+
33
+ if (!visible) {
34
+ return (
35
+ <Visibility
36
+ as='span'
37
+ fireOnMount
38
+ onTopVisible={() => setVisible(true)}
39
+ >
40
+ <Loader
41
+ active
42
+ inline='centered'
43
+ size={props.size}
44
+ />
45
+ </Visibility>
46
+ );
47
+ }
48
+
49
+ return (
50
+ <>
51
+ <Transition
52
+ duration={props.duration}
53
+ visible
54
+ >
55
+ <Dimmer.Dimmable
56
+ as={Segment}
57
+ className='lazy-audio'
58
+ compact
59
+ onBlur={() => setDimmer(false)}
60
+ onMouseEnter={() => setDimmer(true)}
61
+ onMouseLeave={() => setDimmer(false)}
62
+ >
63
+ { props.preview && (
64
+ <Image
65
+ {...props.image}
66
+ size={props.size}
67
+ src={props.preview}
68
+ />
69
+ )}
70
+ { !props.preview && (
71
+ <Image
72
+ {...props.image}
73
+ className='placeholder-image'
74
+ size={props.size}
75
+ >
76
+ <Icon
77
+ name='file audio outline'
78
+ size='big'
79
+ />
80
+ </Image>
81
+ )}
82
+ { (props.src || props.children) && props.dimmable && (
83
+ <Dimmer
84
+ active={dimmer}
85
+ >
86
+ <div
87
+ className='buttons'
88
+ >
89
+ { props.src && (
90
+ <Button
91
+ content={i18n.t('LazyAudio.buttons.play')}
92
+ icon='play circle outline'
93
+ onClick={() => setModal(true)}
94
+ primary
95
+ />
96
+ )}
97
+ { props.children }
98
+ </div>
99
+ </Dimmer>
100
+ )}
101
+ </Dimmer.Dimmable>
102
+ </Transition>
103
+ { props.src && (
104
+ <AudioPlayer
105
+ onClose={() => setModal(false)}
106
+ open={modal}
107
+ size='large'
108
+ src={props.src}
109
+ />
110
+ )}
111
+ </>
112
+ );
113
+ };
114
+
115
+ LazyAudio.defaultProps = {
116
+ dimmable: true,
117
+ duration: 1000,
118
+ preview: undefined,
119
+ size: 'medium',
120
+ src: undefined
121
+ };
122
+
123
+ export default LazyAudio;
@@ -1,4 +1,6 @@
1
1
  .lazy-document.ui.segment {
2
+ display: inline-block !important;
3
+ max-width: 100%;
2
4
  padding: 0;
3
5
  }
4
6
 
@@ -1,6 +1,6 @@
1
1
  // @flow
2
2
 
3
- import React, { useState, useEffect, type Node } from 'react';
3
+ import React, { useState, type Node } from 'react';
4
4
  import { Document, Page } from 'react-pdf/dist/esm/entry.webpack';
5
5
  import {
6
6
  Dimmer,
@@ -20,6 +20,7 @@ type Props = {
20
20
  dimmable?: boolean,
21
21
  duration?: number,
22
22
  image?: any,
23
+ pdf?: boolean,
23
24
  preview?: ?string,
24
25
  size?: string,
25
26
  src?: string
@@ -28,15 +29,6 @@ type Props = {
28
29
  const LazyDocument = (props: Props) => {
29
30
  const [visible, setVisible] = useState(false);
30
31
  const [dimmer, setDimmer] = useState(false);
31
- const [contentType, setContentType] = useState('');
32
-
33
- useEffect(() => {
34
- if (props.src && !props.preview) {
35
- fetch(props.src)
36
- .then((response) => response.blob())
37
- .then((blob) => setContentType(blob.type));
38
- }
39
- }, [props.preview, props.src]);
40
32
 
41
33
  if (!visible) {
42
34
  return (
@@ -75,7 +67,7 @@ const LazyDocument = (props: Props) => {
75
67
  size={props.size}
76
68
  />
77
69
  )}
78
- { !props.preview && props.src && contentType === 'application/pdf' && (
70
+ { !props.preview && props.src && props.pdf && (
79
71
  <Image
80
72
  {...props.image}
81
73
  size={props.size}
@@ -89,7 +81,7 @@ const LazyDocument = (props: Props) => {
89
81
  </Document>
90
82
  </Image>
91
83
  )}
92
- { !props.preview && (!props.src || contentType !== 'application/pdf') && (
84
+ { !props.preview && !(props.src && props.pdf) && (
93
85
  <Image
94
86
  {...props.image}
95
87
  className='placeholder-image'
@@ -113,7 +105,7 @@ const LazyDocument = (props: Props) => {
113
105
  content={i18n.t('LazyDocument.buttons.download')}
114
106
  icon='cloud download'
115
107
  primary
116
- url={props.src || ''}
108
+ url={props.src}
117
109
  />
118
110
  )}
119
111
  { props.children }
@@ -129,6 +121,7 @@ const LazyDocument = (props: Props) => {
129
121
  LazyDocument.defaultProps = {
130
122
  dimmable: true,
131
123
  duration: 1000,
124
+ pdf: false,
132
125
  preview: undefined,
133
126
  size: 'medium',
134
127
  src: undefined
@@ -1,4 +1,6 @@
1
1
  .lazy-image.ui.segment {
2
+ display: inline-block !important;
3
+ max-width: 100%;
2
4
  padding: 0;
3
5
  }
4
6
 
@@ -18,4 +20,4 @@
18
20
  padding-top: 20%;
19
21
  padding-bottom: 20%;
20
22
  text-align: center;
21
- }
23
+ }
@@ -60,14 +60,14 @@ const LazyImage = (props: Props) => {
60
60
  onMouseEnter={() => setDimmer(true)}
61
61
  onMouseLeave={() => setDimmer(false)}
62
62
  >
63
- { props.src && (
63
+ { (props.preview || props.src) && (
64
64
  <Image
65
65
  {...props.image}
66
66
  size={props.size}
67
67
  src={props.preview || props.src}
68
68
  />
69
69
  )}
70
- { !props.src && (
70
+ { !(props.preview || props.src) && (
71
71
  <Image
72
72
  {...props.image}
73
73
  className='placeholder-image'
@@ -100,12 +100,14 @@ const LazyImage = (props: Props) => {
100
100
  )}
101
101
  </Dimmer.Dimmable>
102
102
  </Transition>
103
- <PhotoViewer
104
- image={props.src || ''}
105
- onClose={() => setModal(false)}
106
- open={modal}
107
- size='large'
108
- />
103
+ { props.src && (
104
+ <PhotoViewer
105
+ image={props.src}
106
+ onClose={() => setModal(false)}
107
+ open={modal}
108
+ size='large'
109
+ />
110
+ )}
109
111
  </>
110
112
  );
111
113
  };
@@ -1,4 +1,6 @@
1
1
  .lazy-video.ui.segment {
2
+ display: inline-block !important;
3
+ max-width: 100%;
2
4
  padding: 0;
3
5
  }
4
6
 
@@ -18,4 +20,9 @@
18
20
  padding-top: 20%;
19
21
  padding-bottom: 20%;
20
22
  text-align: center;
21
- }
23
+ }
24
+
25
+ .lazy-video.ui.segment > .image > video {
26
+ display: table;
27
+ width: 100%;
28
+ }
@@ -50,12 +50,15 @@ const ReferenceCodeFormDropdown: ComponentType<any> = (props: Props) => {
50
50
  { modal && (
51
51
  <EditModal
52
52
  component={ReferenceTableModal}
53
- item={{ id: referenceTable }}
53
+ item={{ id: referenceTable, key: referenceTable }}
54
54
  onClose={() => setModal(false)}
55
55
  onInitialize={(key) => (
56
56
  ReferenceTablesService
57
57
  .fetchByKey(key)
58
- .then(({ data }) => data.reference_table)
58
+ .then(({ data }) => ({
59
+ ...data.reference_table,
60
+ key
61
+ }))
59
62
  )}
60
63
  onSave={(record) => (
61
64
  ReferenceTablesService
package/src/i18n/en.json CHANGED
@@ -135,6 +135,11 @@
135
135
  "value": "Value"
136
136
  }
137
137
  },
138
+ "LazyAudio": {
139
+ "buttons": {
140
+ "play": "Play"
141
+ }
142
+ },
138
143
  "LazyDocument": {
139
144
  "buttons": {
140
145
  "download": "Download"
package/src/index.js CHANGED
@@ -9,6 +9,7 @@ export { default as AccordionList } from './components/AccordionList';
9
9
  export { default as AccordionSelector } from './components/AccordionSelector';
10
10
  export { default as ArrowButtons } from './components/ArrowButtons';
11
11
  export { default as AssociatedDropdown } from './components/AssociatedDropdown';
12
+ export { default as AudioPlayer } from './components/AudioPlayer';
12
13
  export { default as BooleanIcon } from './components/BooleanIcon';
13
14
  export { default as CancelButton } from './components/CancelButton';
14
15
  export { default as ColorButton } from './components/ColorButton';
@@ -39,6 +40,7 @@ export { default as ItemList } from './components/ItemList';
39
40
  export { default as Items } from './components/Items';
40
41
  export { default as KeyboardField } from './components/KeyboardField';
41
42
  export { default as KeyValuePairs } from './components/KeyValuePairs';
43
+ export { default as LazyAudio } from './components/LazyAudio';
42
44
  export { default as LazyDocument } from './components/LazyDocument';
43
45
  export { default as LazyImage } from './components/LazyImage';
44
46
  export { default as LazyVideo } from './components/LazyVideo';
@@ -0,0 +1,36 @@
1
+ // @flow
2
+
3
+ import React from 'react';
4
+ import { Button, Modal } from 'semantic-ui-react';
5
+ import i18n from '../i18n/i18n';
6
+ import './AudioPlayer.css';
7
+
8
+ type Props = {
9
+ centered?: boolean,
10
+ onClose: () => void,
11
+ open: boolean,
12
+ src: string
13
+ };
14
+
15
+ const AudioPlayer = (props: Props) => (
16
+ <Modal
17
+ centered={props.centered}
18
+ className='audio-player'
19
+ open={props.open}
20
+ >
21
+ <Modal.Content>
22
+ <audio
23
+ controls
24
+ src={props.src}
25
+ />
26
+ </Modal.Content>
27
+ <Modal.Actions>
28
+ <Button
29
+ content={i18n.t('Common.buttons.close')}
30
+ onClick={props.onClose}
31
+ />
32
+ </Modal.Actions>
33
+ </Modal>
34
+ );
35
+
36
+ export default AudioPlayer;
@@ -0,0 +1,123 @@
1
+ // @flow
2
+
3
+ import React, { useState, type Node } from 'react';
4
+ import {
5
+ Button,
6
+ Dimmer,
7
+ Icon,
8
+ Image,
9
+ Loader,
10
+ Segment,
11
+ Transition,
12
+ Visibility
13
+ } from 'semantic-ui-react';
14
+ import i18n from '../i18n/i18n';
15
+ import AudioPlayer from './AudioPlayer';
16
+ import './LazyAudio.css';
17
+
18
+ type Props = {
19
+ children?: Node,
20
+ dimmable: boolean,
21
+ duration?: number,
22
+ image?: any,
23
+ preview?: string,
24
+ size?: string,
25
+ src?: string
26
+ };
27
+
28
+ const LazyAudio = (props: Props) => {
29
+ const [visible, setVisible] = useState(false);
30
+ const [modal, setModal] = useState(false);
31
+ const [dimmer, setDimmer] = useState(false);
32
+
33
+ if (!visible) {
34
+ return (
35
+ <Visibility
36
+ as='span'
37
+ fireOnMount
38
+ onTopVisible={() => setVisible(true)}
39
+ >
40
+ <Loader
41
+ active
42
+ inline='centered'
43
+ size={props.size}
44
+ />
45
+ </Visibility>
46
+ );
47
+ }
48
+
49
+ return (
50
+ <>
51
+ <Transition
52
+ duration={props.duration}
53
+ visible
54
+ >
55
+ <Dimmer.Dimmable
56
+ as={Segment}
57
+ className='lazy-audio'
58
+ compact
59
+ onBlur={() => setDimmer(false)}
60
+ onMouseEnter={() => setDimmer(true)}
61
+ onMouseLeave={() => setDimmer(false)}
62
+ >
63
+ { props.preview && (
64
+ <Image
65
+ {...props.image}
66
+ size={props.size}
67
+ src={props.preview}
68
+ />
69
+ )}
70
+ { !props.preview && (
71
+ <Image
72
+ {...props.image}
73
+ className='placeholder-image'
74
+ size={props.size}
75
+ >
76
+ <Icon
77
+ name='file audio outline'
78
+ size='big'
79
+ />
80
+ </Image>
81
+ )}
82
+ { (props.src || props.children) && props.dimmable && (
83
+ <Dimmer
84
+ active={dimmer}
85
+ >
86
+ <div
87
+ className='buttons'
88
+ >
89
+ { props.src && (
90
+ <Button
91
+ content={i18n.t('LazyAudio.buttons.play')}
92
+ icon='play circle outline'
93
+ onClick={() => setModal(true)}
94
+ primary
95
+ />
96
+ )}
97
+ { props.children }
98
+ </div>
99
+ </Dimmer>
100
+ )}
101
+ </Dimmer.Dimmable>
102
+ </Transition>
103
+ { props.src && (
104
+ <AudioPlayer
105
+ onClose={() => setModal(false)}
106
+ open={modal}
107
+ size='large'
108
+ src={props.src}
109
+ />
110
+ )}
111
+ </>
112
+ );
113
+ };
114
+
115
+ LazyAudio.defaultProps = {
116
+ dimmable: true,
117
+ duration: 1000,
118
+ preview: undefined,
119
+ size: 'medium',
120
+ src: undefined
121
+ };
122
+
123
+ export default LazyAudio;