goblin-gadgets 3.2.2 → 3.2.3

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 (361) hide show
  1. package/.editorconfig +9 -9
  2. package/.eslintrc.js +28 -28
  3. package/.zou-flow +2 -2
  4. package/builders/builders.js +5 -5
  5. package/builders/gadget.js +85 -85
  6. package/calendar-boards-gadget.js +64 -64
  7. package/demo-gadget.js +17 -17
  8. package/glyphs-dialog.js +13 -13
  9. package/login-dialog.js +13 -13
  10. package/package.json +46 -46
  11. package/pivot-gadget.js +18 -18
  12. package/stack-navigation.js +13 -13
  13. package/table-gadget.js +102 -102
  14. package/test/code-parser.spec.js +61 -61
  15. package/tree-gadget.js +70 -70
  16. package/types/types.js +455 -455
  17. package/widgets/accordion/styles.js +16 -16
  18. package/widgets/accordion/widget.js +90 -90
  19. package/widgets/analog-clock/props.js +102 -102
  20. package/widgets/analog-clock/scenarios.js +43 -43
  21. package/widgets/analog-clock/styles.js +754 -754
  22. package/widgets/analog-clock/widget.js +404 -404
  23. package/widgets/animated-container/animations.js +566 -566
  24. package/widgets/animated-container/styles.js +36 -36
  25. package/widgets/animated-container/widget.js +24 -24
  26. package/widgets/badge/styles.js +107 -107
  27. package/widgets/badge/widget.js +33 -33
  28. package/widgets/button/props.js +377 -377
  29. package/widgets/button/scenarios.js +54 -54
  30. package/widgets/button/styles.js +1082 -1082
  31. package/widgets/button/widget.js +426 -426
  32. package/widgets/button-combo/styles.js +73 -73
  33. package/widgets/button-combo/widget.js +297 -297
  34. package/widgets/calendar/props.js +207 -207
  35. package/widgets/calendar/scenarios.js +50 -50
  36. package/widgets/calendar/styles.js +198 -198
  37. package/widgets/calendar/widget.js +895 -895
  38. package/widgets/calendar-boards/styles.js +29 -29
  39. package/widgets/calendar-boards/widget.js +215 -215
  40. package/widgets/calendar-button/styles.js +273 -273
  41. package/widgets/calendar-button/widget.js +94 -94
  42. package/widgets/calendar-list/styles.js +35 -35
  43. package/widgets/calendar-list/widget.js +223 -223
  44. package/widgets/calendar-recurrence/widget.js +183 -183
  45. package/widgets/carousel/props.js +104 -104
  46. package/widgets/carousel/scenarios.js +163 -163
  47. package/widgets/carousel/styles.js +133 -133
  48. package/widgets/carousel/widget.js +491 -491
  49. package/widgets/carousel-bullet/styles.js +29 -29
  50. package/widgets/carousel-bullet/widget.js +25 -25
  51. package/widgets/carousel-button/styles.js +71 -71
  52. package/widgets/carousel-button/widget.js +33 -33
  53. package/widgets/carousel-item/styles.js +21 -21
  54. package/widgets/carousel-item/widget.js +24 -24
  55. package/widgets/chat-balloon/props.js +65 -65
  56. package/widgets/chat-balloon/scenarios.js +47 -47
  57. package/widgets/chat-balloon/styles.js +193 -193
  58. package/widgets/chat-balloon/widget.js +62 -62
  59. package/widgets/chat-dialog/styles.js +15 -15
  60. package/widgets/chat-dialog/widget.js +62 -62
  61. package/widgets/check-list/styles.js +66 -66
  62. package/widgets/check-list/widget.js +168 -168
  63. package/widgets/checkbox/widget.js +15 -15
  64. package/widgets/checkbox-nc/props.js +191 -191
  65. package/widgets/checkbox-nc/scenarios.js +41 -41
  66. package/widgets/checkbox-nc/styles.js +122 -122
  67. package/widgets/checkbox-nc/widget.js +116 -116
  68. package/widgets/clock-combo/styles.js +174 -174
  69. package/widgets/clock-combo/widget.js +390 -390
  70. package/widgets/color-picker/props.js +145 -145
  71. package/widgets/color-picker/scenarios.js +34 -34
  72. package/widgets/color-picker/styles.js +209 -209
  73. package/widgets/color-picker/widget.js +735 -735
  74. package/widgets/colored-container/props.js +34 -34
  75. package/widgets/colored-container/scenarios.js +54 -54
  76. package/widgets/colored-container/styles.js +100 -100
  77. package/widgets/colored-container/widget.js +27 -27
  78. package/widgets/combo/styles.js +69 -69
  79. package/widgets/combo/widget.js +224 -224
  80. package/widgets/combo-container/styles.js +66 -66
  81. package/widgets/combo-container/widget.js +188 -188
  82. package/widgets/command-button/widget.js +39 -39
  83. package/widgets/container/props.js +295 -295
  84. package/widgets/container/scenarios.js +47 -47
  85. package/widgets/container/styles.js +1439 -1439
  86. package/widgets/container/widget.js +279 -279
  87. package/widgets/demo/widget.js +24 -24
  88. package/widgets/dialog/styles.js +29 -29
  89. package/widgets/dialog/widget.js +26 -26
  90. package/widgets/dialog-modal/props.js +126 -126
  91. package/widgets/dialog-modal/styles.js +234 -234
  92. package/widgets/dialog-modal/widget.js +273 -273
  93. package/widgets/dialog-resizable/props.js +1 -1
  94. package/widgets/dialog-resizable/scenarios.js +18 -18
  95. package/widgets/dialog-resizable/widget.js +367 -367
  96. package/widgets/dialog-resizable-nc/props.js +150 -150
  97. package/widgets/dialog-resizable-nc/scenarios.js +18 -18
  98. package/widgets/dialog-resizable-nc/styles.js +259 -259
  99. package/widgets/dialog-resizable-nc/widget.js +197 -197
  100. package/widgets/directory-input/widget.js +18 -18
  101. package/widgets/directory-input-nc/widget.js +20 -20
  102. package/widgets/document-container/getPath.js +43 -43
  103. package/widgets/document-container/props.js +79 -79
  104. package/widgets/document-container/scenarios.js +39 -39
  105. package/widgets/document-container/styles.js +69 -69
  106. package/widgets/document-container/widget.js +53 -53
  107. package/widgets/drag-cab/styles.js +56 -56
  108. package/widgets/drag-cab/widget.js +285 -285
  109. package/widgets/drag-carrier/styles.js +21 -21
  110. package/widgets/drag-carrier/widget.js +780 -780
  111. package/widgets/dynamic-toolbar/styles.js +110 -110
  112. package/widgets/dynamic-toolbar/widget.js +128 -128
  113. package/widgets/field/readonly/label.js +39 -39
  114. package/widgets/field/widget.js +1743 -1743
  115. package/widgets/file-input/widget.js +18 -18
  116. package/widgets/file-input-nc/styles.js +38 -38
  117. package/widgets/file-input-nc/widget.js +88 -88
  118. package/widgets/flat-combo/styles.js +21 -21
  119. package/widgets/flat-combo/widget.js +61 -61
  120. package/widgets/flat-list/styles.js +30 -30
  121. package/widgets/flat-list/widget.js +219 -219
  122. package/widgets/flying-balloon/styles.js +52 -52
  123. package/widgets/flying-balloon/widget.js +43 -43
  124. package/widgets/fragment/widget.js +26 -26
  125. package/widgets/full-screen/props.js +27 -27
  126. package/widgets/full-screen/styles.js +32 -32
  127. package/widgets/full-screen/widget.js +40 -40
  128. package/widgets/gauge/props.js +71 -71
  129. package/widgets/gauge/scenarios.js +83 -83
  130. package/widgets/gauge/styles.js +183 -183
  131. package/widgets/gauge/widget.js +36 -36
  132. package/widgets/glyph-detail/service.js +9 -9
  133. package/widgets/glyph-detail/widget.js +109 -109
  134. package/widgets/glyphs-dialog/service.js +94 -94
  135. package/widgets/glyphs-dialog/styles.js +37 -37
  136. package/widgets/glyphs-dialog/widget.js +236 -236
  137. package/widgets/goblin-editor/widget.js +146 -146
  138. package/widgets/guild-entry/props.js +53 -53
  139. package/widgets/guild-entry/scenarios.js +26 -26
  140. package/widgets/guild-entry/styles.js +98 -98
  141. package/widgets/guild-entry/widget.js +126 -126
  142. package/widgets/guild-user-logo/guild-helpers.js +77 -77
  143. package/widgets/guild-user-logo/props.js +48 -48
  144. package/widgets/guild-user-logo/scenarios.js +64 -64
  145. package/widgets/guild-user-logo/styles.js +114 -114
  146. package/widgets/guild-user-logo/widget.js +81 -81
  147. package/widgets/guild-user-profile/props.js +73 -73
  148. package/widgets/guild-user-profile/scenarios.js +54 -54
  149. package/widgets/guild-user-profile/styles.js +162 -162
  150. package/widgets/guild-user-profile/widget.js +202 -202
  151. package/widgets/helpers/combo-helpers.js +218 -218
  152. package/widgets/helpers/geom-helpers.js +80 -80
  153. package/widgets/helpers/rect-helpers.js +10 -10
  154. package/widgets/helpers/shortcut-helpers.js +56 -56
  155. package/widgets/helpers/spacing-helpers.js +26 -26
  156. package/widgets/helpers/svg-helpers.js +151 -151
  157. package/widgets/helpers/table-helpers.js +68 -68
  158. package/widgets/hinter/styles.js +79 -79
  159. package/widgets/hinter/widget.js +205 -205
  160. package/widgets/hinter-column/widget.js +49 -49
  161. package/widgets/hinter-field/reducer.js +18 -18
  162. package/widgets/hinter-field/widget.js +176 -176
  163. package/widgets/hinter-field-nc/props.js +114 -114
  164. package/widgets/hinter-field-nc/scenarios.js +47 -47
  165. package/widgets/hinter-field-nc/widget.js +191 -191
  166. package/widgets/input-wrapper/widget.js +157 -157
  167. package/widgets/key-trap.js +96 -96
  168. package/widgets/label/props.js +1 -1
  169. package/widgets/label/scenarios.js +1 -1
  170. package/widgets/label/widget.js +7 -7
  171. package/widgets/label-nc/props.js +308 -308
  172. package/widgets/label-nc/scenarios.js +29 -29
  173. package/widgets/label-nc/styles.js +1218 -1218
  174. package/widgets/label-nc/widget.js +314 -314
  175. package/widgets/label-row/props.js +1 -1
  176. package/widgets/label-row/scenarios.js +1 -1
  177. package/widgets/label-row/widget.js +7 -7
  178. package/widgets/label-row-nc/props.js +94 -94
  179. package/widgets/label-row-nc/scenarios.js +46 -46
  180. package/widgets/label-row-nc/widget.js +81 -81
  181. package/widgets/label-text-field/styles.js +55 -55
  182. package/widgets/label-text-field/widget.js +178 -178
  183. package/widgets/launcher/props.js +177 -177
  184. package/widgets/launcher/scenarios.js +55 -55
  185. package/widgets/launcher/styles.js +46 -46
  186. package/widgets/launcher/widget.js +79 -79
  187. package/widgets/launcher-blob/props.js +25 -25
  188. package/widgets/launcher-blob/scenarios.js +24 -24
  189. package/widgets/launcher-blob/styles.js +62 -62
  190. package/widgets/launcher-blob/widget.js +50 -50
  191. package/widgets/list/widget.js +211 -211
  192. package/widgets/login-dialog/service.js +117 -117
  193. package/widgets/login-dialog/widget.js +117 -117
  194. package/widgets/map/reaflet.js +208 -208
  195. package/widgets/map/widget.js +67 -67
  196. package/widgets/markdown/styles.js +85 -85
  197. package/widgets/markdown/widget.js +31 -31
  198. package/widgets/notification/styles.js +97 -97
  199. package/widgets/notification/widget.js +207 -207
  200. package/widgets/pivot/custom.css +320 -320
  201. package/widgets/pivot/widget.js +42 -42
  202. package/widgets/radio-list/styles.js +48 -48
  203. package/widgets/radio-list/widget.js +111 -111
  204. package/widgets/resizable-container/styles.js +108 -108
  205. package/widgets/resizable-container/widget.js +225 -225
  206. package/widgets/retro-action-button/helpers.js +106 -106
  207. package/widgets/retro-action-button/styles.js +285 -285
  208. package/widgets/retro-action-button/widget.js +364 -364
  209. package/widgets/retro-badge-button/styles.js +87 -87
  210. package/widgets/retro-badge-button/widget.js +251 -251
  211. package/widgets/retro-gear/helpers.js +156 -156
  212. package/widgets/retro-gear/styles.js +130 -130
  213. package/widgets/retro-gear/widget.js +51 -51
  214. package/widgets/retro-illuminated-button/styles.js +274 -274
  215. package/widgets/retro-illuminated-button/widget.js +147 -147
  216. package/widgets/retro-panel/helpers.js +57 -57
  217. package/widgets/retro-panel/styles.js +293 -293
  218. package/widgets/retro-panel/widget.js +239 -239
  219. package/widgets/retro-screw/styles.js +80 -80
  220. package/widgets/retro-screw/widget.js +25 -25
  221. package/widgets/rocket/props.js +124 -124
  222. package/widgets/rocket/scenarios.js +71 -71
  223. package/widgets/rocket/styles.js +306 -306
  224. package/widgets/rocket/widget.js +225 -225
  225. package/widgets/samples-monitor/helpers.js +147 -147
  226. package/widgets/samples-monitor/styles.js +529 -529
  227. package/widgets/samples-monitor/widget.js +516 -516
  228. package/widgets/scrollable-container/styles.js +58 -58
  229. package/widgets/scrollable-container/widget.js +132 -132
  230. package/widgets/scrollable-linkable-container/reducer.js +18 -18
  231. package/widgets/scrollable-linkable-container/styles.js +42 -42
  232. package/widgets/scrollable-linkable-container/widget.js +78 -78
  233. package/widgets/select/styles.js +68 -68
  234. package/widgets/select/widget.js +119 -119
  235. package/widgets/separator/props.js +46 -46
  236. package/widgets/separator/styles.js +116 -116
  237. package/widgets/separator/widget.js +27 -27
  238. package/widgets/slider/props.js +136 -136
  239. package/widgets/slider/scenarios.js +74 -74
  240. package/widgets/slider/styles.js +246 -246
  241. package/widgets/slider/widget.js +404 -404
  242. package/widgets/slider-circle/props.js +72 -72
  243. package/widgets/slider-circle/scenarios.js +16 -16
  244. package/widgets/slider-circle/styles.js +78 -78
  245. package/widgets/slider-circle/widget.js +154 -154
  246. package/widgets/slider-xy/props.js +87 -87
  247. package/widgets/slider-xy/scenarios.js +19 -19
  248. package/widgets/slider-xy/styles.js +102 -102
  249. package/widgets/slider-xy/widget.js +234 -234
  250. package/widgets/smiley/props.js +51 -51
  251. package/widgets/smiley/scenarios.js +58 -58
  252. package/widgets/smiley/styles.js +489 -489
  253. package/widgets/smiley/widget.js +72 -72
  254. package/widgets/spinner/props.js +31 -31
  255. package/widgets/spinner/scenarios.js +31 -31
  256. package/widgets/spinner/styles.js +49 -49
  257. package/widgets/spinner/widget.js +23 -23
  258. package/widgets/splitter/props.js +71 -71
  259. package/widgets/splitter/scenarios.js +182 -182
  260. package/widgets/splitter/styles.js +41 -41
  261. package/widgets/splitter/widget.js +455 -455
  262. package/widgets/stack-navigation/service.js +324 -324
  263. package/widgets/stack-navigation/widget.js +296 -296
  264. package/widgets/state-browser/styles.js +19 -19
  265. package/widgets/state-browser/widget.js +135 -135
  266. package/widgets/state-browser-dialog/styles.js +100 -100
  267. package/widgets/state-browser-dialog/widget.js +253 -253
  268. package/widgets/state-monitor/styles.js +50 -50
  269. package/widgets/state-monitor/widget.js +324 -324
  270. package/widgets/switch-on-off/props.js +30 -30
  271. package/widgets/switch-on-off/scenarios.js +34 -34
  272. package/widgets/switch-on-off/styles.js +63 -63
  273. package/widgets/switch-on-off/widget.js +41 -41
  274. package/widgets/table/helpers.js +160 -160
  275. package/widgets/table/props.js +658 -658
  276. package/widgets/table/reducer.js +196 -196
  277. package/widgets/table/scenarios.js +54 -54
  278. package/widgets/table/widget.js +253 -253
  279. package/widgets/table-cell/props.js +145 -145
  280. package/widgets/table-cell/styles.js +160 -160
  281. package/widgets/table-cell/widget.js +139 -139
  282. package/widgets/table-header-drag-manager/styles.js +184 -184
  283. package/widgets/table-header-drag-manager/widget.js +392 -392
  284. package/widgets/table-nc/styles.js +100 -100
  285. package/widgets/table-nc/widget.js +409 -409
  286. package/widgets/table-row/props.js +73 -73
  287. package/widgets/table-row/styles.js +82 -82
  288. package/widgets/table-row/widget.js +207 -207
  289. package/widgets/text-field/widget.js +18 -18
  290. package/widgets/text-field-combo/widget.js +21 -21
  291. package/widgets/text-field-combo-nc/props.js +300 -300
  292. package/widgets/text-field-combo-nc/scenarios.js +72 -72
  293. package/widgets/text-field-combo-nc/widget.js +339 -339
  294. package/widgets/text-field-date-interval/styles.js +37 -37
  295. package/widgets/text-field-date-interval/widget.js +162 -162
  296. package/widgets/text-field-nc/props.js +40 -40
  297. package/widgets/text-field-nc/scenarios.js +67 -67
  298. package/widgets/text-field-nc/widget.js +14 -14
  299. package/widgets/text-field-time-interval/styles.js +37 -37
  300. package/widgets/text-field-time-interval/widget.js +160 -160
  301. package/widgets/text-field-typed/widget.js +51 -51
  302. package/widgets/text-field-typed-nc/props.js +81 -81
  303. package/widgets/text-field-typed-nc/scenarios.js +105 -105
  304. package/widgets/text-field-typed-nc/styles.js +20 -20
  305. package/widgets/text-field-typed-nc/widget.js +749 -750
  306. package/widgets/text-input-info-nc/props.js +62 -62
  307. package/widgets/text-input-info-nc/widget.js +55 -55
  308. package/widgets/text-input-nc/props.js +143 -143
  309. package/widgets/text-input-nc/scenarios.js +44 -44
  310. package/widgets/text-input-nc/styles.js +242 -242
  311. package/widgets/text-input-nc/widget.js +234 -234
  312. package/widgets/ticket/getPath.js +128 -128
  313. package/widgets/ticket/props.js +181 -181
  314. package/widgets/ticket/scenarios.js +39 -39
  315. package/widgets/ticket/styles.js +332 -332
  316. package/widgets/ticket/ticket-helpers.js +33 -33
  317. package/widgets/ticket/widget.js +348 -348
  318. package/widgets/ticket-hover/styles.js +207 -207
  319. package/widgets/ticket-hover/widget.js +53 -53
  320. package/widgets/time-gauge/widget.js +64 -64
  321. package/widgets/tips/styles.js +48 -48
  322. package/widgets/tips/widget.js +171 -171
  323. package/widgets/translatable-text-field/styles.js +202 -202
  324. package/widgets/translatable-text-field/text-field.js +132 -132
  325. package/widgets/translatable-text-field/widget.js +660 -660
  326. package/widgets/tree/props.js +246 -246
  327. package/widgets/tree/scenarios.js +14 -14
  328. package/widgets/tree/styles.js +142 -142
  329. package/widgets/tree/widget.js +383 -383
  330. package/widgets/tree-cell/styles.js +140 -140
  331. package/widgets/tree-cell/widget.js +100 -100
  332. package/widgets/tree-row/styles.js +77 -77
  333. package/widgets/tree-row/widget.js +135 -135
  334. package/widgets/triangle/props.js +48 -48
  335. package/widgets/triangle/scenarios.js +33 -33
  336. package/widgets/triangle/styles.js +92 -92
  337. package/widgets/triangle/widget.js +36 -36
  338. package/widgets/well-done/widget.js +170 -170
  339. package/widgets/widget-doc/reducer.js +68 -68
  340. package/widgets/widget-doc/styles.js +15 -15
  341. package/widgets/widget-doc/widget-list.js +25 -25
  342. package/widgets/widget-doc/widget.js +89 -89
  343. package/widgets/widget-doc-menu/styles.js +12 -12
  344. package/widgets/widget-doc-menu/widget.js +79 -79
  345. package/widgets/widget-doc-preview/parse-code.js +20 -20
  346. package/widgets/widget-doc-preview/styles.js +77 -77
  347. package/widgets/widget-doc-preview/widget.js +481 -481
  348. package/widgets/widget-doc-preview-container/styles.js +60 -60
  349. package/widgets/widget-doc-preview-container/widget.js +129 -129
  350. package/widgets/widget-doc-properties/styles.js +41 -41
  351. package/widgets/widget-doc-properties/widget.js +307 -307
  352. package/widgets/widget-doc-property/styles.js +75 -75
  353. package/widgets/widget-doc-property/widget.js +108 -108
  354. package/widgets/widget-doc-property-control/styles.js +14 -14
  355. package/widgets/widget-doc-property-control/widget.js +343 -343
  356. package/widgets/wizard/service.js +2132 -2132
  357. package/widgets/wizard/styles.js +21 -21
  358. package/widgets/wizard/widget.js +927 -927
  359. package/widgets/work-dialog/styles.js +31 -31
  360. package/widgets/work-dialog/widget.js +162 -162
  361. package/wizard.js +13 -13
