@occmundial/occ-atomic 3.0.0-beta.3 → 3.0.0-beta.30

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 (61) hide show
  1. package/CHANGELOG.md +247 -0
  2. package/build/Avatar/Avatar.js +69 -21
  3. package/build/Avatar/Avatar.test.js +15 -8
  4. package/build/Avatar/AvatarContent/AvatarContent.js +61 -21
  5. package/build/Avatar/AvatarContent/AvatarContent.test.js +4 -18
  6. package/build/Avatar/AvatarContent/__snapshots__/AvatarContent.test.js.snap +75 -15
  7. package/build/Avatar/AvatarContent/styles.js +88 -21
  8. package/build/Avatar/__snapshots__/Avatar.test.js.snap +11 -2
  9. package/build/Avatar/styles.js +18 -7
  10. package/build/Banner/Banner.js +30 -40
  11. package/build/Banner/Banner.test.js +64 -17
  12. package/build/Banner/__snapshots__/Banner.test.js.snap +0 -28
  13. package/build/Banner/index.js +1 -6
  14. package/build/Button/__snapshots__/Button.test.js.snap +18 -20
  15. package/build/Button/styles.js +6 -8
  16. package/build/Checkbox/Checkbox.js +48 -3
  17. package/build/Checkbox/__snapshots__/Checkbox.test.js.snap +81 -49
  18. package/build/Checkbox/styles.js +91 -48
  19. package/build/Footer/Footer.js +15 -8
  20. package/build/Footer/__snapshots__/Footer.test.js.snap +0 -6
  21. package/build/Footer/styles.js +0 -6
  22. package/build/Grid/Col/__snapshots__/Col.test.js.snap +34 -2
  23. package/build/Grid/Col/styles.js +18 -6
  24. package/build/Grid/Row/__snapshots__/Row.test.js.snap +36 -2
  25. package/build/Grid/Row/styles.js +21 -5
  26. package/build/Grid/styles.js +8 -8
  27. package/build/Pill/Choice/Choice.js +6 -4
  28. package/build/Pill/Choice/styles.js +13 -10
  29. package/build/Pill/Group/styles.js +5 -5
  30. package/build/Pill/Stack/Stack.js +2 -2
  31. package/build/Pill/Stack/styles.js +5 -8
  32. package/build/Radio/Radio.js +42 -6
  33. package/build/Radio/__snapshots__/Radio.test.js.snap +81 -80
  34. package/build/Radio/styles.js +93 -85
  35. package/build/SlideToggle/SlideToggle.js +38 -6
  36. package/build/SlideToggle/SlideToggle.test.js +2 -2
  37. package/build/SlideToggle/__snapshots__/SlideToggle.test.js.snap +53 -37
  38. package/build/SlideToggle/styles.js +65 -45
  39. package/build/Tag/Tag.js +2 -2
  40. package/build/Tag/__snapshots__/Tag.test.js.snap +40 -43
  41. package/build/Tag/styles.js +76 -82
  42. package/build/Text/Text.js +4 -2
  43. package/build/TextField/TextField.js +7 -6
  44. package/build/TextField/__snapshots__/TextField.test.js.snap +3 -0
  45. package/build/TextField/styles.js +3 -0
  46. package/build/Tip/Tip.js +61 -95
  47. package/build/Tip/Tip.test.js +29 -6
  48. package/build/Tip/TipText/index.js +32 -0
  49. package/build/Tip/__snapshots__/Tip.test.js.snap +131 -15
  50. package/build/Tip/styles.js +126 -31
  51. package/build/Toaster/Toast/Toast.js +76 -64
  52. package/build/Toaster/Toast/styles.js +118 -46
  53. package/build/Toaster/Toaster.js +3 -2
  54. package/build/Toaster/Toaster.test.js +5 -2
  55. package/build/Toaster/__snapshots__/Toaster.test.js.snap +1 -1
  56. package/build/Toaster/functions.js +4 -0
  57. package/build/Toaster/styles.js +3 -3
  58. package/build/subatomic/grid.js +5 -5
  59. package/build/tokens/colors.json +21 -3
  60. package/package.json +4 -1
  61. package/build/Banner/styles.js +0 -41
