@targetprocess/dropdown-field 12.20.1-alpha.4 → 12.21.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/CHANGELOG.md CHANGED
@@ -1,23 +1,23 @@
1
- #### v7.1.0
2
-
3
- - (breaking change) Now uses automatic style injection - no style import/`@global-import` is needed
4
-
5
- #### v4.0.0
6
-
7
- - Removed dependency on `lodash-es`.
8
-
9
- #### v3.0.0
10
-
11
- - Switch to newer version of `@targetprocess/input`.
12
-
13
- #### v2.1.5
14
-
15
- - Update box shadow colors to use transparency in `@targetprocess/global-constants`.
16
-
17
- #### v2.0.1
18
-
19
- - Switch to newer version of `@targetprocess/input`.
20
-
21
- #### v2.0.0
22
-
23
- - Fixed missing `module` field in `@targetprocess/popover` dependency `package.json`, which could affect some builds that rely on using CommonJS build of Popover.
1
+ #### v7.1.0
2
+
3
+ - (breaking change) Now uses automatic style injection - no style import/`@global-import` is needed
4
+
5
+ #### v4.0.0
6
+
7
+ - Removed dependency on `lodash-es`.
8
+
9
+ #### v3.0.0
10
+
11
+ - Switch to newer version of `@targetprocess/input`.
12
+
13
+ #### v2.1.5
14
+
15
+ - Update box shadow colors to use transparency in `@targetprocess/global-constants`.
16
+
17
+ #### v2.0.1
18
+
19
+ - Switch to newer version of `@targetprocess/input`.
20
+
21
+ #### v2.0.0
22
+
23
+ - Fixed missing `module` field in `@targetprocess/popover` dependency `package.json`, which could affect some builds that rely on using CommonJS build of Popover.
package/DropdownField.jsx CHANGED
@@ -1,143 +1,143 @@
1
- import React from 'react'
2
- import PropTypes from 'prop-types'
3
- import classnames from 'classnames'
4
- import {Select} from '@targetprocess/select'
5
- import {Popover} from '@targetprocess/popover'
6
- import {Field} from '@targetprocess/field'
7
- import {ChevronIcon, LoadingIcon} from '@targetprocess/icons'
8
- import styles from './style/index.css'
9
-
10
- const dropdownInnerSpace = 4
11
- const boxShadowGutter = 3
12
- /**
13
- * DropdownField is the implementation of common component for the Select and Field
14
- * It is necessary for a unified display the selected options
15
- * from the Selectbox in the Field component
16
- **/
17
-
18
- export class DropdownField extends React.Component {
19
- static defaultProps = {
20
- placeholder: 'Choose option',
21
- isLoading: false,
22
- classNames: {},
23
- items: []
24
- }
25
-
26
- state = {
27
- isOpen: false,
28
- currentValue: {
29
- displayText: ''
30
- }
31
- }
32
-
33
- get body() {
34
- const {
35
- items,
36
- search,
37
- virtualization,
38
- itemListMaxHeight,
39
- classNames: {selectClassName, popoverClassName}
40
- } = this.props
41
-
42
- return (
43
- <Popover.Body
44
- classNameBody={classnames(popoverClassName, styles['popover-body--no-gutters'])}
45
- >
46
- <Select
47
- searchEnabled
48
- className={selectClassName}
49
- itemListMaxHeight={itemListMaxHeight}
50
- showCheckbox={false}
51
- search={search}
52
- virtualization={virtualization}
53
- items={items}
54
- onItemSelectionChange={this.onSelectItem}
55
- />
56
- </Popover.Body>
57
- )
58
- }
59
-
60
- isControlledOpen = (props = this.props) =>
61
- typeof props.isOpen !== 'undefined' && props.isOpen !== null
62
-
63
- isStateless = (props = this.props) =>
64
- typeof props.selectedItem !== 'undefined' && props.selectedItem !== null
65
-
66
- onSetOpened = isOpen =>
67
- this.props.onSetOpened ? this.props.onSetOpened(isOpen) : this.setState({isOpen})
68
-
69
- onSelectItem = item => {
70
- const {onItemSelected} = this.props
71
-
72
- this.setState(
73
- {
74
- ...(this.isStateless() ? {} : {currentValue: item})
75
- },
76
- () => {
77
- if (onItemSelected) {
78
- onItemSelected(item)
79
- }
80
-
81
- this.onSetOpened(false)
82
- }
83
- )
84
- }
85
-
86
- render() {
87
- const {isLoading, errorMessage, selectedItem, placeholder, search, classNames} = this.props
88
- const isOpen = this.isControlledOpen() ? this.props.isOpen : this.state.isOpen
89
- const currentValue = this.isStateless() ? selectedItem : this.state.currentValue
90
- const isSearch = Boolean(search)
91
-
92
- return (
93
- <Popover
94
- onOuterAction={() => this.onSetOpened(false)}
95
- isOpen={isOpen}
96
- body={this.body}
97
- getPopoverPosition={(hostRect, popoverRect, containerScroll) => ({
98
- left: '0',
99
- width: '100%',
100
- top: isSearch
101
- ? -(containerScroll.top + dropdownInnerSpace)
102
- : hostRect.height + containerScroll.top + boxShadowGutter
103
- })}
104
- showTip={false}
105
- >
106
- <Field
107
- disableEdit
108
- className={classNames.fieldClassName}
109
- message={errorMessage}
110
- onEditStart={() => this.onSetOpened(true)}
111
- value={currentValue.displayText}
112
- editing={isOpen}
113
- icon={isLoading ? <LoadingIcon /> : null}
114
- placeholder={placeholder}
115
- editModeProps={{
116
- rightElement: <ChevronIcon />
117
- }}
118
- />
119
- </Popover>
120
- )
121
- }
122
- }
123
-
124
- DropdownField.propTypes = {
125
- placeholder: PropTypes.string,
126
- /* Error/warning message, need for validation */
127
- errorMessage: PropTypes.string,
128
- isLoading: PropTypes.bool,
129
- itemListMaxHeight: PropTypes.number,
130
- onSetOpened: PropTypes.func,
131
- onItemSelected: PropTypes.func,
132
- classNames: PropTypes.shape({
133
- fieldClassName: PropTypes.string,
134
- popoverClassName: PropTypes.string,
135
- selectClassName: PropTypes.string
136
- }),
137
- items: PropTypes.arrayOf(
138
- PropTypes.shape({
139
- displayText: PropTypes.string.isRequired
140
- })
141
- ),
142
- virtualization: PropTypes.shape(Select.propTypes.virtualization)
143
- }
1
+ import React from 'react'
2
+ import PropTypes from 'prop-types'
3
+ import classnames from 'classnames'
4
+ import {Select} from '@targetprocess/select'
5
+ import {Popover} from '@targetprocess/popover'
6
+ import {Field} from '@targetprocess/field'
7
+ import {ChevronIcon, LoadingIcon} from '@targetprocess/icons'
8
+ import styles from './style/index.css'
9
+
10
+ const dropdownInnerSpace = 4
11
+ const boxShadowGutter = 3
12
+ /**
13
+ * DropdownField is the implementation of common component for the Select and Field
14
+ * It is necessary for a unified display the selected options
15
+ * from the Selectbox in the Field component
16
+ **/
17
+
18
+ export class DropdownField extends React.Component {
19
+ static defaultProps = {
20
+ placeholder: 'Choose option',
21
+ isLoading: false,
22
+ classNames: {},
23
+ items: []
24
+ }
25
+
26
+ state = {
27
+ isOpen: false,
28
+ currentValue: {
29
+ displayText: ''
30
+ }
31
+ }
32
+
33
+ get body() {
34
+ const {
35
+ items,
36
+ search,
37
+ virtualization,
38
+ itemListMaxHeight,
39
+ classNames: {selectClassName, popoverClassName}
40
+ } = this.props
41
+
42
+ return (
43
+ <Popover.Body
44
+ classNameBody={classnames(popoverClassName, styles['popover-body--no-gutters'])}
45
+ >
46
+ <Select
47
+ searchEnabled
48
+ className={selectClassName}
49
+ itemListMaxHeight={itemListMaxHeight}
50
+ showCheckbox={false}
51
+ search={search}
52
+ virtualization={virtualization}
53
+ items={items}
54
+ onItemSelectionChange={this.onSelectItem}
55
+ />
56
+ </Popover.Body>
57
+ )
58
+ }
59
+
60
+ isControlledOpen = (props = this.props) =>
61
+ typeof props.isOpen !== 'undefined' && props.isOpen !== null
62
+
63
+ isStateless = (props = this.props) =>
64
+ typeof props.selectedItem !== 'undefined' && props.selectedItem !== null
65
+
66
+ onSetOpened = isOpen =>
67
+ this.props.onSetOpened ? this.props.onSetOpened(isOpen) : this.setState({isOpen})
68
+
69
+ onSelectItem = item => {
70
+ const {onItemSelected} = this.props
71
+
72
+ this.setState(
73
+ {
74
+ ...(this.isStateless() ? {} : {currentValue: item})
75
+ },
76
+ () => {
77
+ if (onItemSelected) {
78
+ onItemSelected(item)
79
+ }
80
+
81
+ this.onSetOpened(false)
82
+ }
83
+ )
84
+ }
85
+
86
+ render() {
87
+ const {isLoading, errorMessage, selectedItem, placeholder, search, classNames} = this.props
88
+ const isOpen = this.isControlledOpen() ? this.props.isOpen : this.state.isOpen
89
+ const currentValue = this.isStateless() ? selectedItem : this.state.currentValue
90
+ const isSearch = Boolean(search)
91
+
92
+ return (
93
+ <Popover
94
+ onOuterAction={() => this.onSetOpened(false)}
95
+ isOpen={isOpen}
96
+ body={this.body}
97
+ getPopoverPosition={(hostRect, popoverRect, containerScroll) => ({
98
+ left: '0',
99
+ width: '100%',
100
+ top: isSearch
101
+ ? -(containerScroll.top + dropdownInnerSpace)
102
+ : hostRect.height + containerScroll.top + boxShadowGutter
103
+ })}
104
+ showTip={false}
105
+ >
106
+ <Field
107
+ disableEdit
108
+ className={classNames.fieldClassName}
109
+ message={errorMessage}
110
+ onEditStart={() => this.onSetOpened(true)}
111
+ value={currentValue.displayText}
112
+ editing={isOpen}
113
+ icon={isLoading ? <LoadingIcon /> : null}
114
+ placeholder={placeholder}
115
+ editModeProps={{
116
+ rightElement: <ChevronIcon />
117
+ }}
118
+ />
119
+ </Popover>
120
+ )
121
+ }
122
+ }
123
+
124
+ DropdownField.propTypes = {
125
+ placeholder: PropTypes.string,
126
+ /* Error/warning message, need for validation */
127
+ errorMessage: PropTypes.string,
128
+ isLoading: PropTypes.bool,
129
+ itemListMaxHeight: PropTypes.number,
130
+ onSetOpened: PropTypes.func,
131
+ onItemSelected: PropTypes.func,
132
+ classNames: PropTypes.shape({
133
+ fieldClassName: PropTypes.string,
134
+ popoverClassName: PropTypes.string,
135
+ selectClassName: PropTypes.string
136
+ }),
137
+ items: PropTypes.arrayOf(
138
+ PropTypes.shape({
139
+ displayText: PropTypes.string.isRequired
140
+ })
141
+ ),
142
+ virtualization: PropTypes.shape(Select.propTypes.virtualization)
143
+ }
@@ -1,54 +1,54 @@
1
- /* eslint-env jest */
2
- import React from 'react'
3
- import {mount} from 'enzyme'
4
- import {DropdownField} from '../DropdownField'
5
- import {Field} from '@targetprocess/field'
6
-
7
- jest.mock('focus-trap', () => {
8
- const trap = {
9
- activate: () => trap,
10
- deactivate: () => trap,
11
- pause: () => {},
12
- unpause: () => {}
13
- }
14
- return () => trap
15
- })
16
-
17
- const renderItem = props => {
18
- const defaultProps = {
19
- search: {
20
- onTextChanged: jest.fn(),
21
- text: ''
22
- },
23
- classNames: {
24
- fieldClassName: 'test',
25
- popoverClassName: 'foo',
26
- selectClassName: 'bar'
27
- }
28
- }
29
-
30
- const dropDownProps = {...defaultProps, ...props}
31
-
32
- const component = mount(<DropdownField {...dropDownProps} />)
33
-
34
- return {
35
- component,
36
- ...defaultProps
37
- }
38
- }
39
-
40
- describe('DropdownField', () => {
41
- it('should render correctly', () => {
42
- const {component} = renderItem()
43
-
44
- expect(component.find(Field)).toHaveLength(1)
45
- })
46
- it('should render statefull field', () => {
47
- const {component} = renderItem({
48
- isOpen: true,
49
- selectedItem: {displayText: 'jora'}
50
- })
51
-
52
- expect(component.find('textarea').instance().value).toBe('jora')
53
- })
54
- })
1
+ /* eslint-env jest */
2
+ import React from 'react'
3
+ import {mount} from 'enzyme'
4
+ import {DropdownField} from '../DropdownField'
5
+ import {Field} from '@targetprocess/field'
6
+
7
+ jest.mock('focus-trap', () => {
8
+ const trap = {
9
+ activate: () => trap,
10
+ deactivate: () => trap,
11
+ pause: () => {},
12
+ unpause: () => {}
13
+ }
14
+ return () => trap
15
+ })
16
+
17
+ const renderItem = props => {
18
+ const defaultProps = {
19
+ search: {
20
+ onTextChanged: jest.fn(),
21
+ text: ''
22
+ },
23
+ classNames: {
24
+ fieldClassName: 'test',
25
+ popoverClassName: 'foo',
26
+ selectClassName: 'bar'
27
+ }
28
+ }
29
+
30
+ const dropDownProps = {...defaultProps, ...props}
31
+
32
+ const component = mount(<DropdownField {...dropDownProps} />)
33
+
34
+ return {
35
+ component,
36
+ ...defaultProps
37
+ }
38
+ }
39
+
40
+ describe('DropdownField', () => {
41
+ it('should render correctly', () => {
42
+ const {component} = renderItem()
43
+
44
+ expect(component.find(Field)).toHaveLength(1)
45
+ })
46
+ it('should render statefull field', () => {
47
+ const {component} = renderItem({
48
+ isOpen: true,
49
+ selectedItem: {displayText: 'jora'}
50
+ })
51
+
52
+ expect(component.find('textarea').instance().value).toBe('jora')
53
+ })
54
+ })
@@ -140,16 +140,16 @@ function styleInject(css, ref) {
140
140
  }
