@pixum/combobox 0.17.0 → 0.18.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 +206 -194
- package/lib/ComboBox.css +0 -0
- package/lib/ComboBox.d.ts +5 -5
- package/lib/ComboBox.js +105 -105
- package/lib/ComboBoxOptions.d.ts +4 -4
- package/lib/ComboBoxOptions.js +60 -60
- package/lib/ComboBoxOptions.js.map +1 -1
- package/lib/helper/calculateListMaxHeight.d.ts +1 -1
- package/lib/helper/calculateListMaxHeight.js +11 -11
- package/lib/helper/scrollOptionToViewport.d.ts +1 -1
- package/lib/helper/scrollOptionToViewport.js +20 -20
- package/lib/helper/useIsDesktop.d.ts +1 -1
- package/lib/helper/useIsDesktop.js +13 -13
- package/lib/index.d.ts +3 -3
- package/lib/index.js +18 -18
- package/lib/types.d.ts +28 -28
- package/lib/types.js +2 -2
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -3,198 +3,210 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
-
# [0.
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
###
|
|
30
|
-
|
|
31
|
-
* **
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
* **combobox:** fix issues after migrate the component ([
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
* **combobox:** fix
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
* **combobox:**
|
|
6
|
+
# [0.18.0](https://git.pixum.net/design-system/component-library/compare/@pixum/combobox@0.17.0...@pixum/combobox@0.18.0) (2023-07-21)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **combobox:** fix data in the combobox options ([37b3b60](https://git.pixum.net/design-system/component-library/commits/37b3b603c542705a2e6c57312738fc446c21eb23))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
# [0.17.0](https://git.pixum.net/design-system/component-library/compare/@pixum/combobox@0.16.1...@pixum/combobox@0.17.0) (2023-07-21)
|
|
19
|
+
|
|
20
|
+
**Note:** Version bump only for package @pixum/combobox
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
## [0.16.1](https://git.pixum.net/design-system/component-library/compare/@pixum/combobox@0.16.0...@pixum/combobox@0.16.1) (2023-07-20)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
### Bug Fixes
|
|
30
|
+
|
|
31
|
+
* **user-input:** fix focus ([ec9a0ea](https://git.pixum.net/design-system/component-library/commits/ec9a0ea1dde2477e6067bfbbc8676cb0321259a9))
|
|
32
|
+
* **user-input:** fix types & story ([3799c07](https://git.pixum.net/design-system/component-library/commits/3799c07a2d34f57773970a12ab27063d15a17428))
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
# [0.16.0](https://git.pixum.net/design-system/component-library/compare/@pixum/combobox@0.15.0...@pixum/combobox@0.16.0) (2023-07-19)
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
### Features
|
|
42
|
+
|
|
43
|
+
* **combobox:** allow placeholder ([4677ad0](https://git.pixum.net/design-system/component-library/commits/4677ad04015e04574ad2ee5e391709deeaa07aa1))
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
# [0.15.0](https://git.pixum.net/design-system/component-library/compare/@pixum/combobox@0.14.0...@pixum/combobox@0.15.0) (2023-07-19)
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
### Features
|
|
53
|
+
|
|
54
|
+
* **combobox:** fix styling issues ([38bec1b](https://git.pixum.net/design-system/component-library/commits/38bec1bbccb7d8f8e3bb445652c844081a12de20))
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
# [0.14.0](https://git.pixum.net/design-system/component-library/compare/@pixum/combobox@0.13.0...@pixum/combobox@0.14.0) (2023-07-19)
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
### Features
|
|
64
|
+
|
|
65
|
+
* **combobox:** fix styling issues ([6c378ce](https://git.pixum.net/design-system/component-library/commits/6c378ce88995fc3d1ea73020304bee7a0e6ec346))
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
# [0.13.0](https://git.pixum.net/design-system/component-library/compare/@pixum/combobox@0.12.0...@pixum/combobox@0.13.0) (2023-07-19)
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
### Features
|
|
75
|
+
|
|
76
|
+
* **combobox:** fix styling issues ([1494f25](https://git.pixum.net/design-system/component-library/commits/1494f2501a9ea45e50f0c3deee83562f927151de))
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
# [0.12.0](https://git.pixum.net/design-system/component-library/compare/@pixum/combobox@0.11.0...@pixum/combobox@0.12.0) (2023-07-18)
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
### Features
|
|
86
|
+
|
|
87
|
+
* **combobox:** fix default value ([178135c](https://git.pixum.net/design-system/component-library/commits/178135c2ca1aea8f16c566c98fdf6200f9b7fd62))
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
# [0.11.0](https://git.pixum.net/design-system/component-library/compare/@pixum/combobox@0.10.0...@pixum/combobox@0.11.0) (2023-07-18)
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
### Features
|
|
97
|
+
|
|
98
|
+
* **button:** remove hover from close icon ([e3071b8](https://git.pixum.net/design-system/component-library/commits/e3071b8e56e4134eb2e90b761027c277e75e94ac))
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
# [0.10.0](https://git.pixum.net/design-system/component-library/compare/@pixum/combobox@0.9.0...@pixum/combobox@0.10.0) (2023-07-18)
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
### Features
|
|
108
|
+
|
|
109
|
+
* **combobox:** generate new version ([11bfce1](https://git.pixum.net/design-system/component-library/commits/11bfce1657fd9497bdf46d5daab4b9b828c4d00f))
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
# [0.9.0](https://git.pixum.net/design-system/component-library/compare/@pixum/combobox@0.8.0...@pixum/combobox@0.9.0) (2023-07-18)
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
### Features
|
|
119
|
+
|
|
120
|
+
* **combobox:** generate new version ([f1f3f33](https://git.pixum.net/design-system/component-library/commits/f1f3f334ae96fd2fd6c522436bc97d5aa55ff99b))
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
# [0.8.0](https://git.pixum.net/design-system/component-library/compare/@pixum/combobox@0.7.0...@pixum/combobox@0.8.0) (2023-07-18)
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
### Features
|
|
130
|
+
|
|
131
|
+
* **combobox:** fix select is compact and selected value ([808aa23](https://git.pixum.net/design-system/component-library/commits/808aa234fc43fe055a77a528c21022144f695fc0))
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
# [0.7.0](https://git.pixum.net/design-system/component-library/compare/@pixum/combobox@0.6.0...@pixum/combobox@0.7.0) (2023-07-18)
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
### Features
|
|
141
|
+
|
|
142
|
+
* **combobox:** fix issues after migrate the component ([220b743](https://git.pixum.net/design-system/component-library/commits/220b74392fd1b759d4133b137c8cec857663d8b8))
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
# [0.6.0](https://git.pixum.net/design-system/component-library/compare/@pixum/combobox@0.5.0...@pixum/combobox@0.6.0) (2023-07-18)
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
### Features
|
|
152
|
+
|
|
153
|
+
* **combobox:** fix issues after migrate the component ([1e238d8](https://git.pixum.net/design-system/component-library/commits/1e238d884cbb2fbdc7b99bf943bb4f180cf95d14))
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
# [0.5.0](https://git.pixum.net/design-system/component-library/compare/@pixum/combobox@0.4.0...@pixum/combobox@0.5.0) (2023-07-18)
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
### Features
|
|
163
|
+
|
|
164
|
+
* **combobox:** fix export and onclick issue ([037570e](https://git.pixum.net/design-system/component-library/commits/037570e64f47f9974d7b305525cc190798bc09f3))
|
|
165
|
+
* **combobox:** fix issues after migrate the component ([019cb85](https://git.pixum.net/design-system/component-library/commits/019cb85d0fce0ba60dff5a7c96bc70e712702218))
|
|
166
|
+
* **combobox:** fix issues after migrate the component ([08cb4a2](https://git.pixum.net/design-system/component-library/commits/08cb4a2410d0eba51fa7acf778dd4cf81cf31859))
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
# [0.4.0](https://git.pixum.net/design-system/component-library/compare/@pixum/combobox@0.3.0...@pixum/combobox@0.4.0) (2023-07-17)
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
### Features
|
|
176
|
+
|
|
177
|
+
* **combobox:** fix export and onclick issue ([d0b1e94](https://git.pixum.net/design-system/component-library/commits/d0b1e94e7a97143550307a58702e219a0ba3f7ac))
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
# [0.3.0](https://git.pixum.net/design-system/component-library/compare/@pixum/combobox@0.2.0...@pixum/combobox@0.3.0) (2023-07-17)
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
### Features
|
|
187
|
+
|
|
188
|
+
* **combobox:** fix export and onclick issue ([4522908](https://git.pixum.net/design-system/component-library/commits/4522908dca84b3b46b1a58e3f40526f1939fb984))
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
# [0.2.0](https://git.pixum.net/design-system/component-library/compare/@pixum/combobox@0.1.0...@pixum/combobox@0.2.0) (2023-07-17)
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
### Features
|
|
198
|
+
|
|
199
|
+
* **combobox:** fix export and onclick issue ([7df79de](https://git.pixum.net/design-system/component-library/commits/7df79debbb129d4b5238e44a11ab24ba5cc01bd3))
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
# 0.1.0 (2023-07-17)
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
### Features
|
|
209
|
+
|
|
210
|
+
* **combobox:** add combobox component ([1fe4ec2](https://git.pixum.net/design-system/component-library/commits/1fe4ec254317fe65faa372cc82a51f1a4afcca9a))
|
|
211
|
+
* **combobox:** apply code-review ([8e79167](https://git.pixum.net/design-system/component-library/commits/8e79167eeb196be32a66e67929864a63a351af36))
|
|
200
212
|
* **combobox:** apply code-review ([2554747](https://git.pixum.net/design-system/component-library/commits/25547475a701273c06c75dc7c051849016ee63d4))
|
package/lib/ComboBox.css
ADDED
|
File without changes
|
package/lib/ComboBox.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { ComboBoxProps } from './types';
|
|
3
|
-
import './styles.css';
|
|
4
|
-
declare const ComboBox: React.FC<ComboBoxProps>;
|
|
5
|
-
export default ComboBox;
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ComboBoxProps } from './types';
|
|
3
|
+
import './styles.css';
|
|
4
|
+
declare const ComboBox: React.FC<ComboBoxProps>;
|
|
5
|
+
export default ComboBox;
|
package/lib/ComboBox.js
CHANGED
|
@@ -1,106 +1,106 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
o[k2] = m[k];
|
|
8
|
-
}));
|
|
9
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
-
}) : function(o, v) {
|
|
12
|
-
o["default"] = v;
|
|
13
|
-
});
|
|
14
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
-
if (mod && mod.__esModule) return mod;
|
|
16
|
-
var result = {};
|
|
17
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
-
__setModuleDefault(result, mod);
|
|
19
|
-
return result;
|
|
20
|
-
};
|
|
21
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
22
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
|
-
};
|
|
24
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
-
var react_1 = __importStar(require("react"));
|
|
26
|
-
var clsx_1 = __importDefault(require("clsx"));
|
|
27
|
-
require("./styles.css");
|
|
28
|
-
var user_input_1 = require("@pixum/user-input");
|
|
29
|
-
var useIsDesktop_1 = require("./helper/useIsDesktop");
|
|
30
|
-
var react_2 = require("react");
|
|
31
|
-
var bottom_sheet_1 = __importDefault(require("@pixum/bottom-sheet"));
|
|
32
|
-
var menu_1 = __importDefault(require("@pixum/menu"));
|
|
33
|
-
var ComboBoxOptions_1 = __importDefault(require("./ComboBoxOptions"));
|
|
34
|
-
var text_1 = __importDefault(require("@pixum/text"));
|
|
35
|
-
var ComboBox = function (_a) {
|
|
36
|
-
var _b = _a.className, className = _b === void 0 ? '' : _b, headline = _a.headline, label = _a.label, _c = _a.onClick, onClick = _c === void 0 ? function () { } : _c, _d = _a.onChange, onChange = _d === void 0 ? function () { } : _d, _e = _a.onOutsideClick, onOutsideClick = _e === void 0 ? function () { } : _e, _f = _a.onOptionItemClick, onOptionItemClick = _f === void 0 ? function () { } : _f, onSheetClose = _a.onSheetClose, _g = _a.searchPattern, searchPattern = _g === void 0 ? '' : _g, _h = _a.open, open = _h === void 0 ? false : _h, options = _a.options, placeholder = _a.placeholder, value = _a.value, noResultsText = _a.noResultsText;
|
|
37
|
-
var comboBoxRef = (0, react_1.useRef)(null);
|
|
38
|
-
var isDesktop = (0, useIsDesktop_1.useIsDesktop)();
|
|
39
|
-
var _j = (0, react_2.useState)(''), searchQuery = _j[0], setSearchQuery = _j[1];
|
|
40
|
-
var _k = (0, react_2.useState)(''), selectedValue = _k[0], setSelectedValue = _k[1];
|
|
41
|
-
var _l = (0, react_2.useState)(open), isOpen = _l[0], setIsOpen = _l[1];
|
|
42
|
-
var optionsExist = Object.keys(options).length > 0;
|
|
43
|
-
var defaultValue = !selectedValue && value ? value : selectedValue;
|
|
44
|
-
(0, react_1.useEffect)(function () {
|
|
45
|
-
!isOpen && (onSheetClose === null || onSheetClose === void 0 ? void 0 : onSheetClose());
|
|
46
|
-
}, [isOpen]);
|
|
47
|
-
var handleChange = function (e) {
|
|
48
|
-
var searchValue = e.target.value;
|
|
49
|
-
setSearchQuery(searchValue);
|
|
50
|
-
onChange(searchValue);
|
|
51
|
-
};
|
|
52
|
-
var handleClearInput = function () {
|
|
53
|
-
setIsOpen(true);
|
|
54
|
-
setSearchQuery('');
|
|
55
|
-
onClick();
|
|
56
|
-
};
|
|
57
|
-
var handleSelectInputClick = function () {
|
|
58
|
-
handleClearInput();
|
|
59
|
-
};
|
|
60
|
-
var clearAndClose = function () {
|
|
61
|
-
setIsOpen(false);
|
|
62
|
-
setSearchQuery('');
|
|
63
|
-
onOutsideClick();
|
|
64
|
-
};
|
|
65
|
-
var handleClickOutside = function (event) {
|
|
66
|
-
if (comboBoxRef.current &&
|
|
67
|
-
!comboBoxRef.current.contains(event.target)) {
|
|
68
|
-
clearAndClose();
|
|
69
|
-
}
|
|
70
|
-
};
|
|
71
|
-
var handleBottomSheetOnClose = function () {
|
|
72
|
-
setIsOpen(false);
|
|
73
|
-
};
|
|
74
|
-
var handleOptionItemClick = function (optionValue) {
|
|
75
|
-
if (optionValue) {
|
|
76
|
-
setSelectedValue(optionValue);
|
|
77
|
-
onOptionItemClick(optionValue);
|
|
78
|
-
}
|
|
79
|
-
setIsOpen(false);
|
|
80
|
-
};
|
|
81
|
-
var handleOnArrowClick = function () {
|
|
82
|
-
clearAndClose();
|
|
83
|
-
};
|
|
84
|
-
var NoResultsTextComponent = function () {
|
|
85
|
-
return (react_1.default.createElement(text_1.default, { variant: "subheadline", className: "combobox--no-results-text" }, noResultsText));
|
|
86
|
-
};
|
|
87
|
-
(0, react_1.useEffect)(function () {
|
|
88
|
-
document.addEventListener('mousedown', handleClickOutside);
|
|
89
|
-
return function () {
|
|
90
|
-
document.removeEventListener('mousedown', handleClickOutside);
|
|
91
|
-
};
|
|
92
|
-
}, []);
|
|
93
|
-
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
94
|
-
!isOpen && (react_1.default.createElement(user_input_1.SelectInput, { label: label, value: defaultValue, onClick: handleSelectInputClick, isCompact: true, readOnly: true })),
|
|
95
|
-
isDesktop && isOpen && (react_1.default.createElement("div", { className: (0, clsx_1.default)("combobox", className), ref: comboBoxRef },
|
|
96
|
-
react_1.default.createElement(user_input_1.SmallSearchInput, { value: searchQuery, pattern: searchPattern, label: label, onChange: handleChange, onClear: handleClearInput, onArrowClick: handleOnArrowClick, show: isOpen, autoFocus: true, isCompact: true }),
|
|
97
|
-
react_1.default.createElement(menu_1.default, { className: (0, clsx_1.default)('combobox__options') }, optionsExist ? (react_1.default.createElement(ComboBoxOptions_1.default, { options: options, onClick: handleOptionItemClick, selectedOption: defaultValue })) : (react_1.default.createElement(NoResultsTextComponent, null))),
|
|
98
|
-
react_1.default.createElement("div", null))),
|
|
99
|
-
!isDesktop && isOpen && (react_1.default.createElement(bottom_sheet_1.default, { open: isOpen, onClose: handleBottomSheetOnClose },
|
|
100
|
-
react_1.default.createElement("div", { className: "combobox--header" },
|
|
101
|
-
react_1.default.createElement(text_1.default, { variant: "headline", className: "combobox--headline" }, headline),
|
|
102
|
-
react_1.default.createElement(user_input_1.SmallSearchInput, { value: searchQuery, pattern: searchPattern, onChange: handleChange, onClear: handleClearInput, placeholder: placeholder, show: isOpen, autoFocus: true, isCompact: true })),
|
|
103
|
-
react_1.default.createElement("div", { className: "combobox__options" }, optionsExist ? (react_1.default.createElement(ComboBoxOptions_1.default, { options: options, onClick: handleOptionItemClick, selectedOption: defaultValue })) : (react_1.default.createElement(NoResultsTextComponent, null)))))));
|
|
104
|
-
};
|
|
105
|
-
exports.default = ComboBox;
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
22
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
|
+
};
|
|
24
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
var react_1 = __importStar(require("react"));
|
|
26
|
+
var clsx_1 = __importDefault(require("clsx"));
|
|
27
|
+
require("./styles.css");
|
|
28
|
+
var user_input_1 = require("@pixum/user-input");
|
|
29
|
+
var useIsDesktop_1 = require("./helper/useIsDesktop");
|
|
30
|
+
var react_2 = require("react");
|
|
31
|
+
var bottom_sheet_1 = __importDefault(require("@pixum/bottom-sheet"));
|
|
32
|
+
var menu_1 = __importDefault(require("@pixum/menu"));
|
|
33
|
+
var ComboBoxOptions_1 = __importDefault(require("./ComboBoxOptions"));
|
|
34
|
+
var text_1 = __importDefault(require("@pixum/text"));
|
|
35
|
+
var ComboBox = function (_a) {
|
|
36
|
+
var _b = _a.className, className = _b === void 0 ? '' : _b, headline = _a.headline, label = _a.label, _c = _a.onClick, onClick = _c === void 0 ? function () { } : _c, _d = _a.onChange, onChange = _d === void 0 ? function () { } : _d, _e = _a.onOutsideClick, onOutsideClick = _e === void 0 ? function () { } : _e, _f = _a.onOptionItemClick, onOptionItemClick = _f === void 0 ? function () { } : _f, onSheetClose = _a.onSheetClose, _g = _a.searchPattern, searchPattern = _g === void 0 ? '' : _g, _h = _a.open, open = _h === void 0 ? false : _h, options = _a.options, placeholder = _a.placeholder, value = _a.value, noResultsText = _a.noResultsText;
|
|
37
|
+
var comboBoxRef = (0, react_1.useRef)(null);
|
|
38
|
+
var isDesktop = (0, useIsDesktop_1.useIsDesktop)();
|
|
39
|
+
var _j = (0, react_2.useState)(''), searchQuery = _j[0], setSearchQuery = _j[1];
|
|
40
|
+
var _k = (0, react_2.useState)(''), selectedValue = _k[0], setSelectedValue = _k[1];
|
|
41
|
+
var _l = (0, react_2.useState)(open), isOpen = _l[0], setIsOpen = _l[1];
|
|
42
|
+
var optionsExist = Object.keys(options).length > 0;
|
|
43
|
+
var defaultValue = !selectedValue && value ? value : selectedValue;
|
|
44
|
+
(0, react_1.useEffect)(function () {
|
|
45
|
+
!isOpen && (onSheetClose === null || onSheetClose === void 0 ? void 0 : onSheetClose());
|
|
46
|
+
}, [isOpen]);
|
|
47
|
+
var handleChange = function (e) {
|
|
48
|
+
var searchValue = e.target.value;
|
|
49
|
+
setSearchQuery(searchValue);
|
|
50
|
+
onChange(searchValue);
|
|
51
|
+
};
|
|
52
|
+
var handleClearInput = function () {
|
|
53
|
+
setIsOpen(true);
|
|
54
|
+
setSearchQuery('');
|
|
55
|
+
onClick();
|
|
56
|
+
};
|
|
57
|
+
var handleSelectInputClick = function () {
|
|
58
|
+
handleClearInput();
|
|
59
|
+
};
|
|
60
|
+
var clearAndClose = function () {
|
|
61
|
+
setIsOpen(false);
|
|
62
|
+
setSearchQuery('');
|
|
63
|
+
onOutsideClick();
|
|
64
|
+
};
|
|
65
|
+
var handleClickOutside = function (event) {
|
|
66
|
+
if (comboBoxRef.current &&
|
|
67
|
+
!comboBoxRef.current.contains(event.target)) {
|
|
68
|
+
clearAndClose();
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
var handleBottomSheetOnClose = function () {
|
|
72
|
+
setIsOpen(false);
|
|
73
|
+
};
|
|
74
|
+
var handleOptionItemClick = function (optionValue) {
|
|
75
|
+
if (optionValue) {
|
|
76
|
+
setSelectedValue(optionValue);
|
|
77
|
+
onOptionItemClick(optionValue);
|
|
78
|
+
}
|
|
79
|
+
setIsOpen(false);
|
|
80
|
+
};
|
|
81
|
+
var handleOnArrowClick = function () {
|
|
82
|
+
clearAndClose();
|
|
83
|
+
};
|
|
84
|
+
var NoResultsTextComponent = function () {
|
|
85
|
+
return (react_1.default.createElement(text_1.default, { variant: "subheadline", className: "combobox--no-results-text" }, noResultsText));
|
|
86
|
+
};
|
|
87
|
+
(0, react_1.useEffect)(function () {
|
|
88
|
+
document.addEventListener('mousedown', handleClickOutside);
|
|
89
|
+
return function () {
|
|
90
|
+
document.removeEventListener('mousedown', handleClickOutside);
|
|
91
|
+
};
|
|
92
|
+
}, []);
|
|
93
|
+
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
94
|
+
!isOpen && (react_1.default.createElement(user_input_1.SelectInput, { label: label, value: defaultValue, onClick: handleSelectInputClick, isCompact: true, readOnly: true })),
|
|
95
|
+
isDesktop && isOpen && (react_1.default.createElement("div", { className: (0, clsx_1.default)("combobox", className), ref: comboBoxRef },
|
|
96
|
+
react_1.default.createElement(user_input_1.SmallSearchInput, { value: searchQuery, pattern: searchPattern, label: label, onChange: handleChange, onClear: handleClearInput, onArrowClick: handleOnArrowClick, show: isOpen, autoFocus: true, isCompact: true }),
|
|
97
|
+
react_1.default.createElement(menu_1.default, { className: (0, clsx_1.default)('combobox__options') }, optionsExist ? (react_1.default.createElement(ComboBoxOptions_1.default, { options: options, onClick: handleOptionItemClick, selectedOption: defaultValue })) : (react_1.default.createElement(NoResultsTextComponent, null))),
|
|
98
|
+
react_1.default.createElement("div", null))),
|
|
99
|
+
!isDesktop && isOpen && (react_1.default.createElement(bottom_sheet_1.default, { open: isOpen, onClose: handleBottomSheetOnClose },
|
|
100
|
+
react_1.default.createElement("div", { className: "combobox--header" },
|
|
101
|
+
react_1.default.createElement(text_1.default, { variant: "headline", className: "combobox--headline" }, headline),
|
|
102
|
+
react_1.default.createElement(user_input_1.SmallSearchInput, { value: searchQuery, pattern: searchPattern, onChange: handleChange, onClear: handleClearInput, placeholder: placeholder, show: isOpen, autoFocus: true, isCompact: true })),
|
|
103
|
+
react_1.default.createElement("div", { className: "combobox__options" }, optionsExist ? (react_1.default.createElement(ComboBoxOptions_1.default, { options: options, onClick: handleOptionItemClick, selectedOption: defaultValue })) : (react_1.default.createElement(NoResultsTextComponent, null)))))));
|
|
104
|
+
};
|
|
105
|
+
exports.default = ComboBox;
|
|
106
106
|
//# sourceMappingURL=ComboBox.js.map
|
package/lib/ComboBoxOptions.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { ComboBoxOptionsProps } from "./types";
|
|
3
|
-
declare const ComboBoxOptions: React.FC<ComboBoxOptionsProps>;
|
|
4
|
-
export default ComboBoxOptions;
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { ComboBoxOptionsProps } from "./types";
|
|
3
|
+
declare const ComboBoxOptions: React.FC<ComboBoxOptionsProps>;
|
|
4
|
+
export default ComboBoxOptions;
|
package/lib/ComboBoxOptions.js
CHANGED
|
@@ -1,61 +1,61 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
o[k2] = m[k];
|
|
8
|
-
}));
|
|
9
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
-
}) : function(o, v) {
|
|
12
|
-
o["default"] = v;
|
|
13
|
-
});
|
|
14
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
-
if (mod && mod.__esModule) return mod;
|
|
16
|
-
var result = {};
|
|
17
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
-
__setModuleDefault(result, mod);
|
|
19
|
-
return result;
|
|
20
|
-
};
|
|
21
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
22
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
|
-
};
|
|
24
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
-
var react_1 = __importStar(require("react"));
|
|
26
|
-
var text_1 = __importDefault(require("@pixum/text"));
|
|
27
|
-
var menu_item_1 = __importDefault(require("@pixum/menu-item"));
|
|
28
|
-
var useIsDesktop_1 = require("./helper/useIsDesktop");
|
|
29
|
-
var scrollOptionToViewport_1 = require("./helper/scrollOptionToViewport");
|
|
30
|
-
var ComboBoxOptions = function (_a) {
|
|
31
|
-
var options = _a.options, selectedOption = _a.selectedOption, onClick = _a.onClick;
|
|
32
|
-
var isDesktop = (0, useIsDesktop_1.useIsDesktop)();
|
|
33
|
-
var handleOnItemClick = function (value) {
|
|
34
|
-
if (value && onClick) {
|
|
35
|
-
onClick(value);
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
(0, react_1.useEffect)(function () {
|
|
39
|
-
(0, scrollOptionToViewport_1.scrollOptionToViewport)(isDesktop);
|
|
40
|
-
}, [isDesktop]);
|
|
41
|
-
return (react_1.default.createElement(react_1.default.Fragment, null, Object.entries(options).map(function (_a) {
|
|
42
|
-
var _b;
|
|
43
|
-
var group = _a[0], items = _a[1];
|
|
44
|
-
return (react_1.default.createElement(react_1.default.Fragment, null, isNaN(
|
|
45
|
-
react_1.default.createElement(react_1.default.Fragment, null,
|
|
46
|
-
react_1.default.createElement(text_1.default, { variant: "headline", className: "sticky-header" }, group),
|
|
47
|
-
items.map(function (item, index) {
|
|
48
|
-
var _a;
|
|
49
|
-
return (react_1.default.createElement(menu_item_1.default, { key: "combobox-item-" + group + "-" + index, className: selectedOption === item.text ? 'selected' : '', onClick: function () { return handleOnItemClick(item.text); }, text: item.text, subtext: item.subtext, subItemProps: {
|
|
50
|
-
text: (_a = item.subItemProps) === null || _a === void 0 ? void 0 : _a.text,
|
|
51
|
-
} }));
|
|
52
|
-
}))
|
|
53
|
-
:
|
|
54
|
-
react_1.default.createElement(react_1.default.Fragment, null,
|
|
55
|
-
react_1.default.createElement(menu_item_1.default, { key: "combobox-item-" + items.text, className: selectedOption === items.text ? 'selected' : '', onClick: function () { return handleOnItemClick(items.text); }, text: items.text, subtext: items.subtext, subItemProps: {
|
|
56
|
-
text: (_b = items.subItemProps) === null || _b === void 0 ? void 0 : _b.text,
|
|
57
|
-
} }))));
|
|
58
|
-
})));
|
|
59
|
-
};
|
|
60
|
-
exports.default = ComboBoxOptions;
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
22
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
|
+
};
|
|
24
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
var react_1 = __importStar(require("react"));
|
|
26
|
+
var text_1 = __importDefault(require("@pixum/text"));
|
|
27
|
+
var menu_item_1 = __importDefault(require("@pixum/menu-item"));
|
|
28
|
+
var useIsDesktop_1 = require("./helper/useIsDesktop");
|
|
29
|
+
var scrollOptionToViewport_1 = require("./helper/scrollOptionToViewport");
|
|
30
|
+
var ComboBoxOptions = function (_a) {
|
|
31
|
+
var options = _a.options, selectedOption = _a.selectedOption, onClick = _a.onClick;
|
|
32
|
+
var isDesktop = (0, useIsDesktop_1.useIsDesktop)();
|
|
33
|
+
var handleOnItemClick = function (value) {
|
|
34
|
+
if (value && onClick) {
|
|
35
|
+
onClick(value);
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
(0, react_1.useEffect)(function () {
|
|
39
|
+
(0, scrollOptionToViewport_1.scrollOptionToViewport)(isDesktop);
|
|
40
|
+
}, [isDesktop]);
|
|
41
|
+
return (react_1.default.createElement(react_1.default.Fragment, null, Object.entries(options).map(function (_a) {
|
|
42
|
+
var _b;
|
|
43
|
+
var group = _a[0], items = _a[1];
|
|
44
|
+
return (react_1.default.createElement(react_1.default.Fragment, null, isNaN(Number(group)) ?
|
|
45
|
+
react_1.default.createElement(react_1.default.Fragment, null,
|
|
46
|
+
react_1.default.createElement(text_1.default, { variant: "headline", className: "sticky-header" }, group),
|
|
47
|
+
items.map(function (item, index) {
|
|
48
|
+
var _a;
|
|
49
|
+
return (react_1.default.createElement(menu_item_1.default, { key: "combobox-item-" + group + "-" + index, className: selectedOption === item.text ? 'selected' : '', onClick: function () { return handleOnItemClick(item.text); }, text: item.text, subtext: item.subtext, subItemProps: {
|
|
50
|
+
text: (_a = item.subItemProps) === null || _a === void 0 ? void 0 : _a.text,
|
|
51
|
+
} }));
|
|
52
|
+
}))
|
|
53
|
+
:
|
|
54
|
+
react_1.default.createElement(react_1.default.Fragment, null,
|
|
55
|
+
react_1.default.createElement(menu_item_1.default, { key: "combobox-item-" + items.text, className: selectedOption === items.text ? 'selected' : '', onClick: function () { return handleOnItemClick(items.text); }, text: items.text, subtext: items.subtext, subItemProps: {
|
|
56
|
+
text: (_b = items.subItemProps) === null || _b === void 0 ? void 0 : _b.text,
|
|
57
|
+
} }))));
|
|
58
|
+
})));
|
|
59
|
+
};
|
|
60
|
+
exports.default = ComboBoxOptions;
|
|
61
61
|
//# sourceMappingURL=ComboBoxOptions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ComboBoxOptions.js","sourceRoot":"","sources":["../src/ComboBoxOptions.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,6CAA0C;AAC1C,qDAA+B;AAC/B,+DAAyD;AAEzD,sDAAoD;AACpD,0EAAyE;AAEzE,IAAM,eAAe,GAAmC,UAAC,EAIxD;QAHG,OAAO,aAAA,EACP,cAAc,oBAAA,EACd,OAAO,aAAA;IAEP,IAAM,SAAS,GAAG,IAAA,2BAAY,GAAE,CAAA;IAEhC,IAAM,iBAAiB,GAAG,UAAC,KAAc;QACrC,IAAI,KAAK,IAAI,OAAO,EAAE;YAClB,OAAO,CAAC,KAAK,CAAC,CAAA;SACjB;IACL,CAAC,CAAA;IAED,IAAA,iBAAS,EAAC;QACN,IAAA,+CAAsB,EAAC,SAAS,CAAC,CAAA;IACrC,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC,CAAA;IAEf,OAAO,CACH,8DACK,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,UAAC,EAAc;;YAAb,KAAK,QAAA,EAAE,KAAK,QAAA;QAAM,OAAA,CAC7C,8DACK,KAAK,CAAC,
|
|
1
|
+
{"version":3,"file":"ComboBoxOptions.js","sourceRoot":"","sources":["../src/ComboBoxOptions.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,6CAA0C;AAC1C,qDAA+B;AAC/B,+DAAyD;AAEzD,sDAAoD;AACpD,0EAAyE;AAEzE,IAAM,eAAe,GAAmC,UAAC,EAIxD;QAHG,OAAO,aAAA,EACP,cAAc,oBAAA,EACd,OAAO,aAAA;IAEP,IAAM,SAAS,GAAG,IAAA,2BAAY,GAAE,CAAA;IAEhC,IAAM,iBAAiB,GAAG,UAAC,KAAc;QACrC,IAAI,KAAK,IAAI,OAAO,EAAE;YAClB,OAAO,CAAC,KAAK,CAAC,CAAA;SACjB;IACL,CAAC,CAAA;IAED,IAAA,iBAAS,EAAC;QACN,IAAA,+CAAsB,EAAC,SAAS,CAAC,CAAA;IACrC,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC,CAAA;IAEf,OAAO,CACH,8DACK,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,UAAC,EAAc;;YAAb,KAAK,QAAA,EAAE,KAAK,QAAA;QAAM,OAAA,CAC7C,8DACK,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAE,CAAC;YACpB;gBACI,8BAAC,cAAI,IAAC,OAAO,EAAC,UAAU,EAAC,SAAS,EAAC,eAAe,IAAE,KAAK,CAAQ;gBAChE,KAAK,CAAC,GAAG,CAAC,UAAC,IAAmB,EAAE,KAAa;;oBAAK,OAAA,CAC/C,8BAAC,mBAAQ,IAAC,GAAG,EAAE,mBAAiB,KAAK,SAAI,KAAO,EAC9C,SAAS,EAAE,cAAc,KAAK,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,EACzD,OAAO,EAAE,cAAM,OAAA,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,EAA5B,CAA4B,EAC3C,IAAI,EAAE,IAAI,CAAC,IAAI,EACf,OAAO,EAAE,IAAI,CAAC,OAAO,EACrB,YAAY,EAAE;4BACV,IAAI,EAAE,MAAA,IAAI,CAAC,YAAY,0CAAE,IAAI;yBAChC,GACD,CACL,CAAA;iBAAA,CAAC,CACH;YACN,CAAC;gBACE;oBACI,8BAAC,mBAAQ,IAAC,GAAG,EAAE,mBAAiB,KAAK,CAAC,IAAM,EAC1C,SAAS,EAAE,cAAc,KAAK,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,EAC1D,OAAO,EAAE,cAAM,OAAA,iBAAiB,CAAC,KAAK,CAAC,IAAI,CAAC,EAA7B,CAA6B,EAC5C,IAAI,EAAE,KAAK,CAAC,IAAI,EAChB,OAAO,EAAE,KAAK,CAAC,OAAO,EACtB,YAAY,EAAE;4BACV,IAAI,EAAE,MAAA,KAAK,CAAC,YAAY,0CAAE,IAAI;yBACjC,GACD,CACH,CAER,CACN,CAAA;KAAA,CAAC,CACH,CACN,CAAC;AACN,CAAC,CAAC;AAEF,kBAAe,eAAe,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const calculateListMaxHeight: () => number;
|
|
1
|
+
export declare const calculateListMaxHeight: () => number;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.calculateListMaxHeight = void 0;
|
|
4
|
-
var calculateListMaxHeight = function () {
|
|
5
|
-
var windowHeight = window.innerHeight;
|
|
6
|
-
var headerHeight = 50;
|
|
7
|
-
var inputFieldHeight = 35;
|
|
8
|
-
var maxListHeight = windowHeight - headerHeight - inputFieldHeight;
|
|
9
|
-
return maxListHeight;
|
|
10
|
-
};
|
|
11
|
-
exports.calculateListMaxHeight = calculateListMaxHeight;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.calculateListMaxHeight = void 0;
|
|
4
|
+
var calculateListMaxHeight = function () {
|
|
5
|
+
var windowHeight = window.innerHeight;
|
|
6
|
+
var headerHeight = 50;
|
|
7
|
+
var inputFieldHeight = 35;
|
|
8
|
+
var maxListHeight = windowHeight - headerHeight - inputFieldHeight;
|
|
9
|
+
return maxListHeight;
|
|
10
|
+
};
|
|
11
|
+
exports.calculateListMaxHeight = calculateListMaxHeight;
|
|
12
12
|
//# sourceMappingURL=calculateListMaxHeight.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const scrollOptionToViewport: (isDesktop: boolean) => void;
|
|
1
|
+
export declare const scrollOptionToViewport: (isDesktop: boolean) => void;
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.scrollOptionToViewport = void 0;
|
|
4
|
-
var scrollOptionToViewport = function (isDesktop) {
|
|
5
|
-
var selectedOption = document.querySelector('.menu-item.selected');
|
|
6
|
-
var container = isDesktop ? document.querySelector('.menu') :
|
|
7
|
-
document.querySelector('.combobox__options');
|
|
8
|
-
if (selectedOption && container) {
|
|
9
|
-
var selectedOptionHeight = selectedOption.offsetHeight;
|
|
10
|
-
var selectedOptionOffsetTop = selectedOption.offsetTop;
|
|
11
|
-
var selectedOptionOffsetBottom = selectedOptionOffsetTop - selectedOptionHeight;
|
|
12
|
-
if (isDesktop) {
|
|
13
|
-
container.scrollTop = selectedOptionOffsetBottom;
|
|
14
|
-
}
|
|
15
|
-
else {
|
|
16
|
-
selectedOption.scrollIntoView({ behavior: "smooth" });
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
|
-
exports.scrollOptionToViewport = scrollOptionToViewport;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.scrollOptionToViewport = void 0;
|
|
4
|
+
var scrollOptionToViewport = function (isDesktop) {
|
|
5
|
+
var selectedOption = document.querySelector('.menu-item.selected');
|
|
6
|
+
var container = isDesktop ? document.querySelector('.menu') :
|
|
7
|
+
document.querySelector('.combobox__options');
|
|
8
|
+
if (selectedOption && container) {
|
|
9
|
+
var selectedOptionHeight = selectedOption.offsetHeight;
|
|
10
|
+
var selectedOptionOffsetTop = selectedOption.offsetTop;
|
|
11
|
+
var selectedOptionOffsetBottom = selectedOptionOffsetTop - selectedOptionHeight;
|
|
12
|
+
if (isDesktop) {
|
|
13
|
+
container.scrollTop = selectedOptionOffsetBottom;
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
selectedOption.scrollIntoView({ behavior: "smooth" });
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
exports.scrollOptionToViewport = scrollOptionToViewport;
|
|
21
21
|
//# sourceMappingURL=scrollOptionToViewport.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const useIsDesktop: () => boolean;
|
|
1
|
+
export declare const useIsDesktop: () => boolean;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useIsDesktop = void 0;
|
|
4
|
-
var react_1 = require("react");
|
|
5
|
-
var react_device_detect_1 = require("react-device-detect");
|
|
6
|
-
var useIsDesktop = function () {
|
|
7
|
-
var _a = (0, react_1.useState)(false), isPageLoaded = _a[0], setPageLoaded = _a[1];
|
|
8
|
-
(0, react_1.useEffect)(function () {
|
|
9
|
-
setPageLoaded(true);
|
|
10
|
-
}, []);
|
|
11
|
-
return (0, react_1.useMemo)(function () { return isPageLoaded && react_device_detect_1.isDesktop; }, [react_device_detect_1.isDesktop, isPageLoaded]);
|
|
12
|
-
};
|
|
13
|
-
exports.useIsDesktop = useIsDesktop;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useIsDesktop = void 0;
|
|
4
|
+
var react_1 = require("react");
|
|
5
|
+
var react_device_detect_1 = require("react-device-detect");
|
|
6
|
+
var useIsDesktop = function () {
|
|
7
|
+
var _a = (0, react_1.useState)(false), isPageLoaded = _a[0], setPageLoaded = _a[1];
|
|
8
|
+
(0, react_1.useEffect)(function () {
|
|
9
|
+
setPageLoaded(true);
|
|
10
|
+
}, []);
|
|
11
|
+
return (0, react_1.useMemo)(function () { return isPageLoaded && react_device_detect_1.isDesktop; }, [react_device_detect_1.isDesktop, isPageLoaded]);
|
|
12
|
+
};
|
|
13
|
+
exports.useIsDesktop = useIsDesktop;
|
|
14
14
|
//# sourceMappingURL=useIsDesktop.js.map
|
package/lib/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import ComboBox from './ComboBox';
|
|
2
|
-
export default ComboBox;
|
|
3
|
-
export * from './types';
|
|
1
|
+
import ComboBox from './ComboBox';
|
|
2
|
+
export default ComboBox;
|
|
3
|
+
export * from './types';
|
package/lib/index.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
o[k2] = m[k];
|
|
8
|
-
}));
|
|
9
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
-
};
|
|
12
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
13
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
14
|
-
};
|
|
15
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
-
var ComboBox_1 = __importDefault(require("./ComboBox"));
|
|
17
|
-
exports.default = ComboBox_1.default;
|
|
18
|
-
__exportStar(require("./types"), exports);
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
+
};
|
|
12
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
13
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
14
|
+
};
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
var ComboBox_1 = __importDefault(require("./ComboBox"));
|
|
17
|
+
exports.default = ComboBox_1.default;
|
|
18
|
+
__exportStar(require("./types"), exports);
|
|
19
19
|
//# sourceMappingURL=index.js.map
|
package/lib/types.d.ts
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
import { MenuItemProps } from '@pixum/menu-item';
|
|
2
|
-
interface ComboBoxOptionsProps {
|
|
3
|
-
options: Record<string, ComboBoxOptionProps[]> | ComboBoxOptionProps[];
|
|
4
|
-
selectedOption?: string;
|
|
5
|
-
onClick?: (value?: string) => void;
|
|
6
|
-
}
|
|
7
|
-
interface ComboBoxProps extends ComboBoxOptionsProps {
|
|
8
|
-
className?: string;
|
|
9
|
-
headline?: string;
|
|
10
|
-
helperText?: string;
|
|
11
|
-
id?: string;
|
|
12
|
-
label?: string;
|
|
13
|
-
onChange?: (value: string) => void;
|
|
14
|
-
onOptionItemClick?: (value: string) => void;
|
|
15
|
-
onOutsideClick?: () => void;
|
|
16
|
-
onClick?: () => void;
|
|
17
|
-
onSheetClose?: () => void;
|
|
18
|
-
placeholder?: string;
|
|
19
|
-
searchPattern?: string;
|
|
20
|
-
open?: boolean;
|
|
21
|
-
value?: string;
|
|
22
|
-
noResultsText?: string;
|
|
23
|
-
}
|
|
24
|
-
interface ComboBoxOptionProps extends MenuItemProps {
|
|
25
|
-
key?: string;
|
|
26
|
-
value: string;
|
|
27
|
-
}
|
|
28
|
-
export { ComboBoxProps, ComboBoxOptionProps, ComboBoxOptionsProps };
|
|
1
|
+
import { MenuItemProps } from '@pixum/menu-item';
|
|
2
|
+
interface ComboBoxOptionsProps {
|
|
3
|
+
options: Record<string, ComboBoxOptionProps[]> | ComboBoxOptionProps[];
|
|
4
|
+
selectedOption?: string;
|
|
5
|
+
onClick?: (value?: string) => void;
|
|
6
|
+
}
|
|
7
|
+
interface ComboBoxProps extends ComboBoxOptionsProps {
|
|
8
|
+
className?: string;
|
|
9
|
+
headline?: string;
|
|
10
|
+
helperText?: string;
|
|
11
|
+
id?: string;
|
|
12
|
+
label?: string;
|
|
13
|
+
onChange?: (value: string) => void;
|
|
14
|
+
onOptionItemClick?: (value: string) => void;
|
|
15
|
+
onOutsideClick?: () => void;
|
|
16
|
+
onClick?: () => void;
|
|
17
|
+
onSheetClose?: () => void;
|
|
18
|
+
placeholder?: string;
|
|
19
|
+
searchPattern?: string;
|
|
20
|
+
open?: boolean;
|
|
21
|
+
value?: string;
|
|
22
|
+
noResultsText?: string;
|
|
23
|
+
}
|
|
24
|
+
interface ComboBoxOptionProps extends MenuItemProps {
|
|
25
|
+
key?: string;
|
|
26
|
+
value: string;
|
|
27
|
+
}
|
|
28
|
+
export { ComboBoxProps, ComboBoxOptionProps, ComboBoxOptionsProps };
|
package/lib/types.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
//# sourceMappingURL=types.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pixum/combobox",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.18.0",
|
|
4
4
|
"main": "lib/index.js",
|
|
5
5
|
"module": "lib/index.js",
|
|
6
6
|
"license": "UNLICENSED",
|
|
@@ -17,5 +17,5 @@
|
|
|
17
17
|
"files": [
|
|
18
18
|
"lib"
|
|
19
19
|
],
|
|
20
|
-
"gitHead": "
|
|
20
|
+
"gitHead": "09fd436a34536c99e27511dad192cd615f86d718"
|
|
21
21
|
}
|