@elastic/eui 94.3.0 → 94.4.1

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 (145) hide show
  1. package/README.md +3 -0
  2. package/dist/eui_charts_theme.js +1519 -1519
  3. package/dist/eui_charts_theme.js.map +1 -1
  4. package/dist/eui_theme_dark.css +41 -497
  5. package/dist/eui_theme_dark.min.css +1 -1
  6. package/dist/eui_theme_light.css +41 -497
  7. package/dist/eui_theme_light.min.css +1 -1
  8. package/es/components/collapsible_nav_beta/collapsible_nav_item/collapsed/collapsed_nav_button.js +5 -1
  9. package/es/components/date_picker/super_date_picker/date_popover/absolute_tab.js +25 -11
  10. package/es/components/form/form.styles.js +26 -3
  11. package/es/components/markdown_editor/markdown_editor.js +12 -8
  12. package/es/components/markdown_editor/markdown_editor.styles.js +29 -0
  13. package/es/components/markdown_editor/markdown_editor_drop_zone.js +22 -9
  14. package/es/components/markdown_editor/markdown_editor_drop_zone.styles.js +33 -0
  15. package/es/components/markdown_editor/markdown_editor_footer.js +11 -2
  16. package/es/components/markdown_editor/markdown_editor_footer.styles.js +26 -0
  17. package/es/components/markdown_editor/markdown_editor_text_area.js +6 -1
  18. package/es/components/markdown_editor/markdown_editor_text_area.styles.js +22 -0
  19. package/es/components/markdown_editor/markdown_editor_toolbar.js +10 -2
  20. package/es/components/markdown_editor/markdown_editor_toolbar.styles.js +21 -0
  21. package/es/components/markdown_editor/markdown_format.js +9 -6
  22. package/es/components/markdown_editor/markdown_format.styles.js +25 -10
  23. package/es/components/markdown_editor/plugins/markdown_checkbox/renderer.js +9 -3
  24. package/es/components/markdown_editor/plugins/markdown_tooltip/renderer.js +13 -2
  25. package/es/components/selectable/selectable.js +10 -2
  26. package/es/components/selectable/selectable_list/selectable_list.js +95 -42
  27. package/es/components/selectable/selectable_list/selectable_list_item.js +234 -204
  28. package/es/components/selectable/selectable_option.js +9 -1
  29. package/es/components/selectable/selectable_templates/selectable_template_sitewide.js +10 -2
  30. package/es/components/text/text_color.js +4 -1
  31. package/es/components/toast/global_toast_list_item.js +5 -5
  32. package/eui.d.ts +332 -234
  33. package/i18ntokens.json +124 -106
  34. package/lib/components/collapsible_nav_beta/collapsible_nav_item/collapsed/collapsed_nav_button.js +5 -1
  35. package/lib/components/date_picker/super_date_picker/date_popover/absolute_tab.js +25 -11
  36. package/lib/components/form/form.styles.js +30 -4
  37. package/lib/components/markdown_editor/markdown_editor.js +12 -8
  38. package/lib/components/markdown_editor/markdown_editor.styles.js +37 -0
  39. package/lib/components/markdown_editor/markdown_editor_drop_zone.js +20 -8
  40. package/lib/components/markdown_editor/markdown_editor_drop_zone.styles.js +38 -0
  41. package/lib/components/markdown_editor/markdown_editor_footer.js +10 -1
  42. package/lib/components/markdown_editor/markdown_editor_footer.styles.js +33 -0
  43. package/lib/components/markdown_editor/markdown_editor_text_area.js +6 -1
  44. package/lib/components/markdown_editor/markdown_editor_text_area.styles.js +29 -0
  45. package/lib/components/markdown_editor/markdown_editor_toolbar.js +10 -2
  46. package/lib/components/markdown_editor/markdown_editor_toolbar.styles.js +28 -0
  47. package/lib/components/markdown_editor/markdown_format.js +8 -5
  48. package/lib/components/markdown_editor/markdown_format.styles.js +25 -10
  49. package/lib/components/markdown_editor/plugins/markdown_checkbox/renderer.js +9 -4
  50. package/lib/components/markdown_editor/plugins/markdown_tooltip/renderer.js +19 -10
  51. package/lib/components/selectable/selectable.js +10 -2
  52. package/lib/components/selectable/selectable_list/selectable_list.js +95 -42
  53. package/lib/components/selectable/selectable_list/selectable_list_item.js +241 -210
  54. package/lib/components/selectable/selectable_option.js +12 -1
  55. package/lib/components/selectable/selectable_templates/selectable_template_sitewide.js +10 -2
  56. package/lib/components/text/text_color.js +6 -2
  57. package/lib/components/toast/global_toast_list_item.js +5 -5
  58. package/optimize/es/components/collapsible_nav_beta/collapsible_nav_item/collapsed/collapsed_nav_button.js +5 -1
  59. package/optimize/es/components/date_picker/super_date_picker/date_popover/absolute_tab.js +25 -11
  60. package/optimize/es/components/form/form.styles.js +26 -3
  61. package/optimize/es/components/markdown_editor/markdown_editor.js +12 -8
  62. package/optimize/es/components/markdown_editor/markdown_editor.styles.js +29 -0
  63. package/optimize/es/components/markdown_editor/markdown_editor_drop_zone.js +19 -9
  64. package/optimize/es/components/markdown_editor/markdown_editor_drop_zone.styles.js +33 -0
  65. package/optimize/es/components/markdown_editor/markdown_editor_footer.js +11 -2
  66. package/optimize/es/components/markdown_editor/markdown_editor_footer.styles.js +26 -0
  67. package/optimize/es/components/markdown_editor/markdown_editor_text_area.js +6 -1
  68. package/optimize/es/components/markdown_editor/markdown_editor_text_area.styles.js +22 -0
  69. package/optimize/es/components/markdown_editor/markdown_editor_toolbar.js +10 -2
  70. package/optimize/es/components/markdown_editor/markdown_editor_toolbar.styles.js +21 -0
  71. package/optimize/es/components/markdown_editor/markdown_format.js +9 -6
  72. package/optimize/es/components/markdown_editor/markdown_format.styles.js +25 -10
  73. package/optimize/es/components/markdown_editor/plugins/markdown_checkbox/renderer.js +9 -3
  74. package/optimize/es/components/markdown_editor/plugins/markdown_tooltip/renderer.js +13 -2
  75. package/optimize/es/components/selectable/selectable_list/selectable_list.js +81 -38
  76. package/optimize/es/components/selectable/selectable_list/selectable_list_item.js +217 -198
  77. package/optimize/es/components/selectable/selectable_option.js +9 -1
  78. package/optimize/es/components/text/text_color.js +4 -1
  79. package/optimize/lib/components/collapsible_nav_beta/collapsible_nav_item/collapsed/collapsed_nav_button.js +5 -1
  80. package/optimize/lib/components/date_picker/super_date_picker/date_popover/absolute_tab.js +25 -11
  81. package/optimize/lib/components/form/form.styles.js +30 -4
  82. package/optimize/lib/components/markdown_editor/markdown_editor.js +12 -8
  83. package/optimize/lib/components/markdown_editor/markdown_editor.styles.js +37 -0
  84. package/optimize/lib/components/markdown_editor/markdown_editor_drop_zone.js +24 -16
  85. package/optimize/lib/components/markdown_editor/markdown_editor_drop_zone.styles.js +38 -0
  86. package/optimize/lib/components/markdown_editor/markdown_editor_footer.js +10 -1
  87. package/optimize/lib/components/markdown_editor/markdown_editor_footer.styles.js +33 -0
  88. package/optimize/lib/components/markdown_editor/markdown_editor_text_area.js +6 -1
  89. package/optimize/lib/components/markdown_editor/markdown_editor_text_area.styles.js +29 -0
  90. package/optimize/lib/components/markdown_editor/markdown_editor_toolbar.js +10 -2
  91. package/optimize/lib/components/markdown_editor/markdown_editor_toolbar.styles.js +28 -0
  92. package/optimize/lib/components/markdown_editor/markdown_format.js +8 -5
  93. package/optimize/lib/components/markdown_editor/markdown_format.styles.js +25 -10
  94. package/optimize/lib/components/markdown_editor/plugins/markdown_checkbox/renderer.js +9 -4
  95. package/optimize/lib/components/markdown_editor/plugins/markdown_tooltip/renderer.js +19 -10
  96. package/optimize/lib/components/selectable/selectable_list/selectable_list.js +81 -38
  97. package/optimize/lib/components/selectable/selectable_list/selectable_list_item.js +224 -204
  98. package/optimize/lib/components/selectable/selectable_option.js +12 -1
  99. package/optimize/lib/components/text/text_color.js +6 -2
  100. package/package.json +5 -12
  101. package/src/components/date_picker/react-datepicker/LICENSE +21 -0
  102. package/src/components/date_picker/react-datepicker/README.md +168 -0
  103. package/src/components/date_picker/super_date_picker/date_popover/_absolute_tab.scss +13 -18
  104. package/src/components/form/checkbox/_checkbox.scss +23 -6
  105. package/src/components/index.scss +0 -1
  106. package/src/components/selectable/selectable_list/_selectable_list_item.scss +4 -0
  107. package/src/components/selectable/selectable_templates/_selectable_template_sitewide_option.scss +5 -1
  108. package/src/services/theme/README.md +153 -0
  109. package/src/test/README.md +44 -0
  110. package/src/themes/amsterdam/overrides/_index.scss +0 -1
  111. package/test-env/components/collapsible_nav_beta/collapsible_nav_item/collapsed/collapsed_nav_button.js +5 -1
  112. package/test-env/components/date_picker/super_date_picker/date_popover/absolute_tab.js +25 -11
  113. package/test-env/components/form/form.styles.js +30 -4
  114. package/test-env/components/markdown_editor/markdown_editor.js +12 -8
  115. package/test-env/components/markdown_editor/markdown_editor.styles.js +37 -0
  116. package/test-env/components/markdown_editor/markdown_editor_drop_zone.js +24 -16
  117. package/test-env/components/markdown_editor/markdown_editor_drop_zone.styles.js +38 -0
  118. package/test-env/components/markdown_editor/markdown_editor_footer.js +10 -1
  119. package/test-env/components/markdown_editor/markdown_editor_footer.styles.js +33 -0
  120. package/test-env/components/markdown_editor/markdown_editor_text_area.js +6 -1
  121. package/test-env/components/markdown_editor/markdown_editor_text_area.styles.js +29 -0
  122. package/test-env/components/markdown_editor/markdown_editor_toolbar.js +10 -2
  123. package/test-env/components/markdown_editor/markdown_editor_toolbar.styles.js +28 -0
  124. package/test-env/components/markdown_editor/markdown_format.js +8 -5
  125. package/test-env/components/markdown_editor/markdown_format.styles.js +25 -10
  126. package/test-env/components/markdown_editor/plugins/markdown_checkbox/renderer.js +9 -4
  127. package/test-env/components/markdown_editor/plugins/markdown_tooltip/renderer.js +19 -10
  128. package/test-env/components/selectable/selectable.js +10 -2
  129. package/test-env/components/selectable/selectable_list/selectable_list.js +95 -42
  130. package/test-env/components/selectable/selectable_list/selectable_list_item.js +233 -205
  131. package/test-env/components/selectable/selectable_option.js +12 -1
  132. package/test-env/components/selectable/selectable_templates/selectable_template_sitewide.js +10 -2
  133. package/test-env/components/text/text_color.js +6 -2
  134. package/test-env/components/toast/global_toast_list_item.js +5 -5
  135. package/src/components/markdown_editor/_index.scss +0 -9
  136. package/src/components/markdown_editor/_markdown_editor.scss +0 -22
  137. package/src/components/markdown_editor/_markdown_editor_drop_zone.scss +0 -58
  138. package/src/components/markdown_editor/_markdown_editor_footer.scss +0 -42
  139. package/src/components/markdown_editor/_markdown_editor_preview.scss +0 -20
  140. package/src/components/markdown_editor/_markdown_editor_text_area.scss +0 -43
  141. package/src/components/markdown_editor/_markdown_editor_toolbar.scss +0 -29
  142. package/src/components/markdown_editor/_markdown_format.scss +0 -78
  143. package/src/components/markdown_editor/_variables.scss +0 -1
  144. package/src/components/markdown_editor/plugins/markdown_tooltip.scss +0 -4
  145. package/src/themes/amsterdam/overrides/_markdown_editor.scss +0 -18