141
141
  }
142
142
 
143
- var css = ".popover-body--no-gutters__dropdown-field__12-20-1-alpha-4 {\r\n padding: 0;\r\n}\r\n";
144
- var styles = {"popover-body--no-gutters":"popover-body--no-gutters__dropdown-field__12-20-1-alpha-4"};
143
+ var css = "/*********************************************************************\n* © Copyright IBM Corp. 2024\n*********************************************************************/\n.popover-body--no-gutters__dropdown-field__12-21-0 {\n padding: 0;\n}\n";
144
+ var styles = {"popover-body--no-gutters":"popover-body--no-gutters__dropdown-field__12-21-0"};
145
145
  styleInject(css);
146
146
 
147
147
  var dropdownInnerSpace = 4;
148
148
  var boxShadowGutter = 3;
149
- /**
150
- * DropdownField is the implementation of common component for the Select and Field
151
- * It is necessary for a unified display the selected options
152
- * from the Selectbox in the Field component
149
+ /**
150
+ * DropdownField is the implementation of common component for the Select and Field
151
+ * It is necessary for a unified display the selected options
152
+ * from the Selectbox in the Field component
153
153
  **/
154
154
 
155
155
  var DropdownField = /*#__PURE__*/function (_React$Component) {
@@ -272,4 +272,8 @@ _defineProperty(DropdownField, "defaultProps", {
272
272
  items: []
273
273
  });
274
274
 
275
+ /*********************************************************************
276
+ * © Copyright IBM Corp. 2024
277
+ *********************************************************************/
278
+
275
279
  export { DropdownField };
@@ -146,16 +146,16 @@ function styleInject(css, ref) {
146
146
  }
147
147
  }
