@performant-software/semantic-components 0.5.5 → 0.5.6

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.
@@ -12,6 +12,7 @@ import {
12
12
  Modal
13
13
  } from 'semantic-ui-react';
14
14
  import i18n from '../i18n/i18n';
15
+ import ModalContext from '../context/ModalContext';
15
16
  import './LoginModal.css';
16
17
 
17
18
  type Props = {
@@ -27,72 +28,78 @@ type Props = {
27
28
  };
28
29
 
29
30
  const LoginModal = (props: Props) => (
30
- <Modal
31
- as={Form}
32
- className='login-modal'
33
- error={props.loginFailed}
34
- open={props.open}
35
- size='small'
36
- trigger={props.trigger}
37
- >
38
- <Header
39
- icon='user circle'
40
- content={i18n.t('LoginModal.header')}
41
- />
42
- <Message
43
- error
44
- header={i18n.t('LoginModal.loginErrorHeader')}
45
- content={i18n.t('LoginModal.loginErrorContent')}
46
- />
47
- <Grid
48
- padded='vertically'
49
- textAlign='center'
50
- >
51
- <Grid.Column>
52
- <Grid.Row>
53
- <Input
54
- autoFocus
55
- className='form-field'
56
- icon={<Icon name='at' />}
57
- onChange={props.onUsernameChange.bind(this)}
58
- placeholder={props.placeholder}
59
- size='huge'
60
- />
61
- </Grid.Row>
62
- <Grid.Row
63
- className='row'
64
- >
65
- <Input
66
- className='form-field'
67
- icon={<Icon name='lock' />}
68
- onChange={props.onPasswordChange.bind(this)}
69
- placeholder={i18n.t('LoginModal.password')}
70
- size='huge'
71
- type='password'
72
- />
73
- </Grid.Row>
74
- </Grid.Column>
75
- </Grid>
76
- <Modal.Actions>
77
- <Button
78
- disabled={props.disabled}
79
- onClick={props.onLogin.bind(this)}
80
- primary
81
- size='large'
82
- type='submit'
83
- >
84
- { i18n.t('LoginModal.buttonLogin') }
85
- </Button>
86
- <Button
87
- inverted
88
- onClick={props.onClose.bind(this)}
89
- primary
90
- size='large'
31
+ <ModalContext.Consumer>
32
+ { (mountNode) => (
33
+ <Modal
34
+ as={Form}
35
+ className='login-modal'
36
+ error={props.loginFailed}
37
+ mountNode={mountNode}
38
+ open={props.open}
39
+ size='small'
40
+ trigger={props.trigger}
91
41
  >
92
- { i18n.t('LoginModal.buttonCancel') }
93
- </Button>
94
- </Modal.Actions>
95
- </Modal>
42
+ <Header
43
+ icon='user circle'
44
+ content={i18n.t('LoginModal.header')}
45
+ />
46
+ <Message
47
+ error
48
+ header={i18n.t('LoginModal.loginErrorHeader')}
49
+ content={i18n.t('LoginModal.loginErrorContent')}
50
+ />
51
+ <Grid
52
+ padded='vertically'
53
+ textAlign='center'
54
+ >
55
+ <Grid.Column>
56
+ <Grid.Row>
57
+ <Input
58
+ autoFocus
59
+ className='form-field'
60
+ icon={<Icon name='at' />}
61
+ onChange={props.onUsernameChange.bind(this)}
62
+ placeholder={props.placeholder}
63
+ size='huge'
64
+ />
65
+ </Grid.Row>
66
+ <Grid.Row
67
+ className='row'
68
+ >
69
+ <Input
70
+ className='form-field'
71
+ icon={<Icon name='lock' />}
72
+ onChange={props.onPasswordChange.bind(this)}
73
+ placeholder={i18n.t('LoginModal.password')}
74
+ size='huge'
75
+ type='password'
76
+ />
77
+ </Grid.Row>
78
+ </Grid.Column>
79
+ </Grid>
80
+ <Modal.Actions>
81
+ <Button
82
+ disabled={props.disabled}
83
+ onClick={props.onLogin.bind(this)}
84
+ primary
85
+ size='large'
86
+ type='submit'
87
+ >
88
+ { i18n.t('LoginModal.buttonLogin') }
89
+ </Button>
90
+ { props.onClose && (
91
+ <Button
92
+ basic
93
+ onClick={props.onClose.bind(this)}
94
+ size='large'
95
+ >
96
+ { i18n.t('LoginModal.buttonCancel') }
97
+ </Button>
98
+ )}
99
+ </Modal.Actions>
100
+ </Modal>
101
+ )}
102
+ </ModalContext.Consumer>
96
103
  );
97
104
 
98
105
  LoginModal.defaultProps = {
@@ -53,6 +53,7 @@ const MenuBar = ({ header, items, ...props }: Props) => {
53
53
  aria-label={item.content}
54
54
  item
55
55
  key={index}
56
+ role='group'
56
57
  text={item.content}
57
58
  >
58
59
  { _.map(item.items, (i) => (i.items ? renderDropdown(i) : renderDropdownItem(i)))}
@@ -2,9 +2,11 @@
2
2
 
3
3
  import React from 'react';
4
4
  import { Image, Modal } from 'semantic-ui-react';
5
+ import ModalContext from '../context/ModalContext';
5
6
  import './PhotoViewer.css';
6
7
 
7
8
  type Props = {
9
+ alt?: string,
8
10
  image: string,
9
11
  onClose: () => void,
10
12
  open: boolean,
@@ -12,21 +14,27 @@ type Props = {
12
14
  };
13
15
 
14
16
  const PhotoViewer = (props: Props) => (
15
- <Modal
16
- centered={false}
17
- className='photo-viewer'
18
- closeIcon
19
- onClose={props.onClose.bind(this)}
20
- open={props.open}
21
- size={props.size}
22
- >
23
- <Modal.Content>
24
- <Image
25
- fluid
26
- src={props.image}
27
- />
28
- </Modal.Content>
29
- </Modal>
17
+ <ModalContext.Consumer>
18
+ { (mountNode) => (
19
+ <Modal
20
+ centered={false}
21
+ className='photo-viewer'
22
+ closeIcon
23
+ mountNode={mountNode}
24
+ onClose={props.onClose.bind(this)}
25
+ open={props.open}
26
+ size={props.size}
27
+ >
28
+ <Modal.Content>
29
+ <Image
30
+ alt={props.alt}
31
+ fluid
32
+ src={props.image}
33
+ />
34
+ </Modal.Content>
35
+ </Modal>
36
+ )}
37
+ </ModalContext.Consumer>
30
38
  );
31
39
 
32
40
  PhotoViewer.defaultProps = {
@@ -4,29 +4,35 @@ import type { EditContainerProps } from '@performant-software/shared-components'
4
4
  import React from 'react';
5
5
  import { Form, Modal } from 'semantic-ui-react';
6
6
  import i18n from '../i18n/i18n';
7
+ import ModalContext from '../context/ModalContext';
7
8
 
8
9
  const ReferenceCodeModal = (props: EditContainerProps) => (
9
- <Modal
10
- as={Form}
11
- centered={false}
12
- open
13
- >
14
- <Modal.Header
15
- content={props.item.id
16
- ? i18n.t('ReferenceCodeModal.title.edit')
17
- : i18n.t('ReferenceCodeModal.title.add')}
18
- />
19
- <Modal.Content>
20
- <Form.Input
21
- error={props.isError('name')}
22
- label={i18n.t('ReferenceCodeModal.labels.name')}
23
- onChange={props.onTextInputChange.bind(this, 'name')}
24
- required={props.isRequired('name')}
25
- value={props.item.name}
26
- />
27
- </Modal.Content>
28
- { props.children }
29
- </Modal>
10
+ <ModalContext.Consumer>
11
+ { (mountNode) => (
12
+ <Modal
13
+ as={Form}
14
+ centered={false}
15
+ mountNode={mountNode}
16
+ open
17
+ >
18
+ <Modal.Header
19
+ content={props.item.id
20
+ ? i18n.t('ReferenceCodeModal.title.edit')
21
+ : i18n.t('ReferenceCodeModal.title.add')}
22
+ />
23
+ <Modal.Content>
24
+ <Form.Input
25
+ error={props.isError('name')}
26
+ label={i18n.t('ReferenceCodeModal.labels.name')}
27
+ onChange={props.onTextInputChange.bind(this, 'name')}
28
+ required={props.isRequired('name')}
29
+ value={props.item.name}
30
+ />
31
+ </Modal.Content>
32
+ { props.children }
33
+ </Modal>
34
+ )}
35
+ </ModalContext.Consumer>
30
36
  );
31
37
 
32
38
  export default ReferenceCodeModal;
@@ -3,65 +3,71 @@
3
3
  import type { EditContainerProps } from '@performant-software/shared-components';
4
4
  import React from 'react';
5
5
  import { Form, Header, Modal } from 'semantic-ui-react';
6
+ import i18n from '../i18n/i18n';
6
7
  import EmbeddedList from './EmbeddedList';
8
+ import ModalContext from '../context/ModalContext';
7
9
  import ReferenceCodeModal from './ReferenceCodeModal';
8
- import i18n from '../i18n/i18n';
9
10
 
10
11
  const ReferenceTableModal = (props: EditContainerProps) => (
11
- <Modal
12
- as={Form}
13
- centered={false}
14
- className='reference-table-modal'
15
- open
16
- >
17
- <Modal.Header
18
- content={props.item.id
19
- ? i18n.t('ReferenceTableModal.title.edit')
20
- : i18n.t('ReferenceTableModal.title.add')}
21
- />
22
- <Modal.Content>
23
- <Form.Input
24
- error={props.isError('name')}
25
- label={i18n.t('ReferenceTableModal.labels.name')}
26
- onChange={props.onTextInputChange.bind(this, 'name')}
27
- required={props.isRequired('name')}
28
- value={props.item.name}
29
- />
30
- <Form.Input
31
- error={props.isError('key')}
32
- label={i18n.t('ReferenceTableModal.labels.key')}
33
- onChange={props.onTextInputChange.bind(this, 'key')}
34
- required={props.isRequired('key')}
35
- value={props.item.key}
36
- />
37
- <Header
38
- content={i18n.t('ReferenceTableModal.labels.referenceCodes')}
39
- />
40
- <EmbeddedList
41
- actions={[{
42
- name: 'edit'
43
- }, {
44
- name: 'copy'
45
- }, {
46
- name: 'delete'
47
- }]}
48
- columns={[{
49
- name: 'name',
50
- label: i18n.t('ReferenceTableModal.referenceCodes.columns.name')
51
- }]}
52
- items={props.item.reference_codes}
53
- modal={{
54
- component: ReferenceCodeModal,
55
- props: {
56
- required: ['name']
57
- }
58
- }}
59
- onDelete={props.onDeleteChildAssociation.bind(this, 'reference_codes')}
60
- onSave={props.onSaveChildAssociation.bind(this, 'reference_codes')}
61
- />
62
- </Modal.Content>
63
- { props.children }
64
- </Modal>
12
+ <ModalContext.Consumer>
13
+ { (mountNode) => (
14
+ <Modal
15
+ as={Form}
16
+ centered={false}
17
+ className='reference-table-modal'
18
+ mountNode={mountNode}
19
+ open
20
+ >
21
+ <Modal.Header
22
+ content={props.item.id
23
+ ? i18n.t('ReferenceTableModal.title.edit')
24
+ : i18n.t('ReferenceTableModal.title.add')}
25
+ />
26
+ <Modal.Content>
27
+ <Form.Input
28
+ error={props.isError('name')}
29
+ label={i18n.t('ReferenceTableModal.labels.name')}
30
+ onChange={props.onTextInputChange.bind(this, 'name')}
31
+ required={props.isRequired('name')}
32
+ value={props.item.name}
33
+ />
34
+ <Form.Input
35
+ error={props.isError('key')}
36
+ label={i18n.t('ReferenceTableModal.labels.key')}
37
+ onChange={props.onTextInputChange.bind(this, 'key')}
38
+ required={props.isRequired('key')}
39
+ value={props.item.key}
40
+ />
41
+ <Header
42
+ content={i18n.t('ReferenceTableModal.labels.referenceCodes')}
43
+ />
44
+ <EmbeddedList
45
+ actions={[{
46
+ name: 'edit'
47
+ }, {
48
+ name: 'copy'
49
+ }, {
50
+ name: 'delete'
51
+ }]}
52
+ columns={[{
53
+ name: 'name',
54
+ label: i18n.t('ReferenceTableModal.referenceCodes.columns.name')
55
+ }]}
56
+ items={props.item.reference_codes}
57
+ modal={{
58
+ component: ReferenceCodeModal,
59
+ props: {
60
+ required: ['name']
61
+ }
62
+ }}
63
+ onDelete={props.onDeleteChildAssociation.bind(this, 'reference_codes')}
64
+ onSave={props.onSaveChildAssociation.bind(this, 'reference_codes')}
65
+ />
66
+ </Modal.Content>
67
+ { props.children }
68
+ </Modal>
69
+ )}
70
+ </ModalContext.Consumer>
65
71
  );
66
72
 
67
73
  export default ReferenceTableModal;
@@ -18,9 +18,10 @@ import {
18
18
  import _ from 'underscore';
19
19
  import SelectizeHeader from './SelectizeHeader';
20
20
  import i18n from '../i18n/i18n';
21
+ import ModalContext from '../context/ModalContext';
21
22
  import useDataList from './DataList';
22
- import './Selectize.css';
23
23
  import useList, { type Props as ListProps } from './List';
24
+ import './Selectize.css';
24
25
 
25
26
  type Props = {
26
27
  centered?: boolean,
@@ -238,51 +239,55 @@ const Selectize = (props: Props) => {
238
239
  }, [onSelect, props.modal]);
239
240
 
240
241
  return (
241
- <Modal
242
- as={Form}
243
- centered={props.centered}
244
- className='selectize'
245
- open
246
- noValidate
247
- size='small'
248
- >
249
- <Modal.Header
250
- content={props.title}
251
- />
252
- <Modal.Content>
253
- <SelectizeGrid
254
- {...props}
255
- actions={[]}
256
- isSelected={isSelected}
257
- onDelete={() => Promise.resolve()}
258
- onDeleteAll={() => Promise.resolve()}
259
- onItemSelection={onItemSelection}
260
- onSave={onSave}
261
- onSelect={onSelect}
262
- selectedItem={selectedItem}
263
- selectedItems={selectedItems}
264
- />
265
- </Modal.Content>
266
- <Modal.Actions>
267
- <Button
268
- onClick={props.onSave.bind(this, selectedItems)}
269
- primary
270
- size='medium'
271
- type='submit'
272
- >
273
- { i18n.t('Common.buttons.save') }
274
- </Button>
275
- <Button
276
- inverted
277
- onClick={props.onClose.bind(this)}
278
- primary
279
- size='medium'
280
- type='button'
242
+ <ModalContext.Consumer>
243
+ { (mountNode) => (
244
+ <Modal
245
+ as={Form}
246
+ centered={props.centered}
247
+ className='selectize'
248
+ mountNode={mountNode}
249
+ noValidate
250
+ open
251
+ size='small'
281
252
  >
282
- { i18n.t('Common.buttons.cancel') }
283
- </Button>
284
- </Modal.Actions>
285
- </Modal>
253
+ <Modal.Header
254
+ content={props.title}
255
+ />
256
+ <Modal.Content>
257
+ <SelectizeGrid
258
+ {...props}
259
+ actions={[]}
260
+ isSelected={isSelected}
261
+ onDelete={() => Promise.resolve()}
262
+ onDeleteAll={() => Promise.resolve()}
263
+ onItemSelection={onItemSelection}
264
+ onSave={onSave}
265
+ onSelect={onSelect}
266
+ selectedItem={selectedItem}
267
+ selectedItems={selectedItems}
268
+ />
269
+ </Modal.Content>
270
+ <Modal.Actions>
271
+ <Button
272
+ onClick={props.onSave.bind(this, selectedItems)}
273
+ primary
274
+ size='medium'
275
+ type='submit'
276
+ >
277
+ { i18n.t('Common.buttons.save') }
278
+ </Button>
279
+ <Button
280
+ basic
281
+ onClick={props.onClose.bind(this)}
282
+ size='medium'
283
+ type='button'
284
+ >
285
+ { i18n.t('Common.buttons.cancel') }
286
+ </Button>
287
+ </Modal.Actions>
288
+ </Modal>
289
+ )}
290
+ </ModalContext.Consumer>
286
291
  );
287
292
  };
288
293
 
@@ -4,6 +4,7 @@ import { Element } from '@performant-software/shared-components';
4
4
  import React, { Component, type Node } from 'react';
5
5
  import { Header, Menu, Modal } from 'semantic-ui-react';
6
6
  import _ from 'underscore';
7
+ import ModalContext from '../context/ModalContext';
7
8
  import './TabbedModal.css';
8
9
 
9
10
  type Props = {
@@ -84,32 +85,37 @@ class TabbedModal extends Component<Props, State> {
84
85
  const tab = _.find(tabs, (t) => t.props.name === this.state.tab);
85
86
 
86
87
  return (
87
- <Modal
88
- className={this.getModalClasses()}
89
- {..._.omit(this.props, 'header', 'renderHeader', 'inlineTabs', 'className')}
90
- >
91
- <Modal.Header
92
- className={this.getHeaderClasses()}
93
- >
94
- { this.renderHeader() }
95
- <Menu
96
- float='right'
97
- secondary
88
+ <ModalContext.Consumer>
89
+ { (mountNode) => (
90
+ <Modal
91
+ className={this.getModalClasses()}
92
+ mountNode={mountNode}
93
+ {..._.omit(this.props, 'header', 'renderHeader', 'inlineTabs', 'className')}
98
94
  >
99
- { _.map(Element.findByType(this.props.children, TabbedModal.Tab), this.renderTab.bind(this)) }
100
- </Menu>
101
- </Modal.Header>
102
- <Modal.Content>
103
- { tab && (
104
- <div
105
- key={tab.props.name}
95
+ <Modal.Header
96
+ className={this.getHeaderClasses()}
106
97
  >
107
- { tab.props.children }
108
- </div>
109
- )}
110
- </Modal.Content>
111
- { Element.findByType(this.props.children, Modal.Actions) }
112
- </Modal>
98
+ { this.renderHeader() }
99
+ <Menu
100
+ float='right'
101
+ secondary
102
+ >
103
+ { _.map(Element.findByType(this.props.children, TabbedModal.Tab), this.renderTab.bind(this)) }
104
+ </Menu>
105
+ </Modal.Header>
106
+ <Modal.Content>
107
+ { tab && (
108
+ <div
109
+ key={tab.props.name}
110
+ >
111
+ { tab.props.children }
112
+ </div>
113
+ )}
114
+ </Modal.Content>
115
+ { Element.findByType(this.props.children, Modal.Actions) }
116
+ </Modal>
117
+ )}
118
+ </ModalContext.Consumer>
113
119
  );
114
120
  }
115
121