@@ -0,0 +1,168 @@
1
+ _Forked by @elastic/eui from Hacker0x01/react-datepicker for accessibility and consolidation of services._
2
+
3
+ Decision to not use a more traditional "vendor" directory approach includes redundant services, unnecessary dependencies, and a separate build pipeline. Most notably, `react-datepicker` included third-party popover and focus trap service and components that do not align with EUI interaction standards and were replaced, at parity, with EUI components.
4
+
5
+ Other modifications:
6
+
7
+ * Changed to `.js` naming to conform to EUI build processes
8
+ * Removed files related to repository management and publishing
9
+ * Adjusted `babel.rc` and `package.json` naming to avoid babel configuration conflicts
10
+
11
+ ___
12
+ # React Date Picker
13
+
14
+ [![npm version](https://badge.fury.io/js/react-datepicker.svg)](https://badge.fury.io/js/react-datepicker)
15
+ [![Build Status](https://travis-ci.org/Hacker0x01/react-datepicker.svg?branch=master)](https://travis-ci.org/Hacker0x01/react-datepicker)
16
+ [![Dependency Status](https://david-dm.org/Hacker0x01/react-datepicker.svg)](https://david-dm.org/Hacker0x01/react-datepicker)
17
+ [![codecov](https://codecov.io/gh/Hacker0x01/react-datepicker/branch/master/graph/badge.svg)](https://codecov.io/gh/Hacker0x01/react-datepicker)
18
+ [![Downloads](http://img.shields.io/npm/dm/react-datepicker.svg)](https://npmjs.org/package/react-datepicker)
19
+ [![Code Quality: Javascript](https://img.shields.io/lgtm/grade/javascript/g/Hacker0x01/react-datepicker.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/Hacker0x01/react-datepicker/context:javascript)
20
+ [![Total Alerts](https://img.shields.io/lgtm/alerts/g/Hacker0x01/react-datepicker.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/Hacker0x01/react-datepicker/alerts)
21
+
22
+ A simple and reusable Datepicker component for React ([Demo](https://reactdatepicker.com/))
23
+
24
+ ![](https://cloud.githubusercontent.com/assets/1412392/5339491/c40de124-7ee1-11e4-9f07-9276e2545f27.png)
25
+
26
+ ## Installation
27
+
28
+ The package can be installed via NPM:
29
+
30
+ ```
31
+ npm install react-datepicker --save
32
+ ```
33
+
34
+ You’ll need to install React, PropTypes, and Moment.js separately since those dependencies aren’t included in the package. Below is a simple example of how to use the Datepicker in a React view. You will also need to require the CSS file from this package (or provide your own). The example below shows how to include the CSS from this package if your build system supports requiring CSS files (Webpack is one that does).
35
+
36
+ ```js
37
+ import React from "react";
38
+ import DatePicker from "react-datepicker";
39
+ import moment from "moment";
40
+
41
+ import "react-datepicker/dist/react-datepicker.css";
42
+
43
+ // CSS Modules, react-datepicker-cssmodules.css
44
+ // import 'react-datepicker/dist/react-datepicker-cssmodules.css';
45
+
46
+ class Example extends React.Component {
47
+ constructor(props) {
48
+ super(props);
49
+ this.state = {
50
+ startDate: moment()
51
+ };
52
+ this.handleChange = this.handleChange.bind(this);
53
+ }
54
+
55
+ handleChange(date) {
56
+ this.setState({
57
+ startDate: date
58
+ });
59
+ }
60
+
61
+ render() {
62
+ return (
63
+ <DatePicker
64
+ selected={this.state.startDate}
65
+ onChange={this.handleChange}
66
+ />
67
+ );
68
+ }
69
+ }
70
+ ```
71
+
72
+ ## Configuration
73
+
74
+ The most basic use of the DatePicker can be described with:
75
+
76
+ ```js
77
+ <DatePicker selected={this.state.date} onChange={this.handleChange} />
78
+ ```
79
+
80
+ You can use `onSelect` event handler which fires each time some calendar date has been selected
81
+
82
+ ```js
83
+ <DatePicker
84
+ selected={this.state.date}
85
+ onSelect={this.handleSelect} //when day is clicked
86
+ onChange={this.handleChange} //only when value has changed
87
+ />
88
+ ```
89
+
90
+ `onClickOutside` handler may be useful to close datepicker in `inline` mode
91
+
92
+ See [here](https://github.com/Hacker0x01/react-datepicker/blob/master/docs/datepicker.md) for a full list of props that may be passed to the component. Examples are given on the [main website](https://hacker0x01.github.io/react-datepicker).
93
+
94
+ ### Time picker
95
+
96
+ You can also include a time picker by adding the showTimeSelect prop
97
+
98
+ ```js
99
+ <DatePicker
100
+ selected={this.state.date}
101
+ onChange={this.handleChange}
102
+ showTimeSelect
103
+ dateFormat="LLL"
104
+ />
105
+ ```
106
+
107
+ Times will be displayed at 30-minute intervals by default (default configurable via timeInterval prop)
108
+
109
+ More examples of how to use the time picker are given on the [main website](https://hacker0x01.github.io/react-datepicker)
110
+
111
+ ### Localization
112
+
113
+ The date picker relies on [moment.js internationalization](http://momentjs.com/docs/#/i18n/) to localize its display components. By default, the date picker will use the locale globally set in moment, which is English. Locales can be changed in the following ways:
114
+
115
+ * **Globally** by calling `moment.locale(lang)`
116
+ * **Picker-specific** by providing the `locale` prop
117
+
118
+ Locales can be further configured in moment with various [customization options](http://momentjs.com/docs/#/customization/).
119
+
120
+ _As of version 0.23, the `weekdays` and `weekStart` DatePicker props have been removed. Instead, they can be configured with the `weekdaysMin` and `week.dow` moment locale customization options._
121
+
122
+ ## Compatibility
123
+
124
+ ### React
125
+
126
+ We're always trying to stay compatible with the latest version of React. We can't support all older versions of React.
127
+
128
+ Latest compatible versions:
129
+
130
+ * React 15.5 or newer: All above React-datepicker v.0.40.0
131
+ * React 15.4.1: needs React-datepicker v0.40.0, newer won't work (due to react-onclickoutside dependencies)
132
+ * React 0.14 or newer: All above React-datepicker v0.13.0
133
+ * React 0.13: React-datepicker v0.13.0
134
+ * pre React 0.13: React-datepicker v0.6.2
135
+
136
+ ### Browser Support
137
+
138
+ The date picker is compatible with the latest versions of Chrome, Firefox, and IE10+.
139
+
140
+ Unfortunately, it is difficult to support legacy browsers while maintaining our ability to develop new features in the future. For IE9 support, it is known that the [classlist polyfill](https://www.npmjs.com/package/classlist-polyfill) is needed, but this may change or break at any point in the future.
141
+
142
+ ## Local Development
143
+
144
+ The `master` branch contains the latest version of the Datepicker component. To start your example app, you can run `yarn start`. This starts a simple webserver on http://localhost:8080.
145
+
146
+ You can run `yarn test` to execute the test suite and linters. To help you develop the component we’ve set up some tests that cover the basic functionality (can be found in `/tests`). Even though we’re big fans of testing, this only covers a small piece of the component. We highly recommend you add tests when you’re adding new functionality.
147
+
148
+ ### The examples
149
+
150
+ The examples are hosted within the docs folder and are ran in the simple app that loads the Datepicker. To extend the examples with a new example, you can simply duplicate one of the existing examples and change the unique properties of your example.
151
+
152
+ ## Accessibility
153
+
154
+ ### Keyboard support
155
+
156
+ * _Left_: Move to the previous day.
157
+ * _Right_: Move to the next day.
158
+ * _Up_: Move to the previous week.
159
+ * _Down_: Move to the next week.
160
+ * _PgUp_: Move to the previous month.
161
+ * _PgDn_: Move to the next month.
162
+ * _Home_: Move to the previous year.
163
+ * _End_: Move to the next year.
164
+ * _Enter/Esc/Tab_: close the calendar. (Enter & Esc calls preventDefault)
165
+
166
+ ## License
167
+
168
+ Copyright (c) 2018 HackerOne Inc. and individual contributors. Licensed under MIT license, see [LICENSE](LICENSE) for the full license.
@@ -1,24 +1,19 @@
1
- .euiSuperDatePicker__absoluteDateFormRow {
1
+ .euiSuperDatePicker__absoluteDateForm {
2
2
  padding: 0 $euiSizeS $euiSizeS;
3
+ }
3
4
 
4
- /* A bit of a visual trickery to make the format "hint" become an "error" text.
5
- NOTE: Normally reordering visually (vs DOM) isn't super great for screen reader users,
6
- but as the help text is already read out via `aria-describedby`, and the error text
7
- is read out immediately via `aria-live`, we can fairly safely prioritize visuals instead */
8
- .euiFormRow__fieldWrapper {
9
- display: flex;
10
- flex-direction: column;
11
- };
12
-
13
- .euiFormControlLayout {
14
- order: 0;
15
- }
5
+ .euiSuperDatePicker__absoluteDateFormSubmit {
6
+ flex-shrink: 0;
7
+ }
16
8
 
17
- .euiFormHelpText {
18
- order: 1;
19
- }
9
+ .euiSuperDatePicker__absoluteDateFormRow {
10
+ flex-grow: 1;
20
11
 
21
- .euiFormErrorText {
22
- order: 2;
12
+ // CSS hack to make the help/error text extend to the submit button.
13
+ // We can't actually put the submit button within an EuiFormRow due to
14
+ // cloneElement limitations (https://github.com/elastic/eui/issues/2493#issuecomment-561278494)
15
+ // TODO: Remove this and clean up DOM rendering once we can
16
+ .euiFormRow__text {
17
+ margin-inline-end: -1 * ($euiSizeXL + $euiSizeS); // XL - size of the button, S - size of the flex gap
23
18
  }
24
19
  }
@@ -50,6 +50,29 @@
50
50
  }
51
51
  }
52
52
 
53
+ &:focus {
54
+ + .euiCheckbox__square {
55
+ @include euiCustomControlFocused;
56
+ }
57
+ }
58
+
59
+ // Readonly checkboxes are used by EuiMarkdownEditor
60
+ &[readonly] {
61
+ cursor: default !important; // stylelint-disable-line declaration-no-important
62
+
63
+ ~ .euiCheckbox__label {
64
+ cursor: default !important; // stylelint-disable-line declaration-no-important
65
+ }
66
+
67
+ // maintain the initial color to enforce that clicks are not doing anything
68
+ &:focus {
69
+ + .euiCheckbox__square {
70
+ outline-color: $euiFormCustomControlBorderColor !important; // stylelint-disable-line declaration-no-important
71
+ border-color: $euiFormCustomControlBorderColor;
72
+ }
73
+ }
74
+ }
75
+
53
76
  &[disabled] {
54
77
  cursor: not-allowed !important; // stylelint-disable-line declaration-no-important
55
78
 
@@ -74,12 +97,6 @@
74
97
  @include euiCustomControlDisabled($type: 'square');
75
98
  }
76
99
  }
77
-
78
- &:focus {
79
- + .euiCheckbox__square {
80
- @include euiCustomControlFocused;
81
- }
82
- }
83
100
  }
84
101
 
85
102
  &.euiCheckbox--inList,
@@ -5,5 +5,4 @@
5
5
  @import 'date_picker/index';
6
6
  @import 'datagrid/index';
7
7
  @import 'form/index';
8
- @import 'markdown_editor/index';
9
8
  @import 'selectable/index';
@@ -56,3 +56,7 @@
56
56
  @include euiTextTruncate;
57
57
  }
58
58
  }
59
+
60
+ .euiSelectableListItem__tooltipAnchor {
61
+ width: 100%;
62
+ }
@@ -1,3 +1,7 @@
1
+ .euiSelectableTemplateSitewide {
2
+ display: block; // Override .euiSelectable flex display, which fixes the anchor positioning for mobile `popoverButton`s
3
+ }
4
+
1
5
  .euiSelectableTemplateSitewide__listItem {
2
6
  .euiSelectableListItem__text {
3
7
  text-decoration: none !important; // stylelint-disable-line declaration-no-important
@@ -32,4 +36,4 @@
32
36
  #{$property}: $value;
33
37
  }
34
38
  }
35
- }
39
+ }
@@ -0,0 +1,153 @@
1
+ # JavaScript-based theming in EUI
2
+
3
+ The style system to replace Sass and Sass-based design tokens in EUI.
4
+
5
+ * Theme construction via a Proxy-based system with cascading and computed values
6
+ * Proxy-based: allows for the theme system to reference its own values (for reuse or for computational manipulation)
7
+ * Cascading: conceptually similar to Sass, where variable location and order are important
8
+ * Extendable: allows for appending style variables to the EUI theme structure, scoped to a React context provider
9
+ * Override-able: all theme tokens/variables can be altered by consumers
10
+ * Theme consumption via React hook and HOC methods
11
+ * Color mode support as first-class consideration
12
+ * "Light" and "dark" mode accounting
13
+ * Theme consumption is scoped to the current color mode (set in the context provider)
14
+ * Style adaptaion based on a smal set of base values
15
+ * Text colors are calculated with WCAG Level AA (4.5:1) in mind
16
+ * Scalable typographic and spacing rhythms
17
+
18
+
19
+ ## Layers of the theme system
20
+
21
+ ### Unbuilt theme
22
+
23
+ _See [`euiThemeDefault`](../../themes/eui/theme.ts)_
24
+ An unbuilt theme is a composed object of style values or `computed` functions.
25
+
26
+ #### Style values
27
+
28
+ Think design tokens or CSS property values. Ready to be consumed as-is in an application environment, using some JavaScript method of applying styles (i.e., a CSS-in-JS library is not required).
29
+
30
+ #### `computed` functions
31
+
32
+ These properties specify that the value depends upon some other value in the theme, in the shape of:
33
+
34
+ ```js
35
+ computed(
36
+ ([size]) => size * 2 // predicate. What to do with the dependency values,
37
+ ['sizes.euiSize'], // dependency array, referencing other properties in the theme object
38
+ )
39
+ ```
40
+
41
+ The dependency array is optional. Omitting the array gives access to the computed theme.
42
+
43
+ ```js
44
+ computed(
45
+ (theme) => theme.sizes.euiSize * 2
46
+ )
47
+ ```
48
+
49
+ ### Theme system (built theme)
50
+
51
+ _See [`EuiThemeDefault`](../../themes/eui/theme.ts)_
52
+ A built theme by way of `buildTheme`, which transforms the object containing static style values and `computed` functions into a JavaScript Proxy object with handler traps. In this state, the theme is essentially inaccessible and immutable, that is, it requires `getComputed` to correctly order and access values and dependencies, and `set()` is disabled.
53
+
54
+ ### Computed theme
55
+
56
+ _See [`EuiThemeContext`](../../themes/eui/context.ts)_
57
+ A consumable theme object in which all `computed` function values have been computed; all values are accessible and usable in an application environment.
58
+ Returned from `getComputed`, in the shape of:
59
+
60
+ ```js
61
+ getComputed(
62
+ EuiThemeDefault, // Theme system (Proxy)
63
+ {}, // Modifications object
64
+ 'light' // Color mode
65
+ )
66
+ ```
67
+
68
+ #### Modifications
69
+
70
+ Because the theme system (built theme) is immutable, modifications can only be made at compute time by providing overrides and extensions for theme property values. These modifications are passed to the `EuiThemeProvider` via the `modify` prop and should match the high-level object shape of the theme.
71
+
72
+ #### Color mode
73
+
74
+ Think light and dark mode. A theme has built-in color mode support, using the reserved `LIGHT` and `DARK` keys as a marker:
75
+
76
+ ```js
77
+ colors: {
78
+ LIGHT: {...}
79
+ DARK : {...}
80
+ }
81
+ ```
82
+ The reserved color mode keys can be used at any level and location in a theme.
83
+ `getComputed` will only compute and return values in the specified current color mode.
84
+
85
+
86
+ ## React-specific context
87
+
88
+ ### EuiThemeProvider
89
+
90
+ _See [`EuiThemeProvider`](../../themes/eui/provider.ts)_
91
+ Umbrella provider component that holds the various top-level theme configuration option providers: theme system, color mode, modifications; as well as the primary output provider: computed theme.
92
+ The actual computation for computed theme values takes place at this level, where the three inputs are known (theme system, color mode, modifications) and the output (computed theme) can be cached for consumption. Input changes are captured and the output is recomputed.
93
+
94
+ ```js
95
+ <EuiThemeProvider
96
+ theme={DefaultEuiTheme}
97
+ colorMode="light"
98
+ modify={{}}
99
+ />
100
+ ```
101
+
102
+ All three props are optional. The default values for EUI will be used in the event that no configuration is provided. Note, however that colorMode switching will require consumers to maintain that app state.
103
+
104
+ ### useEuiTheme
105
+
106
+ _See [`useEuiTheme`](../../themes/eui/hooks.tsx)_
107
+ A custom React hook that returns the computed theme. This hook is little more than a wrapper around the `useContext` hook, accessing three of the top-level providers: computed theme, color mode, and modifications.
108
+
109
+ ```js
110
+ const { euiTheme, colorMode, modifications } = useEuiTheme();
111
+ ```
112
+
113
+ The `euiTheme` variable has TypeScript support, which will result in IDE autocomplete availability.
114
+
115
+ ### WithEuiTheme
116
+ A higher-order-component that wraps `useEuiTheme` for React class components.
117
+
118
+
119
+ ___
120
+
121
+
122
+ ## Emotion
123
+
124
+ [Emotion](https://emotion.sh/docs/introduction) is the CSS-in-JS library currently selected for use in EUI. Nothing in the EUI theming system is dependent upon Emotion packages, but the Emotion ecosystem will have impacts on generated styles.
125
+
126
+ ### Composition
127
+
128
+ * Prefer the use of [`css` prop](https://emotion.sh/docs/css-prop) construction over [styled-component-like](https://emotion.sh/docs/styled) component construction
129
+ * Babel-based build accommodation
130
+
131
+ ### Testing
132
+
133
+ Snapshot testing ([as currently configured](https://emotion.sh/docs/testing#writing-a-test)) will result in generic `emotion-${n}` class names with the generated style object as part of the snapshot.
134
+
135
+ * This seems good for EUI, but it also affects consumers
136
+ * Consumers will need to use the `@emotion/jest` snapshot serializer to avoid class name churn.
137
+ * Not ideal; unsure of any other solutions
138
+ * During the conversion process, the snapshot diffs will look less than ideal when using `shallow` (a single wrapper element; DOM itself is unchanged):
139
+
140
+ ```diff
141
+ - <div
142
+ - className="euiTableRowCell__mobileHeader euiTableRowCell--hideForDesktop"
143
+ + <EmotionCssPropInternal
144
+ + __EMOTION_LABEL_PLEASE_DO_NOT_USE__="EuiTableRowCell"
145
+ + __EMOTION_TYPE_PLEASE_DO_NOT_USE__="td"
146
+ + className="euiTableRowCell"
147
+ + style={
148
+ + Object {
149
+ + "width": undefined,
150
+ + }
151
+ + }
152
+ >
153
+ ```
@@ -0,0 +1,44 @@
1
+ # Testing-related utilities
2
+
3
+ EUI uses many of the utilities in this directory in its own Jest tests and, in case they are useful for consuming apps, exports them from `@elastic/eui/lib/test` (commonjs) and `@elastic/eui/es/test` (esm)
4
+
5
+ ### findTestSubject
6
+
7
+ Provides a quick mechanism for searching an Enzyme-mounted component tree for an element with a specific `data-test-subj` attribute.
8
+
9
+ ```js
10
+ // if mountedComponent contains e.g. <button data-test-subj="custom-button"/>, this would return that button
11
+ const component = findTestSubject(mountedComponent, 'custom-button');
12
+ ```
13
+
14
+ ### startThrowingReactWarnings
15
+
16
+ Patches `console.warn` and `console.error` to throw any warnings or errors, causing Jest to fail the test. This catches warnings emitted by React.
17
+
18
+ ### stopThrowingReactWarnings
19
+
20
+ Must be called after `startThrowingReactWarnings`, this unpatches the console and restores normal functionality.
21
+
22
+ ### sleep
23
+
24
+ Returns an `await`able promise that resolves after the specified duration.
25
+
26
+ ```js
27
+ doSomeAction();
28
+ await sleep(500); // wait 500ms
29
+ expect(resultOfSomeAction);
30
+ ```
31
+
32
+ ### takeMountedSnapshot
33
+
34
+ Use this function to generate a Jest snapshot of components that have been fully rendered using Enzyme's `mount` method. Typically, a mounted component will result in a snapshot containing both React components and HTML elements. This function removes the React components, leaving only HTML elements in the snapshot.
35
+
36
+ This function takes an optional configuration as a second argument, which supports one option: `hasArrayOutput`. Enable this option if the mounted component has multiple direct children, otherwise only the first is included in the snapshot.
37
+
38
+ ```js
39
+ expect(
40
+ takeMountedSnapshot(mountedComponent, {
41
+ hasArrayOutput: true,
42
+ })
43
+ ).toMatchSnapshot();
44
+ ```
@@ -4,4 +4,3 @@
4
4
  @import 'form_control_layout_delimited';
5
5
  @import 'form_controls';
6
6
  @import 'hue';
7
- @import 'markdown_editor';
@@ -16,6 +16,7 @@ var _button_icon = require("../../../button/button_icon");
16
16
  var _tool_tip = require("../../../tool_tip");
17
17
  var _context = require("../../context");
18
18
  var _collapsed_nav_button = require("./collapsed_nav_button.styles");
19
+ var _i18n = require("../../../i18n");
19
20
  var _react2 = require("@emotion/react");
20
21
  var _excluded = ["href", "title", "icon", "iconProps", "isSelected", "onClick", "hideToolTip", "linkProps", "titleElement"];
21
22
  /*
@@ -45,6 +46,9 @@ var EuiCollapsedNavButton = function EuiCollapsedNavButton(_ref) {
45
46
  var buttonClassName = (0, _classnames.default)('euiCollapsedNavButton', linkProps === null || linkProps === void 0 ? void 0 : linkProps.className);
46
47
  var tooltipStyles = (0, _services.useEuiMemoizedStyles)(_collapsed_nav_button.euiCollapsedNavItemTooltipStyles);
47
48
  var tooltipCssStyles = [tooltipStyles.euiCollapsedNavItemTooltip, tooltipStyles[side], hideToolTip && tooltipStyles.hidden];
49
+ var buttonIconAriaLabel = (0, _i18n.useEuiI18n)('euiCollapsedNavButton.ariaLabelButtonIcon', '{title}, quick navigation menu', {
50
+ title: title
51
+ });
48
52
  return (0, _react2.jsx)(_tool_tip.EuiToolTip, {
49
53
  content: title,
50
54
  css: tooltipCssStyles,
@@ -57,7 +61,7 @@ var EuiCollapsedNavButton = function EuiCollapsedNavButton(_ref) {
57
61
  color: "text",
58
62
  href: href,
59
63
  onClick: onClick,
60
- "aria-label": title
64
+ "aria-label": buttonIconAriaLabel
61
65
  }, linkProps, {
62
66
  // Exclusive union shenanigans
63
67
  className: buttonClassName,
@@ -18,8 +18,9 @@ var _react = _interopRequireWildcard(require("react"));
18
18
  var _propTypes = _interopRequireDefault(require("prop-types"));
19
19
  var _moment = _interopRequireDefault(require("moment"));
20
20
  var _datemath = _interopRequireDefault(require("@elastic/datemath"));
21
- var _services = require("../../../../services");
22
21
  var _form = require("../../../form");
22
+ var _flex = require("../../../flex");
23
+ var _button = require("../../../button");
23
24
  var _code = require("../../../code");
24
25
  var _i18n = require("../../../i18n");
25
26
  var _date_picker = require("../../date_picker");
@@ -153,20 +154,29 @@ var EuiAbsoluteTab = /*#__PURE__*/function (_Component) {
153
154
  locale: locale,
154
155
  utcOffset: utcOffset
155
156
  }), (0, _react2.jsx)(_i18n.EuiI18n, {
156
- tokens: ['euiAbsoluteTab.dateFormatHint', 'euiAbsoluteTab.dateFormatError'],
157
- defaults: ['Press the Enter key to parse as a date.', 'Allowed formats: {dateFormat}, ISO 8601, RFC 2822, or Unix timestamp.'],
157
+ tokens: ['euiAbsoluteTab.dateFormatButtonLabel', 'euiAbsoluteTab.dateFormatError'],
158
+ defaults: ['Parse date', 'Allowed formats: {dateFormat}, ISO 8601, RFC 2822, or Unix timestamp.'],
158
159
  values: {
159
160
  dateFormat: (0, _react2.jsx)(_code.EuiCode, null, dateFormat)
160
161
  }
161
162
  }, function (_ref) {
162
163
  var _ref2 = (0, _slicedToArray2.default)(_ref, 2),
163
- dateFormatHint = _ref2[0],
164
+ dateFormatButtonLabel = _ref2[0],
164
165
  dateFormatError = _ref2[1];
165
- return (0, _react2.jsx)(_form.EuiFormRow, {
166
+ return (0, _react2.jsx)(_flex.EuiFlexGroup, {
167
+ component: "form",
168
+ onSubmit: function onSubmit(e) {
169
+ e.preventDefault(); // Prevents a page refresh/reload
170
+ _this2.parseUserDateInput(textInputValue);
171
+ },
172
+ className: "euiSuperDatePicker__absoluteDateForm",
173
+ gutterSize: "s",
174
+ responsive: false
175
+ }, (0, _react2.jsx)(_form.EuiFormRow, {
166
176
  className: "euiSuperDatePicker__absoluteDateFormRow",
167
177
  isInvalid: isTextInvalid,
168
178
  error: isTextInvalid ? dateFormatError : undefined,
169
- helpText: hasUnparsedText ? isTextInvalid ? dateFormatHint : [dateFormatHint, dateFormatError] : undefined
179
+ helpText: hasUnparsedText && !isTextInvalid ? dateFormatError : undefined
170
180
  }, (0, _react2.jsx)(_form.EuiFieldText, {
171
181
  compressed: true,
172
182
  isInvalid: isTextInvalid,
@@ -175,13 +185,17 @@ var EuiAbsoluteTab = /*#__PURE__*/function (_Component) {
175
185
  onPaste: function onPaste(event) {
176
186
  _this2.parseUserDateInput(event.clipboardData.getData('text'));
177
187
  },
178
- onKeyDown: function onKeyDown(event) {
179
- if (event.key === _services.keys.ENTER) {
180
- _this2.parseUserDateInput(textInputValue);
181
- }
182
- },
183
188
  "data-test-subj": "superDatePickerAbsoluteDateInput",
184
189
  prepend: (0, _react2.jsx)(_form.EuiFormLabel, null, labelPrefix)
190
+ })), hasUnparsedText && (0, _react2.jsx)(_button.EuiButtonIcon, {
191
+ type: "submit",
192
+ className: "euiSuperDatePicker__absoluteDateFormSubmit",
193
+ size: "s",
194
+ display: "base",
195
+ iconType: "check",
196
+ "aria-label": dateFormatButtonLabel,
197
+ title: dateFormatButtonLabel,
198
+ "data-test-subj": "parseAbsoluteDateFormat"
185
199
  }));
186
200
  }));
187
201
  }
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.euiFormVariables = exports.euiFormControlSize = exports.euiCustomControl = void 0;
7
+ exports.euiFormVariables = exports.euiFormControlText = exports.euiFormControlSize = exports.euiFormControlFocusStyles = exports.euiFormControlDefaultShadow = exports.euiCustomControl = void 0;
8
8
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
9
  var _services = require("../../services");
10
10
  var _global_styling = require("../../global_styling");
@@ -70,7 +70,9 @@ var euiFormVariables = function euiFormVariables(euiThemeContext) {
70
70
  xxl: euiTheme.size.xxl
71
71
  }
72
72
  };
73
- return _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({}, sizes), colors), customControlColors), iconSizes), controlLayout);
73
+ return _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({}, sizes), colors), customControlColors), iconSizes), controlLayout), {}, {
74
+ animationTiming: "".concat(euiTheme.animation.fast, " ease-in")
75
+ });
74
76
  };
75
77
  exports.euiFormVariables = euiFormVariables;
76
78
  var euiFormControlSize = function euiFormControlSize(euiThemeContext) {
@@ -106,6 +108,30 @@ var euiCustomControl = function euiCustomControl(euiThemeContext) {
106
108
  } else if (type === 'square') {
107
109
  borderRadiusStyle = "border-radius: ".concat(form.controlCompressedBorderRadius, ";");
108
110
  }
109
- return "\n ".concat(padddingStyle, "\n ").concat(borderRadiusStyle, "\n border: ").concat(euiTheme.border.width.thin, " solid ").concat(form.customControlBorderColor, ";\n background: ").concat(euiTheme.colors.emptyShade, " no-repeat center;\n\n ").concat(_global_styling.euiCanAnimate, " {\n transition: background-color ").concat(euiTheme.animation.fast, " ease-in,\n border-color ").concat(euiTheme.animation.fast, " ease-in;\n }\n ");
111
+ return "\n ".concat(padddingStyle, "\n ").concat(borderRadiusStyle, "\n border: ").concat(euiTheme.border.width.thin, " solid ").concat(form.customControlBorderColor, ";\n background: ").concat(euiTheme.colors.emptyShade, " no-repeat center;\n\n ").concat(_global_styling.euiCanAnimate, " {\n transition: background-color ").concat(form.animationTiming, ",\n border-color ").concat(form.animationTiming, ";\n }\n ");
110
112
  };
111
- exports.euiCustomControl = euiCustomControl;
113
+ exports.euiCustomControl = euiCustomControl;
114
+ var euiFormControlText = function euiFormControlText(euiThemeContext) {
115
+ var euiTheme = euiThemeContext.euiTheme;
116
+ var _euiFontSize = (0, _global_styling.euiFontSize)(euiThemeContext, 's'),
117
+ fontSize = _euiFontSize.fontSize;
118
+ var _euiFormVariables = euiFormVariables(euiThemeContext),
119
+ controlPlaceholderText = _euiFormVariables.controlPlaceholderText;
120
+ return "\n font-family: ".concat(euiTheme.font.family, ";\n font-size: ").concat(fontSize, ";\n color: ").concat(euiTheme.colors.text, ";\n\n ").concat(euiPlaceholderPerBrowser("color: ".concat(controlPlaceholderText)), "\n ");
121
+ };
122
+ exports.euiFormControlText = euiFormControlText;
123
+ var euiFormControlDefaultShadow = function euiFormControlDefaultShadow(euiThemeContext) {
124
+ var euiTheme = euiThemeContext.euiTheme;
125
+ var form = euiFormVariables(euiThemeContext);
126
+ return "\n box-shadow: inset 0 0 0 1px ".concat(form.borderColor, ";\n background-color: ").concat(form.backgroundColor, ";\n\n background-repeat: no-repeat;\n background-size: 0% 100%;\n background-image: linear-gradient(to top,\n var(--euiFormStateColor),\n var(--euiFormStateColor) ").concat(euiTheme.border.width.thick, ",\n transparent ").concat(euiTheme.border.width.thick, ",\n transparent 100%\n );\n\n ").concat(_global_styling.euiCanAnimate, " {\n transition:\n box-shadow ").concat(form.animationTiming, ",\n background-image ").concat(form.animationTiming, ",\n background-size ").concat(form.animationTiming, ",\n background-color ").concat(form.animationTiming, ";\n }\n ");
127
+ };
128
+ exports.euiFormControlDefaultShadow = euiFormControlDefaultShadow;
129
+ var euiFormControlFocusStyles = function euiFormControlFocusStyles(_ref) {
130
+ var euiTheme = _ref.euiTheme,
131
+ colorMode = _ref.colorMode;
132
+ return "\n --euiFormStateColor: ".concat(euiTheme.colors.primary, ";\n background-color: ").concat(colorMode === 'DARK' ? (0, _services.shade)(euiTheme.colors.emptyShade, 0.4) : euiTheme.colors.emptyShade, ";\n background-size: 100% 100%;\n outline: none; /* Remove all outlines and rely on our own bottom border gradient */\n");
133
+ };
134
+ exports.euiFormControlFocusStyles = euiFormControlFocusStyles;
135
+ var euiPlaceholderPerBrowser = function euiPlaceholderPerBrowser(content) {
136
+ return "\n &::-webkit-input-placeholder { ".concat(content, "; opacity: 1; }\n &::-moz-placeholder { ").concat(content, "; opacity: 1; }\n &:-ms-input-placeholder { ").concat(content, "; opacity: 1; }\n &:-moz-placeholder { ").concat(content, "; opacity: 1; }\n &::placeholder { ").concat(content, "; opacity: 1; }\n");
137
+ };