@@ -1,1218 +1,1218 @@
1
- //T:2019-02-27
2
-
3
- import {Unit} from 'goblin-theme';
4
- import {ColorHelpers} from 'goblin-theme';
5
- import {ColorManipulator} from 'goblin-theme';
6
- import * as SpacingHelpers from 'goblin-gadgets/widgets/helpers/spacing-helpers';
7
- const to = Unit.to;
8
-
9
- function convertJustify(justify) {
10
- switch (justify) {
11
- case 'start':
12
- case 'left':
13
- return 'flex-start';
14
- case 'end':
15
- case 'right':
16
- return 'flex-end';
17
- case 'around':
18
- return 'space-around';
19
- case 'between':
20
- return 'space-between';
21
- default:
22
- return justify;
23
- }
24
- }
25
-
26
- /******************************************************************************/
27
-
28
- export const propNames = [
29
- 'width',
30
- 'height',
31
- 'grow',
32
- 'justify',
33
- 'zIndex',
34
- 'visibility',
35
- 'glyphSize',
36
- 'weight',
37
- 'wrap',
38
- 'textTransform',
39
- 'fontSize',
40
- 'cursor',
41
- 'horizontalSpacing',
42
- 'disabled',
43
- 'readonly',
44
- 'insideButton',
45
- 'isDragged',
46
- 'hasHeLeft',
47
- 'bottomSpacing',
48
- 'glyph',
49
- 'text',
50
- 'glyphPosition',
51
- 'shortcut',
52
- 'kind',
53
- 'active',
54
- 'focused',
55
- 'subkind',
56
- 'dimmed',
57
- 'empty',
58
- 'activeColor',
59
- 'vpos',
60
- 'shape',
61
- 'glyphColor',
62
- 'textColor',
63
- 'backgroundColor',
64
- 'buttonBackgroundColor',
65
- 'fontWeight',
66
- 'fontStyle',
67
- 'fontFamily',
68
- 'userSelect',
69
- 'cssUnit',
70
- ];
71
-
72
- export function mapProps(props) {
73
- return {
74
- ...props,
75
- text: Boolean(props.text),
76
- glyph: Boolean(props.glyph),
77
- shortcut: Boolean(props.shortcut),
78
- };
79
- }
80
-
81
- export default function styles(theme, props) {
82
- let {
83
- width,
84
- height,
85
- grow,
86
- justify,
87
- zIndex,
88
- visibility,
89
- glyphSize,
90
- weight,
91
- wrap,
92
- textTransform,
93
- fontSize,
94
- cursor,
95
- horizontalSpacing,
96
- disabled,
97
- readonly,
98
- insideButton,
99
- isDragged,
100
- hasHeLeft,
101
- bottomSpacing,
102
- glyph,
103
- text,
104
- glyphPosition,
105
- shortcut,
106
- kind,
107
- active,
108
- focused,
109
- subkind,
110
- dimmed,
111
- empty,
112
- activeColor,
113
- vpos,
114
- shape,
115
- glyphColor,
116
- textColor,
117
- backgroundColor,
118
- buttonBackgroundColor,
119
- fontWeight,
120
- fontStyle,
121
- fontFamily,
122
- userSelect,
123
- cssUnit = 'px',
124
- } = props;
125
-
126
- const m = Unit.multiply(to(theme.shapes.containerMargin, cssUnit), 0.5);
127
-
128
- let boxWidth = width;
129
- let boxHeight = height;
130
- let boxMaxHeight = null;
131
- let boxFlexDirection = 'row';
132
- let boxFlexGrow = grow;
133
- let boxFlexShrink = null;
134
- let boxFlexBasis = null;
135
- let boxJustifyContent = convertJustify(justify);
136
- let boxAlignItems = 'center';
137
- let boxMarginTop = to(0, cssUnit);
138
- let boxMarginRight = to(0, cssUnit);
139
- let boxMarginBottom = to(0, cssUnit);
140
- let boxMarginLeft = to(0, cssUnit);
141
- let boxPaddingTop = to(0, cssUnit);
142
- let boxPaddingRight = to(0, cssUnit);
143
- let boxPaddingBottom = to(0, cssUnit);
144
- let boxPaddingLeft = to(0, cssUnit);
145
- let boxShadow = null;
146
- let boxZIndex = zIndex;
147
- let boxOpacity = visibility === false ? 0 : null;
148
- let border = null;
149
- let borderTop = null;
150
- let borderBottom = null;
151
- let borderLeft = null;
152
- let borderRight = null;
153
- let boxSizing = null;
154
- let borderRadius = to(0, cssUnit);
155
- let backgroundColorFromKind = null;
156
- let textHoverColor = null;
157
- let glyphPaddingTop = to(0, cssUnit);
158
- let glyphPaddingRight = to(0, cssUnit);
159
- let glyphPaddingBottom = to(0, cssUnit);
160
- let glyphPaddingLeft = to(0, cssUnit);
161
- let glyphJustify = 'center';
162
- let glyphMinWidth = to(theme.shapes.lineHeight, cssUnit);
163
- let glyphHeight = to(theme.shapes.lineHeight, cssUnit);
164
- let glyphColorFromKind = null;
165
- let glyphTransform = null;
166
- let glyphMargin = null;
167
- let textWidth = null;
168
- let textMarginTop = to(0, cssUnit);
169
- let textMarginRight = m;
170
- let textMarginBottom = to(0, cssUnit);
171
- let textMarginLeft = m;
172
- let textPaddingTop = to(0, cssUnit);
173
- let textPaddingRight = to(0, cssUnit);
174
- let textPaddingBottom = to(0, cssUnit);
175
- let textPaddingLeft = to(0, cssUnit);
176
- let textWeight = weight;
177
- let textWrap = wrap;
178
- let textSize = fontSize ? fontSize : to(theme.shapes.labelTextSize, cssUnit);
179
- let boxAlignSelf = null;
180
- let textColorFromKind = null;
181
- let linesOverflow = null;
182
- let textOverflow = null;
183
- let textTextOverflow = null;
184
- let textWhiteSpace = null;
185
- let textWordBreak = null;
186
- let textAlign = null;
187
- let textDirection = null;
188
- cursor = cursor || 'default';
189
- let specialDisabled = false;
190
- let specialHover = false;
191
-
192
- disabled = disabled || readonly;
193
-
194
- if (insideButton) {
195
- boxHeight = height ? height : to(theme.shapes.lineHeight, cssUnit);
196
- horizontalSpacing = null;
197
- textWrap = textWrap ? textWrap : 'no';
198
- } else {
199
- textWrap = textWrap ? textWrap : 'yes';
200
- }
201
-
202
- if (!isDragged && hasHeLeft) {
203
- boxOpacity = 0.1;
204
- }
205
-
206
- // Initialise bottom margin according to bottom-spacing.
207
- if (bottomSpacing === 'large') {
208
- boxMarginBottom = m;
209
- }
210
- // Initialise right margin according to horizontalSpacing.
211
- boxMarginRight = SpacingHelpers.getHorizontalSpacingRightMargin(
212
- theme,
213
- horizontalSpacing
214
- );
215
- if (horizontalSpacing === 'compact' || horizontalSpacing === 'zero') {
216
- glyphMinWidth = null;
217
- }
218
-
219
- // Decrease space between glyph and text.
220
- if (glyph && text) {
221
- if (glyphPosition === 'right') {
222
- textMarginRight = to(0, cssUnit);
223
- } else {
224
- textMarginLeft = to(0, cssUnit);
225
- }
226
- }
227
-
228
- if (!insideButton && !glyph) {
229
- // Label without glyph ?
230
- if (boxJustifyContent === 'flex-end') {
231
- textMarginRight = to(0, cssUnit); // push to right frame border
232
- } else if (!boxJustifyContent || boxJustifyContent === 'flex-start') {
233
- textMarginLeft = to(0, cssUnit); // push to left frame border
234
- }
235
- }
236
-
237
- if (shortcut) {
238
- textMarginRight = to(0, cssUnit); // push shortcut to right frame border
239
- }
240
-
241
- // Choice glyph position into his square.
242
- if (insideButton) {
243
- glyphJustify = 'center';
244
- } else {
245
- if (glyphPosition === 'right') {
246
- glyphJustify = 'flex-end'; // push to right frame border
247
- } else if (glyphPosition === 'center') {
248
- glyphJustify = 'center';
249
- } else {
250
- glyphJustify = 'flex-start'; // push to left frame border
251
- }
252
- }
253
-
254
- if (kind === 'compact') {
255
- textMarginLeft = to(0, cssUnit);
256
- textMarginRight = to(0, cssUnit);
257
- }
258
-
259
- if (kind === 'table-cell-sorting-header') {
260
- glyphMinWidth = to(15, cssUnit);
261
- boxMarginRight = to(0, cssUnit);
262
- textMarginLeft = to(0, cssUnit);
263
- textMarginRight = to(0, cssUnit);
264
- glyphHeight = null;
265
- }
266
-
267
- if (kind === 'table-cell') {
268
- boxMarginRight = to(0, cssUnit);
269
- textMarginLeft = to(0, cssUnit);
270
- textMarginRight = to(0, cssUnit);
271
- glyphHeight = null;
272
- }
273
-
274
- if (kind === 'table-action-frame' || kind === 'table-action') {
275
- textSize = to(theme.shapes.tableActionTextSize, cssUnit);
276
- textTransform = textTransform || 'uppercase';
277
- textWeight = 'bold';
278
- }
279
-
280
- if (kind === 'tree-expand') {
281
- textHoverColor = theme.palette.treeExpandButtonHover;
282
- specialDisabled = true;
283
- glyphColorFromKind = textColorFromKind;
284
- glyphSize =
285
- glyphSize || to(theme.shapes.treeExpandButtonGlyphSize, cssUnit);
286
- }
287
-
288
- if (kind === 'pane-header') {
289
- boxHeight = to(50, cssUnit);
290
- boxMaxHeight = to(50, cssUnit);
291
- textSize = to(theme.shapes.paneHeaderTextSize, cssUnit);
292
- textWeight = 'bold';
293
- textTransform = 'uppercase';
294
- glyphColorFromKind = theme.palette.paneHeaderText;
295
- textColorFromKind = theme.palette.paneHeaderText;
296
- }
297
-
298
- if (kind === 'pane-warning') {
299
- textWeight = 'bold';
300
- textTransform = 'uppercase';
301
- glyphColorFromKind = theme.palette.statusText;
302
- textColorFromKind = theme.palette.statusText;
303
- }
304
-
305
- if (kind === 'title') {
306
- textSize = to(theme.shapes.labelTitleTextSize, cssUnit);
307
- textWeight = 'bold';
308
- textTransform = 'uppercase';
309
- }
310
-
311
- if (kind === 'title-recurrence') {
312
- boxPaddingTop = to(0, cssUnit);
313
- boxPaddingRight = to(theme.shapes.lineSpacing, cssUnit);
314
- boxPaddingBottom = to(0, cssUnit);
315
- boxPaddingLeft = to(theme.shapes.lineSpacing, cssUnit);
316
- }
317
-
318
- if (kind === 'big-center') {
319
- textSize = to(theme.shapes.labelBigTextSize, cssUnit);
320
- textWeight = 'bold';
321
- textTransform = 'uppercase';
322
- boxJustifyContent = boxJustifyContent || 'center';
323
- }
324
-
325
- if (kind === 'floating-header') {
326
- glyphMinWidth = null;
327
- glyphHeight = to(theme.shapes.floatingHeaderGlyphHeight, cssUnit);
328
- glyphSize = to(theme.shapes.floatingHeaderGlyphSize, cssUnit);
329
- glyphColorFromKind = theme.palette.floatingBackground;
330
- textColorFromKind = theme.palette.floatingBackground;
331
- }
332
-
333
- if (kind === 'floating-footer') {
334
- glyphMinWidth = null;
335
- textSize = to(theme.shapes.floatingFooterTextSize, cssUnit);
336
- glyphColorFromKind = theme.palette.floatingSecondary;
337
- textColorFromKind = theme.palette.floatingSecondary;
338
- }
339
-
340
- if (kind === 'info') {
341
- backgroundColorFromKind = theme.palette.infoBackground;
342
- boxJustifyContent = boxJustifyContent || 'center';
343
- boxPaddingTop = to(0, cssUnit);
344
- boxPaddingRight = to(10, cssUnit);
345
- boxPaddingBottom = to(0, cssUnit);
346
- boxPaddingLeft = to(10, cssUnit);
347
- }
348
-
349
- if (kind === 'footer') {
350
- glyphColorFromKind = theme.palette.footerText;
351
- textColorFromKind = theme.palette.footerText;
352
- boxPaddingTop = to(0, cssUnit);
353
- boxPaddingRight = to(20, cssUnit);
354
- boxPaddingBottom = to(0, cssUnit);
355
- boxPaddingLeft = to(20, cssUnit);
356
- }
357
-
358
- if (kind === 'notification') {
359
- boxMarginLeft = m;
360
- glyphColorFromKind = theme.palette.notificationMessage;
361
- textColorFromKind = theme.palette.notificationMessage;
362
- }
363
-
364
- if (kind === 'flying-balloon') {
365
- glyphColorFromKind = theme.palette.flyingBalloonText;
366
- textColorFromKind = theme.palette.flyingBalloonText;
367
- textSize = to(theme.shapes.flyingBalloonTextSize, cssUnit);
368
- textMarginTop = to(0, cssUnit);
369
- textMarginRight = to(0, cssUnit);
370
- textMarginBottom = to(0, cssUnit);
371
- textMarginLeft = to(0, cssUnit);
372
- }
373
-
374
- if (kind === 'task') {
375
- boxPaddingTop = to(theme.shapes.taskLabelTopMargin, cssUnit);
376
- boxPaddingRight = to(0, cssUnit);
377
- boxPaddingBottom = to(theme.shapes.taskLabelBottomMargin, cssUnit);
378
- boxPaddingLeft = to(theme.shapes.taskTabLeftMargin, cssUnit);
379
- glyphColorFromKind = theme.palette.taskLabelText;
380
- textColorFromKind = theme.palette.taskLabelText;
381
- textWeight = 'bold';
382
- textSize = to(theme.shapes.taskTabTextSize, cssUnit);
383
- glyphSize = to(theme.shapes.taskTabGlyphSize, cssUnit);
384
- }
385
-
386
- if (kind === 'center-to-box') {
387
- glyphMinWidth = null;
388
- boxJustifyContent = boxJustifyContent || 'center';
389
- boxMarginTop = m;
390
- boxMarginRight = to(0, cssUnit);
391
- boxMarginBottom = m;
392
- boxMarginLeft = to(0, cssUnit);
393
- }
394
-
395
- if (kind === 'large-left') {
396
- const hm = Unit.multiply(m, 0.5);
397
- boxMarginTop = hm;
398
- boxMarginRight = to(0, cssUnit);
399
- boxMarginBottom = hm;
400
- boxMarginLeft = m;
401
- }
402
- if (kind === 'large-right') {
403
- const hm = Unit.multiply(m, 0.5);
404
- boxMarginTop = hm;
405
- boxMarginRight = m;
406
- boxMarginBottom = hm;
407
- boxMarginLeft = to(0, cssUnit);
408
- }
409
- if (kind === 'large-single') {
410
- const hm = Unit.multiply(m, 0.5);
411
- boxMarginTop = hm;
412
- boxMarginRight = m;
413
- boxMarginBottom = hm;
414
- boxMarginLeft = m;
415
- }
416
-
417
- if (kind === 'ticket-warning') {
418
- boxMarginTop = to(5, cssUnit);
419
- }
420
-
421
- if (kind === 'mission-top') {
422
- boxAlignSelf = 'flex-start';
423
- textMarginTop = to(7, cssUnit);
424
- textMarginLeft = to(0, cssUnit);
425
- textMarginRight = to(0, cssUnit);
426
- }
427
-
428
- if (kind === 'one-line-height') {
429
- boxHeight = to(theme.shapes.lineHeight, cssUnit);
430
- }
431
-
432
- if (kind === 'combo-text-markdown') {
433
- const s = to(theme.shapes.smoothRadius, cssUnit);
434
- boxPaddingTop = to(6, cssUnit);
435
- boxPaddingRight = to(10, cssUnit);
436
- boxPaddingBottom = to(7, cssUnit);
437
- boxPaddingLeft = to(10, cssUnit);
438
- border = `${to(1, cssUnit)} solid ${theme.palette.buttonBorder}`;
439
- borderRadius = `${s} ${to(0, cssUnit)} ${to(0, cssUnit)} ${s}`;
440
- backgroundColorFromKind = theme.palette.textFieldReadonlyBackground;
441
- boxSizing = 'border-box';
442
- boxHeight = Unit.add(to(32, cssUnit), to(2, cssUnit));
443
- boxAlignItems = 'flex-start';
444
- glyphPaddingTop = to(2, cssUnit);
445
- glyphHeight = null;
446
- glyphJustify = 'center';
447
- if (theme.look.name === 'retro') {
448
- boxShadow =
449
- `${to(2, cssUnit)} ${to(3, cssUnit)} ` +
450
- `${to(10, cssUnit)} ${to(0, cssUnit)} ` +
451
- `rgba(0, 0, 0, 0.4)`;
452
- }
453
- }
454
-
455
- if (kind === 'field-combo') {
456
- boxHeight = to(theme.shapes.lineHeight, cssUnit);
457
- textMarginLeft = m;
458
- textMarginRight = m;
459
- border = `${to(1, cssUnit)} solid ` + theme.palette.buttonBorder;
460
- backgroundColorFromKind = theme.palette.textFieldReadonlyBackground;
461
- glyphJustify = 'flex-end';
462
- }
463
-
464
- if (kind === 'label-field') {
465
- boxJustifyContent = boxJustifyContent || 'none';
466
- boxHeight = null;
467
- boxAlignItems = 'flex-start';
468
- if (disabled) {
469
- glyphColorFromKind = theme.palette.textFieldDisableText;
470
- textColorFromKind = theme.palette.textFieldDisableText;
471
- specialDisabled = true;
472
- }
473
- }
474
-
475
- if (kind === 'note-hidden') {
476
- textMarginLeft = theme.spacing.lineSpacing;
477
- glyphColorFromKind = theme.palette.textFieldDisableText;
478
- textColorFromKind = theme.palette.textFieldDisableText;
479
- specialDisabled = true;
480
- }
481
-
482
- if (kind === 'ticket-title') {
483
- boxPaddingTop = to(7, cssUnit);
484
- boxAlignItems = 'flex-start';
485
- glyphHeight = null;
486
- textWeight = 'bold';
487
- }
488
-
489
- if (kind === 'ticket-label') {
490
- boxPaddingTop = to(7, cssUnit);
491
- boxAlignItems = 'flex-start';
492
- glyphHeight = null;
493
- }
494
-
495
- if (kind === 'compact-glyph') {
496
- glyphMinWidth = null;
497
- boxMarginLeft = to(5, cssUnit);
498
- }
499
-
500
- if (kind === 'ticket-hud') {
501
- boxJustifyContent = 'center';
502
- glyphJustify = 'center';
503
- glyphSize = '120%';
504
- glyphColorFromKind = theme.palette.ticketHudContent;
505
- textWeight = 'bold';
506
- }
507
-
508
- if (kind === 'text-field-combo-glyph') {
509
- glyphPaddingLeft = to(10, cssUnit);
510
- boxJustifyContent = 'center';
511
- glyphJustify = 'center';
512
- }
513
-
514
- /******************************************************************************/
515
- // Styles for Labels inside LabelTextFields.
516
- /******************************************************************************/
517
-
518
- if (kind === 'label-text-field') {
519
- boxJustifyContent = boxJustifyContent || 'none';
520
- boxHeight = null;
521
- textPaddingTop = to(8, cssUnit);
522
- boxAlignItems = 'flex-start';
523
- if (disabled) {
524
- glyphColorFromKind = theme.palette.textFieldDisableText;
525
- textColorFromKind = theme.palette.textFieldDisableText;
526
- specialDisabled = true;
527
- }
528
- }
529
-
530
- /******************************************************************************/
531
- // Styles for Labels inside Buttons.
532
- /******************************************************************************/
533
-
534
- // task-logo button (usual parent container with kind='task-bar').
535
- if (kind === 'task-logo') {
536
- boxFlexDirection = 'column';
537
- textWidth = to(theme.shapes.taskButtonWidth, cssUnit);
538
- textAlign = 'center';
539
- if (active) {
540
- textColorFromKind = theme.palette.taskTabActiveText;
541
- }
542
- textMarginTop = to(0, cssUnit);
543
- textMarginRight = to(0, cssUnit);
544
- textMarginBottom = to(0, cssUnit);
545
- textMarginLeft = to(0, cssUnit);
546
- textTransform = textTransform || 'uppercase';
547
- textWeight = 'bold';
548
- textSize = to(theme.shapes.taskLogoTextSize, cssUnit);
549
- glyphSize = to(theme.shapes.taskLogoGlyphSize, cssUnit);
550
- }
551
-
552
- // Task button (usual parent is container with kind='task-bar').
553
- if (kind === 'task-bar') {
554
- boxFlexDirection = 'column';
555
- textWidth = to(theme.shapes.taskButtonWidth, cssUnit);
556
- textAlign = 'center';
557
- textMarginTop = to(0, cssUnit);
558
- textMarginRight = to(0, cssUnit);
559
- textMarginBottom = to(0, cssUnit);
560
- textMarginLeft = to(0, cssUnit);
561
- textSize = to(theme.shapes.taskTextSize, cssUnit);
562
- textColorFromKind = theme.palette.taskButtonText;
563
- glyphSize = to(theme.shapes.taskGlyphSize, cssUnit);
564
- glyphColorFromKind = theme.palette.taskButtonText;
565
- }
566
-
567
- // main-tab button (usual parent is container with kind='main-tab').
568
- if (kind === 'main-tab') {
569
- textTransform = textTransform || 'uppercase';
570
- textWeight = 'bold';
571
- textSize = to(theme.shapes.mainTabTextSize, cssUnit);
572
- textColorFromKind = theme.palette.mainTabText;
573
- }
574
-
575
- if (kind === 'main-tab-right') {
576
- textColorFromKind = theme.palette.mainTabText;
577
- }
578
-
579
- // view-tab button (usual parent is container with kind='view-tab').
580
- if (
581
- kind === 'view-tab' ||
582
- kind === 'view-tab-first' ||
583
- kind === 'view-tab-last' ||
584
- kind === 'view-tab-single'
585
- ) {
586
- textSize = to(theme.shapes.viewTabTextSize, cssUnit);
587
- glyphColorFromKind = theme.palette.viewTabGlyph;
588
- }
589
-
590
- if (kind === 'view-tab-right') {
591
- textWeight = 'bold';
592
- textColorFromKind = theme.palette.viewTabRightText;
593
- glyphColorFromKind = theme.palette.viewTabRightText;
594
- }
595
-
596
- // task-tab button (usual parent is container with kind='task-bar').
597
- if (kind === 'task-tab') {
598
- boxJustifyContent = boxJustifyContent || 'flex-start';
599
- if (active) {
600
- textColorFromKind = theme.palette.taskTabActiveText;
601
- textWeight = 'bold';
602
- } else {
603
- textColorFromKind = theme.palette.taskTabInactiveText;
604
- }
605
- const mm = glyph
606
- ? to(0, cssUnit)
607
- : to(theme.shapes.taskTabLeftMargin, cssUnit);
608
- textMarginTop = to(0, cssUnit);
609
- textMarginRight = to(0, cssUnit);
610
- textMarginBottom = to(0, cssUnit);
611
- textMarginLeft = mm;
612
- textSize = to(theme.shapes.taskTabTextSize, cssUnit);
613
- glyphSize = to(theme.shapes.taskTabGlyphSize, cssUnit);
614
- }
615
-
616
- // pane-navigator button (usual parent is container with kind='pane-navigator').
617
- if (kind === 'pane-navigator') {
618
- textTransform = textTransform || 'uppercase';
619
- textWeight = 'bold';
620
- textSize = to(theme.shapes.paneNavigatorTextSize, cssUnit);
621
- if (active === false) {
622
- textColorFromKind = theme.palette.paneNavigatorInactiveText;
623
- }
624
- }
625
-
626
- // pane-hnavigator button (usual parent is container with kind='pane-hnavigator').
627
- if (kind === 'pane-hnavigator') {
628
- textSize = to(theme.shapes.paneNavigatorTextSize, cssUnit);
629
- if (active === false) {
630
- textColorFromKind = theme.palette.paneNavigatorInactiveText;
631
- }
632
- }
633
-
634
- // pane-vnavigator button (usual parent is container with kind='pane-vnavigator').
635
- if (kind === 'pane-vnavigator') {
636
- textSize = to(theme.shapes.paneNavigatorTextSize, cssUnit);
637
- }
638
-
639
- // Footer button (usual parent is container with kind='footer').
640
- if (kind === 'button-footer') {
641
- textSize = to(theme.shapes.footerTextSize, cssUnit);
642
- glyphSize = to(theme.shapes.footerGlyphSize, cssUnit);
643
- }
644
-
645
- // Notification button (usual parent is container with kind='notification-header').
646
- if (kind === 'button-notification') {
647
- glyphHeight = null;
648
- textSize = to(theme.shapes.notificationButtonTextSize, cssUnit);
649
- glyphSize = to(theme.shapes.notificationButtonGlyphSize, cssUnit);
650
- glyphMargin =
651
- `${to(10, cssUnit)} ${to(20, cssUnit)} ` +
652
- `${to(10, cssUnit)} ${to(0, cssUnit)}`;
653
- glyphColorFromKind = theme.palette.notificationText;
654
- textColorFromKind = theme.palette.notificationText;
655
- textHoverColor = theme.palette.notificationTextHover;
656
- if (disabled) {
657
- glyphColorFromKind = ColorManipulator.darken(
658
- theme.palette.notificationText,
659
- 0.4
660
- );
661
- textColorFromKind = ColorManipulator.darken(
662
- theme.palette.notificationText,
663
- 0.4
664
- );
665
- }
666
- specialDisabled = true;
667
- }
668
- if (kind === 'notification-close' || kind === 'notification-extend') {
669
- glyphColorFromKind = theme.palette.notificationText;
670
- textColorFromKind = theme.palette.notificationText;
671
- textHoverColor = theme.palette.notificationTextHover;
672
- }
673
-
674
- if (kind === 'check-button') {
675
- textHoverColor = theme.palette.checkButtonTextHover;
676
- if (disabled) {
677
- glyphColorFromKind = theme.palette.textFieldDisableText;
678
- textColorFromKind = theme.palette.textFieldDisableText;
679
- specialDisabled = true;
680
- }
681
- }
682
-
683
- if (kind === 'plugin-light') {
684
- glyphColorFromKind = theme.palette.pluginLightButtonGlyph;
685
- textColorFromKind = theme.palette.pluginLightButtonGlyph;
686
- textHoverColor = theme.palette.pluginLightButtonGlyphHover;
687
- specialHover = true;
688
- }
689
- if (kind === 'plugin-dark') {
690
- glyphColorFromKind = theme.palette.pluginDarkButtonGlyph;
691
- textColorFromKind = theme.palette.pluginDarkButtonGlyph;
692
- textHoverColor = theme.palette.pluginDarkButtonGlyphHover;
693
- specialHover = true;
694
- }
695
-
696
- // Warning button (usual parent is container with kind='footer').
697
- if (kind === 'warning') {
698
- textWeight = 'bold';
699
- textSize = to(theme.shapes.warningTextSize, cssUnit);
700
- glyphSize = to(theme.shapes.warningGlyphSize, cssUnit);
701
- textColorFromKind = theme.palette.warningText;
702
- }
703
-
704
- // Action button (usual parent is container with kind='actions').
705
- if (kind === 'action') {
706
- textSize = to(theme.shapes.actionTextSize, cssUnit);
707
- glyphSize = to(theme.shapes.actionGlyphSize, cssUnit);
708
- boxJustifyContent = boxJustifyContent || 'none';
709
- }
710
-
711
- // Action button (usual parent is container with kind='actions-line-secondary').
712
- if (kind === 'secondary-action') {
713
- textSize = to(theme.shapes.secondaryActionTextSize, cssUnit);
714
- glyphSize = to(theme.shapes.secondaryActionGlyphSize, cssUnit);
715
- boxJustifyContent = boxJustifyContent || 'none';
716
- }
717
-
718
- // Subaction button (usual parent is container with kind='row-pane' and subkind='box').
719
- if (kind === 'subaction') {
720
- textColorFromKind = theme.palette.subactionButtonText;
721
- glyphColorFromKind = theme.palette.subactionButtonText;
722
- textSize = to(theme.shapes.subactionTextSize, cssUnit);
723
- textTransform = textTransform || 'uppercase';
724
- textWeight = 'bold';
725
- }
726
-
727
- // Combo button, place to the right of a TextFieldCombo component.
728
- if (kind === 'combo') {
729
- if (disabled) {
730
- glyphColorFromKind = theme.palette.textFieldDisableText;
731
- textColorFromKind = theme.palette.textFieldDisableText;
732
- specialDisabled = true;
733
- } else if (active) {
734
- glyphColorFromKind = theme.palette.comboActiveGlyph;
735
- }
736
- }
737
-
738
- if (kind === 'round') {
739
- textColorFromKind = theme.palette.roundButtonText;
740
- glyphColorFromKind = theme.palette.roundButtonGlyph;
741
- }
742
-
743
- if (kind === 'identity') {
744
- glyphSize = to(theme.shapes.identityGlyphSize, cssUnit);
745
- textColorFromKind = theme.palette.identityButtonText;
746
- glyphColorFromKind = theme.palette.identityButtonGlyph;
747
- }
748
-
749
- if (kind === 'menu-item') {
750
- textWidth = 'max-content';
751
- textMarginTop = to(0, cssUnit);
752
- textMarginRight = to(theme.shapes.containerMargin, cssUnit);
753
- textMarginBottom = to(0, cssUnit);
754
- textMarginLeft = to(theme.shapes.containerMargin, cssUnit);
755
- boxJustifyContent = boxJustifyContent || 'flex-start';
756
- textSize = to(theme.shapes.menuTextSize, cssUnit);
757
- textTransform = textTransform || 'uppercase';
758
- textWeight = 'bold';
759
- if (active) {
760
- glyphColorFromKind = theme.palette.menuText;
761
- textColorFromKind = theme.palette.menuText;
762
- } else if (focused) {
763
- glyphColorFromKind = theme.palette.menuFocusText;
764
- textColorFromKind = theme.palette.menuFocusText;
765
- } else {
766
- glyphColorFromKind = theme.palette.menuText;
767
- textColorFromKind = theme.palette.menuText;
768
- }
769
- }
770
-
771
- if (kind === 'combo-item') {
772
- textWidth = 'max-content';
773
- textMarginTop = to(0, cssUnit);
774
- textMarginRight = to(theme.shapes.containerMargin, cssUnit);
775
- textMarginBottom = to(0, cssUnit);
776
- textMarginLeft = to(theme.shapes.containerMargin, cssUnit);
777
- boxJustifyContent = boxJustifyContent || 'flex-start';
778
- textSize = to(theme.shapes.menuTextSize, cssUnit);
779
- textTransform = textTransform || 'uppercase';
780
- }
781
- if (kind === 'flat-list-combo-item') {
782
- textSize = to(theme.shapes.menuTextSize, cssUnit);
783
- textColor = theme.palette.comboItemText;
784
- glyphColor = glyphColor || theme.palette.comboItemText;
785
- }
786
-
787
- if (kind === 'combo-wrap-item') {
788
- textWidth = 'max-content';
789
- textMarginTop = to(0, cssUnit);
790
- textMarginRight = to(0, cssUnit);
791
- textMarginBottom = to(0, cssUnit);
792
- textMarginLeft = to(0, cssUnit);
793
- boxJustifyContent = boxJustifyContent || 'flex-start';
794
- textSize = to(theme.shapes.menuTextSize, cssUnit);
795
- textTransform = textTransform || 'uppercase';
796
- glyphJustify = 'flex-start';
797
- }
798
-
799
- if (kind === 'glyph-item') {
800
- textWidth = 'max-content';
801
- boxJustifyContent = boxJustifyContent || 'flex-start';
802
- glyphSize = '120%';
803
- }
804
-
805
- if (kind === 'desk-title') {
806
- boxJustifyContent = boxJustifyContent || 'flex-start';
807
- glyphColorFromKind = theme.palette.ticketGlueTitle;
808
- textColorFromKind = theme.palette.ticketGlueTitle;
809
- textWeight = 'bold';
810
- textSize = to(theme.shapes.ticketGlueTitleSize, cssUnit);
811
- }
812
-
813
- if (kind === 'task-show-footer') {
814
- boxJustifyContent = boxJustifyContent || 'flex-end';
815
- glyphColorFromKind = theme.palette.ticketGlueTitle;
816
- textColorFromKind = theme.palette.ticketGlueTitle;
817
- textWeight = 'bold';
818
- textSize = to(theme.shapes.ticketGlueTitleSize, cssUnit);
819
- }
820
-
821
- // Button with a day in Calendar component.
822
- if (
823
- kind === 'calendar' ||
824
- kind === 'calendar-navigator' ||
825
- kind === 'calendar-list' ||
826
- kind === 'calendar-title'
827
- ) {
828
- textMarginRight = to(0, cssUnit);
829
- textMarginLeft = to(0, cssUnit);
830
- textSize = to(theme.shapes.calendarTextSize, cssUnit);
831
- textColorFromKind = kind === 'calendar' ? theme.palette.calendarText : null;
832
- if (active) {
833
- if (subkind === 'add') {
834
- textColorFromKind = theme.palette.calendarActiveAddText;
835
- if (kind === 'calendar') {
836
- textWeight = 'bold';
837
- }
838
- } else if (subkind === 'sub') {
839
- textColorFromKind = theme.palette.calendarActiveSubText;
840
- } else {
841
- textColorFromKind = theme.palette.calendarActiveText;
842
- if (kind === 'calendar') {
843
- textWeight = 'bold';
844
- }
845
- }
846
- }
847
- if (dimmed) {
848
- textColorFromKind = theme.palette.calendarDimmedText;
849
- }
850
- if (kind === 'calendar-navigator') {
851
- if (disabled) {
852
- textColorFromKind = theme.palette.calendarDimmedText;
853
- }
854
- specialDisabled = true;
855
- }
856
- if (kind === 'calendar-title') {
857
- textSize = '100%';
858
- textWeight = 'bold';
859
- textTransform = 'uppercase';
860
- }
861
- glyphColorFromKind = textColorFromKind;
862
- }
863
-
864
- if (kind === 'container') {
865
- boxAlignItems = 'stretch';
866
- }
867
-
868
- if (kind === 'container-start') {
869
- boxJustifyContent = boxJustifyContent || 'flex-start';
870
- boxAlignItems = 'stretch';
871
- }
872
-
873
- if (kind === 'box') {
874
- boxAlignItems = 'stretch';
875
- }
876
-
877
- if (kind === 'chronos-navigator') {
878
- if (active === false) {
879
- glyphColorFromKind = theme.palette.chronoNavigatorText;
880
- textColorFromKind = theme.palette.chronoNavigatorText;
881
- }
882
- }
883
-
884
- if (kind === 'recurrence') {
885
- if (active) {
886
- glyphColorFromKind = theme.palette.calendarActiveText;
887
- textColorFromKind = theme.palette.calendarActiveText;
888
- }
889
- }
890
-
891
- if (kind === 'dynamic-toolbar') {
892
- glyphColorFromKind = theme.palette.dynamicToolbarButtonGlyph;
893
- textColorFromKind = theme.palette.dynamicToolbarButtonGlyph;
894
- if (active) {
895
- glyphColorFromKind = theme.palette.dynamicToolbarButtonActiveGlyph;
896
- textColorFromKind = theme.palette.dynamicToolbarButtonActiveGlyph;
897
- }
898
- }
899
-
900
- if (kind === 'toolbar') {
901
- if (active) {
902
- glyphColorFromKind = theme.palette.toolbarActiveText;
903
- textColorFromKind = theme.palette.toolbarActiveText;
904
- } else {
905
- glyphColorFromKind = theme.palette.toolbarInactiveText;
906
- textColorFromKind = theme.palette.toolbarInactiveText;
907
- }
908
- }
909
-
910
- if (kind === 'alert') {
911
- textPaddingTop = to(6, cssUnit);
912
- textPaddingBottom = to(6, cssUnit);
913
- }
914
-
915
- if (kind === 'flat-combo') {
916
- if (active) {
917
- textColorFromKind = disabled
918
- ? theme.palette.flatComboDisableActiveText
919
- : theme.palette.flatComboActiveText;
920
- } else {
921
- textColorFromKind = disabled
922
- ? theme.palette.flatComboDisableInactiveText
923
- : theme.palette.flatComboInactiveText;
924
- }
925
- glyphColorFromKind = textColorFromKind;
926
- specialDisabled = true;
927
- }
928
-
929
- if (empty) {
930
- border = `${to(2, cssUnit)} dotted #ccc`;
931
- boxHeight = Unit.sub(to(theme.shapes.lineHeight, cssUnit), to(2, cssUnit));
932
- boxSizing = 'border-box';
933
- boxMarginTop = to(2, cssUnit);
934
- }
935
-
936
- if (!kind) {
937
- borderRadius = to(theme.shapes.smoothRadius, cssUnit);
938
- if (active) {
939
- backgroundColorFromKind = activeColor
940
- ? activeColor
941
- : theme.palette.boxActiveBackground;
942
- }
943
- }
944
-
945
- if (vpos === 'top') {
946
- boxAlignSelf = 'flex-start';
947
- } else if (vpos === 'first-line') {
948
- boxAlignSelf = 'flex-start';
949
- boxMarginTop = to(3, cssUnit);
950
- }
951
-
952
- if (textWrap === 'no') {
953
- linesOverflow = 'hidden';
954
- textOverflow = 'hidden';
955
- textTextOverflow = 'ellipsis';
956
- textWhiteSpace = 'nowrap';
957
- } else if (textWrap === 'no-end') {
958
- linesOverflow = 'hidden';
959
- textOverflow = 'hidden';
960
- textTextOverflow = 'ellipsis';
961
- textWhiteSpace = 'nowrap';
962
- textAlign = 'left';
963
- textDirection = 'rtl';
964
- } else if (textWrap === 'no-strict') {
965
- linesOverflow = 'hidden';
966
- textOverflow = 'hidden';
967
- textTextOverflow = 'ellipsis';
968
- textWhiteSpace = 'nowrap';
969
- boxWidth = to(0, cssUnit);
970
- if (!boxFlexGrow) {
971
- boxFlexGrow = '1';
972
- }
973
- } else if (textWrap === 'yes-permissive') {
974
- // Intentionally empty.
975
- } else if (textWrap === 'yes') {
976
- textWordBreak = 'break-word';
977
- }
978
-
979
- if (shape) {
980
- const r = Unit.multiply(to(theme.shapes.lineHeight, cssUnit), 0.5);
981
- const s = to(theme.shapes.smoothRadius, cssUnit);
982
- if (shape === 'rounded') {
983
- borderRadius = r;
984
- } else if (shape === 'left-rounded') {
985
- borderRadius = r + ` ${to(0, cssUnit)} ${to(0, cssUnit)} ` + r;
986
- } else if (shape === 'right-rounded') {
987
- borderRadius = `${to(0, cssUnit)} ` + r + ' ' + r + ` ${to(0, cssUnit)}`;
988
- } else if (shape === 'smooth') {
989
- borderRadius = s;
990
- } else if (shape === 'left-smooth') {
991
- borderRadius = s + ` ${to(0, cssUnit)} ${to(0, cssUnit)} ` + s;
992
- } else if (shape === 'right-smooth') {
993
- borderRadius = `${to(0, cssUnit)} ` + s + ' ' + s + ` ${to(0, cssUnit)}`;
994
- }
995
- }
996
-
997
- // Force colors according to properties glyphColor, textColor and backgroundColor.
998
- if (glyphColor) {
999
- glyphColor = ColorHelpers.getMarkColor(theme, glyphColor);
1000
- } else {
1001
- glyphColor = glyphColorFromKind;
1002
- }
1003
- if (textColor) {
1004
- textColor = ColorHelpers.getMarkColor(theme, textColor);
1005
- } else {
1006
- textColor = textColorFromKind;
1007
- }
1008
- if (backgroundColor) {
1009
- backgroundColor = ColorHelpers.getMarkColor(theme, backgroundColor);
1010
- } else {
1011
- backgroundColor = backgroundColorFromKind;
1012
- }
1013
-
1014
- // Sets default colors if they are undefined
1015
- if (!glyphColor) {
1016
- glyphColor = ColorManipulator.emphasize(buttonBackgroundColor, 0.8);
1017
- }
1018
- if (!textColor) {
1019
- textColor = ColorManipulator.emphasize(buttonBackgroundColor, 0.9);
1020
- }
1021
-
1022
- // Alter colors if component is disable.
1023
- if (disabled && !specialDisabled) {
1024
- if (backgroundColor) {
1025
- backgroundColor = theme.palette.buttonDisableBackground;
1026
- }
1027
- if (glyphColor !== 'transparent') {
1028
- glyphColor = theme.palette.buttonDisableGlyph;
1029
- }
1030
- textColor = theme.palette.buttonDisableText;
1031
- }
1032
-
1033
- // If the Label is in a Button, it never has a backgroundColor.
1034
- // Indeed, the background color is drawn by the Button.
1035
- if (insideButton) {
1036
- backgroundColor = null;
1037
- }
1038
-
1039
- if (boxFlexGrow) {
1040
- boxFlexShrink = '1';
1041
- boxFlexBasis = '0%';
1042
- }
1043
-
1044
- if (fontWeight) {
1045
- textWeight = fontWeight;
1046
- }
1047
-
1048
- if (!boxJustifyContent) {
1049
- if (insideButton) {
1050
- boxJustifyContent = 'center';
1051
- } else {
1052
- boxJustifyContent = 'flex-start';
1053
- }
1054
- }
1055
- if (boxJustifyContent === 'none') {
1056
- boxJustifyContent = null;
1057
- }
1058
-
1059
- if (textTransform === 'none') {
1060
- textTransform = null;
1061
- }
1062
-
1063
- const boxStyle = {
1064
- width: boxWidth,
1065
- minWidth: boxWidth ? boxWidth : to(0, cssUnit),
1066
- minHeight: boxHeight,
1067
- maxHeight: boxMaxHeight,
1068
- paddingTop: boxPaddingTop,
1069
- paddingRight: boxPaddingRight,
1070
- paddingBottom: boxPaddingBottom,
1071
- paddingLeft: boxPaddingLeft,
1072
- marginTop: boxMarginTop,
1073
- marginRight: boxMarginRight,
1074
- marginBottom: boxMarginBottom,
1075
- marginLeft: boxMarginLeft,
1076
- display: 'flex',
1077
- flexDirection: boxFlexDirection,
1078
- alignItems: boxAlignItems,
1079
- justifyContent: boxJustifyContent,
1080
- alignSelf: boxAlignSelf,
1081
- flexGrow: boxFlexGrow,
1082
- flexShrink: boxFlexShrink,
1083
- flexBasis: boxFlexBasis,
1084
- border: border,
1085
- borderTop: borderTop,
1086
- borderBottom: borderBottom,
1087
- borderLeft: borderLeft,
1088
- borderRight: borderRight,
1089
- boxSizing: boxSizing,
1090
- borderRadius: borderRadius,
1091
- boxShadow: boxShadow,
1092
- backgroundColor: backgroundColor,
1093
- opacity: boxOpacity,
1094
- zIndex: boxZIndex,
1095
- userSelect: userSelect || 'none',
1096
- cursor: cursor,
1097
- };
1098
-
1099
- if (glyphSize) {
1100
- const s = Unit.parse(glyphSize);
1101
- if (s.unit !== '%') {
1102
- throw new Error(`GlyphSize '${glyphSize}' has an unexpected format`);
1103
- }
1104
- const ss = s.value / 100;
1105
- if (!glyphTransform) {
1106
- glyphTransform = 'scale(' + ss + ')';
1107
- }
1108
- if (!glyphMargin) {
1109
- const mm = Unit.multiply(m, ss);
1110
- glyphMargin = `${to(0, cssUnit)} ` + mm + ` ${to(0, cssUnit)} ` + mm;
1111
- }
1112
- }
1113
-
1114
- const glyphStyle = {
1115
- display: 'flex',
1116
- flexDirection: 'row',
1117
- justifyContent: glyphJustify,
1118
- alignItems: 'center',
1119
- minWidth: glyphMinWidth,
1120
- height: glyphHeight,
1121
- paddingTop: glyphPaddingTop,
1122
- paddingRight: glyphPaddingRight,
1123
- paddingBottom: glyphPaddingBottom,
1124
- paddingLeft: glyphPaddingLeft,
1125
- margin: glyphMargin,
1126
- color: glyphColor,
1127
- transform: glyphTransform,
1128
- userSelect: 'none',
1129
- };
1130
-
1131
- const linesStyle = {
1132
- width: '100%',
1133
- overflow: linesOverflow,
1134
- userSelect: userSelect || 'none',
1135
- };
1136
-
1137
- const textStyle = {
1138
- display: 'block', // required because <T/> use a 'span' (previously, all the styling was planned for a 'div')
1139
- width: textWidth,
1140
- marginTop: textMarginTop,
1141
- marginRight: textMarginRight,
1142
- marginBottom: textMarginBottom,
1143
- marginLeft: textMarginLeft,
1144
- paddingTop: textPaddingTop,
1145
- paddingRight: textPaddingRight,
1146
- paddingBottom: textPaddingBottom,
1147
- paddingLeft: textPaddingLeft,
1148
- fontSize: Unit.multiply(textSize, theme.typo.fontScale),
1149
- fontWeight: textWeight,
1150
- fontStyle: fontStyle,
1151
- fontFamily: fontFamily,
1152
- color: textColor,
1153
- textTransform: textTransform,
1154
- overflow: textOverflow,
1155
- textOverflow: textTextOverflow,
1156
- whiteSpace: textWhiteSpace,
1157
- wordWrap: 'break-word',
1158
- wordBreak: textWordBreak,
1159
- textAlign: textAlign,
1160
- direction: textDirection,
1161
- userSelect: userSelect || 'none',
1162
- };
1163
-
1164
- const normalFragmentStyle = {
1165
- color: textColor,
1166
- };
1167
-
1168
- const hilitedFragmentStyle = {
1169
- color: theme.palette.highlightedText,
1170
- backgroundColor: theme.palette.highlightedTextBackground,
1171
- padding: to(1, cssUnit),
1172
- };
1173
-
1174
- if (!disabled && insideButton && boxOpacity !== 0) {
1175
- if (specialHover) {
1176
- glyphStyle[':hover'] = {
1177
- color: textHoverColor,
1178
- };
1179
- textStyle[':hover'] = {
1180
- color: textHoverColor,
1181
- };
1182
- } else {
1183
- boxStyle[':hover'] = {
1184
- color: textHoverColor, // (*)
1185
- opacity: 1.0,
1186
- };
1187
-
1188
- if (textHoverColor) {
1189
- textStyle.color = null; // (*)
1190
- glyphStyle.color = null; // (*)
1191
- }
1192
- // (*) If hover change the color of glyph and text, it is necessary to change
1193
- // the color of parent (and not the glyph/text children). This system
1194
- // causes the change simultaneously for the two children.
1195
- }
1196
-
1197
- boxStyle[':active'] = {
1198
- color: ColorManipulator.darken(textColor, 0.1),
1199
- };
1200
- textStyle[':active'] = {
1201
- color: ColorManipulator.darken(textColor, 0.1),
1202
- };
1203
- glyphStyle[':active'] = {
1204
- color: ColorManipulator.darken(glyphColor, 0.1),
1205
- };
1206
- }
1207
-
1208
- return {
1209
- box: boxStyle,
1210
- glyph: glyphStyle,
1211
- lines: linesStyle,
1212
- text: textStyle,
1213
- normalFragment: normalFragmentStyle,
1214
- hilitedFragment: hilitedFragmentStyle,
1215
- };
1216
- }
1217
-
1218
- /******************************************************************************/
1
+ //T:2019-02-27
2
+
3
+ import {Unit} from 'goblin-theme';
4
+ import {ColorHelpers} from 'goblin-theme';
5
+ import {ColorManipulator} from 'goblin-theme';
6
+ import * as SpacingHelpers from 'goblin-gadgets/widgets/helpers/spacing-helpers';
7
+ const to = Unit.to;
8
+
9
+ function convertJustify(justify) {
10
+ switch (justify) {
11
+ case 'start':
12
+ case 'left':
13
+ return 'flex-start';
14
+ case 'end':
15
+ case 'right':
16
+ return 'flex-end';
17
+ case 'around':
18
+ return 'space-around';
19
+ case 'between':
20
+ return 'space-between';
21
+ default:
22
+ return justify;
23
+ }
24
+ }
25
+
26
+ /******************************************************************************/
27
+
28
+ export const propNames = [
29
+ 'width',
30
+ 'height',
31
+ 'grow',
32
+ 'justify',
33
+ 'zIndex',
34
+ 'visibility',
35
+ 'glyphSize',
36
+ 'weight',
37
+ 'wrap',
38
+ 'textTransform',
39
+ 'fontSize',
40
+ 'cursor',
41
+ 'horizontalSpacing',
42
+ 'disabled',
43
+ 'readonly',
44
+ 'insideButton',
45
+ 'isDragged',
46
+ 'hasHeLeft',
47
+ 'bottomSpacing',
48
+ 'glyph',
49
+ 'text',
50
+ 'glyphPosition',
51
+ 'shortcut',
52
+ 'kind',
53
+ 'active',
54
+ 'focused',
55
+ 'subkind',
56
+ 'dimmed',
57
+ 'empty',
58
+ 'activeColor',
59
+ 'vpos',
60
+ 'shape',
61
+ 'glyphColor',
62
+ 'textColor',
63
+ 'backgroundColor',
64
+ 'buttonBackgroundColor',
65
+ 'fontWeight',
66
+ 'fontStyle',
67
+ 'fontFamily',
68
+ 'userSelect',
69
+ 'cssUnit',
70
+ ];
71
+
72
+ export function mapProps(props) {
73
+ return {
74
+ ...props,
75
+ text: Boolean(props.text),
76
+ glyph: Boolean(props.glyph),
77
+ shortcut: Boolean(props.shortcut),
78
+ };
79
+ }
80
+
81
+ export default function styles(theme, props) {
82
+ let {
83
+ width,
84
+ height,
85
+ grow,
86
+ justify,
87
+ zIndex,
88
+ visibility,
89
+ glyphSize,
90
+ weight,
91
+ wrap,
92
+ textTransform,
93
+ fontSize,
94
+ cursor,
95
+ horizontalSpacing,
96
+ disabled,
97
+ readonly,
98
+ insideButton,
99
+ isDragged,
100
+ hasHeLeft,
101
+ bottomSpacing,
102
+ glyph,
103
+ text,
104
+ glyphPosition,
105
+ shortcut,
106
+ kind,
107
+ active,
108
+ focused,
109
+ subkind,
110
+ dimmed,
111
+ empty,
112
+ activeColor,
113
+ vpos,
114
+ shape,
115
+ glyphColor,
116
+ textColor,
117
+ backgroundColor,
118
+ buttonBackgroundColor,
119
+ fontWeight,
120
+ fontStyle,
121
+ fontFamily,
122
+ userSelect,
123
+ cssUnit = 'px',
124
+ } = props;
125
+
126
+ const m = Unit.multiply(to(theme.shapes.containerMargin, cssUnit), 0.5);
127
+
128
+ let boxWidth = width;
129
+ let boxHeight = height;
130
+ let boxMaxHeight = null;
131
+ let boxFlexDirection = 'row';
132
+ let boxFlexGrow = grow;
133
+ let boxFlexShrink = null;
134
+ let boxFlexBasis = null;
135
+ let boxJustifyContent = convertJustify(justify);
136
+ let boxAlignItems = 'center';
137
+ let boxMarginTop = to(0, cssUnit);
138
+ let boxMarginRight = to(0, cssUnit);
139
+ let boxMarginBottom = to(0, cssUnit);
140
+ let boxMarginLeft = to(0, cssUnit);
141
+ let boxPaddingTop = to(0, cssUnit);
142
+ let boxPaddingRight = to(0, cssUnit);
143
+ let boxPaddingBottom = to(0, cssUnit);
144
+ let boxPaddingLeft = to(0, cssUnit);
145
+ let boxShadow = null;
146
+ let boxZIndex = zIndex;
147
+ let boxOpacity = visibility === false ? 0 : null;
148
+ let border = null;
149
+ let borderTop = null;
150
+ let borderBottom = null;
151
+ let borderLeft = null;
152
+ let borderRight = null;
153
+ let boxSizing = null;
154
+ let borderRadius = to(0, cssUnit);
155
+ let backgroundColorFromKind = null;
156
+ let textHoverColor = null;
157
+ let glyphPaddingTop = to(0, cssUnit);
158
+ let glyphPaddingRight = to(0, cssUnit);
159
+ let glyphPaddingBottom = to(0, cssUnit);
160
+ let glyphPaddingLeft = to(0, cssUnit);
161
+ let glyphJustify = 'center';
162
+ let glyphMinWidth = to(theme.shapes.lineHeight, cssUnit);
163
+ let glyphHeight = to(theme.shapes.lineHeight, cssUnit);
164
+ let glyphColorFromKind = null;
165
+ let glyphTransform = null;
166
+ let glyphMargin = null;
167
+ let textWidth = null;
168
+ let textMarginTop = to(0, cssUnit);
169
+ let textMarginRight = m;
170
+ let textMarginBottom = to(0, cssUnit);
171
+ let textMarginLeft = m;
172
+ let textPaddingTop = to(0, cssUnit);
173
+ let textPaddingRight = to(0, cssUnit);
174
+ let textPaddingBottom = to(0, cssUnit);
175
+ let textPaddingLeft = to(0, cssUnit);
176
+ let textWeight = weight;
177
+ let textWrap = wrap;
178
+ let textSize = fontSize ? fontSize : to(theme.shapes.labelTextSize, cssUnit);
179
+ let boxAlignSelf = null;
180
+ let textColorFromKind = null;
181
+ let linesOverflow = null;
182
+ let textOverflow = null;
183
+ let textTextOverflow = null;
184
+ let textWhiteSpace = null;
185
+ let textWordBreak = null;
186
+ let textAlign = null;
187
+ let textDirection = null;
188
+ cursor = cursor || 'default';
189
+ let specialDisabled = false;
190
+ let specialHover = false;
191
+
192
+ disabled = disabled || readonly;
193
+
194
+ if (insideButton) {
195
+ boxHeight = height ? height : to(theme.shapes.lineHeight, cssUnit);
196
+ horizontalSpacing = null;
197
+ textWrap = textWrap ? textWrap : 'no';
198
+ } else {
199
+ textWrap = textWrap ? textWrap : 'yes';
200
+ }
201
+
202
+ if (!isDragged && hasHeLeft) {
203
+ boxOpacity = 0.1;
204
+ }
205
+
206
+ // Initialise bottom margin according to bottom-spacing.
207
+ if (bottomSpacing === 'large') {
208
+ boxMarginBottom = m;
209
+ }
210
+ // Initialise right margin according to horizontalSpacing.
211
+ boxMarginRight = SpacingHelpers.getHorizontalSpacingRightMargin(
212
+ theme,
213
+ horizontalSpacing
214
+ );
215
+ if (horizontalSpacing === 'compact' || horizontalSpacing === 'zero') {
216
+ glyphMinWidth = null;
217
+ }
218
+
219
+ // Decrease space between glyph and text.
220
+ if (glyph && text) {
221
+ if (glyphPosition === 'right') {
222
+ textMarginRight = to(0, cssUnit);
223
+ } else {
224
+ textMarginLeft = to(0, cssUnit);
225
+ }
226
+ }
227
+
228
+ if (!insideButton && !glyph) {
229
+ // Label without glyph ?
230
+ if (boxJustifyContent === 'flex-end') {
231
+ textMarginRight = to(0, cssUnit); // push to right frame border
232
+ } else if (!boxJustifyContent || boxJustifyContent === 'flex-start') {
233
+ textMarginLeft = to(0, cssUnit); // push to left frame border
234
+ }
235
+ }
236
+
237
+ if (shortcut) {
238
+ textMarginRight = to(0, cssUnit); // push shortcut to right frame border
239
+ }
240
+
241
+ // Choice glyph position into his square.
242
+ if (insideButton) {
243
+ glyphJustify = 'center';
244
+ } else {
245
+ if (glyphPosition === 'right') {
246
+ glyphJustify = 'flex-end'; // push to right frame border
247
+ } else if (glyphPosition === 'center') {
248
+ glyphJustify = 'center';
249
+ } else {
250
+ glyphJustify = 'flex-start'; // push to left frame border
251
+ }
252
+ }
253
+
254
+ if (kind === 'compact') {
255
+ textMarginLeft = to(0, cssUnit);
256
+ textMarginRight = to(0, cssUnit);
257
+ }
258
+
259
+ if (kind === 'table-cell-sorting-header') {
260
+ glyphMinWidth = to(15, cssUnit);
261
+ boxMarginRight = to(0, cssUnit);
262
+ textMarginLeft = to(0, cssUnit);
263
+ textMarginRight = to(0, cssUnit);
264
+ glyphHeight = null;
265
+ }
266
+
267
+ if (kind === 'table-cell') {
268
+ boxMarginRight = to(0, cssUnit);
269
+ textMarginLeft = to(0, cssUnit);
270
+ textMarginRight = to(0, cssUnit);
271
+ glyphHeight = null;
272
+ }
273
+
274
+ if (kind === 'table-action-frame' || kind === 'table-action') {
275
+ textSize = to(theme.shapes.tableActionTextSize, cssUnit);
276
+ textTransform = textTransform || 'uppercase';
277
+ textWeight = 'bold';
278
+ }
279
+
280
+ if (kind === 'tree-expand') {
281
+ textHoverColor = theme.palette.treeExpandButtonHover;
282
+ specialDisabled = true;
283
+ glyphColorFromKind = textColorFromKind;
284
+ glyphSize =
285
+ glyphSize || to(theme.shapes.treeExpandButtonGlyphSize, cssUnit);
286
+ }
287
+
288
+ if (kind === 'pane-header') {
289
+ boxHeight = to(50, cssUnit);
290
+ boxMaxHeight = to(50, cssUnit);
291
+ textSize = to(theme.shapes.paneHeaderTextSize, cssUnit);
292
+ textWeight = 'bold';
293
+ textTransform = 'uppercase';
294
+ glyphColorFromKind = theme.palette.paneHeaderText;
295
+ textColorFromKind = theme.palette.paneHeaderText;
296
+ }
297
+
298
+ if (kind === 'pane-warning') {
299
+ textWeight = 'bold';
300
+ textTransform = 'uppercase';
301
+ glyphColorFromKind = theme.palette.statusText;
302
+ textColorFromKind = theme.palette.statusText;
303
+ }
304
+
305
+ if (kind === 'title') {
306
+ textSize = to(theme.shapes.labelTitleTextSize, cssUnit);
307
+ textWeight = 'bold';
308
+ textTransform = 'uppercase';
309
+ }
310
+
311
+ if (kind === 'title-recurrence') {
312
+ boxPaddingTop = to(0, cssUnit);
313
+ boxPaddingRight = to(theme.shapes.lineSpacing, cssUnit);
314
+ boxPaddingBottom = to(0, cssUnit);
315
+ boxPaddingLeft = to(theme.shapes.lineSpacing, cssUnit);
316
+ }
317
+
318
+ if (kind === 'big-center') {
319
+ textSize = to(theme.shapes.labelBigTextSize, cssUnit);
320
+ textWeight = 'bold';
321
+ textTransform = 'uppercase';
322
+ boxJustifyContent = boxJustifyContent || 'center';
323
+ }
324
+
325
+ if (kind === 'floating-header') {
326
+ glyphMinWidth = null;
327
+ glyphHeight = to(theme.shapes.floatingHeaderGlyphHeight, cssUnit);
328
+ glyphSize = to(theme.shapes.floatingHeaderGlyphSize, cssUnit);
329
+ glyphColorFromKind = theme.palette.floatingBackground;
330
+ textColorFromKind = theme.palette.floatingBackground;
331
+ }
332
+
333
+ if (kind === 'floating-footer') {
334
+ glyphMinWidth = null;
335
+ textSize = to(theme.shapes.floatingFooterTextSize, cssUnit);
336
+ glyphColorFromKind = theme.palette.floatingSecondary;
337
+ textColorFromKind = theme.palette.floatingSecondary;
338
+ }
339
+
340
+ if (kind === 'info') {
341
+ backgroundColorFromKind = theme.palette.infoBackground;
342
+ boxJustifyContent = boxJustifyContent || 'center';
343
+ boxPaddingTop = to(0, cssUnit);
344
+ boxPaddingRight = to(10, cssUnit);
345
+ boxPaddingBottom = to(0, cssUnit);
346
+ boxPaddingLeft = to(10, cssUnit);
347
+ }
348
+
349
+ if (kind === 'footer') {
350
+ glyphColorFromKind = theme.palette.footerText;
351
+ textColorFromKind = theme.palette.footerText;
352
+ boxPaddingTop = to(0, cssUnit);
353
+ boxPaddingRight = to(20, cssUnit);
354
+ boxPaddingBottom = to(0, cssUnit);
355
+ boxPaddingLeft = to(20, cssUnit);
356
+ }
357
+
358
+ if (kind === 'notification') {
359
+ boxMarginLeft = m;
360
+ glyphColorFromKind = theme.palette.notificationMessage;
361
+ textColorFromKind = theme.palette.notificationMessage;
362
+ }
363
+
364
+ if (kind === 'flying-balloon') {
365
+ glyphColorFromKind = theme.palette.flyingBalloonText;
366
+ textColorFromKind = theme.palette.flyingBalloonText;
367
+ textSize = to(theme.shapes.flyingBalloonTextSize, cssUnit);
368
+ textMarginTop = to(0, cssUnit);
369
+ textMarginRight = to(0, cssUnit);
370
+ textMarginBottom = to(0, cssUnit);
371
+ textMarginLeft = to(0, cssUnit);
372
+ }
373
+
374
+ if (kind === 'task') {
375
+ boxPaddingTop = to(theme.shapes.taskLabelTopMargin, cssUnit);
376
+ boxPaddingRight = to(0, cssUnit);
377
+ boxPaddingBottom = to(theme.shapes.taskLabelBottomMargin, cssUnit);
378
+ boxPaddingLeft = to(theme.shapes.taskTabLeftMargin, cssUnit);
379
+ glyphColorFromKind = theme.palette.taskLabelText;
380
+ textColorFromKind = theme.palette.taskLabelText;
381
+ textWeight = 'bold';
382
+ textSize = to(theme.shapes.taskTabTextSize, cssUnit);
383
+ glyphSize = to(theme.shapes.taskTabGlyphSize, cssUnit);
384
+ }
385
+
386
+ if (kind === 'center-to-box') {
387
+ glyphMinWidth = null;
388
+ boxJustifyContent = boxJustifyContent || 'center';
389
+ boxMarginTop = m;
390
+ boxMarginRight = to(0, cssUnit);
391
+ boxMarginBottom = m;
392
+ boxMarginLeft = to(0, cssUnit);
393
+ }
394
+
395
+ if (kind === 'large-left') {
396
+ const hm = Unit.multiply(m, 0.5);
397
+ boxMarginTop = hm;
398
+ boxMarginRight = to(0, cssUnit);
399
+ boxMarginBottom = hm;
400
+ boxMarginLeft = m;
401
+ }
402
+ if (kind === 'large-right') {
403
+ const hm = Unit.multiply(m, 0.5);
404
+ boxMarginTop = hm;
405
+ boxMarginRight = m;
406
+ boxMarginBottom = hm;
407
+ boxMarginLeft = to(0, cssUnit);
408
+ }
409
+ if (kind === 'large-single') {
410
+ const hm = Unit.multiply(m, 0.5);
411
+ boxMarginTop = hm;
412
+ boxMarginRight = m;
413
+ boxMarginBottom = hm;
414
+ boxMarginLeft = m;
415
+ }
416
+
417
+ if (kind === 'ticket-warning') {
418
+ boxMarginTop = to(5, cssUnit);
419
+ }
420
+
421
+ if (kind === 'mission-top') {
422
+ boxAlignSelf = 'flex-start';
423
+ textMarginTop = to(7, cssUnit);
424
+ textMarginLeft = to(0, cssUnit);
425
+ textMarginRight = to(0, cssUnit);
426
+ }
427
+
428
+ if (kind === 'one-line-height') {
429
+ boxHeight = to(theme.shapes.lineHeight, cssUnit);
430
+ }
431
+
432
+ if (kind === 'combo-text-markdown') {
433
+ const s = to(theme.shapes.smoothRadius, cssUnit);
434
+ boxPaddingTop = to(6, cssUnit);
435
+ boxPaddingRight = to(10, cssUnit);
436
+ boxPaddingBottom = to(7, cssUnit);
437
+ boxPaddingLeft = to(10, cssUnit);
438
+ border = `${to(1, cssUnit)} solid ${theme.palette.buttonBorder}`;
439
+ borderRadius = `${s} ${to(0, cssUnit)} ${to(0, cssUnit)} ${s}`;
440
+ backgroundColorFromKind = theme.palette.textFieldReadonlyBackground;
441
+ boxSizing = 'border-box';
442
+ boxHeight = Unit.add(to(32, cssUnit), to(2, cssUnit));
443
+ boxAlignItems = 'flex-start';
444
+ glyphPaddingTop = to(2, cssUnit);
445
+ glyphHeight = null;
446
+ glyphJustify = 'center';
447
+ if (theme.look.name === 'retro') {
448
+ boxShadow =
449
+ `${to(2, cssUnit)} ${to(3, cssUnit)} ` +
450
+ `${to(10, cssUnit)} ${to(0, cssUnit)} ` +
451
+ `rgba(0, 0, 0, 0.4)`;
452
+ }
453
+ }
454
+
455
+ if (kind === 'field-combo') {
456
+ boxHeight = to(theme.shapes.lineHeight, cssUnit);
457
+ textMarginLeft = m;
458
+ textMarginRight = m;
459
+ border = `${to(1, cssUnit)} solid ` + theme.palette.buttonBorder;
460
+ backgroundColorFromKind = theme.palette.textFieldReadonlyBackground;
461
+ glyphJustify = 'flex-end';
462
+ }
463
+
464
+ if (kind === 'label-field') {
465
+ boxJustifyContent = boxJustifyContent || 'none';
466
+ boxHeight = null;
467
+ boxAlignItems = 'flex-start';
468
+ if (disabled) {
469
+ glyphColorFromKind = theme.palette.textFieldDisableText;
470
+ textColorFromKind = theme.palette.textFieldDisableText;
471
+ specialDisabled = true;
472
+ }
473
+ }
474
+
475
+ if (kind === 'note-hidden') {
476
+ textMarginLeft = theme.spacing.lineSpacing;
477
+ glyphColorFromKind = theme.palette.textFieldDisableText;
478
+ textColorFromKind = theme.palette.textFieldDisableText;
479
+ specialDisabled = true;
480
+ }
481
+
482
+ if (kind === 'ticket-title') {
483
+ boxPaddingTop = to(7, cssUnit);
484
+ boxAlignItems = 'flex-start';
485
+ glyphHeight = null;
486
+ textWeight = 'bold';
487
+ }
488
+
489
+ if (kind === 'ticket-label') {
490
+ boxPaddingTop = to(7, cssUnit);
491
+ boxAlignItems = 'flex-start';
492
+ glyphHeight = null;
493
+ }
494
+
495
+ if (kind === 'compact-glyph') {
496
+ glyphMinWidth = null;
497
+ boxMarginLeft = to(5, cssUnit);
498
+ }
499
+
500
+ if (kind === 'ticket-hud') {
501
+ boxJustifyContent = 'center';
502
+ glyphJustify = 'center';
503
+ glyphSize = '120%';
504
+ glyphColorFromKind = theme.palette.ticketHudContent;
505
+ textWeight = 'bold';
506
+ }
507
+
508
+ if (kind === 'text-field-combo-glyph') {
509
+ glyphPaddingLeft = to(10, cssUnit);
510
+ boxJustifyContent = 'center';
511
+ glyphJustify = 'center';
512
+ }
513
+
514
+ /******************************************************************************/
515
+ // Styles for Labels inside LabelTextFields.
516
+ /******************************************************************************/
517
+
518
+ if (kind === 'label-text-field') {
519
+ boxJustifyContent = boxJustifyContent || 'none';
520
+ boxHeight = null;
521
+ textPaddingTop = to(8, cssUnit);
522
+ boxAlignItems = 'flex-start';
523
+ if (disabled) {
524
+ glyphColorFromKind = theme.palette.textFieldDisableText;
525
+ textColorFromKind = theme.palette.textFieldDisableText;
526
+ specialDisabled = true;
527
+ }
528
+ }
529
+
530
+ /******************************************************************************/
531
+ // Styles for Labels inside Buttons.
532
+ /******************************************************************************/
533
+
534
+ // task-logo button (usual parent container with kind='task-bar').
535
+ if (kind === 'task-logo') {
536
+ boxFlexDirection = 'column';
537
+ textWidth = to(theme.shapes.taskButtonWidth, cssUnit);
538
+ textAlign = 'center';
539
+ if (active) {
540
+ textColorFromKind = theme.palette.taskTabActiveText;
541
+ }
542
+ textMarginTop = to(0, cssUnit);
543
+ textMarginRight = to(0, cssUnit);
544
+ textMarginBottom = to(0, cssUnit);
545
+ textMarginLeft = to(0, cssUnit);
546
+ textTransform = textTransform || 'uppercase';
547
+ textWeight = 'bold';
548
+ textSize = to(theme.shapes.taskLogoTextSize, cssUnit);
549
+ glyphSize = to(theme.shapes.taskLogoGlyphSize, cssUnit);
550
+ }
551
+
552
+ // Task button (usual parent is container with kind='task-bar').
553
+ if (kind === 'task-bar') {
554
+ boxFlexDirection = 'column';
555
+ textWidth = to(theme.shapes.taskButtonWidth, cssUnit);
556
+ textAlign = 'center';
557
+ textMarginTop = to(0, cssUnit);
558
+ textMarginRight = to(0, cssUnit);
559
+ textMarginBottom = to(0, cssUnit);
560
+ textMarginLeft = to(0, cssUnit);
561
+ textSize = to(theme.shapes.taskTextSize, cssUnit);
562
+ textColorFromKind = theme.palette.taskButtonText;
563
+ glyphSize = to(theme.shapes.taskGlyphSize, cssUnit);
564
+ glyphColorFromKind = theme.palette.taskButtonText;
565
+ }
566
+
567
+ // main-tab button (usual parent is container with kind='main-tab').
568
+ if (kind === 'main-tab') {
569
+ textTransform = textTransform || 'uppercase';
570
+ textWeight = 'bold';
571
+ textSize = to(theme.shapes.mainTabTextSize, cssUnit);
572
+ textColorFromKind = theme.palette.mainTabText;
573
+ }
574
+
575
+ if (kind === 'main-tab-right') {
576
+ textColorFromKind = theme.palette.mainTabText;
577
+ }
578
+
579
+ // view-tab button (usual parent is container with kind='view-tab').
580
+ if (
581
+ kind === 'view-tab' ||
582
+ kind === 'view-tab-first' ||
583
+ kind === 'view-tab-last' ||
584
+ kind === 'view-tab-single'
585
+ ) {
586
+ textSize = to(theme.shapes.viewTabTextSize, cssUnit);
587
+ glyphColorFromKind = theme.palette.viewTabGlyph;
588
+ }
589
+
590
+ if (kind === 'view-tab-right') {
591
+ textWeight = 'bold';
592
+ textColorFromKind = theme.palette.viewTabRightText;
593
+ glyphColorFromKind = theme.palette.viewTabRightText;
594
+ }
595
+
596
+ // task-tab button (usual parent is container with kind='task-bar').
597
+ if (kind === 'task-tab') {
598
+ boxJustifyContent = boxJustifyContent || 'flex-start';
599
+ if (active) {
600
+ textColorFromKind = theme.palette.taskTabActiveText;
601
+ textWeight = 'bold';
602
+ } else {
603
+ textColorFromKind = theme.palette.taskTabInactiveText;
604
+ }
605
+ const mm = glyph
606
+ ? to(0, cssUnit)
607
+ : to(theme.shapes.taskTabLeftMargin, cssUnit);
608
+ textMarginTop = to(0, cssUnit);
609
+ textMarginRight = to(0, cssUnit);
610
+ textMarginBottom = to(0, cssUnit);
611
+ textMarginLeft = mm;
612
+ textSize = to(theme.shapes.taskTabTextSize, cssUnit);
613
+ glyphSize = to(theme.shapes.taskTabGlyphSize, cssUnit);
614
+ }
615
+
616
+ // pane-navigator button (usual parent is container with kind='pane-navigator').
617
+ if (kind === 'pane-navigator') {
618
+ textTransform = textTransform || 'uppercase';
619
+ textWeight = 'bold';
620
+ textSize = to(theme.shapes.paneNavigatorTextSize, cssUnit);
621
+ if (active === false) {
622
+ textColorFromKind = theme.palette.paneNavigatorInactiveText;
623
+ }
624
+ }
625
+
626
+ // pane-hnavigator button (usual parent is container with kind='pane-hnavigator').
627
+ if (kind === 'pane-hnavigator') {
628
+ textSize = to(theme.shapes.paneNavigatorTextSize, cssUnit);
629
+ if (active === false) {
630
+ textColorFromKind = theme.palette.paneNavigatorInactiveText;
631
+ }
632
+ }
633
+
634
+ // pane-vnavigator button (usual parent is container with kind='pane-vnavigator').
635
+ if (kind === 'pane-vnavigator') {
636
+ textSize = to(theme.shapes.paneNavigatorTextSize, cssUnit);
637
+ }
638
+
639
+ // Footer button (usual parent is container with kind='footer').
640
+ if (kind === 'button-footer') {
641
+ textSize = to(theme.shapes.footerTextSize, cssUnit);
642
+ glyphSize = to(theme.shapes.footerGlyphSize, cssUnit);
643
+ }
644
+
645
+ // Notification button (usual parent is container with kind='notification-header').
646
+ if (kind === 'button-notification') {
647
+ glyphHeight = null;
648
+ textSize = to(theme.shapes.notificationButtonTextSize, cssUnit);
649
+ glyphSize = to(theme.shapes.notificationButtonGlyphSize, cssUnit);
650
+ glyphMargin =
651
+ `${to(10, cssUnit)} ${to(20, cssUnit)} ` +
652
+ `${to(10, cssUnit)} ${to(0, cssUnit)}`;
653
+ glyphColorFromKind = theme.palette.notificationText;
654
+ textColorFromKind = theme.palette.notificationText;
655
+ textHoverColor = theme.palette.notificationTextHover;
656
+ if (disabled) {
657
+ glyphColorFromKind = ColorManipulator.darken(
658
+ theme.palette.notificationText,
659
+ 0.4
660
+ );
661
+ textColorFromKind = ColorManipulator.darken(
662
+ theme.palette.notificationText,
663
+ 0.4
664
+ );
665
+ }
666
+ specialDisabled = true;
667
+ }
668
+ if (kind === 'notification-close' || kind === 'notification-extend') {
669
+ glyphColorFromKind = theme.palette.notificationText;
670
+ textColorFromKind = theme.palette.notificationText;
671
+ textHoverColor = theme.palette.notificationTextHover;
672
+ }
673
+
674
+ if (kind === 'check-button') {
675
+ textHoverColor = theme.palette.checkButtonTextHover;
676
+ if (disabled) {
677
+ glyphColorFromKind = theme.palette.textFieldDisableText;
678
+ textColorFromKind = theme.palette.textFieldDisableText;
679
+ specialDisabled = true;
680
+ }
681
+ }
682
+
683
+ if (kind === 'plugin-light') {
684
+ glyphColorFromKind = theme.palette.pluginLightButtonGlyph;
685
+ textColorFromKind = theme.palette.pluginLightButtonGlyph;
686
+ textHoverColor = theme.palette.pluginLightButtonGlyphHover;
687
+ specialHover = true;
688
+ }
689
+ if (kind === 'plugin-dark') {
690
+ glyphColorFromKind = theme.palette.pluginDarkButtonGlyph;
691
+ textColorFromKind = theme.palette.pluginDarkButtonGlyph;
692
+ textHoverColor = theme.palette.pluginDarkButtonGlyphHover;
693
+ specialHover = true;
694
+ }
695
+
696
+ // Warning button (usual parent is container with kind='footer').
697
+ if (kind === 'warning') {
698
+ textWeight = 'bold';
699
+ textSize = to(theme.shapes.warningTextSize, cssUnit);
700
+ glyphSize = to(theme.shapes.warningGlyphSize, cssUnit);
701
+ textColorFromKind = theme.palette.warningText;
702
+ }
703
+
704
+ // Action button (usual parent is container with kind='actions').
705
+ if (kind === 'action') {
706
+ textSize = to(theme.shapes.actionTextSize, cssUnit);
707
+ glyphSize = to(theme.shapes.actionGlyphSize, cssUnit);
708
+ boxJustifyContent = boxJustifyContent || 'none';
709
+ }
710
+
711
+ // Action button (usual parent is container with kind='actions-line-secondary').
712
+ if (kind === 'secondary-action') {
713
+ textSize = to(theme.shapes.secondaryActionTextSize, cssUnit);
714
+ glyphSize = to(theme.shapes.secondaryActionGlyphSize, cssUnit);
715
+ boxJustifyContent = boxJustifyContent || 'none';
716
+ }
717
+
718
+ // Subaction button (usual parent is container with kind='row-pane' and subkind='box').
719
+ if (kind === 'subaction') {
720
+ textColorFromKind = theme.palette.subactionButtonText;
721
+ glyphColorFromKind = theme.palette.subactionButtonText;
722
+ textSize = to(theme.shapes.subactionTextSize, cssUnit);
723
+ textTransform = textTransform || 'uppercase';
724
+ textWeight = 'bold';
725
+ }
726
+
727
+ // Combo button, place to the right of a TextFieldCombo component.
728
+ if (kind === 'combo') {
729
+ if (disabled) {
730
+ glyphColorFromKind = theme.palette.textFieldDisableText;
731
+ textColorFromKind = theme.palette.textFieldDisableText;
732
+ specialDisabled = true;
733
+ } else if (active) {
734
+ glyphColorFromKind = theme.palette.comboActiveGlyph;
735
+ }
736
+ }
737
+
738
+ if (kind === 'round') {
739
+ textColorFromKind = theme.palette.roundButtonText;
740
+ glyphColorFromKind = theme.palette.roundButtonGlyph;
741
+ }
742
+
743
+ if (kind === 'identity') {
744
+ glyphSize = to(theme.shapes.identityGlyphSize, cssUnit);
745
+ textColorFromKind = theme.palette.identityButtonText;
746
+ glyphColorFromKind = theme.palette.identityButtonGlyph;
747
+ }
748
+
749
+ if (kind === 'menu-item') {
750
+ textWidth = 'max-content';
751
+ textMarginTop = to(0, cssUnit);
752
+ textMarginRight = to(theme.shapes.containerMargin, cssUnit);
753
+ textMarginBottom = to(0, cssUnit);
754
+ textMarginLeft = to(theme.shapes.containerMargin, cssUnit);
755
+ boxJustifyContent = boxJustifyContent || 'flex-start';
756
+ textSize = to(theme.shapes.menuTextSize, cssUnit);
757
+ textTransform = textTransform || 'uppercase';
758
+ textWeight = 'bold';
759
+ if (active) {
760
+ glyphColorFromKind = theme.palette.menuText;
761
+ textColorFromKind = theme.palette.menuText;
762
+ } else if (focused) {
763
+ glyphColorFromKind = theme.palette.menuFocusText;
764
+ textColorFromKind = theme.palette.menuFocusText;
765
+ } else {
766
+ glyphColorFromKind = theme.palette.menuText;
767
+ textColorFromKind = theme.palette.menuText;
768
+ }
769
+ }
770
+
771
+ if (kind === 'combo-item') {
772
+ textWidth = 'max-content';
773
+ textMarginTop = to(0, cssUnit);
774
+ textMarginRight = to(theme.shapes.containerMargin, cssUnit);
775
+ textMarginBottom = to(0, cssUnit);
776
+ textMarginLeft = to(theme.shapes.containerMargin, cssUnit);
777
+ boxJustifyContent = boxJustifyContent || 'flex-start';
778
+ textSize = to(theme.shapes.menuTextSize, cssUnit);
779
+ textTransform = textTransform || 'uppercase';
780
+ }
781
+ if (kind === 'flat-list-combo-item') {
782
+ textSize = to(theme.shapes.menuTextSize, cssUnit);
783
+ textColor = theme.palette.comboItemText;
784
+ glyphColor = glyphColor || theme.palette.comboItemText;
785
+ }
786
+
787
+ if (kind === 'combo-wrap-item') {
788
+ textWidth = 'max-content';
789
+ textMarginTop = to(0, cssUnit);
790
+ textMarginRight = to(0, cssUnit);
791
+ textMarginBottom = to(0, cssUnit);
792
+ textMarginLeft = to(0, cssUnit);
793
+ boxJustifyContent = boxJustifyContent || 'flex-start';
794
+ textSize = to(theme.shapes.menuTextSize, cssUnit);
795
+ textTransform = textTransform || 'uppercase';
796
+ glyphJustify = 'flex-start';
797
+ }
798
+
799
+ if (kind === 'glyph-item') {
800
+ textWidth = 'max-content';
801
+ boxJustifyContent = boxJustifyContent || 'flex-start';
802
+ glyphSize = '120%';
803
+ }
804
+
805
+ if (kind === 'desk-title') {
806
+ boxJustifyContent = boxJustifyContent || 'flex-start';
807
+ glyphColorFromKind = theme.palette.ticketGlueTitle;
808
+ textColorFromKind = theme.palette.ticketGlueTitle;
809
+ textWeight = 'bold';
810
+ textSize = to(theme.shapes.ticketGlueTitleSize, cssUnit);
811
+ }
812
+
813
+ if (kind === 'task-show-footer') {
814
+ boxJustifyContent = boxJustifyContent || 'flex-end';
815
+ glyphColorFromKind = theme.palette.ticketGlueTitle;
816
+ textColorFromKind = theme.palette.ticketGlueTitle;
817
+ textWeight = 'bold';
818
+ textSize = to(theme.shapes.ticketGlueTitleSize, cssUnit);
819
+ }
820
+
821
+ // Button with a day in Calendar component.
822
+ if (
823
+ kind === 'calendar' ||
824
+ kind === 'calendar-navigator' ||
825
+ kind === 'calendar-list' ||
826
+ kind === 'calendar-title'
827
+ ) {
828
+ textMarginRight = to(0, cssUnit);
829
+ textMarginLeft = to(0, cssUnit);
830
+ textSize = to(theme.shapes.calendarTextSize, cssUnit);
831
+ textColorFromKind = kind === 'calendar' ? theme.palette.calendarText : null;
832
+ if (active) {
833
+ if (subkind === 'add') {
834
+ textColorFromKind = theme.palette.calendarActiveAddText;
835
+ if (kind === 'calendar') {
836
+ textWeight = 'bold';
837
+ }
838
+ } else if (subkind === 'sub') {
839
+ textColorFromKind = theme.palette.calendarActiveSubText;
840
+ } else {
841
+ textColorFromKind = theme.palette.calendarActiveText;
842
+ if (kind === 'calendar') {
843
+ textWeight = 'bold';
844
+ }
845
+ }
846
+ }
847
+ if (dimmed) {
848
+ textColorFromKind = theme.palette.calendarDimmedText;
849
+ }
850
+ if (kind === 'calendar-navigator') {
851
+ if (disabled) {
852
+ textColorFromKind = theme.palette.calendarDimmedText;
853
+ }
854
+ specialDisabled = true;
855
+ }
856
+ if (kind === 'calendar-title') {
857
+ textSize = '100%';
858
+ textWeight = 'bold';
859
+ textTransform = 'uppercase';
860
+ }
861
+ glyphColorFromKind = textColorFromKind;
862
+ }
863
+
864
+ if (kind === 'container') {
865
+ boxAlignItems = 'stretch';
866
+ }
867
+
868
+ if (kind === 'container-start') {
869
+ boxJustifyContent = boxJustifyContent || 'flex-start';
870
+ boxAlignItems = 'stretch';
871
+ }
872
+
873
+ if (kind === 'box') {
874
+ boxAlignItems = 'stretch';
875
+ }
876
+
877
+ if (kind === 'chronos-navigator') {
878
+ if (active === false) {
879
+ glyphColorFromKind = theme.palette.chronoNavigatorText;
880
+ textColorFromKind = theme.palette.chronoNavigatorText;
881
+ }
882
+ }
883
+
884
+ if (kind === 'recurrence') {
885
+ if (active) {
886
+ glyphColorFromKind = theme.palette.calendarActiveText;
887
+ textColorFromKind = theme.palette.calendarActiveText;
888
+ }
889
+ }
890
+
891
+ if (kind === 'dynamic-toolbar') {
892
+ glyphColorFromKind = theme.palette.dynamicToolbarButtonGlyph;
893
+ textColorFromKind = theme.palette.dynamicToolbarButtonGlyph;
894
+ if (active) {
895
+ glyphColorFromKind = theme.palette.dynamicToolbarButtonActiveGlyph;
896
+ textColorFromKind = theme.palette.dynamicToolbarButtonActiveGlyph;
897
+ }
898
+ }
899
+
900
+ if (kind === 'toolbar') {
901
+ if (active) {
902
+ glyphColorFromKind = theme.palette.toolbarActiveText;
903
+ textColorFromKind = theme.palette.toolbarActiveText;
904
+ } else {
905
+ glyphColorFromKind = theme.palette.toolbarInactiveText;
906
+ textColorFromKind = theme.palette.toolbarInactiveText;
907
+ }
908
+ }
909
+
910
+ if (kind === 'alert') {
911
+ textPaddingTop = to(6, cssUnit);
912
+ textPaddingBottom = to(6, cssUnit);
913
+ }
914
+
915
+ if (kind === 'flat-combo') {
916
+ if (active) {
917
+ textColorFromKind = disabled
918
+ ? theme.palette.flatComboDisableActiveText
919
+ : theme.palette.flatComboActiveText;
920
+ } else {
921
+ textColorFromKind = disabled
922
+ ? theme.palette.flatComboDisableInactiveText
923
+ : theme.palette.flatComboInactiveText;
924
+ }
925
+ glyphColorFromKind = textColorFromKind;
926
+ specialDisabled = true;
927
+ }
928
+
929
+ if (empty) {
930
+ border = `${to(2, cssUnit)} dotted #ccc`;
931
+ boxHeight = Unit.sub(to(theme.shapes.lineHeight, cssUnit), to(2, cssUnit));
932
+ boxSizing = 'border-box';
933
+ boxMarginTop = to(2, cssUnit);
934
+ }
935
+
936
+ if (!kind) {
937
+ borderRadius = to(theme.shapes.smoothRadius, cssUnit);
938
+ if (active) {
939
+ backgroundColorFromKind = activeColor
940
+ ? activeColor
941
+ : theme.palette.boxActiveBackground;
942
+ }
943
+ }
944
+
945
+ if (vpos === 'top') {
946
+ boxAlignSelf = 'flex-start';
947
+ } else if (vpos === 'first-line') {
948
+ boxAlignSelf = 'flex-start';
949
+ boxMarginTop = to(3, cssUnit);
950
+ }
951
+
952
+ if (textWrap === 'no') {
953
+ linesOverflow = 'hidden';
954
+ textOverflow = 'hidden';
955
+ textTextOverflow = 'ellipsis';
956
+ textWhiteSpace = 'nowrap';
957
+ } else if (textWrap === 'no-end') {
958
+ linesOverflow = 'hidden';
959
+ textOverflow = 'hidden';
960
+ textTextOverflow = 'ellipsis';
961
+ textWhiteSpace = 'nowrap';
962
+ textAlign = 'left';
963
+ textDirection = 'rtl';
964
+ } else if (textWrap === 'no-strict') {
965
+ linesOverflow = 'hidden';
966
+ textOverflow = 'hidden';
967
+ textTextOverflow = 'ellipsis';
968
+ textWhiteSpace = 'nowrap';
969
+ boxWidth = to(0, cssUnit);
970
+ if (!boxFlexGrow) {
971
+ boxFlexGrow = '1';
972
+ }
973
+ } else if (textWrap === 'yes-permissive') {
974
+ // Intentionally empty.
975
+ } else if (textWrap === 'yes') {
976
+ textWordBreak = 'break-word';
977
+ }
978
+
979
+ if (shape) {
980
+ const r = Unit.multiply(to(theme.shapes.lineHeight, cssUnit), 0.5);
981
+ const s = to(theme.shapes.smoothRadius, cssUnit);
982
+ if (shape === 'rounded') {
983
+ borderRadius = r;
984
+ } else if (shape === 'left-rounded') {
985
+ borderRadius = r + ` ${to(0, cssUnit)} ${to(0, cssUnit)} ` + r;
986
+ } else if (shape === 'right-rounded') {
987
+ borderRadius = `${to(0, cssUnit)} ` + r + ' ' + r + ` ${to(0, cssUnit)}`;
988
+ } else if (shape === 'smooth') {
989
+ borderRadius = s;
990
+ } else if (shape === 'left-smooth') {
991
+ borderRadius = s + ` ${to(0, cssUnit)} ${to(0, cssUnit)} ` + s;
992
+ } else if (shape === 'right-smooth') {
993
+ borderRadius = `${to(0, cssUnit)} ` + s + ' ' + s + ` ${to(0, cssUnit)}`;
994
+ }
995
+ }
996
+
997
+ // Force colors according to properties glyphColor, textColor and backgroundColor.
998
+ if (glyphColor) {
999
+ glyphColor = ColorHelpers.getMarkColor(theme, glyphColor);
1000
+ } else {
1001
+ glyphColor = glyphColorFromKind;
1002
+ }
1003
+ if (textColor) {
1004
+ textColor = ColorHelpers.getMarkColor(theme, textColor);
1005
+ } else {
1006
+ textColor = textColorFromKind;
1007
+ }
1008
+ if (backgroundColor) {
1009
+ backgroundColor = ColorHelpers.getMarkColor(theme, backgroundColor);
1010
+ } else {
1011
+ backgroundColor = backgroundColorFromKind;
1012
+ }
1013
+
1014
+ // Sets default colors if they are undefined
1015
+ if (!glyphColor) {
1016
+ glyphColor = ColorManipulator.emphasize(buttonBackgroundColor, 0.8);
1017
+ }
1018
+ if (!textColor) {
1019
+ textColor = ColorManipulator.emphasize(buttonBackgroundColor, 0.9);
1020
+ }
1021
+
1022
+ // Alter colors if component is disable.
1023
+ if (disabled && !specialDisabled) {
1024
+ if (backgroundColor) {
1025
+ backgroundColor = theme.palette.buttonDisableBackground;
1026
+ }
1027
+ if (glyphColor !== 'transparent') {
1028
+ glyphColor = theme.palette.buttonDisableGlyph;
1029
+ }
1030
+ textColor = theme.palette.buttonDisableText;
1031
+ }
1032
+
1033
+ // If the Label is in a Button, it never has a backgroundColor.
1034
+ // Indeed, the background color is drawn by the Button.
1035
+ if (insideButton) {
1036
+ backgroundColor = null;
1037
+ }
1038
+
1039
+ if (boxFlexGrow) {
1040
+ boxFlexShrink = '1';
1041
+ boxFlexBasis = '0%';
1042
+ }
1043
+
1044
+ if (fontWeight) {
1045
+ textWeight = fontWeight;
1046
+ }
1047
+
1048
+ if (!boxJustifyContent) {
1049
+ if (insideButton) {
1050
+ boxJustifyContent = 'center';
1051
+ } else {
1052
+ boxJustifyContent = 'flex-start';
1053
+ }
1054
+ }
1055
+ if (boxJustifyContent === 'none') {
1056
+ boxJustifyContent = null;
1057
+ }
1058
+
1059
+ if (textTransform === 'none') {
1060
+ textTransform = null;
1061
+ }
1062
+
1063
+ const boxStyle = {
1064
+ width: boxWidth,
1065
+ minWidth: boxWidth ? boxWidth : to(0, cssUnit),
1066
+ minHeight: boxHeight,
1067
+ maxHeight: boxMaxHeight,
1068
+ paddingTop: boxPaddingTop,
1069
+ paddingRight: boxPaddingRight,
1070
+ paddingBottom: boxPaddingBottom,
1071
+ paddingLeft: boxPaddingLeft,
1072
+ marginTop: boxMarginTop,
1073
+ marginRight: boxMarginRight,
1074
+ marginBottom: boxMarginBottom,
1075
+ marginLeft: boxMarginLeft,
1076
+ display: 'flex',
1077
+ flexDirection: boxFlexDirection,
1078
+ alignItems: boxAlignItems,
1079
+ justifyContent: boxJustifyContent,
1080
+ alignSelf: boxAlignSelf,
1081
+ flexGrow: boxFlexGrow,
1082
+ flexShrink: boxFlexShrink,
1083
+ flexBasis: boxFlexBasis,
1084
+ border: border,
1085
+ borderTop: borderTop,
1086
+ borderBottom: borderBottom,
1087
+ borderLeft: borderLeft,
1088
+ borderRight: borderRight,
1089
+ boxSizing: boxSizing,
1090
+ borderRadius: borderRadius,
1091
+ boxShadow: boxShadow,
1092
+ backgroundColor: backgroundColor,
1093
+ opacity: boxOpacity,
1094
+ zIndex: boxZIndex,
1095
+ userSelect: userSelect || 'none',
1096
+ cursor: cursor,
1097
+ };
1098
+
1099
+ if (glyphSize) {
1100
+ const s = Unit.parse(glyphSize);
1101
+ if (s.unit !== '%') {
1102
+ throw new Error(`GlyphSize '${glyphSize}' has an unexpected format`);
1103
+ }
1104
+ const ss = s.value / 100;
1105
+ if (!glyphTransform) {
1106
+ glyphTransform = 'scale(' + ss + ')';
1107
+ }
1108
+ if (!glyphMargin) {
1109
+ const mm = Unit.multiply(m, ss);
1110
+ glyphMargin = `${to(0, cssUnit)} ` + mm + ` ${to(0, cssUnit)} ` + mm;
1111
+ }
1112
+ }
1113
+
1114
+ const glyphStyle = {
1115
+ display: 'flex',
1116
+ flexDirection: 'row',
1117
+ justifyContent: glyphJustify,
1118
+ alignItems: 'center',
1119
+ minWidth: glyphMinWidth,
1120
+ height: glyphHeight,
1121
+ paddingTop: glyphPaddingTop,
1122
+ paddingRight: glyphPaddingRight,
1123
+ paddingBottom: glyphPaddingBottom,
1124
+ paddingLeft: glyphPaddingLeft,
1125
+ margin: glyphMargin,
1126
+ color: glyphColor,
1127
+ transform: glyphTransform,
1128
+ userSelect: 'none',
1129
+ };
1130
+
1131
+ const linesStyle = {
1132
+ width: '100%',
1133
+ overflow: linesOverflow,
1134
+ userSelect: userSelect || 'none',
1135
+ };
1136
+
1137
+ const textStyle = {
1138
+ display: 'block', // required because <T/> use a 'span' (previously, all the styling was planned for a 'div')
1139
+ width: textWidth,
1140
+ marginTop: textMarginTop,
1141
+ marginRight: textMarginRight,
1142
+ marginBottom: textMarginBottom,
1143
+ marginLeft: textMarginLeft,
1144
+ paddingTop: textPaddingTop,
1145
+ paddingRight: textPaddingRight,
1146
+ paddingBottom: textPaddingBottom,
1147
+ paddingLeft: textPaddingLeft,
1148
+ fontSize: Unit.multiply(textSize, theme.typo.fontScale),
1149
+ fontWeight: textWeight,
1150
+ fontStyle: fontStyle,
1151
+ fontFamily: fontFamily,
1152
+ color: textColor,
1153
+ textTransform: textTransform,
1154
+ overflow: textOverflow,
1155
+ textOverflow: textTextOverflow,
1156
+ whiteSpace: textWhiteSpace,
1157
+ wordWrap: 'break-word',
1158
+ wordBreak: textWordBreak,
1159
+ textAlign: textAlign,
1160
+ direction: textDirection,
1161
+ userSelect: userSelect || 'none',
1162
+ };
1163
+
1164
+ const normalFragmentStyle = {
1165
+ color: textColor,
1166
+ };
1167
+
1168
+ const hilitedFragmentStyle = {
1169
+ color: theme.palette.highlightedText,
1170
+ backgroundColor: theme.palette.highlightedTextBackground,
1171
+ padding: to(1, cssUnit),
1172
+ };
1173
+
1174
+ if (!disabled && insideButton && boxOpacity !== 0) {
1175
+ if (specialHover) {
1176
+ glyphStyle[':hover'] = {
1177
+ color: textHoverColor,
1178
+ };
1179
+ textStyle[':hover'] = {
1180
+ color: textHoverColor,
1181
+ };
1182
+ } else {
1183
+ boxStyle[':hover'] = {
1184
+ color: textHoverColor, // (*)
1185
+ opacity: 1.0,
1186
+ };
1187
+
1188
+ if (textHoverColor) {
1189
+ textStyle.color = null; // (*)
1190
+ glyphStyle.color = null; // (*)
1191
+ }
1192
+ // (*) If hover change the color of glyph and text, it is necessary to change
1193
+ // the color of parent (and not the glyph/text children). This system
1194
+ // causes the change simultaneously for the two children.
1195
+ }
1196
+
1197
+ boxStyle[':active'] = {
1198
+ color: ColorManipulator.darken(textColor, 0.1),
1199
+ };
1200
+ textStyle[':active'] = {
1201
+ color: ColorManipulator.darken(textColor, 0.1),
1202
+ };
1203
+ glyphStyle[':active'] = {
1204
+ color: ColorManipulator.darken(glyphColor, 0.1),
1205
+ };
1206
+ }
1207
+
1208
+ return {
1209
+ box: boxStyle,
1210
+ glyph: glyphStyle,
1211
+ lines: linesStyle,
1212
+ text: textStyle,
1213
+ normalFragment: normalFragmentStyle,
1214
+ hilitedFragment: hilitedFragmentStyle,
1215
+ };
1216
+ }
1217
+
1218
+ /******************************************************************************/