@lumx/core 3.1.0 → 3.1.2

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 (290) hide show
  1. package/{dist/CONTRIBUTING.md → CONTRIBUTING.md} +0 -0
  2. package/{dist/LICENSE.md → LICENSE.md} +0 -0
  3. package/{dist/css → css}/_retro-compat-v2.css +0 -0
  4. package/{dist/css → css}/design-tokens.css +0 -0
  5. package/{dist/css → css}/material.css +0 -0
  6. package/{dist/js → js}/constants/design-tokens.js +0 -0
  7. package/{dist/js → js}/constants/design-tokens.min.js +0 -0
  8. package/{dist/js → js}/constants/design-tokens.min.js.map +0 -0
  9. package/{dist/js → js}/constants/design-tokens.ts +0 -0
  10. package/{dist/js → js}/constants/index.js +0 -0
  11. package/{dist/js → js}/constants/index.min.js +0 -0
  12. package/{dist/js → js}/constants/index.min.js.map +0 -0
  13. package/{dist/js → js}/constants/index.ts +0 -0
  14. package/{dist/js → js}/constants/keycodes.js +0 -0
  15. package/{dist/js → js}/constants/keycodes.min.js +0 -0
  16. package/{dist/js → js}/constants/keycodes.min.js.map +0 -0
  17. package/{dist/js → js}/constants/keycodes.ts +0 -0
  18. package/{dist/js → js}/custom-colors.js +0 -0
  19. package/{dist/js → js}/custom-colors.min.js +0 -0
  20. package/js/custom-colors.min.js.map +1 -0
  21. package/{dist/js → js}/custom-colors.ts +0 -0
  22. package/{dist/js → js}/date-picker.js +0 -0
  23. package/{dist/js → js}/date-picker.min.js +0 -0
  24. package/js/date-picker.min.js.map +1 -0
  25. package/{dist/js → js}/date-picker.ts +0 -0
  26. package/{dist/js → js}/utils.js +0 -0
  27. package/{dist/js → js}/utils.min.js +0 -0
  28. package/js/utils.min.js.map +1 -0
  29. package/{dist/js → js}/utils.ts +0 -0
  30. package/{dist/lumx.css → lumx.css} +1 -1
  31. package/{dist/lumx.min.css → lumx.min.css} +1 -1
  32. package/package.json +1 -1
  33. package/{dist/scss → scss}/_components.scss +0 -0
  34. package/{dist/scss → scss}/_core.scss +0 -0
  35. package/{dist/scss → scss}/_design-tokens.scss +0 -0
  36. package/{dist/scss → scss}/_retro-compat-v2.scss +0 -0
  37. package/{dist/scss → scss}/components/avatar/_index.scss +0 -0
  38. package/{dist/scss → scss}/components/badge/_index.scss +0 -0
  39. package/{dist/scss → scss}/components/button/_index.scss +0 -0
  40. package/{dist/scss → scss}/components/button/_mixins.scss +0 -0
  41. package/{dist/scss → scss}/components/button/_variables.scss +0 -0
  42. package/{dist/scss → scss}/components/checkbox/_index.scss +0 -0
  43. package/{dist/scss → scss}/components/checkbox/_mixins.scss +0 -0
  44. package/{dist/scss → scss}/components/chip/_index.scss +0 -0
  45. package/{dist/scss → scss}/components/chip/_mixins.scss +0 -0
  46. package/{dist/scss → scss}/components/chip/_variables.scss +0 -0
  47. package/{dist/scss → scss}/components/comment-block/_index.scss +0 -0
  48. package/{dist/scss → scss}/components/date-picker/_index.scss +0 -0
  49. package/{dist/scss → scss}/components/dialog/_index.scss +0 -0
  50. package/{dist/scss → scss}/components/dialog/_variables.scss +0 -0
  51. package/{dist/scss → scss}/components/divider/_index.scss +0 -0
  52. package/{dist/scss → scss}/components/divider/_mixins.scss +0 -0
  53. package/{dist/scss → scss}/components/divider/_variables.scss +0 -0
  54. package/{dist/scss → scss}/components/drag-handle/_index.scss +0 -0
  55. package/{dist/scss → scss}/components/dropdown/_index.scss +0 -0
  56. package/{dist/scss → scss}/components/expansion-panel/_index.scss +0 -0
  57. package/{dist/scss → scss}/components/expansion-panel/_variables.scss +0 -0
  58. package/{dist/scss → scss}/components/flag/_index.scss +0 -0
  59. package/{dist/scss → scss}/components/flex-box/_index.scss +0 -0
  60. package/{dist/scss → scss}/components/generic-block/_index.scss +0 -0
  61. package/{dist/scss → scss}/components/grid/_index.scss +0 -0
  62. package/{dist/scss → scss}/components/grid-column/_index.scss +0 -0
  63. package/{dist/scss → scss}/components/icon/_index.scss +0 -0
  64. package/{dist/scss → scss}/components/icon/_mixins.scss +0 -0
  65. package/{dist/scss → scss}/components/icon/_variables.scss +0 -0
  66. package/{dist/scss → scss}/components/image-block/_index.scss +0 -0
  67. package/{dist/scss → scss}/components/inline-list/_index.scss +0 -0
  68. package/{dist/scss → scss}/components/input-helper/_index.scss +0 -0
  69. package/{dist/scss → scss}/components/input-helper/_mixins.scss +0 -0
  70. package/{dist/scss → scss}/components/input-helper/_variables.scss +0 -0
  71. package/{dist/scss → scss}/components/input-label/_index.scss +0 -0
  72. package/{dist/scss → scss}/components/input-label/_mixins.scss +0 -0
  73. package/{dist/scss → scss}/components/lightbox/_index.scss +0 -0
  74. package/{dist/scss → scss}/components/lightbox/_variables.scss +0 -0
  75. package/{dist/scss → scss}/components/link/_index.scss +0 -0
  76. package/{dist/scss → scss}/components/link/_mixins.scss +0 -0
  77. package/{dist/scss → scss}/components/link-preview/_index.scss +0 -0
  78. package/{dist/scss → scss}/components/list/_index.scss +0 -0
  79. package/{dist/scss → scss}/components/list/_mixins.scss +0 -0
  80. package/{dist/scss → scss}/components/list/_variables.scss +0 -0
  81. package/{dist/scss → scss}/components/message/_index.scss +0 -0
  82. package/{dist/scss → scss}/components/mosaic/_index.scss +0 -0
  83. package/{dist/scss → scss}/components/notification/_index.scss +0 -0
  84. package/{dist/scss → scss}/components/notification/_variables.scss +0 -0
  85. package/{dist/scss → scss}/components/notification-block/_index.scss +0 -0
  86. package/{dist/scss → scss}/components/popover/_index.scss +0 -0
  87. package/{dist/scss → scss}/components/popover/_variables.scss +0 -0
  88. package/{dist/scss → scss}/components/post-block/_index.scss +0 -0
  89. package/{dist/scss → scss}/components/progress/_index.scss +0 -0
  90. package/{dist/scss → scss}/components/progress/_variables.scss +0 -0
  91. package/{dist/scss → scss}/components/progress-tracker/_index.scss +0 -0
  92. package/{dist/scss → scss}/components/progress-tracker/_variables.scss +0 -0
  93. package/{dist/scss → scss}/components/radio-button/_index.scss +0 -0
  94. package/{dist/scss → scss}/components/radio-button/_mixins.scss +0 -0
  95. package/{dist/scss → scss}/components/select/_index.scss +0 -0
  96. package/{dist/scss → scss}/components/select/_mixins.scss +0 -0
  97. package/{dist/scss → scss}/components/side-navigation/_index.scss +0 -0
  98. package/{dist/scss → scss}/components/side-navigation/_mixins.scss +0 -0
  99. package/{dist/scss → scss}/components/skeleton/_index.scss +0 -0
  100. package/{dist/scss → scss}/components/skeleton/_mixins.scss +0 -0
  101. package/{dist/scss → scss}/components/slider/_index.scss +0 -0
  102. package/{dist/scss → scss}/components/slideshow/_index.scss +0 -0
  103. package/{dist/scss → scss}/components/slideshow/_variables.scss +0 -0
  104. package/{dist/scss → scss}/components/switch/_index.scss +0 -0
  105. package/{dist/scss → scss}/components/switch/_mixins.scss +0 -0
  106. package/{dist/scss → scss}/components/table/_index.scss +0 -0
  107. package/{dist/scss → scss}/components/table/_mixins.scss +0 -0
  108. package/{src/scss → scss}/components/tabs/_index.scss +5 -1
  109. package/{dist/scss → scss}/components/tabs/_mixins.scss +0 -0
  110. package/{dist/scss → scss}/components/text/_index.scss +0 -0
  111. package/{dist/scss → scss}/components/text-field/_index.scss +0 -0
  112. package/{dist/scss → scss}/components/text-field/_mixins.scss +0 -0
  113. package/{dist/scss → scss}/components/text-field/_variables.scss +0 -0
  114. package/{dist/scss → scss}/components/thumbnail/_index.scss +0 -0
  115. package/{dist/scss → scss}/components/thumbnail/_variables.scss +0 -0
  116. package/{dist/scss → scss}/components/toolbar/_index.scss +0 -0
  117. package/{dist/scss → scss}/components/toolbar/_variables.scss +0 -0
  118. package/{dist/scss → scss}/components/tooltip/_index.scss +0 -0
  119. package/{dist/scss → scss}/components/tooltip/_variables.scss +0 -0
  120. package/{dist/scss → scss}/components/uploader/_index.scss +0 -0
  121. package/{dist/scss → scss}/components/user-block/_index.scss +0 -0
  122. package/{dist/scss → scss}/core/base/_functions.scss +0 -0
  123. package/{dist/scss → scss}/core/base/_helpers.scss +0 -0
  124. package/{dist/scss → scss}/core/base/_index.scss +0 -0
  125. package/{dist/scss → scss}/core/base/_normalize.scss +0 -0
  126. package/{dist/scss → scss}/core/base/_variables.scss +0 -0
  127. package/{dist/scss → scss}/core/color/_functions.scss +0 -0
  128. package/{dist/scss → scss}/core/color/_index.scss +0 -0
  129. package/{dist/scss → scss}/core/color/_variables.scss +0 -0
  130. package/{dist/scss → scss}/core/elevation/_mixins.scss +0 -0
  131. package/{dist/scss → scss}/core/elevation/_variables.scss +0 -0
  132. package/{dist/scss → scss}/core/size/_variables.scss +0 -0
  133. package/{dist/scss → scss}/core/spacing/_index.scss +0 -0
  134. package/{dist/scss → scss}/core/spacing/_variables.scss +0 -0
  135. package/{dist/scss → scss}/core/state/_mixins.scss +0 -0
  136. package/{dist/scss → scss}/core/state/_variables.scss +0 -0
  137. package/{dist/scss → scss}/core/typography/_index.scss +0 -0
  138. package/{dist/scss → scss}/core/typography/_mixins.scss +0 -0
  139. package/{dist/scss → scss}/core/typography/_variables.scss +0 -0
  140. package/{dist/scss → scss}/lumx.scss +0 -0
  141. package/dist/js/custom-colors.min.js.map +0 -1
  142. package/dist/js/date-picker.min.js.map +0 -1
  143. package/dist/js/utils.min.js.map +0 -1
  144. package/dist/package.json +0 -81
  145. package/dist/scss/components/tabs/_index.scss +0 -111
  146. package/src/css/_retro-compat-v2.css +0 -117
  147. package/src/css/design-tokens.css +0 -544
  148. package/src/css/material.css +0 -62
  149. package/src/js/constants/design-tokens.ts +0 -2157
  150. package/src/js/constants/index.ts +0 -35
  151. package/src/js/constants/keycodes.ts +0 -44
  152. package/src/js/custom-colors.ts +0 -56
  153. package/src/js/date-picker.ts +0 -71
  154. package/src/js/utils.ts +0 -296
  155. package/src/scss/_components.scss +0 -35
  156. package/src/scss/_core.scss +0 -12
  157. package/src/scss/_design-tokens.scss +0 -1667
  158. package/src/scss/_retro-compat-v2.scss +0 -95
  159. package/src/scss/components/avatar/_index.scss +0 -42
  160. package/src/scss/components/badge/_index.scss +0 -47
  161. package/src/scss/components/button/_index.scss +0 -166
  162. package/src/scss/components/button/_mixins.scss +0 -271
  163. package/src/scss/components/button/_variables.scss +0 -6
  164. package/src/scss/components/checkbox/_index.scss +0 -231
  165. package/src/scss/components/checkbox/_mixins.scss +0 -69
  166. package/src/scss/components/chip/_index.scss +0 -156
  167. package/src/scss/components/chip/_mixins.scss +0 -37
  168. package/src/scss/components/chip/_variables.scss +0 -1
  169. package/src/scss/components/comment-block/_index.scss +0 -170
  170. package/src/scss/components/date-picker/_index.scss +0 -67
  171. package/src/scss/components/dialog/_index.scss +0 -169
  172. package/src/scss/components/dialog/_variables.scss +0 -8
  173. package/src/scss/components/divider/_index.scss +0 -39
  174. package/src/scss/components/divider/_mixins.scss +0 -60
  175. package/src/scss/components/divider/_variables.scss +0 -7
  176. package/src/scss/components/drag-handle/_index.scss +0 -7
  177. package/src/scss/components/dropdown/_index.scss +0 -22
  178. package/src/scss/components/expansion-panel/_index.scss +0 -80
  179. package/src/scss/components/expansion-panel/_variables.scss +0 -2
  180. package/src/scss/components/flag/_index.scss +0 -41
  181. package/src/scss/components/flex-box/_index.scss +0 -132
  182. package/src/scss/components/generic-block/_index.scss +0 -11
  183. package/src/scss/components/grid/_index.scss +0 -147
  184. package/src/scss/components/grid-column/_index.scss +0 -18
  185. package/src/scss/components/icon/_index.scss +0 -106
  186. package/src/scss/components/icon/_mixins.scss +0 -42
  187. package/src/scss/components/icon/_variables.scss +0 -6
  188. package/src/scss/components/image-block/_index.scss +0 -108
  189. package/src/scss/components/inline-list/_index.scss +0 -15
  190. package/src/scss/components/input-helper/_index.scss +0 -27
  191. package/src/scss/components/input-helper/_mixins.scss +0 -12
  192. package/src/scss/components/input-helper/_variables.scss +0 -1
  193. package/src/scss/components/input-label/_index.scss +0 -23
  194. package/src/scss/components/input-label/_mixins.scss +0 -12
  195. package/src/scss/components/lightbox/_index.scss +0 -59
  196. package/src/scss/components/lightbox/_variables.scss +0 -1
  197. package/src/scss/components/link/_index.scss +0 -35
  198. package/src/scss/components/link/_mixins.scss +0 -25
  199. package/src/scss/components/link-preview/_index.scss +0 -95
  200. package/src/scss/components/list/_index.scss +0 -96
  201. package/src/scss/components/list/_mixins.scss +0 -128
  202. package/src/scss/components/list/_variables.scss +0 -7
  203. package/src/scss/components/message/_index.scss +0 -36
  204. package/src/scss/components/mosaic/_index.scss +0 -120
  205. package/src/scss/components/notification/_index.scss +0 -78
  206. package/src/scss/components/notification/_variables.scss +0 -3
  207. package/src/scss/components/notification-block/_index.scss +0 -42
  208. package/src/scss/components/popover/_index.scss +0 -64
  209. package/src/scss/components/popover/_variables.scss +0 -1
  210. package/src/scss/components/post-block/_index.scss +0 -101
  211. package/src/scss/components/progress/_index.scss +0 -190
  212. package/src/scss/components/progress/_variables.scss +0 -12
  213. package/src/scss/components/progress-tracker/_index.scss +0 -131
  214. package/src/scss/components/progress-tracker/_variables.scss +0 -2
  215. package/src/scss/components/radio-button/_index.scss +0 -180
  216. package/src/scss/components/radio-button/_mixins.scss +0 -82
  217. package/src/scss/components/select/_index.scss +0 -295
  218. package/src/scss/components/select/_mixins.scss +0 -36
  219. package/src/scss/components/side-navigation/_index.scss +0 -69
  220. package/src/scss/components/side-navigation/_mixins.scss +0 -61
  221. package/src/scss/components/skeleton/_index.scss +0 -143
  222. package/src/scss/components/skeleton/_mixins.scss +0 -9
  223. package/src/scss/components/slider/_index.scss +0 -209
  224. package/src/scss/components/slideshow/_index.scss +0 -171
  225. package/src/scss/components/slideshow/_variables.scss +0 -1
  226. package/src/scss/components/switch/_index.scss +0 -257
  227. package/src/scss/components/switch/_mixins.scss +0 -77
  228. package/src/scss/components/table/_index.scss +0 -138
  229. package/src/scss/components/table/_mixins.scss +0 -115
  230. package/src/scss/components/tabs/_mixins.scss +0 -104
  231. package/src/scss/components/text/_index.scss +0 -29
  232. package/src/scss/components/text-field/_index.scss +0 -323
  233. package/src/scss/components/text-field/_mixins.scss +0 -149
  234. package/src/scss/components/text-field/_variables.scss +0 -2
  235. package/src/scss/components/thumbnail/_index.scss +0 -227
  236. package/src/scss/components/thumbnail/_variables.scss +0 -6
  237. package/src/scss/components/toolbar/_index.scss +0 -38
  238. package/src/scss/components/toolbar/_variables.scss +0 -1
  239. package/src/scss/components/tooltip/_index.scss +0 -91
  240. package/src/scss/components/tooltip/_variables.scss +0 -4
  241. package/src/scss/components/uploader/_index.scss +0 -115
  242. package/src/scss/components/user-block/_index.scss +0 -106
  243. package/src/scss/core/base/_functions.scss +0 -3
  244. package/src/scss/core/base/_helpers.scss +0 -21
  245. package/src/scss/core/base/_index.scss +0 -54
  246. package/src/scss/core/base/_normalize.scss +0 -353
  247. package/src/scss/core/base/_variables.scss +0 -39
  248. package/src/scss/core/color/_functions.scss +0 -7
  249. package/src/scss/core/color/_index.scss +0 -15
  250. package/src/scss/core/color/_variables.scss +0 -4
  251. package/src/scss/core/elevation/_mixins.scss +0 -10
  252. package/src/scss/core/elevation/_variables.scss +0 -7
  253. package/src/scss/core/size/_variables.scss +0 -3
  254. package/src/scss/core/spacing/_index.scss +0 -15
  255. package/src/scss/core/spacing/_variables.scss +0 -22
  256. package/src/scss/core/state/_mixins.scss +0 -127
  257. package/src/scss/core/state/_variables.scss +0 -1
  258. package/src/scss/core/typography/_index.scss +0 -16
  259. package/src/scss/core/typography/_mixins.scss +0 -25
  260. package/src/scss/core/typography/_variables.scss +0 -6
  261. package/src/scss/lumx.scss +0 -69
  262. package/style-dictionary/.eslintignore +0 -1
  263. package/style-dictionary/README.md +0 -19
  264. package/style-dictionary/config/_run.js +0 -12
  265. package/style-dictionary/config/_transform-group.js +0 -16
  266. package/style-dictionary/config/gen-css-variables.js +0 -25
  267. package/style-dictionary/config/gen-scss-variables.js +0 -65
  268. package/style-dictionary/config/gen-ts-variables.js +0 -52
  269. package/style-dictionary/config/utils/_color-attributes.js +0 -24
  270. package/style-dictionary/config/utils/_color-rgba-value.js +0 -22
  271. package/style-dictionary/config/utils/_css-prefer-variable.js +0 -24
  272. package/style-dictionary/config/utils/_genHeader.js +0 -3
  273. package/style-dictionary/config/utils/_lumx-variables.js +0 -12
  274. package/style-dictionary/config/utils/_pickFieldsInTree.js +0 -22
  275. package/style-dictionary/config/utils/_prettier-scss.js +0 -13
  276. package/style-dictionary/config/utils/_prettier-ts.js +0 -13
  277. package/style-dictionary/config/utils/_resolve-structure-alias.js +0 -76
  278. package/style-dictionary/index.js +0 -11
  279. package/style-dictionary/properties/components/button.json +0 -206
  280. package/style-dictionary/properties/components/material.json +0 -64
  281. package/style-dictionary/properties/components/navigation.json +0 -207
  282. package/style-dictionary/properties/components/tabs.json +0 -168
  283. package/style-dictionary/properties/components/text-field.json +0 -167
  284. package/style-dictionary/properties/core/border-radius.json +0 -3
  285. package/style-dictionary/properties/core/color.json +0 -421
  286. package/style-dictionary/properties/core/size.json +0 -11
  287. package/style-dictionary/properties/core/spacing.json +0 -11
  288. package/style-dictionary/properties/core/typography.json +0 -127
  289. package/tsconfig.json +0 -3
  290. package/webpack.config.js +0 -202
