@pie-lib/text-select 1.12.7 → 1.12.8-next.1639

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.
Files changed (35) hide show
  1. package/CHANGELOG.json +1 -632
  2. package/CHANGELOG.md +178 -28
  3. package/NEXT.CHANGELOG.json +1 -0
  4. package/lib/legend.js +63 -36
  5. package/lib/legend.js.map +1 -1
  6. package/lib/token-select/index.js +3 -2
  7. package/lib/token-select/index.js.map +1 -1
  8. package/lib/token-select/token.js +113 -74
  9. package/lib/token-select/token.js.map +1 -1
  10. package/lib/tokenizer/controls.js +14 -0
  11. package/lib/tokenizer/controls.js.map +1 -1
  12. package/lib/tokenizer/token-text.js +11 -2
  13. package/lib/tokenizer/token-text.js.map +1 -1
  14. package/package.json +8 -6
  15. package/src/__tests__/__snapshots__/text-select.test.jsx.snap +21 -0
  16. package/src/__tests__/text-select.test.jsx +34 -0
  17. package/src/__tests__/utils.test.jsx +27 -0
  18. package/src/legend.js +54 -36
  19. package/src/token-select/__tests__/__snapshots__/index.test.jsx.snap +49 -0
  20. package/src/token-select/__tests__/__snapshots__/token.test.jsx.snap +27 -0
  21. package/src/token-select/__tests__/index.test.jsx +257 -0
  22. package/src/token-select/__tests__/token.test.jsx +33 -0
  23. package/src/token-select/index.jsx +3 -1
  24. package/src/token-select/token.jsx +98 -72
  25. package/src/tokenizer/__tests__/__snapshots__/controls.test.jsx.snap +59 -0
  26. package/src/tokenizer/__tests__/__snapshots__/index.test.jsx.snap +31 -0
  27. package/src/tokenizer/__tests__/__snapshots__/token-text.test.jsx.snap +17 -0
  28. package/src/tokenizer/__tests__/builder.test.js +256 -0
  29. package/src/tokenizer/__tests__/controls.test.jsx +25 -0
  30. package/src/tokenizer/__tests__/index.test.jsx +140 -0
  31. package/src/tokenizer/__tests__/selection-utils.test.js +26 -0
  32. package/src/tokenizer/__tests__/token-text.test.jsx +136 -0
  33. package/src/tokenizer/controls.jsx +20 -1
  34. package/src/tokenizer/token-text.jsx +9 -0
  35. package/README.md +0 -3
package/CHANGELOG.md CHANGED
@@ -3,7 +3,7 @@
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
- ## [1.12.7](https://github.com/pie-framework/pie-lib/compare/@pie-lib/text-select@1.12.6...@pie-lib/text-select@1.12.7) (2023-10-03)
6
+ # [1.27.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/text-select@1.26.0...@pie-lib/text-select@1.27.0) (2025-09-18)
7
7
 
8
8
  **Note:** Version bump only for package @pie-lib/text-select
9
9
 
@@ -11,7 +11,7 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
11
11
 
12
12
 
13
13
 
14
- ## [1.12.6](https://github.com/pie-framework/pie-lib/compare/@pie-lib/text-select@1.12.5...@pie-lib/text-select@1.12.6) (2023-10-01)
14
+ # [1.26.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/text-select@1.25.0...@pie-lib/text-select@1.26.0) (2025-09-18)
15
15
 
16
16
  **Note:** Version bump only for package @pie-lib/text-select
17
17
 
@@ -19,7 +19,23 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
19
19
 
20
20
 
21
21
 