148
148
 
149
- var css = ".popover-body--no-gutters__dropdown-field__12-20-1-alpha-4 {\r\n padding: 0;\r\n}\r\n";
150
- var styles = {"popover-body--no-gutters":"popover-body--no-gutters__dropdown-field__12-20-1-alpha-4"};
149
+ var css = "/*********************************************************************\n* © Copyright IBM Corp. 2024\n*********************************************************************/\n.popover-body--no-gutters__dropdown-field__12-21-0 {\n padding: 0;\n}\n";
150
+ var styles = {"popover-body--no-gutters":"popover-body--no-gutters__dropdown-field__12-21-0"};
151
151
  styleInject(css);
152
152
 
153
153
  var dropdownInnerSpace = 4;
154
154
  var boxShadowGutter = 3;
155
- /**
156
- * DropdownField is the implementation of common component for the Select and Field
157
- * It is necessary for a unified display the selected options
158
- * from the Selectbox in the Field component
155
+ /**
156
+ * DropdownField is the implementation of common component for the Select and Field
157
+ * It is necessary for a unified display the selected options
158
+ * from the Selectbox in the Field component
159
159
  **/
160
160
 
161
161
  var DropdownField = /*#__PURE__*/function (_React$Component) {
@@ -278,4 +278,8 @@ _defineProperty(DropdownField, "defaultProps", {
278
278
  items: []
279
279
  });
280
280
 
281
+ /*********************************************************************
282
+ * © Copyright IBM Corp. 2024
283
+ *********************************************************************/
284
+
281
285
  exports.DropdownField = DropdownField;
package/index.js CHANGED
@@ -1 +1,4 @@
1
- export {DropdownField} from './DropdownField'
1
+ /*********************************************************************
2
+ * © Copyright IBM Corp. 2024
3
+ *********************************************************************/
4
+ export {DropdownField} from './DropdownField'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@targetprocess/dropdown-field",
3
- "version": "12.20.1-alpha.4",
3
+ "version": "12.21.0",
4
4
  "description": "",
5
5
  "main": "dist/dropdown-field.js",
6
6
  "module": "dist/dropdown-field.es.js",
@@ -10,10 +10,10 @@
10
10
  "prepack": "node -r ../../.ts-node.js ../../config/rollup.config.js ."
11
11
  },