package/CHANGELOG.md CHANGED
@@ -1,3 +1,250 @@
1
+ # [3.0.0-beta.30](https://github.com/occmundial/occ-atomic/compare/v3.0.0-beta.29...v3.0.0-beta.30) (2024-07-16)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * Remove unnecesary bp props in grid col ([97e839a](https://github.com/occmundial/occ-atomic/commit/97e839aa4621fcbb964615167165132628b646c3))
7
+ * Remove unnecesary margins and set auto ([96d016a](https://github.com/occmundial/occ-atomic/commit/96d016a6f3f461f5b44cbd299d8c135dc846561c))
8
+
9
+
10
+ ### Features
11
+
12
+ * Update grid with new design tokens ([0fd904d](https://github.com/occmundial/occ-atomic/commit/0fd904d044323108a1e573a93e7e1a6dea99d0ef))
13
+
14
+ # [3.0.0-beta.29](https://github.com/occmundial/occ-atomic/compare/v3.0.0-beta.28...v3.0.0-beta.29) (2024-07-09)
15
+
16
+
17
+ ### Bug Fixes
18
+
19
+ * Remove extra padding in label ([efda99e](https://github.com/occmundial/occ-atomic/commit/efda99e0fca815e6f60c7277da52b41dfcd21e72))
20
+
21
+ # [3.0.0-beta.28](https://github.com/occmundial/occ-atomic/compare/v3.0.0-beta.27...v3.0.0-beta.28) (2024-07-08)
22
+
23
+
24
+ ### Bug Fixes
25
+
26
+ * Add hover transition styles to link toaster ([dcb67ab](https://github.com/occmundial/occ-atomic/commit/dcb67aba17e6f669d5554f397c516aca687ebc53))
27
+ * Move css to flexbox props ([cedb764](https://github.com/occmundial/occ-atomic/commit/cedb7644bdc88a19ca385e4a0d8902f19900eaf0))
28
+
29
+ # [3.0.0-beta.27](https://github.com/occmundial/occ-atomic/compare/v3.0.0-beta.26...v3.0.0-beta.27) (2024-07-08)
30
+
31
+
32
+ ### Bug Fixes
33
+
34
+ * CHanged outlines with shadows ([bba0c01](https://github.com/occmundial/occ-atomic/commit/bba0c01a54a13b1b405c2405eb1ab764cc1ab367))
35
+
36
+
37
+ ### Features
38
+
39
+ * Changed tag border to outline ([89ccbaf](https://github.com/occmundial/occ-atomic/commit/89ccbaf7f1d0c183940cfb3ef2fb8f270928aedf))
40
+
41
+ # [3.0.0-beta.26](https://github.com/occmundial/occ-atomic/compare/v3.0.0-beta.25...v3.0.0-beta.26) (2024-07-05)
42
+
43
+
44
+ ### Bug Fixes
45
+
46
+ * Align title if not description ([ef6a12a](https://github.com/occmundial/occ-atomic/commit/ef6a12a1dba3d5440220cfe2798801d7d08c441c))
47
+
48
+ # [3.0.0-beta.25](https://github.com/occmundial/occ-atomic/compare/v3.0.0-beta.24...v3.0.0-beta.25) (2024-07-03)
49
+
50
+
51
+ ### Bug Fixes
52
+
53
+ * Add hover styles to alert link action ([1e7efde](https://github.com/occmundial/occ-atomic/commit/1e7efde311085677f43c5057769d406c88d13c33))
54
+ * Move hover styles to cta classname ([b457e9b](https://github.com/occmundial/occ-atomic/commit/b457e9b639627361ee4b272dc64663457d67a60f))
55
+
56
+ # [3.0.0-beta.24](https://github.com/occmundial/occ-atomic/compare/v3.0.0-beta.23...v3.0.0-beta.24) (2024-06-28)
57
+
58
+
59
+ ### Bug Fixes
60
+
61
+ * Handle key press on Avatar ([5821f9a](https://github.com/occmundial/occ-atomic/commit/5821f9ab94ee67af5a6ceebfe587dfa23656a9be))
62
+ * Update structure and styles of Avatar ([ed5ad44](https://github.com/occmundial/occ-atomic/commit/ed5ad44f42e8e2665f6b1e59db149fc27b8842f4))
63
+
64
+ # [3.0.0-beta.23](https://github.com/occmundial/occ-atomic/compare/v3.0.0-beta.22...v3.0.0-beta.23) (2024-06-27)
65
+
66
+
67
+ ### Bug Fixes
68
+
69
+ * Align vertical centered tip and banner text ([032a704](https://github.com/occmundial/occ-atomic/commit/032a704707562dab93707a3c31aa1b26dc6be0dd))
70
+
71
+ # [3.0.0-beta.22](https://github.com/occmundial/occ-atomic/compare/v3.0.0-beta.21...v3.0.0-beta.22) (2024-06-26)
72
+
73
+
74
+ ### Features
75
+
76
+ * Tag compnent and documentation updated ([718378f](https://github.com/occmundial/occ-atomic/commit/718378ffd916c98673a3b10f7b9ba827d806aa1c))
77
+
78
+ # [3.0.0-beta.21](https://github.com/occmundial/occ-atomic/compare/v3.0.0-beta.20...v3.0.0-beta.21) (2024-06-25)
79
+
80
+
81
+ ### Bug Fixes
82
+
83
+ * Add outline border and merge with beta ([a212aa3](https://github.com/occmundial/occ-atomic/commit/a212aa3f87471092a246925e79a9d787535b13ba))
84
+ * Resolve conflicts ([99b08cb](https://github.com/occmundial/occ-atomic/commit/99b08cb290979fa7f1aad3dd2c04f65b1b494559))
85
+ * Resolve conflicts ([81776b7](https://github.com/occmundial/occ-atomic/commit/81776b701b168e66a1f1dfa7b785227b40a76dc9))
86
+ * Set md size for tip close icon ([759e6d1](https://github.com/occmundial/occ-atomic/commit/759e6d10842e2c55cf81d2aff57f60479e3a3395))
87
+ * Set min width for desktop and conditionated on mouse events ([98857fd](https://github.com/occmundial/occ-atomic/commit/98857fd313d247e618c64dbbaacea93c6ab084ae))
88
+
89
+
90
+ ### Features
91
+
92
+ * Add close icon prop and conditionated onclose func ([e456d38](https://github.com/occmundial/occ-atomic/commit/e456d384a82d4b6105e27bb36d693b43d5608c1c))
93
+ * Update toaster with new design tokens ([88edaa8](https://github.com/occmundial/occ-atomic/commit/88edaa8fe5c3c04bc9f634f6a287c1614c893d15))
94
+
95
+ # [3.0.0-beta.20](https://github.com/occmundial/occ-atomic/compare/v3.0.0-beta.19...v3.0.0-beta.20) (2024-06-25)
96
+
97
+
98
+ ### Bug Fixes
99
+
100
+ * Add condition to set test id prop ([4e90cea](https://github.com/occmundial/occ-atomic/commit/4e90cea0a6f5c627c8b2a398a9aef449fa3e1b7c))
101
+ * Adjust tip styles and add banner prop ([04d17ff](https://github.com/occmundial/occ-atomic/commit/04d17ff0fe74186da32d15f91001406344867bb4))
102
+ * Merge beta changes ([218b68a](https://github.com/occmundial/occ-atomic/commit/218b68a7347b025dc2cdd8171f7d4c22bbd383f1))
103
+ * Resolve component data conflicts ([c390f1f](https://github.com/occmundial/occ-atomic/commit/c390f1f485415dc15251386527c0caaa70e9814f))
104
+
105
+
106
+ ### Features
107
+
108
+ * Add test id prop and add new tests ([aba7d32](https://github.com/occmundial/occ-atomic/commit/aba7d3215e0b19e635b53546f66accd327ebed42))
109
+
110
+ # [3.0.0-beta.19](https://github.com/occmundial/occ-atomic/compare/v3.0.0-beta.18...v3.0.0-beta.19) (2024-06-21)
111
+
112
+
113
+ ### Bug Fixes
114
+
115
+ * Prevent default to avoid scroll on key down ([9ee17d2](https://github.com/occmundial/occ-atomic/commit/9ee17d2a247a02a7be7e1c743669c8833d3f5748))
116
+
117
+ # [3.0.0-beta.18](https://github.com/occmundial/occ-atomic/compare/v3.0.0-beta.17...v3.0.0-beta.18) (2024-06-21)
118
+
119
+
120
+ ### Bug Fixes
121
+
122
+ * Replace onKeyDown for onKeyUp ([e574e9c](https://github.com/occmundial/occ-atomic/commit/e574e9c42f7a55723794269ede7a4f58dd899e58))
123
+
124
+ # [3.0.0-beta.17](https://github.com/occmundial/occ-atomic/compare/v3.0.0-beta.16...v3.0.0-beta.17) (2024-06-19)
125
+
126
+
127
+ ### Bug Fixes
128
+
129
+ * Change icon size and adjust margin ([0411455](https://github.com/occmundial/occ-atomic/commit/041145590cd765e5b81937f07ef676d2fc5e8826))
130
+ * Remove selector not active for focus visible ([dbec333](https://github.com/occmundial/occ-atomic/commit/dbec33316a94826d2007a044b634f944ffe01715))
131
+
132
+ # [3.0.0-beta.16](https://github.com/occmundial/occ-atomic/compare/v3.0.0-beta.15...v3.0.0-beta.16) (2024-06-19)
133
+
134
+
135
+ ### Bug Fixes
136
+
137
+ * Change focus behavior in form components ([a3b6c9b](https://github.com/occmundial/occ-atomic/commit/a3b6c9b5194b1d8302a6f73bb5522df9e6a756fc))
138
+ * Changes to structure and styles of Checkbox ([6ed54c0](https://github.com/occmundial/occ-atomic/commit/6ed54c0a5ebae0542431b8305d0da8a052c2d3fb))
139
+ * Changes to structure and styles of Radio ([694c995](https://github.com/occmundial/occ-atomic/commit/694c9950a4c6c43a5bd7987536a293835860421e))
140
+ * Changes to structure and styles of SlideToggle ([5ec340f](https://github.com/occmundial/occ-atomic/commit/5ec340f0cc09b04d032ebb888034a92cf71f2f8a))
141
+ * Fix focus styles in form components ([e69d45b](https://github.com/occmundial/occ-atomic/commit/e69d45b84c3e35a433f37feb7c9b0012137bc2bb))
142
+ * Fix spacing and sizing of radio, checkbox and toggle ([b3a71c2](https://github.com/occmundial/occ-atomic/commit/b3a71c2e30e2b810036104a4ee57b6b805d2780c))
143
+ * Fix styles and icon color on Checkbox ([1c4e360](https://github.com/occmundial/occ-atomic/commit/1c4e360ec0d3291048d14f4ccd3859d0bdbc2817))
144
+ * Fix transition value in SlideToggle ([8423fc6](https://github.com/occmundial/occ-atomic/commit/8423fc6b9eea3219ed052add95f27ef4d181f5b5))
145
+ * Update componentData ([ff7c0bd](https://github.com/occmundial/occ-atomic/commit/ff7c0bd47ed55d652b01ace7526867d751a6e1c7))
146
+
147
+ # [3.0.0-beta.15](https://github.com/occmundial/occ-atomic/compare/v3.0.0-beta.14...v3.0.0-beta.15) (2024-06-18)
148
+
149
+
150
+ ### Bug Fixes
151
+
152
+ * Centered select icon and set cursor pointer for select box ([05fa3f1](https://github.com/occmundial/occ-atomic/commit/05fa3f1ca0efdf7e2b75c468eb23279aafbc58ce))
153
+ * Remove class condition ([59ef135](https://github.com/occmundial/occ-atomic/commit/59ef1353213a9df3737d59c13385254767c41372))
154
+
155
+ # [3.0.0-beta.14](https://github.com/occmundial/occ-atomic/compare/v3.0.0-beta.13...v3.0.0-beta.14) (2024-06-13)
156
+
157
+
158
+ ### Bug Fixes
159
+
160
+ * Fix toggle background on focus when hovered ([8c35f96](https://github.com/occmundial/occ-atomic/commit/8c35f96b77fdb3d1692d864159561842a3213bba))
161
+
162
+ # [3.0.0-beta.13](https://github.com/occmundial/occ-atomic/compare/v3.0.0-beta.12...v3.0.0-beta.13) (2024-06-13)
163
+
164
+
165
+ ### Bug Fixes
166
+
167
+ * Add form nav behavior to SwitchToggle ([e1e74ed](https://github.com/occmundial/occ-atomic/commit/e1e74edf8306250d0ae7a723b758c9426593c295))
168
+
169
+ # [3.0.0-beta.12](https://github.com/occmundial/occ-atomic/compare/v3.0.0-beta.11...v3.0.0-beta.12) (2024-06-07)
170
+
171
+
172
+ ### Bug Fixes
173
+
174
+ * Add form nav behavior to checkbox ([6b2c664](https://github.com/occmundial/occ-atomic/commit/6b2c664e165bb4617dc53874be69bb9d8c8e6bc3))
175
+
176
+ # [3.0.0-beta.11](https://github.com/occmundial/occ-atomic/compare/v3.0.0-beta.10...v3.0.0-beta.11) (2024-06-07)
177
+
178
+
179
+ ### Bug Fixes
180
+
181
+ * Call hoc window size and improve tip text use memo ([840e108](https://github.com/occmundial/occ-atomic/commit/840e1089cb3e80c6b2d2686c56b577166f6bc66f))
182
+ * Resolve conflicts ([23e9ba8](https://github.com/occmundial/occ-atomic/commit/23e9ba8008ffe55e8af6910394580123032aee0e))
183
+
184
+ # [3.0.0-beta.10](https://github.com/occmundial/occ-atomic/compare/v3.0.0-beta.9...v3.0.0-beta.10) (2024-06-06)
185
+
186
+
187
+ ### Features
188
+
189
+ * Checkbox redesigned and documentation created ([48fbc8d](https://github.com/occmundial/occ-atomic/commit/48fbc8d0a912c300324fe244e9692a49f3a152b5))
190
+ * Remove updates to component ([ab71716](https://github.com/occmundial/occ-atomic/commit/ab71716991a7700134dbafe0d8eda63e18ff8eab))
191
+
192
+ # [3.0.0-beta.9](https://github.com/occmundial/occ-atomic/compare/v3.0.0-beta.8...v3.0.0-beta.9) (2024-06-06)
193
+
194
+
195
+ ### Bug Fixes
196
+
197
+ * Move use memo before early return ([3d290c9](https://github.com/occmundial/occ-atomic/commit/3d290c9675fb24e20d131fdbaeef023920f3e439))
198
+
199
+ # [3.0.0-beta.8](https://github.com/occmundial/occ-atomic/compare/v3.0.0-beta.7...v3.0.0-beta.8) (2024-06-06)
200
+
201
+
202
+ ### Bug Fixes
203
+
204
+ * Add border for promote alert ([5050f18](https://github.com/occmundial/occ-atomic/commit/5050f187b60f98118654ecbbe3e2cba7b29790ab))
205
+ * Add min height to tip container ([579d263](https://github.com/occmundial/occ-atomic/commit/579d26306d59ce73b5084f9cd632dd12ed162fc5))
206
+ * Resolve conflicts ([0a15dfa](https://github.com/occmundial/occ-atomic/commit/0a15dfa8d8da38a724d71622809f0e02c5bed0e9))
207
+
208
+
209
+ ### Features
210
+
211
+ * Render tip in banner component ([239e2c8](https://github.com/occmundial/occ-atomic/commit/239e2c82c23d79698bd912931b314ceddf252fb4))
212
+ * Update tip component with new design tokens ([b2367fc](https://github.com/occmundial/occ-atomic/commit/b2367fcaade288609df4c841c91fb308841ae4b0))
213
+
214
+
215
+ ### Performance Improvements
216
+
217
+ * Memoize text replace in tip text component ([69180ce](https://github.com/occmundial/occ-atomic/commit/69180ce9cb1e812769e31a837257d8c8e6f24199))
218
+
219
+ # [3.0.0-beta.7](https://github.com/occmundial/occ-atomic/compare/v3.0.0-beta.6...v3.0.0-beta.7) (2024-06-06)
220
+
221
+
222
+ ### Bug Fixes
223
+
224
+ * Fix radio styles and add a form nav behavior ([59f0320](https://github.com/occmundial/occ-atomic/commit/59f03207a45b1ec27e02970668cffe2cfd5931a9))
225
+ * Ignore tab index if radio element is disabled ([e479098](https://github.com/occmundial/occ-atomic/commit/e4790982a127408a474f688a4647612ef8fbb446))
226
+
227
+ # [3.0.0-beta.6](https://github.com/occmundial/occ-atomic/compare/v3.0.0-beta.5...v3.0.0-beta.6) (2024-06-05)
228
+
229
+
230
+ ### Bug Fixes
231
+
232
+ * Text new emphasis props ([bc3e934](https://github.com/occmundial/occ-atomic/commit/bc3e934299230cb0b3a0fddeb4c8fcd2b72a052f))
233
+
234
+ # [3.0.0-beta.5](https://github.com/occmundial/occ-atomic/compare/v3.0.0-beta.4...v3.0.0-beta.5) (2024-06-04)
235
+
236
+
237
+ ### Bug Fixes
238
+
239
+ * Remove fixed size for right-side icon in button ([1228467](https://github.com/occmundial/occ-atomic/commit/1228467ba0d107bba0e70603c28a3ccffaec306b))
240
+
241
+ # [3.0.0-beta.4](https://github.com/occmundial/occ-atomic/compare/v3.0.0-beta.3...v3.0.0-beta.4) (2024-06-04)
242
+
243
+
244
+ ### Bug Fixes
245
+
246
+ * Make toggle unshrinkable inside a flex box ([6067fba](https://github.com/occmundial/occ-atomic/commit/6067fbad2276824bcec0c35748beea0006b73300))
247
+
1
248
  # [3.0.0-beta.3](https://github.com/occmundial/occ-atomic/compare/v3.0.0-beta.2...v3.0.0-beta.3) (2024-05-30)
2
249
 
3
250
 
@@ -15,6 +15,12 @@ var _AvatarContent = _interopRequireDefault(require("./AvatarContent"));
15
15
 
16
16
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
17
17
 
18
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
19
+
20
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
21
+
22
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
23
+
18
24
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
19
25
 
20
26
  function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
@@ -44,33 +50,72 @@ var Avatar = /*#__PURE__*/function (_React$Component) {
44
50
 
45
51
  var _super = _createSuper(Avatar);
46
52
 
47
- function Avatar() {
53
+ function Avatar(props) {
54
+ var _this;
55
+
48
56
  _classCallCheck(this, Avatar);
49
57
 
50
- return _super.apply(this, arguments);
58
+ _this = _super.call(this, props);
59
+ _this.handleKeyUp = _this.handleKeyUp.bind(_assertThisInitialized(_this));
60
+ return _this;
51
61
  }
52
62
 
53
63
  _createClass(Avatar, [{
64
+ key: "handleKeyDown",
65
+ value: function handleKeyDown(e) {
66
+ if (e.keyCode == 13 || e.keyCode == 32) {
67
+ e.preventDefault();
68
+ }
69
+ }
70
+ }, {
71
+ key: "handleKeyUp",
72
+ value: function handleKeyUp(e) {
73
+ if (e.keyCode == 13 || e.keyCode == 32) {
74
+ var _this$props = this.props,
75
+ onEdit = _this$props.onEdit,
76
+ onClick = _this$props.onClick;
77
+ var isEditable = onEdit || onClick;
78
+ var handleClick = isEditable ? onClick || onEdit : undefined;
79
+ if (handleClick) handleClick();
80
+ }
81
+ }
82
+ }, {
54
83
  key: "render",
55
84
  value: function render() {
56
- var _this$props = this.props,
57
- classes = _this$props.classes,
58
- photo = _this$props.photo,
59
- gender = _this$props.gender,
60
- name = _this$props.name,
61
- size = _this$props.size,
62
- id = _this$props.id,
63
- className = _this$props.className,
64
- style = _this$props.style;
85
+ var _this$props2 = this.props,
86
+ classes = _this$props2.classes,
87
+ photo = _this$props2.photo,
88
+ name = _this$props2.name,
89
+ _this$props2$size = _this$props2.size,
90
+ size = _this$props2$size === void 0 ? 40 : _this$props2$size,
91
+ id = _this$props2.id,
92
+ className = _this$props2.className,
93
+ style = _this$props2.style,
94
+ onEdit = _this$props2.onEdit,
95
+ onClick = _this$props2.onClick,
96
+ disabled = _this$props2.disabled;
97
+ var isEditable = onEdit || onClick;
98
+ var handleClick = isEditable ? onClick || onEdit : undefined;
99
+ var tabIndexValue = isEditable && !disabled ? 0 : undefined;
100
+ var combinedClasses = "".concat(classes.circle).concat(isEditable ? " ".concat(classes.editable) : '').concat(disabled ? " ".concat(classes.disabled) : '').concat(className ? " ".concat(className) : '');
65
101
  return /*#__PURE__*/_react["default"].createElement("div", {
66
102
  id: id,
67
- className: "".concat(classes.circle).concat(className ? " ".concat(className) : ''),
68
- style: style
103
+ className: combinedClasses,
104
+ onClick: handleClick,
105
+ onKeyDown: this.handleKeyDown,
106
+ onKeyUp: this.handleKeyUp,
107
+ tabIndex: tabIndexValue,
108
+ style: _objectSpread(_objectSpread({}, style), {}, {
109
+ width: size,
110
+ height: size
111
+ })
69
112
  }, /*#__PURE__*/_react["default"].createElement(_AvatarContent["default"], {
70
113
  photo: photo,
71
- gender: gender,
72
114
  name: name,
73
- size: size
115
+ size: size,
116
+ onEdit: onEdit,
117
+ onClick: onClick,
118
+ disabled: disabled
74
119
  }));
75
120
  }
76
121
  }]);
@@ -78,23 +123,26 @@ var Avatar = /*#__PURE__*/function (_React$Component) {
78
123
  return Avatar;
79
124
  }(_react["default"].Component);
80
125
 
81
- Avatar.defaultProps = {
82
- size: 70
83
- };
84
126
  Avatar.propTypes = {
85
127
  classes: _propTypes["default"].object.isRequired,
86
128
 
87
129
  /** A url to show a photo as the avatar. */
88
130
  photo: _propTypes["default"].string,
89
131
 
90
- /** Use the values 'm' or 'f' to show a default avatar with an icon representing the gender. */
91
- gender: _propTypes["default"].oneOf(['f', 'm']),
92
-
93
132
  /** Pass a name to show two initials. */
94
133
  name: _propTypes["default"].string,
95
134
 
96
135
  /** The size of the avatar. */
97
136
  size: _propTypes["default"].number,
137
+
138
+ /** A function to handle the click action for editing. */
139
+ onEdit: _propTypes["default"].func,
140
+
141
+ /** A function to handle the click. */
142
+ onClick: _propTypes["default"].func,
143
+
144
+ /** Determines if the avatar is disabled. */
145
+ disabled: _propTypes["default"].bool,
98
146
  id: _propTypes["default"].string,
99
147
  className: _propTypes["default"].string,
100
148
  style: _propTypes["default"].object
@@ -35,17 +35,24 @@ describe("AvatarJSS", function () {
35
35
  }));
36
36
  expect(wrapper).toMatchSnapshot();
37
37
  });
38
+ it('returns the right width and height', function () {
39
+ var wrapper = (0, _enzyme.shallow)( /*#__PURE__*/_react["default"].createElement(_index["default"], {
40
+ name: "John Doe",
41
+ size: 50
42
+ }));
43
+ var styles = wrapper.dive().props().style;
44
+ expect(styles.width).toBe(50);
45
+ expect(styles.height).toBe(50);
46
+ wrapper.setProps({
47
+ size: 70
48
+ });
49
+ var styles2 = wrapper.dive().props().style;
50
+ expect(styles2.width).toBe(70);
51
+ expect(styles2.height).toBe(70);
52
+ });
38
53
  });
39
54
  describe("Avatar styles", function () {
40
55
  it('matches the snapshot', function () {
41
56
  expect(_styles["default"]).toMatchSnapshot();
42
57
  });
43
- it('returns the right width and height', function () {
44
- var props = {};
45
- expect(_styles["default"].circle.width(props)).toBe(70);
46
- expect(_styles["default"].circle.height(props)).toBe(70);
47
- props.size = 50;
48
- expect(_styles["default"].circle.width(props)).toBe(50);
49
- expect(_styles["default"].circle.height(props)).toBe(50);
50
- });
51
58
  });
@@ -9,40 +9,77 @@ var _react = _interopRequireDefault(require("react"));
9
9
 
10
10
  var _propTypes = _interopRequireDefault(require("prop-types"));
11
11
 
12
+ var _Icon = _interopRequireDefault(require("../../Icon"));
13
+
14
+ var _colors = _interopRequireDefault(require("../../tokens/colors.json"));
15
+
12
16
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
13
17
 
14
- var capitalLetter = function capitalLetter(name) {
15
- if (name) {
16
- var capitals = name.toUpperCase().split(" ");
17
- capitals = capitals.filter(Boolean);
18
- return /*#__PURE__*/_react["default"].createElement("span", null, capitals[0] ? capitals[0].charAt(0) : 'N', capitals[1] ? capitals[1].charAt(0) : 'O');
18
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
19
+
20
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
21
+
22
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
23
+
24
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
25
+
26
+ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
27
+
28
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
29
+
30
+ var getInitials = function getInitials(name) {
31
+ if (name && name.trim()) {
32
+ var _name$trim$replace$to = name.trim().replace(/\s+/g, ' ').toUpperCase().split(' '),
33
+ _name$trim$replace$to2 = _slicedToArray(_name$trim$replace$to, 2),
34
+ firstName = _name$trim$replace$to2[0],
35
+ lastName = _name$trim$replace$to2[1];
36
+
37
+ return "".concat(firstName === null || firstName === void 0 ? void 0 : firstName.charAt(0)).concat(lastName === null || lastName === void 0 ? void 0 : lastName.charAt(0));
19
38
  }
20
39
 
21
- return "";
40
+ return null;
22
41
  };
23
42
 
24
43
  var AvatarContent = function AvatarContent(_ref) {
25
44
  var classes = _ref.classes,
26
45
  photo = _ref.photo,
27
- gender = _ref.gender,
28
46
  name = _ref.name,
29
- size = _ref.size;
47
+ size = _ref.size,
48
+ onEdit = _ref.onEdit,
49
+ onClick = _ref.onClick,
50
+ disabled = _ref.disabled;
51
+ var initials = getInitials(name);
30
52
  return /*#__PURE__*/_react["default"].createElement("div", {
31
53
  className: classes.wrap
32
- }, gender && /*#__PURE__*/_react["default"].createElement("div", {
33
- className: "".concat(classes.cont, " ").concat(classes[gender])
34
- }), !gender && name && /*#__PURE__*/_react["default"].createElement("div", {
35
- className: "".concat(classes.cont, " ").concat(classes.capital),
54
+ }, /*#__PURE__*/_react["default"].createElement("div", {
55
+ className: "".concat(classes.cont).concat(onClick ? " ".concat(classes.clickable) : '').concat(onEdit ? " ".concat(classes.editable) : '').concat(disabled ? " ".concat(classes.disabled) : '').concat(photo ? " ".concat(classes.photo) : '').concat(photo && (onClick || onEdit) ? " ".concat(classes.hoverPhoto) : ''),
56
+ style: photo ? {
57
+ background: "url('".concat(photo, "') no-repeat center center / cover")
58
+ } : null
59
+ }, !photo && !initials && /*#__PURE__*/_react["default"].createElement(_Icon["default"], {
60
+ iconName: "person",
61
+ className: classes.person,
62
+ colors: [disabled ? _colors["default"].icon["default"].disabled : _colors["default"].icon.brand["default"]],
63
+ size: 24,
36
64
  style: size ? {
37
- fontSize: "".concat(size * 0.4, "px"),
38
- lineHeight: "".concat(size, "px")
65
+ transform: "scale(".concat(size / 40, ")")
39
66
  } : {}
40
- }, capitalLetter(name)), photo && /*#__PURE__*/_react["default"].createElement("div", {
41
- className: classes.cont,
42
- style: {
43
- background: "url('".concat(photo, "') no-repeat center center / cover")
44
- }
45
- }));
67
+ }), initials && /*#__PURE__*/_react["default"].createElement("span", {
68
+ className: "".concat(classes.initials, " ").concat(disabled ? classes.disabledInitials : ''),
69
+ style: size ? {
70
+ transform: "scale(".concat(size / 40, ")")
71
+ } : {}
72
+ }, initials), /*#__PURE__*/_react["default"].createElement("div", {
73
+ className: classes.overlay
74
+ }, onEdit && !disabled && /*#__PURE__*/_react["default"].createElement(_Icon["default"], {
75
+ iconName: "camera",
76
+ className: classes.camera,
77
+ colors: [disabled ? _colors["default"].icon["default"].disabled : _colors["default"].icon.inverse["default"]],
78
+ size: 24,
79
+ style: size ? {
80
+ transform: "scale(".concat(size / 40, ")")
81
+ } : {}
82
+ }))));
46
83
  };
47
84
 
48
85
  AvatarContent.propTypes = {
@@ -50,7 +87,10 @@ AvatarContent.propTypes = {
50
87
  photo: _propTypes["default"].string,
51
88
  gender: _propTypes["default"].string,
52
89
  name: _propTypes["default"].string,
53
- size: _propTypes["default"].number
90
+ size: _propTypes["default"].number,
91
+ onEdit: _propTypes["default"].func,
92
+ onClick: _propTypes["default"].func,
93
+ disabled: _propTypes["default"].bool
54
94
  };
55
95
  var _default = AvatarContent;
56
96
  exports["default"] = _default;
@@ -27,25 +27,12 @@ describe("AvatarContent", function () {
27
27
  }));
28
28
  expect(wrapper).toMatchSnapshot();
29
29
  });
30
- it('returns the first two capital letters of the name', function () {
30
+ it('returns the first two initial letters of the name', function () {
31
31
  var wrapper = (0, _enzyme.shallow)( /*#__PURE__*/_react["default"].createElement(_AvatarContent["default"], {
32
32
  name: "John Doe",
33
33
  classes: classes
34
34
  }));
35
- expect(wrapper.find('.capital span').text()).toEqual('JD');
36
- });
37
- it('shows the right gender icon', function () {
38
- var wrapper = (0, _enzyme.shallow)( /*#__PURE__*/_react["default"].createElement(_AvatarContent["default"], {
39
- gender: "m",
40
- classes: classes
41
- }));
42
- expect(wrapper.find('.m').length).toBe(1);
43
- expect(wrapper.find('.f').length).toBe(0);
44
- wrapper.setProps({
45
- gender: 'f'
46
- });
47
- expect(wrapper.find('.m').length).toBe(0);
48
- expect(wrapper.find('.f').length).toBe(1);
35
+ expect(wrapper.find('.initials').text()).toEqual('JD');
49
36
  });
50
37
  it('renders the photo as a background', function () {
51
38
  var wrapper = (0, _enzyme.shallow)( /*#__PURE__*/_react["default"].createElement(_AvatarContent["default"], {
@@ -60,9 +47,8 @@ describe("AvatarContent", function () {
60
47
  size: 50,
61
48
  classes: classes
62
49
  }));
63
- var styles = wrapper.find('.capital').prop('style');
64
- expect(styles).toHaveProperty('fontSize', '20px');
65
- expect(styles).toHaveProperty('lineHeight', '50px');
50
+ var styles = wrapper.find('.initials').prop('style');
51
+ expect(styles).toHaveProperty('transform', 'scale(1.25)');
66
52
  });
67
53
  });
68
54
  describe("AvatarContentJSS", function () {