22
- ## [1.12.5](https://github.com/pie-framework/pie-lib/compare/@pie-lib/text-select@1.12.4...@pie-lib/text-select@1.12.5) (2023-09-27)
22
+ # [1.25.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/text-select@1.12.7...@pie-lib/text-select@1.25.0) (2025-09-18)
23
+
24
+
25
+ ### Bug Fixes
26
+
27
+ * fixed pie-lib/icons import [PD-5126] ([dcb506c](https://github.com/pie-framework/pie-lib/commit/dcb506c914a177f6d88bf73247a023bfe71dac1f))
28
+
29
+
30
+ ### Features
31
+
32
+ * split pie-toolbox into multiple packages [PD-5126] ([7d55a25](https://github.com/pie-framework/pie-lib/commit/7d55a2552d084cd3d0d5c00dc77411b2ced2f5e2))
33
+
34
+
35
+
36
+
37
+
38
+ # [1.24.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/text-select@1.23.0...@pie-lib/text-select@1.24.0) (2025-09-17)
23
39
 
24
40
  **Note:** Version bump only for package @pie-lib/text-select
25
41
 
@@ -27,7 +43,7 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
27
43
 
28
44
 
29
45
 
30
- ## [1.12.4](https://github.com/pie-framework/pie-lib/compare/@pie-lib/text-select@1.12.3...@pie-lib/text-select@1.12.4) (2023-09-27)
46
+ # [1.23.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/text-select@1.22.0...@pie-lib/text-select@1.23.0) (2025-09-17)
31
47
 
32
48
  **Note:** Version bump only for package @pie-lib/text-select
33
49
 
@@ -35,7 +51,7 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
35
51
 
36
52
 
37
53
 
38
- ## [1.12.3](https://github.com/pie-framework/pie-lib/compare/@pie-lib/text-select@1.12.2...@pie-lib/text-select@1.12.3) (2023-09-25)
54
+ # [1.22.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/text-select@1.21.1...@pie-lib/text-select@1.22.0) (2025-09-17)
39
55
 
40
56
  **Note:** Version bump only for package @pie-lib/text-select
41
57
 
@@ -43,109 +59,243 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
43
59
 
44
60
 
45
61
 
46
- ## [1.12.2](https://github.com/pie-framework/pie-lib/compare/@pie-lib/text-select@1.12.1...@pie-lib/text-select@1.12.2) (2023-09-20)
62
+ ## [1.21.1](https://github.com/pie-framework/pie-lib/compare/@pie-lib/text-select@1.12.7...@pie-lib/text-select@1.21.1) (2025-08-11)
63
+
64
+
65
+ ### Bug Fixes
66
+
67
+ * fixed pie-lib/icons import [PD-5126] ([dcb506c](https://github.com/pie-framework/pie-lib/commit/dcb506c914a177f6d88bf73247a023bfe71dac1f))
68
+
69
+
70
+ ### Features
71
+
72
+ * split pie-toolbox into multiple packages [PD-5126] ([7d55a25](https://github.com/pie-framework/pie-lib/commit/7d55a2552d084cd3d0d5c00dc77411b2ced2f5e2))
73
+
74
+
75
+
76
+
77
+
78
+ # [1.21.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/text-select@1.12.7...@pie-lib/text-select@1.21.0) (2025-08-07)
79
+
80
+ ### Features
81
+
82
+ - split pie-toolbox into multiple packages [PD-5126](<[7d55a25](https://github.com/pie-framework/pie-lib/commit/7d55a2552d084cd3d0d5c00dc77411b2ced2f5e2)>)
83
+
84
+ # [1.20.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/text-select@1.12.7...@pie-lib/text-select@1.20.0) (2025-07-31)
47
85
 
48
86
  **Note:** Version bump only for package @pie-lib/text-select
49
87
 
88
+ # [1.19.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/text-select@1.12.7...@pie-lib/text-select@1.19.0) (2025-07-31)
50
89
 
90
+ **Note:** Version bump only for package @pie-lib/text-select
51
91
 
92
+ # [1.18.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/text-select@1.12.7...@pie-lib/text-select@1.18.0) (2025-07-31)
52
93
 
94
+ **Note:** Version bump only for package @pie-lib/text-select
53
95
 
54
- ## [1.12.1](https://github.com/pie-framework/pie-lib/compare/@pie-lib/text-select@1.12.0...@pie-lib/text-select@1.12.1) (2023-09-20)
96
+ # [1.17.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/text-select@1.12.7...@pie-lib/text-select@1.17.0) (2025-07-31)
55
97
 
56
98
  **Note:** Version bump only for package @pie-lib/text-select
57
99
 
100
+ # [1.16.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/text-select@1.12.7...@pie-lib/text-select@1.16.0) (2025-07-31)
58
101
 
102
+ **Note:** Version bump only for package @pie-lib/text-select
59
103
 
104
+ # [1.15.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/text-select@1.12.7...@pie-lib/text-select@1.15.0) (2025-07-31)
60
105
 
106
+ **Note:** Version bump only for package @pie-lib/text-select
61
107
 
62
- # [1.12.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/text-select@1.11.3...@pie-lib/text-select@1.12.0) (2023-09-18)
108
+ # [1.17.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/text-select@1.12.7...@pie-lib/text-select@1.17.0) (2025-07-31)
63
109
 
110
+ **Note:** Version bump only for package @pie-lib/text-select
64
111
 
65
- ### Features
112
+ # [1.16.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/text-select@1.12.7...@pie-lib/text-select@1.16.0) (2025-07-31)
66
113
 
67
- * **translator, text-select:** add translations for new text-select legend PD-3162 ([20ee2c1](https://github.com/pie-framework/pie-lib/commit/20ee2c17873985fa06b4b58cf781742a5923b532))
114
+ **Note:** Version bump only for package @pie-lib/text-select
68
115
 
116
+ # [1.15.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/text-select@1.12.7...@pie-lib/text-select@1.15.0) (2025-07-31)
69
117
 
118
+ **Note:** Version bump only for package @pie-lib/text-select
70
119
 
120
+ # [1.16.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/text-select@1.12.7...@pie-lib/text-select@1.16.0) (2025-07-31)
71
121
 
122
+ **Note:** Version bump only for package @pie-lib/text-select
72
123
 
73
- ## [1.11.3](https://github.com/pie-framework/pie-lib/compare/@pie-lib/text-select@1.11.2...@pie-lib/text-select@1.11.3) (2023-09-14)
124
+ # [1.15.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/text-select@1.12.7...@pie-lib/text-select@1.15.0) (2025-07-31)
74
125
 
75
126
  **Note:** Version bump only for package @pie-lib/text-select
76
127
 
128
+ # [1.14.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/text-select@1.12.7...@pie-lib/text-select@1.14.0) (2025-07-31)
77
129
 
130
+ **Note:** Version bump only for package @pie-lib/text-select
78
131
 
132
+ # [1.14.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/text-select@1.12.7...@pie-lib/text-select@1.14.0) (2025-07-31)
79
133
 
134
+ **Note:** Version bump only for package @pie-lib/text-select
80
135
 
81
- ## [1.11.2](https://github.com/pie-framework/pie-lib/compare/@pie-lib/text-select@1.11.1...@pie-lib/text-select@1.11.2) (2023-08-29)
136
+ # [1.15.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/text-select@1.12.7...@pie-lib/text-select@1.15.0) (2025-07-31)
82
137
 
138
+ **Note:** Version bump only for package @pie-lib/text-select
83
139
 
84
- ### Bug Fixes
140
+ # [1.14.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/text-select@1.12.7...@pie-lib/text-select@1.14.0) (2025-07-31)
85
141
 
86
- * **text-select:** PD-3117 - avoids tokens overlapping in eval mode ([728c242](https://github.com/pie-framework/pie-lib/commit/728c24274c726907de568600b074305a145320ca))
87
- * **text-select:** PD-3134 replace typography with span to prevent materialui from overwriting styling ([a9c4860](https://github.com/pie-framework/pie-lib/commit/a9c4860701355e3e6b33145414658da06ba5a5a3))
142
+ **Note:** Version bump only for package @pie-lib/text-select
88
143
 
144
+ # [1.13.0-beta.8](https://github.com/pie-framework/pie-lib/compare/@pie-lib/text-select@1.12.7...@pie-lib/text-select@1.13.0-beta.8) (2025-07-25)
89
145
 
146
+ **Note:** Version bump only for package @pie-lib/text-select
90
147
 
148
+ # [1.13.0-beta.7](https://github.com/pie-framework/pie-lib/compare/@pie-lib/text-select@1.12.7...@pie-lib/text-select@1.13.0-beta.7) (2025-07-25)
91
149
 
150
+ **Note:** Version bump only for package @pie-lib/text-select
92
151
 
93
- ## [1.11.1](https://github.com/pie-framework/pie-lib/compare/@pie-lib/text-select@1.11.0...@pie-lib/text-select@1.11.1) (2023-08-21)
152
+ # [1.13.0-beta.7](https://github.com/pie-framework/pie-lib/compare/@pie-lib/text-select@1.12.7...@pie-lib/text-select@1.13.0-beta.7) (2025-07-25)
94
153
 
95
154
  **Note:** Version bump only for package @pie-lib/text-select
96
155
 
156
+ # [1.13.0-beta.6](https://github.com/pie-framework/pie-lib/compare/@pie-lib/text-select@1.12.7...@pie-lib/text-select@1.13.0-beta.6) (2025-07-25)
97
157
 
158
+ **Note:** Version bump only for package @pie-lib/text-select
98
159
 
160
+ # [1.13.0-beta.6](https://github.com/pie-framework/pie-lib/compare/@pie-lib/text-select@1.12.7...@pie-lib/text-select@1.13.0-beta.6) (2025-07-25)
99
161
 
162
+ **Note:** Version bump only for package @pie-lib/text-select
100
163
 
101
- # [1.11.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/text-select@1.10.0...@pie-lib/text-select@1.11.0) (2023-08-16)
164
+ # [1.13.0-beta.5](https://github.com/pie-framework/pie-lib/compare/@pie-lib/text-select@1.12.7...@pie-lib/text-select@1.13.0-beta.5) (2025-07-25)
102
165
 
166
+ **Note:** Version bump only for package @pie-lib/text-select
103
167
 
104
- ### Features
168
+ # [1.13.0-beta.5](https://github.com/pie-framework/pie-lib/compare/@pie-lib/text-select@1.12.7...@pie-lib/text-select@1.13.0-beta.5) (2025-07-25)
105
169
 
106
- * **text-select:** PD-1163 - add legend for icons used in eval mode ([7b2bac2](https://github.com/pie-framework/pie-lib/commit/7b2bac262d29986db2ce57ff6cee6c04af08472a))
170
+ **Note:** Version bump only for package @pie-lib/text-select
107
171
 
172
+ # [1.13.0-beta.4](https://github.com/pie-framework/pie-lib/compare/@pie-lib/text-select@1.12.7...@pie-lib/text-select@1.13.0-beta.4) (2025-07-25)
108
173
 
174
+ **Note:** Version bump only for package @pie-lib/text-select
175
+
176
+ # [1.13.0-beta.3](https://github.com/pie-framework/pie-lib/compare/@pie-lib/text-select@1.12.7...@pie-lib/text-select@1.13.0-beta.3) (2025-07-25)
109
177
 
178
+ **Note:** Version bump only for package @pie-lib/text-select
110
179
 
180
+ # [1.13.0-beta.4](https://github.com/pie-framework/pie-lib/compare/@pie-lib/text-select@1.12.7...@pie-lib/text-select@1.13.0-beta.4) (2025-07-23)
111
181
 
112
- # [1.10.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/text-select@1.9.29...@pie-lib/text-select@1.10.0) (2023-08-15)
182
+ **Note:** Version bump only for package @pie-lib/text-select
113
183
 
184
+ # [1.13.0-beta.3](https://github.com/pie-framework/pie-lib/compare/@pie-lib/text-select@1.12.7...@pie-lib/text-select@1.13.0-beta.3) (2025-07-23)
114
185
 
115
- ### Features
186
+ **Note:** Version bump only for package @pie-lib/text-select
187
+
188
+ # [1.13.0-beta.3](https://github.com/pie-framework/pie-lib/compare/@pie-lib/text-select@1.12.7...@pie-lib/text-select@1.13.0-beta.3) (2025-07-20)
116
189
 
117
- * **text-select:** adjust colors and alignment of the color ([a51ba55](https://github.com/pie-framework/pie-lib/commit/a51ba5547f6e1559915d6ea967d406923831b561))
118
- * **text-select:** PD-1163 create wrapper component ([b41db39](https://github.com/pie-framework/pie-lib/commit/b41db39ade332d19dca70a06d54acf51b5888c69))
119
- * **text-select:** PD-1163 update snapshots ([6b8edf8](https://github.com/pie-framework/pie-lib/commit/6b8edf83b763abdd93eee2655be3600cef90586b))
120
- * **text-select:** PD-1163 updates to tokens in text select ([2535c91](https://github.com/pie-framework/pie-lib/commit/2535c911f378f4cf41c8471bfa1898b996ffacee))
190
+ **Note:** Version bump only for package @pie-lib/text-select
121
191
 
192
+ # [1.13.0-beta.2](https://github.com/pie-framework/pie-lib/compare/@pie-lib/text-select@1.12.7...@pie-lib/text-select@1.13.0-beta.2) (2025-07-20)
122
193
 
194
+ **Note:** Version bump only for package @pie-lib/text-select
123
195
 
196
+ # [1.13.0-beta.1](https://github.com/pie-framework/pie-lib/compare/@pie-lib/text-select@1.12.7...@pie-lib/text-select@1.13.0-beta.1) (2025-07-20)
124
197
 
198
+ **Note:** Version bump only for package @pie-lib/text-select
125
199
 
126
- ## [1.9.29](https://github.com/pie-framework/pie-lib/compare/@pie-lib/text-select@1.9.28...@pie-lib/text-select@1.9.29) (2023-07-24)
200
+ # [1.13.0-beta.2](https://github.com/pie-framework/pie-lib/compare/@pie-lib/text-select@1.12.7...@pie-lib/text-select@1.13.0-beta.2) (2025-07-20)
127
201
 
128
202
  **Note:** Version bump only for package @pie-lib/text-select
129
203
 
204
+ # [1.13.0-beta.1](https://github.com/pie-framework/pie-lib/compare/@pie-lib/text-select@1.12.7...@pie-lib/text-select@1.13.0-beta.1) (2025-07-20)
130
205
 
206
+ **Note:** Version bump only for package @pie-lib/text-select
131
207
 
208
+ # [1.13.0-beta.1](https://github.com/pie-framework/pie-lib/compare/@pie-lib/text-select@1.12.7...@pie-lib/text-select@1.13.0-beta.1) (2025-07-20)
132
209
 
210
+ **Note:** Version bump only for package @pie-lib/text-select
133
211
 
134
- ## [1.9.28](https://github.com/pie-framework/pie-lib/compare/@pie-lib/text-select@1.9.27...@pie-lib/text-select@1.9.28) (2023-06-24)
212
+ # [1.13.0-beta.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/text-select@1.12.7...@pie-lib/text-select@1.13.0-beta.0) (2025-07-20)
213
+
214
+ **Note:** Version bump only for package @pie-lib/text-select
215
+
216
+ # [1.14.0-beta.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/text-select@1.12.7...@pie-lib/text-select@1.14.0-beta.0) (2025-07-15)
135
217
 
136
218
  **Note:** Version bump only for package @pie-lib/text-select
137
219
 
220
+ # [1.13.0-beta.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/text-select@1.12.7...@pie-lib/text-select@1.13.0-beta.0) (2025-07-15)
138
221
 
222
+ **Note:** Version bump only for package @pie-lib/text-select
139
223
 
224
+ ## [1.12.7](https://github.com/pie-framework/pie-lib/compare/@pie-lib/text-select@1.12.6...@pie-lib/text-select@1.12.7) (2023-10-03)
140
225
 
226
+ **Note:** Version bump only for package @pie-lib/text-select
141
227
 
142
- ## [1.9.27](https://github.com/pie-framework/pie-lib/compare/@pie-lib/text-select@1.9.26...@pie-lib/text-select@1.9.27) (2023-06-13)
228
+ ## [1.12.6](https://github.com/pie-framework/pie-lib/compare/@pie-lib/text-select@1.12.5...@pie-lib/text-select@1.12.6) (2023-10-01)
229
+
230
+ **Note:** Version bump only for package @pie-lib/text-select
231
+
232
+ ## [1.12.5](https://github.com/pie-framework/pie-lib/compare/@pie-lib/text-select@1.12.4...@pie-lib/text-select@1.12.5) (2023-09-27)
233
+
234
+ **Note:** Version bump only for package @pie-lib/text-select
235
+
236
+ ## [1.12.4](https://github.com/pie-framework/pie-lib/compare/@pie-lib/text-select@1.12.3...@pie-lib/text-select@1.12.4) (2023-09-27)
237
+
238
+ **Note:** Version bump only for package @pie-lib/text-select
239
+
240
+ ## [1.12.3](https://github.com/pie-framework/pie-lib/compare/@pie-lib/text-select@1.12.2...@pie-lib/text-select@1.12.3) (2023-09-25)
143
241
 
144
242
  **Note:** Version bump only for package @pie-lib/text-select
145
243
 
244
+ ## [1.12.2](https://github.com/pie-framework/pie-lib/compare/@pie-lib/text-select@1.12.1...@pie-lib/text-select@1.12.2) (2023-09-20)
146
245
 
246
+ **Note:** Version bump only for package @pie-lib/text-select
147
247
 
248
+ ## [1.12.1](https://github.com/pie-framework/pie-lib/compare/@pie-lib/text-select@1.12.0...@pie-lib/text-select@1.12.1) (2023-09-20)
249
+
250
+ **Note:** Version bump only for package @pie-lib/text-select
251
+
252
+ # [1.12.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/text-select@1.11.3...@pie-lib/text-select@1.12.0) (2023-09-18)
253
+
254
+ ### Features
148
255
 
256
+ - **translator, text-select:** add translations for new text-select legend PD-3162 ([20ee2c1](https://github.com/pie-framework/pie-lib/commit/20ee2c17873985fa06b4b58cf781742a5923b532))
257
+
258
+ ## [1.11.3](https://github.com/pie-framework/pie-lib/compare/@pie-lib/text-select@1.11.2...@pie-lib/text-select@1.11.3) (2023-09-14)
259
+
260
+ **Note:** Version bump only for package @pie-lib/text-select
261
+
262
+ ## [1.11.2](https://github.com/pie-framework/pie-lib/compare/@pie-lib/text-select@1.11.1...@pie-lib/text-select@1.11.2) (2023-08-29)
263
+
264
+ ### Bug Fixes
265
+
266
+ - **text-select:** PD-3117 - avoids tokens overlapping in eval mode ([728c242](https://github.com/pie-framework/pie-lib/commit/728c24274c726907de568600b074305a145320ca))
267
+ - **text-select:** PD-3134 replace typography with span to prevent materialui from overwriting styling ([a9c4860](https://github.com/pie-framework/pie-lib/commit/a9c4860701355e3e6b33145414658da06ba5a5a3))
268
+
269
+ ## [1.11.1](https://github.com/pie-framework/pie-lib/compare/@pie-lib/text-select@1.11.0...@pie-lib/text-select@1.11.1) (2023-08-21)
270
+
271
+ **Note:** Version bump only for package @pie-lib/text-select
272
+
273
+ # [1.11.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/text-select@1.10.0...@pie-lib/text-select@1.11.0) (2023-08-16)
274
+
275
+ ### Features
276
+
277
+ - **text-select:** PD-1163 - add legend for icons used in eval mode ([7b2bac2](https://github.com/pie-framework/pie-lib/commit/7b2bac262d29986db2ce57ff6cee6c04af08472a))
278
+
279
+ # [1.10.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/text-select@1.9.29...@pie-lib/text-select@1.10.0) (2023-08-15)
280
+
281
+ ### Features
282
+
283
+ - **text-select:** adjust colors and alignment of the color ([a51ba55](https://github.com/pie-framework/pie-lib/commit/a51ba5547f6e1559915d6ea967d406923831b561))
284
+ - **text-select:** PD-1163 create wrapper component ([b41db39](https://github.com/pie-framework/pie-lib/commit/b41db39ade332d19dca70a06d54acf51b5888c69))
285
+ - **text-select:** PD-1163 update snapshots ([6b8edf8](https://github.com/pie-framework/pie-lib/commit/6b8edf83b763abdd93eee2655be3600cef90586b))
286
+ - **text-select:** PD-1163 updates to tokens in text select ([2535c91](https://github.com/pie-framework/pie-lib/commit/2535c911f378f4cf41c8471bfa1898b996ffacee))
287
+
288
+ ## [1.9.29](https://github.com/pie-framework/pie-lib/compare/@pie-lib/text-select@1.9.28...@pie-lib/text-select@1.9.29) (2023-07-24)
289
+
290
+ **Note:** Version bump only for package @pie-lib/text-select
291
+
292
+ ## [1.9.28](https://github.com/pie-framework/pie-lib/compare/@pie-lib/text-select@1.9.27...@pie-lib/text-select@1.9.28) (2023-06-24)
293
+
294
+ **Note:** Version bump only for package @pie-lib/text-select
295
+
296
+ ## [1.9.27](https://github.com/pie-framework/pie-lib/compare/@pie-lib/text-select@1.9.26...@pie-lib/text-select@1.9.27) (2023-06-13)
297
+
298
+ **Note:** Version bump only for package @pie-lib/text-select
149
299
 
150
300
  ## [1.9.26](https://github.com/pie-framework/pie-lib/compare/@pie-lib/text-select@1.9.25...@pie-lib/text-select@1.9.26) (2023-06-12)
151
301
 
@@ -0,0 +1 @@
1
+ []
package/lib/legend.js CHANGED
@@ -15,18 +15,19 @@ var _Check = _interopRequireDefault(require("@material-ui/icons/Check"));
15
15
 
16
16
  var _Close = _interopRequireDefault(require("@material-ui/icons/Close"));
17
17
 
18
- var _Remove = _interopRequireDefault(require("@material-ui/icons/Remove"));
19
-
20
18
  var _renderUi = require("@pie-lib/render-ui");
21
19
 
22
20
  var _translator = _interopRequireDefault(require("@pie-lib/translator"));
23
21
 
22
+ var _classnames = _interopRequireDefault(require("classnames"));
23
+
24
24
  var translator = _translator["default"].translator;
25
25
  var Legend = (0, _styles.withStyles)(function (theme) {
26
26
  return {
27
27
  flexContainer: {
28
28
  display: 'flex',
29
29
  flexDirection: 'row',
30
+ alignItems: 'center',
30
31
  gap: "".concat(2 * theme.spacing.unit, "px"),
31
32
  borderBottom: '1px solid lightgrey',
32
33
  borderTop: '1px solid lightgrey',
@@ -34,65 +35,91 @@ var Legend = (0, _styles.withStyles)(function (theme) {
34
35
  paddingTop: theme.spacing.unit,
35
36
  marginBottom: theme.spacing.unit
36
37
  },
38
+ key: {
39
+ fontSize: '14px',
40
+ fontWeight: 'bold',
41
+ color: _renderUi.color.black(),
42
+ marginLeft: theme.spacing.unit
43
+ },
37
44
  container: {
38
- display: 'flex',
39
- flexDirection: 'row',
40
- gap: "".concat(theme.spacing.unit / 2, "px"),
41
- alignItems: 'center'
45
+ position: 'relative',
46
+ padding: '4px',
47
+ fontSize: '14px',
48
+ borderRadius: '4px'
42
49
  },
43
50
  correct: {
44
- fontSize: 'larger',
45
- color: _renderUi.color.correct(),
46
- backgroundColor: _renderUi.color.correctSecondary(),
47
- border: "2px solid ".concat(_renderUi.color.correct())
51
+ border: "".concat(_renderUi.color.correctTertiary(), " solid 2px")
48
52
  },
49
53
  incorrect: {
50
- fontSize: 'larger',
51
- color: _renderUi.color.missing(),
52
- backgroundColor: _renderUi.color.incorrectSecondary(),
53
- border: "2px solid ".concat(_renderUi.color.missing())
54
+ border: "".concat(_renderUi.color.incorrectWithIcon(), " solid 2px")
54
55
  },
55
56
  missing: {
56
- fontSize: 'larger',
57
- color: _renderUi.color.missing(),
58
- backgroundColor: _renderUi.color.incorrectSecondary(),
59
- border: "2px dashed ".concat(_renderUi.color.missing())
57
+ border: "".concat(_renderUi.color.incorrectWithIcon(), " dashed 2px")
58
+ },
59
+ incorrectIcon: {
60
+ backgroundColor: _renderUi.color.incorrectWithIcon()
61
+ },
62
+ correctIcon: {
63
+ backgroundColor: _renderUi.color.correctTertiary()
64
+ },
65
+ icon: {
66
+ color: _renderUi.color.white(),
67
+ position: 'absolute',
68
+ top: '-8px',
69
+ left: '-8px',
70
+ borderRadius: '50%',
71
+ fontSize: '12px',
72
+ padding: '2px'
60
73
  }
61
74
  };
62
75
  })(function (_ref) {
63
76
  var classes = _ref.classes,
64
- language = _ref.language;
65
- var icons = [{
66
- iconName: _Check["default"],
77
+ language = _ref.language,
78
+ showOnlyCorrect = _ref.showOnlyCorrect;
79
+ var legendItems = [{
80
+ Icon: _Check["default"],
67
81
  label: translator.t('selectText.correctAnswerSelected', {
68
82
  lng: language
69
83
  }),
70
- className: classes.correct
84
+ containerClass: (0, _classnames["default"])(classes.correct, classes.container),
85
+ iconClass: (0, _classnames["default"])(classes.correctIcon, classes.icon)
71
86
  }, {
72
- iconName: _Remove["default"],
73
- label: translator.t('selectText.correctAnswerNotSelected', {
87
+ Icon: _Close["default"],
88
+ label: translator.t('selectText.incorrectSelection', {
74
89
  lng: language
75
90
  }),
76
- className: classes.missing
91
+ containerClass: (0, _classnames["default"])(classes.incorrect, classes.container),
92
+ iconClass: (0, _classnames["default"])(classes.incorrectIcon, classes.icon)
77
93
  }, {
78
- iconName: _Close["default"],
79
- label: translator.t('selectText.incorrectSelection', {
94
+ Icon: _Close["default"],
95
+ label: translator.t('selectText.correctAnswerNotSelected', {
80
96
  lng: language
81
97
  }),
82
- className: classes.incorrect
98
+ containerClass: (0, _classnames["default"])(classes.missing, classes.container),
99
+ iconClass: (0, _classnames["default"])(classes.incorrectIcon, classes.icon)
83
100
  }];
101
+
102
+ if (showOnlyCorrect) {
103
+ legendItems.splice(1, 2);
104
+ }
105
+
84
106
  return /*#__PURE__*/_react["default"].createElement("div", {
85
107
  className: classes.flexContainer
86
- }, icons.map(function (icon, index) {
87
- var Icon = icon.iconName;
108
+ }, /*#__PURE__*/_react["default"].createElement("span", {
109
+ className: classes.key
110
+ }, translator.t('selectText.key', {
111
+ lng: language
112
+ })), legendItems.map(function (_ref2, idx) {
113
+ var Icon = _ref2.Icon,
114
+ label = _ref2.label,
115
+ containerClass = _ref2.containerClass,
116
+ iconClass = _ref2.iconClass;
88
117
  return /*#__PURE__*/_react["default"].createElement("div", {
89
- key: index,
90
- className: classes.container
118
+ key: idx,
119
+ className: containerClass
91
120
  }, /*#__PURE__*/_react["default"].createElement(Icon, {
92
- className: icon.className,
93
- width: '19px',
94
- height: '19px'
95
- }), /*#__PURE__*/_react["default"].createElement("span", null, icon.label));
121
+ className: iconClass
122
+ }), /*#__PURE__*/_react["default"].createElement("span", null, label));
96
123
  }));
97
124
  });
98
125
  exports.Legend = Legend;
package/lib/legend.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/legend.js"],"names":["translator","Translator","Legend","theme","flexContainer","display","flexDirection","gap","spacing","unit","borderBottom","borderTop","paddingBottom","paddingTop","marginBottom","container","alignItems","correct","fontSize","color","backgroundColor","correctSecondary","border","incorrect","missing","incorrectSecondary","classes","language","icons","iconName","Check","label","t","lng","className","Remove","Close","map","icon","index","Icon"],"mappings":";;;;;;;;;A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AAAM,MAAA,SAAS,EAAEuB,IAAI,CAACJ,SAAtB;AAAiC,MAAA,KAAK,EAAE,MAAxC;AAAgD,MAAA,MAAM,EAAE;AAAxD,MADF,eAEE,8CAAOI,IAAI,CAACP,KAAZ,CAFF,CADF;AAMD,GARA,CADH,CADF;AAaD,CAnEqB,CAAf","sourcesContent":["import React from 'react';\nimport { withStyles } from '@material-ui/core/styles';\nimport Check from '@material-ui/icons/Check';\nimport Close from '@material-ui/icons/Close';\nimport Remove from '@material-ui/icons/Remove';\nimport { color } from '@pie-lib/render-ui';\nimport Translator from '@pie-lib/translator';\n\nconst { translator } = Translator;\n\nexport const Legend = withStyles((theme) => ({\n flexContainer: {\n display: 'flex',\n flexDirection: 'row',\n gap: `${2 * theme.spacing.unit}px`,\n borderBottom: '1px solid lightgrey',\n borderTop: '1px solid lightgrey',\n paddingBottom: theme.spacing.unit,\n paddingTop: theme.spacing.unit,\n marginBottom: theme.spacing.unit,\n },\n container: {\n display: 'flex',\n flexDirection: 'row',\n gap: `${theme.spacing.unit / 2}px`,\n alignItems: 'center',\n },\n correct: {\n fontSize: 'larger',\n color: color.correct(),\n backgroundColor: color.correctSecondary(),\n border: `2px solid ${color.correct()}`,\n },\n incorrect: {\n fontSize: 'larger',\n color: color.missing(),\n backgroundColor: color.incorrectSecondary(),\n border: `2px solid ${color.missing()}`,\n },\n missing: {\n fontSize: 'larger',\n color: color.missing(),\n backgroundColor: color.incorrectSecondary(),\n border: `2px dashed ${color.missing()}`,\n },\n}))(({ classes, language }) => {\n const icons = [\n {\n iconName: Check,\n label: translator.t('selectText.correctAnswerSelected', { lng: language }),\n className: classes.correct,\n },\n {\n iconName: Remove,\n label: translator.t('selectText.correctAnswerNotSelected', { lng: language }),\n className: classes.missing,\n },\n {\n iconName: Close,\n label: translator.t('selectText.incorrectSelection', { lng: language }),\n className: classes.incorrect,\n },\n ];\n\n return (\n <div className={classes.flexContainer}>\n {icons.map((icon, index) => {\n const Icon = icon.iconName;\n return (\n <div key={index} className={classes.container}>\n <Icon className={icon.className} width={'19px'} height={'19px'}></Icon>\n <span>{icon.label}</span>\n </div>\n );\n })}\n </div>\n );\n});\n"],"file":"legend.js"}
1
+ {"version":3,"sources":["../src/legend.js"],"names":["translator","Translator","Legend","theme","flexContainer","display","flexDirection","alignItems","gap","spacing","unit","borderBottom","borderTop","paddingBottom","paddingTop","marginBottom","key","fontSize","fontWeight","color","black","marginLeft","container","position","padding","borderRadius","correct","border","correctTertiary","incorrect","incorrectWithIcon","missing","incorrectIcon","backgroundColor","correctIcon","icon","white","top","left","classes","language","showOnlyCorrect","legendItems","Icon","Check","label","t","lng","containerClass","iconClass","Close","splice","map","idx"],"mappings":";;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA,IAAQA,UAAR,GAAuBC,sBAAvB,CAAQD,UAAR;AAEO,IAAME,MAAM,GAAG,wBAAW,UAACC,KAAD;AAAA,SAAY;AAC3CC,IAAAA,aAAa,EAAE;AACbC,MAAAA,OAAO,EAAE,MADI;AAEbC,MAAAA,aAAa,EAAE,KAFF;AAGbC,MAAAA,UAAU,EAAE,QAHC;AAIbC,MAAAA,GAAG,YAAK,IAAIL,KAAK,CAACM,OAAN,CAAcC,IAAvB,OAJU;AAKbC,MAAAA,YAAY,EAAE,qBALD;AAMbC,MAAAA,SAAS,EAAE,qBANE;AAObC,MAAAA,aAAa,EAAEV,KAAK,CAACM,OAAN,CAAcC,IAPhB;AAQbI,MAAAA,UAAU,EAAEX,KAAK,CAACM,OAAN,CAAcC,IARb;AASbK,MAAAA,YAAY,EAAEZ,KAAK,CAACM,OAAN,CAAcC;AATf,KAD4B;AAY3CM,IAAAA,GAAG,EAAE;AACHC,MAAAA,QAAQ,EAAE,MADP;AAEHC,MAAAA,UAAU,EAAE,MAFT;AAGHC,MAAAA,KAAK,EAAEA,gBAAMC,KAAN,EAHJ;AAIHC,MAAAA,UAAU,EAAElB,KAAK,CAACM,OAAN,CAAcC;AAJvB,KAZsC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AAA,QAAGV,IAAH,SAAGA,IAAH;AAAA,QAASE,KAAT,SAASA,KAAT;AAAA,QAAgBG,cAAhB,SAAgBA,cAAhB;AAAA,QAAgCC,SAAhC,SAAgCA,SAAhC;AAAA,wBACf;AAAK,MAAA,GAAG,EAAEI,GAAV;AAAe,MAAA,SAAS,EAAEL;AAA1B,oBACE,gCAAC,IAAD;AAAM,MAAA,SAAS,EAAEC;AAAjB,MADF,eAEE,8CAAOJ,KAAP,CAFF,CADe;AAAA,GAAhB,CAFH,CADF;AAWD,CArFqB,CAAf","sourcesContent":["import React from 'react';\nimport { withStyles } from '@material-ui/core/styles';\nimport Check from '@material-ui/icons/Check';\nimport Close from '@material-ui/icons/Close';\nimport { color } from '@pie-lib/render-ui';\nimport Translator from '@pie-lib/translator';\nimport classNames from 'classnames';\n\nconst { translator } = Translator;\n\nexport const Legend = withStyles((theme) => ({\n flexContainer: {\n display: 'flex',\n flexDirection: 'row',\n alignItems: 'center',\n gap: `${2 * theme.spacing.unit}px`,\n borderBottom: '1px solid lightgrey',\n borderTop: '1px solid lightgrey',\n paddingBottom: theme.spacing.unit,\n paddingTop: theme.spacing.unit,\n marginBottom: theme.spacing.unit,\n },\n key: {\n fontSize: '14px',\n fontWeight: 'bold',\n color: color.black(),\n marginLeft: theme.spacing.unit,\n },\n container: {\n position: 'relative',\n padding: '4px',\n fontSize: '14px',\n borderRadius: '4px',\n },\n correct: {\n border: `${color.correctTertiary()} solid 2px`,\n },\n incorrect: {\n border: `${color.incorrectWithIcon()} solid 2px`,\n },\n missing: {\n border: `${color.incorrectWithIcon()} dashed 2px`,\n },\n incorrectIcon: {\n backgroundColor: color.incorrectWithIcon(),\n },\n correctIcon: {\n backgroundColor: color.correctTertiary(),\n },\n icon: {\n color: color.white(),\n position: 'absolute',\n top: '-8px',\n left: '-8px',\n borderRadius: '50%',\n fontSize: '12px',\n padding: '2px',\n },\n}))(({ classes, language, showOnlyCorrect }) => {\n const legendItems = [\n {\n Icon: Check,\n label: translator.t('selectText.correctAnswerSelected', { lng: language }),\n containerClass: classNames(classes.correct, classes.container),\n iconClass: classNames(classes.correctIcon, classes.icon),\n },\n {\n Icon: Close,\n label: translator.t('selectText.incorrectSelection', { lng: language }),\n containerClass: classNames(classes.incorrect, classes.container),\n iconClass: classNames(classes.incorrectIcon, classes.icon),\n },\n {\n Icon: Close,\n label: translator.t('selectText.correctAnswerNotSelected', { lng: language }),\n containerClass: classNames(classes.missing, classes.container),\n iconClass: classNames(classes.incorrectIcon, classes.icon),\n },\n ];\n\n if (showOnlyCorrect) {\n legendItems.splice(1, 2);\n }\n\n return (\n <div className={classes.flexContainer}>\n <span className={classes.key}>{translator.t('selectText.key', { lng: language })}</span>\n {legendItems.map(({ Icon, label, containerClass, iconClass }, idx) => (\n <div key={idx} className={containerClass}>\n <Icon className={iconClass} />\n <span>{label}</span>\n </div>\n ))}\n </div>\n );\n});\n"],"file":"legend.js"}
@@ -97,9 +97,10 @@ var TokenSelect = /*#__PURE__*/function (_React$Component) {
97
97
  var tokensCloned = (0, _clone["default"])(tokens);
98
98
  var targetSpanWrapper = target.closest(".".concat(_token["default"].rootClassName));
99
99
  var targetedTokenIndex = targetSpanWrapper && targetSpanWrapper.dataset && targetSpanWrapper.dataset.indexkey;
100
- var t = targetedTokenIndex && tokensCloned[targetedTokenIndex];
100
+ var t = targetedTokenIndex && tokensCloned[targetedTokenIndex]; // don't toggle if we are in print mode, token correctness is defined or if it's missing
101
+ // (missing means that it was evaluated as correct and not selected)
101
102
 
102
- if (t && t.correct === undefined && !animationsDisabled) {
103
+ if (t && t.correct === undefined && !animationsDisabled && !t.isMissing) {
103
104
  var _this$props2 = _this.props,
104
105
  onChange = _this$props2.onChange,
105
106
  maxNoOfSelections = _this$props2.maxNoOfSelections;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/token-select/index.jsx"],"names":["log","TokenSelect","props","tokens","filter","t","selected","length","selectedCount","maxNoOfSelections","isFinite","event","target","animationsDisabled","tokensCloned","targetSpanWrapper","closest","Token","rootClassName","targetedTokenIndex","dataset","indexkey","correct","undefined","onChange","selectedToken","updatedTokens","map","token","selectable","update","splice","disabled","highlightChoices","isLineBreak","text","isNewParagraph","reducer","accumulator","index","canSelectMore","showCorrectAnswer","finalAcc","isMissing","predefined","reduceResult","reduce","classes","classNameProp","className","tokenSelect","html","generateTokensInHtml","__html","toggleToken","React","Component","PropTypes","arrayOf","shape","TokenTypes","isRequired","string","object","func","bool","number","backgroundColor","whiteSpace"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;;;;;AAEA,IAAMA,GAAG,GAAG,uBAAM,mCAAN,CAAZ;;IAEaC,W;;;;;;;;;;;;;;;sGAkBK;AAAA,aAAM,MAAKC,KAAL,CAAWC,MAAX,CAAkBC,MAAlB,CAAyB,UAACC,CAAD;AAAA,eAAOA,CAAC,CAACC,QAAT;AAAA,OAAzB,EAA4CC,MAAlD;AAAA,K;sGAEA,UAACC,aAAD,EAAmB;AACjC,UAAQC,iBAAR,GAA8B,MAAKP,KAAnC,CAAQO,iBAAR;;AAEA,UAAIA,iBAAiB,KAAK,CAA1B,EAA6B;AAC3B,eAAO,IAAP;AACD;;AAEDT,MAAAA,GAAG,CAAC,qCAAD,EAAwCS,iBAAxC,EAA2D,iBAA3D,EAA8ED,aAA9E,CAAH;AACA,aAAOC,iBAAiB,IAAI,CAArB,IAA2BC,QAAQ,CAACD,iBAAD,CAAR,IAA+BD,aAAa,GAAGC,iBAAjF;AACD,K;oGAUa,UAACE,KAAD,EAAW;AACvB,UAAQC,MAAR,GAAmBD,KAAnB,CAAQC,MAAR;AACA,wBAAuC,MAAKV,KAA5C;AAAA,UAAQC,MAAR,eAAQA,MAAR;AAAA,UAAgBU,kBAAhB,eAAgBA,kBAAhB;AACA,UAAMC,YAAY,GAAG,uBAAMX,MAAN,CAArB;AACA,UAAMY,iBAAiB,GAAGH,MA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,eACQ;AACjBE,EAAAA,MAAM,EAAEsD,sBAAUC,OAAV,CAAkBD,sBAAUE,KAAV,CAAgBC,iBAAhB,CAAlB,EAA+CC,UADtC;AAEjBZ,EAAAA,SAAS,EAAEQ,sBAAUK,MAFJ;AAGjBf,EAAAA,OAAO,EAAEU,sBAAUM,MAAV,CAAiBF,UAHT;AAIjBrC,EAAAA,QAAQ,EAAEiC,sBAAUO,IAAV,CAAeH,UAJR;AAKjB7B,EAAAA,QAAQ,EAAEyB,sBAAUQ,IALH;AAMjBhC,EAAAA,gBAAgB,EAAEwB,sBAAUQ,IANX;AAOjBpD,EAAAA,kBAAkB,EAAE4C,sBAAUQ,IAPb;AAQjBxD,EAAAA,iBAAiB,EAAEgD,sBAAUS;AARZ,C;iCADRjE,W,kBAYW;AACpBgC,EAAAA,gBAAgB,EAAE,KADE;AAEpBxB,EAAAA,iBAAiB,EAAE,CAFC;AAGpBN,EAAAA,MAAM,EAAE;AAHY,C;;eA+HT,wBAAW;AAAA,SAAO;AAC/B+C,IAAAA,WAAW;AACTiB,MAAAA,eAAe,EAAE,MADR;AAETC,MAAAA,UAAU,EAAE;AAFH,OAGN,2BAHM;AAIT,aAAO;AACLA,QAAAA,UAAU,EAAE;AADP;AAJE;AADoB,GAAP;AAAA,CAAX,EASXnE,WATW,C","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport Token, { TokenTypes } from './token';\nimport { withStyles } from '@material-ui/core/styles';\nimport classNames from 'classnames';\nimport clone from 'lodash/clone';\nimport debug from 'debug';\nimport { noSelect } from '@pie-lib/style-utils';\nimport { renderToString } from 'react-dom/server';\nimport isEqual from 'lodash/isEqual';\n\nconst log = debug('@pie-lib:text-select:token-select');\n\nexport class TokenSelect extends React.Component {\n static propTypes = {\n tokens: PropTypes.arrayOf(PropTypes.shape(TokenTypes)).isRequired,\n className: PropTypes.string,\n classes: PropTypes.object.isRequired,\n onChange: PropTypes.func.isRequired,\n disabled: PropTypes.bool,\n highlightChoices: PropTypes.bool,\n animationsDisabled: PropTypes.bool,\n maxNoOfSelections: PropTypes.number,\n };\n\n static defaultProps = {\n highlightChoices: false,\n maxNoOfSelections: 0,\n tokens: [],\n };\n\n selectedCount = () => this.props.tokens.filter((t) => t.selected).length;\n\n canSelectMore = (selectedCount) => {\n const { maxNoOfSelections } = this.props;\n\n if (maxNoOfSelections === 1) {\n return true;\n }\n\n log('[canSelectMore] maxNoOfSelections: ', maxNoOfSelections, 'selectedCount: ', selectedCount);\n return maxNoOfSelections <= 0 || (isFinite(maxNoOfSelections) && selectedCount < maxNoOfSelections);\n };\n\n /**\n @function\n @param { object } event\n\n @description\n each token is wrapped into a span that has Token.rootClassName class and indexkey attribute (represents the index of the token)\n tokens are updated with the targeted token having the correct value set for 'selected' property\n */\n toggleToken = (event) => {\n const { target } = event;\n const { tokens, animationsDisabled } = this.props;\n const tokensCloned = clone(tokens);\n const targetSpanWrapper = target.closest(`.${Token.rootClassName}`);\n const targetedTokenIndex = targetSpanWrapper && targetSpanWrapper.dataset && targetSpanWrapper.dataset.indexkey;\n const t = targetedTokenIndex && tokensCloned[targetedTokenIndex];\n\n if (t && t.correct === undefined && !animationsDisabled) {\n const { onChange, maxNoOfSelections } = this.props;\n const selected = !t.selected;\n\n if (maxNoOfSelections === 1 && this.selectedCount() === 1) {\n const selectedToken = (tokens || []).filter((t) => t.selected);\n\n const updatedTokens = tokensCloned.map((token) => {\n if (isEqual(token, selectedToken[0])) {\n return { ...token, selected: false };\n }\n\n return { ...token, selectable: true };\n });\n\n const update = { ...t, selected: !t.selected };\n\n updatedTokens.splice(targetedTokenIndex, 1, update);\n onChange(updatedTokens);\n } else {\n if (selected && maxNoOfSelections > 0 && this.selectedCount() >= maxNoOfSelections) {\n log('skip toggle max reached');\n return;\n }\n\n const update = { ...t, selected: !t.selected };\n\n tokensCloned.splice(targetedTokenIndex, 1, update);\n onChange(tokensCloned);\n }\n }\n };\n\n generateTokensInHtml = () => {\n const { tokens, disabled, highlightChoices, animationsDisabled } = this.props;\n const selectedCount = this.selectedCount();\n const isLineBreak = (text) => text === '\\n';\n const isNewParagraph = (text) => text === '\\n\\n';\n\n const reducer = (accumulator, t, index) => {\n const selectable = t.selected || (t.selectable && this.canSelectMore(selectedCount));\n const showCorrectAnswer = t.correct !== undefined && (t.selectable || t.selected);\n let finalAcc = accumulator;\n\n if (isNewParagraph(t.text)) {\n return finalAcc + '</p><p>';\n }\n\n if (isLineBreak(t.text)) {\n return finalAcc + '<br>';\n }\n\n if (\n (selectable && !disabled) ||\n showCorrectAnswer ||\n t.selected ||\n t.isMissing ||\n (animationsDisabled && t.predefined) // if we are in print mode\n ) {\n return (\n finalAcc +\n renderToString(\n <Token\n key={index}\n disabled={disabled}\n index={index}\n {...t}\n selectable={selectable}\n highlight={highlightChoices}\n animationsDisabled={animationsDisabled}\n />,\n )\n );\n } else {\n return accumulator + t.text;\n }\n };\n\n const reduceResult = (tokens || []).reduce(reducer, '<p>');\n\n return reduceResult + '</p>';\n };\n\n render() {\n const { classes, className: classNameProp } = this.props;\n const className = classNames(classes.tokenSelect, classNameProp);\n const html = this.generateTokensInHtml();\n\n return <div className={className} dangerouslySetInnerHTML={{ __html: html }} onClick={this.toggleToken} />;\n }\n}\n\nexport default withStyles(() => ({\n tokenSelect: {\n backgroundColor: 'none',\n whiteSpace: 'pre',\n ...noSelect(),\n '& p': {\n whiteSpace: 'break-spaces',\n },\n },\n}))(TokenSelect);\n"],"file":"index.js"}
1
+ {"version":3,"sources":["../../src/token-select/index.jsx"],"names":["log","TokenSelect","props","tokens","filter","t","selected","length","selectedCount","maxNoOfSelections","isFinite","event","target","animationsDisabled","tokensCloned","targetSpanWrapper","closest","Token","rootClassName","targetedTokenIndex","dataset","indexkey","correct","undefined","isMissing","onChange","selectedToken","updatedTokens","map","token","selectable","update","splice","disabled","highlightChoices","isLineBreak","text","isNewParagraph","reducer","accumulator","index","canSelectMore","showCorrectAnswer","finalAcc","predefined","reduceResult","reduce","classes","classNameProp","className","tokenSelect","html","generateTokensInHtml","__html","toggleToken","React","Component","PropTypes","arrayOf","shape","TokenTypes","isRequired","string","object","func","bool","number","backgroundColor","whiteSpace"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;;;;;AAEA,IAAMA,GAAG,GAAG,uBAAM,mCAAN,CAAZ;;IAEaC,W;;;;;;;;;;;;;;;sGAkBK;AAAA,aAAM,MAAKC,KAAL,CAAWC,MAAX,CAAkBC,MAAlB,CAAyB,UAACC,CAAD;AAAA,eAAOA,CAAC,CAACC,QAAT;AAAA,OAAzB,EAA4CC,MAAlD;AAAA,K;sGAEA,UAACC,aAAD,EAAmB;AACjC,UAAQC,iBAAR,GAA8B,MAAKP,KAAnC,CAAQO,iBAAR;;AAEA,UAAIA,iBAAiB,KAAK,CAA1B,EAA6B;AAC3B,eAAO,IAAP;AACD;;AAEDT,MAAAA,GAAG,CAAC,qCAAD,EAAwCS,iBAAxC,EAA2D,iBAA3D,EAA8ED,aAA9E,CAAH;AACA,aAAOC,iBAAiB,IAAI,CAArB,IAA2BC,QAAQ,CAACD,iBAAD,CAAR,IAA+BD,aAAa,GAAGC,iBAAjF;AACD,K;oGAUa,UAACE,KAAD,EAAW;AACvB,UAAQC,MAAR,GAAmBD,KAAnB,CAAQC,MAAR;AACA,wBAAuC,MAAKV,KAA5C;AAAA,UAAQC,MAAR,eAAQA,MAAR;AAAA,UAAgBU,kBAAhB,eAAgBA,kBAAhB;AACA,UAAMC,YAAY,GAAG,uBAAMX,MAAN,CAArB;AACA,UAAMY,iBAAiB,GAAGH,MAAM,CAACI,OAAP,YAAmBC,kBAAMC,aAAzB,EAA1B;AACA,UAAMC,kBAAkB,GAAGJ,iBAAiB,IAAIA,iBAAiB,CAACK,OAAvC,IAAkDL,iBAAiB,CAACK,OAAlB,CAA0BC,QAAvG;AACA,UAAMhB,CAAC,GAAGc,kBAAkB,IAAIL,YAAY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GjBf,EAAAA,OAAO,EAAEU,sBAAUM,MAAV,CAAiBF,UAHT;AAIjBpC,EAAAA,QAAQ,EAAEgC,sBAAUO,IAAV,CAAeH,UAJR;AAKjB5B,EAAAA,QAAQ,EAAEwB,sBAAUQ,IALH;AAMjB/B,EAAAA,gBAAgB,EAAEuB,sBAAUQ,IANX;AAOjBpD,EAAAA,kBAAkB,EAAE4C,sBAAUQ,IAPb;AAQjBxD,EAAAA,iBAAiB,EAAEgD,sBAAUS;AARZ,C;iCADRjE,W,kBAYW;AACpBiC,EAAAA,gBAAgB,EAAE,KADE;AAEpBzB,EAAAA,iBAAiB,EAAE,CAFC;AAGpBN,EAAAA,MAAM,EAAE;AAHY,C;;eAiIT,wBAAW;AAAA,SAAO;AAC/B+C,IAAAA,WAAW;AACTiB,MAAAA,eAAe,EAAE,MADR;AAETC,MAAAA,UAAU,EAAE;AAFH,OAGN,2BAHM;AAIT,aAAO;AACLA,QAAAA,UAAU,EAAE;AADP;AAJE;AADoB,GAAP;AAAA,CAAX,EASXnE,WATW,C","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport Token, { TokenTypes } from './token';\nimport { withStyles } from '@material-ui/core/styles';\nimport classNames from 'classnames';\nimport clone from 'lodash/clone';\nimport debug from 'debug';\nimport { noSelect } from '@pie-lib/style-utils';\nimport { renderToString } from 'react-dom/server';\nimport isEqual from 'lodash/isEqual';\n\nconst log = debug('@pie-lib:text-select:token-select');\n\nexport class TokenSelect extends React.Component {\n static propTypes = {\n tokens: PropTypes.arrayOf(PropTypes.shape(TokenTypes)).isRequired,\n className: PropTypes.string,\n classes: PropTypes.object.isRequired,\n onChange: PropTypes.func.isRequired,\n disabled: PropTypes.bool,\n highlightChoices: PropTypes.bool,\n animationsDisabled: PropTypes.bool,\n maxNoOfSelections: PropTypes.number,\n };\n\n static defaultProps = {\n highlightChoices: false,\n maxNoOfSelections: 0,\n tokens: [],\n };\n\n selectedCount = () => this.props.tokens.filter((t) => t.selected).length;\n\n canSelectMore = (selectedCount) => {\n const { maxNoOfSelections } = this.props;\n\n if (maxNoOfSelections === 1) {\n return true;\n }\n\n log('[canSelectMore] maxNoOfSelections: ', maxNoOfSelections, 'selectedCount: ', selectedCount);\n return maxNoOfSelections <= 0 || (isFinite(maxNoOfSelections) && selectedCount < maxNoOfSelections);\n };\n\n /**\n @function\n @param { object } event\n\n @description\n each token is wrapped into a span that has Token.rootClassName class and indexkey attribute (represents the index of the token)\n tokens are updated with the targeted token having the correct value set for 'selected' property\n */\n toggleToken = (event) => {\n const { target } = event;\n const { tokens, animationsDisabled } = this.props;\n const tokensCloned = clone(tokens);\n const targetSpanWrapper = target.closest(`.${Token.rootClassName}`);\n const targetedTokenIndex = targetSpanWrapper && targetSpanWrapper.dataset && targetSpanWrapper.dataset.indexkey;\n const t = targetedTokenIndex && tokensCloned[targetedTokenIndex];\n\n // don't toggle if we are in print mode, token correctness is defined or if it's missing\n // (missing means that it was evaluated as correct and not selected)\n if (t && t.correct === undefined && !animationsDisabled && !t.isMissing) {\n const { onChange, maxNoOfSelections } = this.props;\n const selected = !t.selected;\n\n if (maxNoOfSelections === 1 && this.selectedCount() === 1) {\n const selectedToken = (tokens || []).filter((t) => t.selected);\n\n const updatedTokens = tokensCloned.map((token) => {\n if (isEqual(token, selectedToken[0])) {\n return { ...token, selected: false };\n }\n\n return { ...token, selectable: true };\n });\n\n const update = { ...t, selected: !t.selected };\n\n updatedTokens.splice(targetedTokenIndex, 1, update);\n onChange(updatedTokens);\n } else {\n if (selected && maxNoOfSelections > 0 && this.selectedCount() >= maxNoOfSelections) {\n log('skip toggle max reached');\n return;\n }\n\n const update = { ...t, selected: !t.selected };\n\n tokensCloned.splice(targetedTokenIndex, 1, update);\n onChange(tokensCloned);\n }\n }\n };\n\n generateTokensInHtml = () => {\n const { tokens, disabled, highlightChoices, animationsDisabled } = this.props;\n const selectedCount = this.selectedCount();\n const isLineBreak = (text) => text === '\\n';\n const isNewParagraph = (text) => text === '\\n\\n';\n\n const reducer = (accumulator, t, index) => {\n const selectable = t.selected || (t.selectable && this.canSelectMore(selectedCount));\n const showCorrectAnswer = t.correct !== undefined && (t.selectable || t.selected);\n let finalAcc = accumulator;\n\n if (isNewParagraph(t.text)) {\n return finalAcc + '</p><p>';\n }\n\n if (isLineBreak(t.text)) {\n return finalAcc + '<br>';\n }\n\n if (\n (selectable && !disabled) ||\n showCorrectAnswer ||\n t.selected ||\n t.isMissing ||\n (animationsDisabled && t.predefined) // if we are in print mode\n ) {\n return (\n finalAcc +\n renderToString(\n <Token\n key={index}\n disabled={disabled}\n index={index}\n {...t}\n selectable={selectable}\n highlight={highlightChoices}\n animationsDisabled={animationsDisabled}\n />,\n )\n );\n } else {\n return accumulator + t.text;\n }\n };\n\n const reduceResult = (tokens || []).reduce(reducer, '<p>');\n\n return reduceResult + '</p>';\n };\n\n render() {\n const { classes, className: classNameProp } = this.props;\n const className = classNames(classes.tokenSelect, classNameProp);\n const html = this.generateTokensInHtml();\n\n return <div className={className} dangerouslySetInnerHTML={{ __html: html }} onClick={this.toggleToken} />;\n }\n}\n\nexport default withStyles(() => ({\n tokenSelect: {\n backgroundColor: 'none',\n whiteSpace: 'pre',\n ...noSelect(),\n '& p': {\n whiteSpace: 'break-spaces',\n },\n },\n}))(TokenSelect);\n"],"file":"index.js"}