@@ -1,35 +0,0 @@
1
- /**
2
- * The prefix to use for the CSS classes.
3
- */
4
- export const CSS_PREFIX = 'lumx';
5
-
6
- /**
7
- * Key codes.
8
- */
9
- export * from './keycodes';
10
-
11
- /**
12
- * Animation duration constants. Take into consideration that if you change one of these variables,
13
- * you need to update their scss counterpart as well
14
- */
15
- export const DIALOG_TRANSITION_DURATION = 400;
16
- export const NOTIFICATION_TRANSITION_DURATION = 200;
17
- export const SLIDESHOW_TRANSITION_DURATION = 5000;
18
-
19
- /**
20
- * Delay on hover after which we open or close the tooltip.
21
- * Only applies to devices supporting pointer hover.
22
- */
23
- export const TOOLTIP_HOVER_DELAY = {
24
- open: 500,
25
- close: 0,
26
- };
27
-
28
- /**
29
- * Delay on long press after which we open or close the tooltip.
30
- * Only applies to devices not supporting pointer hover.
31
- */
32
- export const TOOLTIP_LONG_PRESS_DELAY = {
33
- open: 250,
34
- close: 3000,
35
- };
@@ -1,44 +0,0 @@
1
- /**
2
- * The down key code.
3
- */
4
- export const DOWN_KEY_CODE = 40;
5
-
6
- /**
7
- * The enter/return key code.
8
- */
9
- export const ENTER_KEY_CODE = 13;
10
-
11
- /**
12
- * The space key code.
13
- */
14
- export const SPACE_KEY_CODE = 32;
15
-
16
- /**
17
- * The escape key code.
18
- */
19
- export const ESCAPE_KEY_CODE = 27;
20
-
21
- /**
22
- * The left key code.
23
- */
24
- export const LEFT_KEY_CODE = 37;
25
-
26
- /**
27
- * The right key code.
28
- */
29
- export const RIGHT_KEY_CODE = 39;
30
-
31
- /**
32
- * The tab key code.
33
- */
34
- export const TAB_KEY_CODE = 9;
35
-
36
- /**
37
- * The up key code.
38
- */
39
- export const UP_KEY_CODE = 38;
40
-
41
- /**
42
- * The up key code.
43
- */
44
- export const BACKSPACE_KEY_CODE = 8;
@@ -1,56 +0,0 @@
1
- interface Variants {
2
- D2?: string;
3
- D1?: string;
4
- N?: string;
5
- L1?: string;
6
- L2?: string;
7
- L3?: string;
8
- L4?: string;
9
- L5?: string;
10
- L6?: string;
11
- }
12
-
13
- type ColorPalette = Partial<Record<'primary' | 'secondary', Variants>>;
14
-
15
- /**
16
- * Generate CSS variables for the given color palette.
17
- */
18
- export function generateCSSColorVariables(palette: ColorPalette): string {
19
- let output = '';
20
- for (const [color, variants] of Object.entries(palette)) {
21
- if (!variants) continue;
22
-
23
- for (const [variantName, colorValue] of Object.entries(variants)) {
24
- output += `--lumx-color-${color}-${variantName}: ${colorValue};\n`;
25
- }
26
- }
27
- return output;
28
- }
29
-
30
- /**
31
- * Add a css rule in a given sheet.
32
- *
33
- * @param sheet The sheet to insert the new rules in.
34
- * @param selector The css rules selector.
35
- * @param rules The css rules.
36
- * @param index The css rule index.
37
- */
38
- function _addCSSRule(sheet: CSSStyleSheet, selector: string, rules: string, index: number) {
39
- if ('insertRule' in sheet) {
40
- sheet.insertRule(`${selector}{${rules}}`, index);
41
- } else if ('addRule' in sheet) {
42
- (sheet as any).addRule(selector, rules, index);
43
- }
44
- }
45
-
46
- /**
47
- * Set primary and secondary custom colors.
48
- *
49
- * @param sheet The sheet to insert the custom rules in.
50
- * @param colorPalette The custom color palette.
51
- * @param selector The selector used to scope the custom colors (defaults to ':root').
52
- */
53
- export function setCustomColors(sheet: CSSStyleSheet, colorPalette: ColorPalette, selector = ':root') {
54
- const rules = generateCSSColorVariables(colorPalette);
55
- _addCSSRule(sheet, selector, rules, 0);
56
- }
@@ -1,71 +0,0 @@
1
- import range from 'lodash/range';
2
- import mMoment, { Moment } from 'moment';
3
- import { extendMoment } from 'moment-range';
4
-
5
- const moment = extendMoment(mMoment as any);
6
-
7
- const DAYS_PER_WEEK = 7;
8
-
9
- interface AnnotatedDate {
10
- date: Moment;
11
- isDisplayed: boolean;
12
- isClickable: boolean;
13
- isToday: boolean;
14
- }
15
-
16
- /**
17
- * Get the list of days in a week based on locale.
18
- *
19
- * @param locale The locale using to generate the order of days in a week.
20
- * @return The list of days in a week based on locale.
21
- */
22
- export function getWeekDays(locale: string): Moment[] {
23
- return range(DAYS_PER_WEEK).map((_, i) => moment().locale(locale).weekday(i));
24
- }
25
-
26
- /**
27
- * Get month calendar based on locale and start date.
28
- *
29
- * @param locale The locale using to generate the order of days in a week.
30
- * @param selectedMonth The selected month.
31
- * @return The list of days in a week based on locale.
32
- */
33
- export function getMonthCalendar(locale: string, selectedMonth?: Moment): Moment[] {
34
- const firstDayOfMonth = moment(selectedMonth).startOf('month');
35
- const endDayOfMonth = moment(selectedMonth).endOf('month');
36
- // The first day of the week depends on the locale used. In FR the first day is a monday but in EN the first day is sunday
37
- const firstDay = firstDayOfMonth.locale(locale).startOf('week');
38
- const monthRange = moment.range(firstDay.toDate(), endDayOfMonth.toDate());
39
-
40
- return Array.from(monthRange.by('day'));
41
- }
42
-
43
- /**
44
- * Get month calendar based on locale and start date.
45
- * Each day is annotated to know if they are displayed and/or clickable.
46
- *
47
- * @param locale The locale using to generate the order of days in a week.
48
- * @param minDate The first selectable date.
49
- * @param maxDate The last selectable date.
50
- * @param selectedMonth The selected month.
51
- * @return The list of days in a week based on locale.
52
- */
53
- export function getAnnotatedMonthCalendar(
54
- locale: string,
55
- minDate?: Date,
56
- maxDate?: Date,
57
- selectedMonth?: Moment,
58
- ): AnnotatedDate[] {
59
- const month = moment(selectedMonth).locale(locale).month();
60
-
61
- const clickableRange = moment.range(minDate as Date, maxDate as Date);
62
-
63
- return getMonthCalendar(locale, selectedMonth).map((date) => {
64
- return {
65
- date,
66
- isClickable: clickableRange.contains(date),
67
- isDisplayed: date.month() === month,
68
- isToday: date.isSame(moment(), 'day'),
69
- };
70
- });
71
- }
package/src/js/utils.ts DELETED
@@ -1,296 +0,0 @@
1
- import classNames from 'classnames';
2
- // eslint-disable-next-line import/no-extraneous-dependencies
3
- import React from 'react';
4
-
5
- import isBoolean from 'lodash/isBoolean';
6
- import isEmpty from 'lodash/isEmpty';
7
- import kebabCase from 'lodash/kebabCase';
8
- import noop from 'lodash/noop';
9
-
10
- /**
11
- * Enhance isEmpty method to also works with numbers.
12
- *
13
- * @param value The value to check.
14
- * @return Whether the input value is empty or != 0.
15
- */
16
- const _isEmpty = (value: any) => {
17
- if (typeof value === 'number') {
18
- return value === 0;
19
- }
20
-
21
- return isEmpty(value);
22
- };
23
-
24
- /**
25
- * Get the basic CSS class for the given type.
26
- *
27
- * @param prefix The class name prefix for the generated CSS class.
28
- * @param type The type of CSS class we want to generate (e.g.: 'color', 'variant', ...).
29
- * @param value The value of the type of the CSS class (e.g.: 'primary', 'button', ...).
30
- * @return The basic CSS class.
31
- */
32
- export function getBasicClass({
33
- prefix,
34
- type,
35
- value,
36
- }: {
37
- prefix: string;
38
- type: string;
39
- value: string | number | boolean | undefined;
40
- }): string {
41
- if (isBoolean(value)) {
42
- if (!value) {
43
- // False value should not return a class.
44
- return '';
45
- }
46
- const booleanPrefixes = ['has', 'is'];
47
-
48
- if (booleanPrefixes.some((booleanPrefix) => type.toString().startsWith(booleanPrefix))) {
49
- return `${prefix}--${kebabCase(type)}`;
50
- }
51
-
52
- return `${prefix}--is-${kebabCase(type)}`;
53
- }
54
-
55
- return `${prefix}--${kebabCase(type)}-${value}`;
56
- }
57
-
58
- /**
59
- * Return all basic LumX CSS classes which are available for every components.
60
- *
61
- * @see {@link /src/components/index.d.ts} for the possible values of each parameter.
62
- *
63
- * @param prefix The class name prefix for the generated CSS class.
64
- * @param props All the other props you want to generate a class.
65
- * The rule of thumb: the key is the name of the prop in the class, the value a string that will
66
- * be used in the classname to represent the value of the given prop.
67
- * @return All LumX basic CSS classes.
68
- */
69
- export function handleBasicClasses({ prefix, ...props }: { prefix: string; [prop: string]: any }): string {
70
- const otherClasses: any = {};
71
- if (!isEmpty(props)) {
72
- Object.keys(props).forEach((prop) => {
73
- otherClasses[getBasicClass({ prefix, type: prop, value: props[prop] })] = isBoolean(props[prop])
74
- ? props[prop]
75
- : !_isEmpty(props[prop]);
76
- });
77
- }
78
-
79
- return classNames(prefix, otherClasses);
80
- }
81
-
82
- declare type SwipeDirection = 'none' | 'up' | 'down' | 'left' | 'right';
83
-
84
- /**
85
- * Detects swipe direction.
86
- * Credits: http://javascriptkit.com/javatutors/touchevents2.shtml.
87
- *
88
- * @deprecated use `detectHorizontalSwipe` instead if possible (better performance and does not block scroll)
89
- * @param touchSurface Element that will hold touch events.
90
- * @param handleSwipe Callback function.
91
- * @return Function to remove listeners.
92
- */
93
- export function detectSwipe(touchSurface: Element, handleSwipe: (direction: SwipeDirection) => void = noop) {
94
- let distX: number;
95
- let distY: number;
96
- let startX: number;
97
- let startY: number;
98
- let direction: SwipeDirection;
99
- // Required min distance traveled to be considered swipe.
100
- const threshold = 150;
101
- // Maximum distance allowed at the same time in perpendicular direction.
102
- const restraint = 100;
103
- // Maximum time allowed to travel that distance.
104
- const allowedTime = 300;
105
- let elapsedTime: number;
106
- let startTime: number;
107
-
108
- const onTouchStart = (evt: Event) => {
109
- const [touch] = Array.from((evt as TouchEvent).changedTouches);
110
- direction = 'none';
111
- // Const dist = 0;
112
- startX = touch.pageX;
113
- startY = touch.pageY;
114
- // Record time when finger first makes contact with surface.
115
- startTime = new Date().getTime();
116
- evt.preventDefault();
117
- };
118
-
119
- const onTouchMove = (evt: Event) => {
120
- // Prevent scrolling when inside DIV.
121
- evt.preventDefault();
122
- };
123
-
124
- const onTouchEnd = (evt: Event) => {
125
- const [touch] = Array.from((evt as TouchEvent).changedTouches);
126
- // Get horizontal dist traveled by finger while in contact with surface.
127
- distX = touch.pageX - startX;
128
- // Get vertical dist traveled by finger while in contact with surface.
129
- distY = touch.pageY - startY;
130
- // Get time elapsed.
131
- elapsedTime = new Date().getTime() - startTime;
132
- if (elapsedTime <= allowedTime) {
133
- // First condition for awipe met.
134
- if (Math.abs(distX) >= threshold && Math.abs(distY) <= restraint) {
135
- // 2nd condition for horizontal swipe met.
136
- // If dist traveled is negative, it indicates left swipe.
137
- direction = distX < 0 ? 'left' : 'right';
138
- } else if (Math.abs(distY) >= threshold && Math.abs(distX) <= restraint) {
139
- // 2nd condition for vertical swipe met.
140
- // If dist traveled is negative, it indicates up swipe.
141
- direction = distY < 0 ? 'up' : 'down';
142
- }
143
- }
144
- handleSwipe(direction);
145
- evt.preventDefault();
146
- };
147
-
148
- touchSurface.addEventListener('touchstart', onTouchStart, false);
149
- touchSurface.addEventListener('touchmove', onTouchMove, false);
150
- touchSurface.addEventListener('touchend', onTouchEnd, false);
151
-
152
- return () => {
153
- touchSurface.removeEventListener('touchstart', onTouchStart, false);
154
- touchSurface.removeEventListener('touchmove', onTouchMove, false);
155
- touchSurface.removeEventListener('touchend', onTouchEnd, false);
156
- };
157
- }
158
-
159
- /**
160
- * Checks whether or not the browser support passive events.
161
- * @see https://github.com/Modernizr/Modernizr/blob/6d56d814b9682843313b16060adb25a58d83a317/feature-detects/dom/passiveeventlisteners.js
162
- */
163
- function isPassiveEventAvailable() {
164
- let supportsPassiveOption = false;
165
- try {
166
- const opts = Object.defineProperty({}, 'passive', {
167
- get() {
168
- supportsPassiveOption = true;
169
- },
170
- });
171
- window.addEventListener('testPassiveEventSupport', noop, opts);
172
- window.removeEventListener('testPassiveEventSupport', noop, opts);
173
- } catch (e) {
174
- // ignored
175
- }
176
- return supportsPassiveOption;
177
- }
178
-
179
- /**
180
- * Detects horizontal swipe direction without blocking the browser scroll using passive event.
181
- * @see http://javascriptkit.com/javatutors/touchevents2.shtml
182
- * @see https://github.com/WICG/EventListenerOptions/blob/gh-pages/explainer.md
183
- */
184
- export function detectHorizontalSwipe(touchSurface: Element, handleSwipe: (direction: 'right' | 'left') => void) {
185
- let startX: number;
186
- let startY: number;
187
- // Required min distance traveled to be considered swipe.
188
- const threshold = 150;
189
- // Maximum distance allowed at the same time in perpendicular direction.
190
- const restraint = 150;
191
- // Maximum time allowed to travel that distance.
192
- const allowedTime = 300;
193
- let elapsedTime: number;
194
- let startTime: number;
195
- let finished: boolean;
196
-
197
- const onTouchStart = (evt: Event) => {
198
- const [touch] = Array.from((evt as TouchEvent).changedTouches);
199
- startX = touch.pageX;
200
- startY = touch.pageY;
201
- // Record time when finger first makes contact with surface.
202
- startTime = new Date().getTime();
203
- finished = false;
204
- };
205
-
206
- const onTouchMove = (evt: Event) => {
207
- if (finished) {
208
- return;
209
- }
210
-
211
- elapsedTime = new Date().getTime() - startTime;
212
- if (elapsedTime > allowedTime) {
213
- // Touch swipe too long to be considered.
214
- return;
215
- }
216
-
217
- const [touch] = Array.from((evt as TouchEvent).changedTouches);
218
- // Get horizontal dist traveled by finger while in contact with surface.
219
- const distX = touch.pageX - startX;
220
- // Get vertical dist traveled by finger while in contact with surface.
221
- const distY = touch.pageY - startY;
222
-
223
- if (!(Math.abs(distX) >= threshold && Math.abs(distY) <= restraint)) {
224
- // Swipe is not horizontal.
225
- return;
226
- }
227
- // Swipe direction.
228
- const direction = distX < 0 ? 'left' : 'right';
229
-
230
- handleSwipe(direction);
231
- finished = true;
232
- };
233
-
234
- // Activate passive event if possible for better scrolling performance.
235
- const eventOptions: any = isPassiveEventAvailable() ? { passive: true } : false;
236
- touchSurface.addEventListener('touchstart', onTouchStart, eventOptions);
237
- touchSurface.addEventListener('touchmove', onTouchMove, eventOptions);
238
-
239
- return () => {
240
- touchSurface.removeEventListener('touchstart', onTouchStart, eventOptions);
241
- touchSurface.removeEventListener('touchmove', onTouchMove, eventOptions);
242
- };
243
- }
244
-
245
- type KeyboardEventHandler<E extends KeyboardEvent | React.KeyboardEvent> = (event: E) => void;
246
-
247
- /**
248
- * Make sure the pressed key is the enter key before calling the callback.
249
- *
250
- * @param handler The handler to call on enter/return press.
251
- * @return The decorated function.
252
- */
253
- export function onEnterPressed<E extends KeyboardEvent | React.KeyboardEvent>(
254
- handler: KeyboardEventHandler<E>,
255
- ): KeyboardEventHandler<E> {
256
- return (evt) => {
257
- if (evt.key !== 'Enter') {
258
- return;
259
- }
260
- handler(evt);
261
- };
262
- }
263
-
264
- /**
265
- * Make sure the pressed key is the escape key before calling the callback.
266
- *
267
- * @param handler The handler to call on enter/return press.
268
- * @return The decorated function.
269
- */
270
- export function onEscapePressed<E extends KeyboardEvent | React.KeyboardEvent>(
271
- handler: KeyboardEventHandler<E>,
272
- ): KeyboardEventHandler<E> {
273
- return (evt) => {
274
- if (evt.key !== 'Escape') {
275
- return;
276
- }
277
- handler(evt);
278
- };
279
- }
280
-
281
- /**
282
- * Handle button key pressed (Enter + Space).
283
- *
284
- * @param handler The handler to call.
285
- * @return The decorated function.
286
- */
287
- export function onButtonPressed<E extends KeyboardEvent | React.KeyboardEvent>(
288
- handler: KeyboardEventHandler<E>,
289
- ): KeyboardEventHandler<E> {
290
- return (evt) => {
291
- if (evt.key !== 'Enter' && evt.key !== ' ') {
292
- return;
293
- }
294
- handler(evt);
295
- };
296
- }
@@ -1,35 +0,0 @@
1
- @import "./components/button/variables";
2
- @import "./components/button/mixins";
3
- @import "./components/checkbox/mixins";
4
- @import "./components/chip/variables";
5
- @import "./components/chip/mixins";
6
- @import "./components/dialog/variables";
7
- @import "./components/divider/variables";
8
- @import "./components/divider/mixins";
9
- @import "./components/expansion-panel/variables";
10
- @import "./components/input-helper/variables";
11
- @import "./components/input-helper/mixins";
12
- @import "./components/input-label/mixins";
13
- @import "./components/icon/variables";
14
- @import "./components/icon/mixins";
15
- @import "./components/lightbox/variables";
16
- @import "./components/link/mixins";
17
- @import "./components/list/variables";
18
- @import "./components/list/mixins";
19
- @import "./components/notification/variables";
20
- @import "./components/progress/variables";
21
- @import "./components/progress-tracker/variables";
22
- @import "./components/popover/variables";
23
- @import "./components/radio-button/mixins";
24
- @import "./components/select/mixins";
25
- @import "./components/side-navigation/mixins";
26
- @import "./components/skeleton/mixins";
27
- @import "./components/slideshow/variables";
28
- @import "./components/switch/mixins";
29
- @import "./components/table/mixins";
30
- @import "./components/tabs/mixins";
31
- @import "./components/text-field/variables";
32
- @import "./components/text-field/mixins";
33
- @import "./components/thumbnail/variables";
34
- @import "./components/toolbar/variables";
35
- @import "./components/tooltip/variables";
@@ -1,12 +0,0 @@
1
- @import "./core/base/variables";
2
- @import "./core/base/functions";
3
- @import "./core/elevation/variables";
4
- @import "./core/elevation/mixins";
5
- @import "./core/size/variables";
6
- @import "./core/spacing/variables";
7
- @import "./core/state/variables";
8
- @import "./core/state/mixins";
9
- @import "./core/color/variables";
10
- @import "./core/color/functions";
11
- @import "./core/typography/variables";
12
- @import "./core/typography/mixins";