12
12
  "dependencies": {
13
- "@targetprocess/field": "^12.20.1-alpha.4",
14
- "@targetprocess/icons": "^12.20.1-alpha.4",
15
- "@targetprocess/popover": "^12.20.1-alpha.4",
16
- "@targetprocess/select": "^12.20.1-alpha.4",
13
+ "@targetprocess/field": "^12.21.0",
14
+ "@targetprocess/icons": "^12.21.0",
15
+ "@targetprocess/popover": "^12.21.0",
16
+ "@targetprocess/select": "^12.21.0",
17
17
  "classnames": "^2.2.5",
18
18
  "prop-types": "^15.6.0",
19
19
  "react": "^16.7.0"
@@ -22,5 +22,5 @@
22
22
  "access": "public"
23
23
  },
24
24
  "sideEffects": false,
25
- "gitHead": "ef8076c362ed99ebe19488c7386126c7468c7db5"
25
+ "gitHead": "973be848e3196688a1b9ee91d308a15d9cec95a1"
26
26
  }
package/style/index.css CHANGED
@@ -1,3 +1,6 @@
1
- .popover-body--no-gutters {
2
- padding: 0;
3
- }
1
+ /*********************************************************************
2
+ * © Copyright IBM Corp. 2024
3
+ *********************************************************************/
4
+ .popover-body--no-gutters {
5
+ padding: 0;
6
+ }