@elastic/eui 73.0.0 → 74.0.0

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 (63) hide show
  1. package/dist/eui_theme_dark.css +0 -55
  2. package/dist/eui_theme_dark.min.css +1 -1
  3. package/dist/eui_theme_light.css +0 -55
  4. package/dist/eui_theme_light.min.css +1 -1
  5. package/es/components/basic_table/basic_table.js +56 -101
  6. package/es/components/basic_table/basic_table.styles.js +45 -0
  7. package/es/components/modal/confirm_modal.js +5 -3
  8. package/es/components/modal/modal.a11y.js +1 -1
  9. package/es/components/modal/modal_header_title.js +12 -3
  10. package/es/components/resizable_container/resizable_panel.js +5 -0
  11. package/es/services/security/get_secure_rel_for_target.js +2 -8
  12. package/es/services/theme/hooks.js +18 -0
  13. package/es/services/theme/index.js +1 -1
  14. package/eui.d.ts +46 -19
  15. package/i18ntokens.json +18 -18
  16. package/lib/components/basic_table/basic_table.js +56 -100
  17. package/lib/components/basic_table/basic_table.styles.js +54 -0
  18. package/lib/components/modal/confirm_modal.js +5 -3
  19. package/lib/components/modal/modal.a11y.js +1 -1
  20. package/lib/components/modal/modal_header_title.js +12 -3
  21. package/lib/components/resizable_container/resizable_panel.js +5 -0
  22. package/lib/services/security/get_secure_rel_for_target.js +2 -9
  23. package/lib/services/theme/hooks.js +22 -2
  24. package/lib/services/theme/index.js +6 -0
  25. package/optimize/es/components/basic_table/basic_table.js +56 -101
  26. package/optimize/es/components/basic_table/basic_table.styles.js +45 -0
  27. package/optimize/es/components/modal/confirm_modal.js +4 -3
  28. package/optimize/es/components/modal/modal.a11y.js +1 -1
  29. package/optimize/es/components/modal/modal_header_title.js +4 -2
  30. package/optimize/es/services/security/get_secure_rel_for_target.js +2 -8
  31. package/optimize/es/services/theme/hooks.js +18 -0
  32. package/optimize/es/services/theme/index.js +1 -1
  33. package/optimize/lib/components/basic_table/basic_table.js +56 -95
  34. package/optimize/lib/components/basic_table/basic_table.styles.js +56 -0
  35. package/optimize/lib/components/modal/confirm_modal.js +4 -3
  36. package/optimize/lib/components/modal/modal.a11y.js +1 -1
  37. package/optimize/lib/components/modal/modal_header_title.js +4 -2
  38. package/optimize/lib/services/security/get_secure_rel_for_target.js +2 -9
  39. package/optimize/lib/services/theme/hooks.js +22 -2
  40. package/optimize/lib/services/theme/index.js +6 -0
  41. package/package.json +1 -1
  42. package/src/components/index.scss +0 -1
  43. package/test-env/components/basic_table/basic_table.js +56 -95
  44. package/test-env/components/basic_table/basic_table.styles.js +56 -0
  45. package/test-env/components/modal/confirm_modal.js +5 -3
  46. package/test-env/components/modal/modal.a11y.js +1 -1
  47. package/test-env/components/modal/modal_header_title.js +12 -3
  48. package/test-env/components/resizable_container/resizable_panel.js +5 -0
  49. package/test-env/services/security/get_secure_rel_for_target.js +2 -9
  50. package/test-env/services/theme/hooks.js +22 -2
  51. package/test-env/services/theme/index.js +6 -0
  52. package/CHANGELOG.md +0 -6185
  53. package/es/services/url.js +0 -23
  54. package/lib/services/url.js +0 -32
  55. package/optimize/es/services/url.js +0 -23
  56. package/optimize/lib/services/url.js +0 -32
  57. package/src/components/basic_table/_basic_table.scss +0 -41
  58. package/src/components/basic_table/_index.scss +0 -1
  59. package/src/components/date_picker/react-datepicker/LICENSE +0 -21
  60. package/src/components/date_picker/react-datepicker/README.md +0 -168
  61. package/src/services/theme/README.md +0 -153
  62. package/src/test/README.md +0 -59
  63. package/test-env/services/url.js +0 -32
@@ -1,23 +0,0 @@
1
- /*
2
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3
- * or more contributor license agreements. Licensed under the Elastic License
4
- * 2.0 and the Server Side Public License, v 1; you may not use this file except
5
- * in compliance with, at your election, the Elastic License 2.0 or the Server
6
- * Side Public License, v 1.
7
- */
8
- var isElasticHost = /^([a-zA-Z0-9]+\.)*elastic\.co$/; // In order for the domain to be secure it needs to be in a parsable format,
9
- // with the protocol of http: or https: and the host matching elastic.co or
10
- // of one its subdomains
11
-
12
- export var isDomainSecure = function isDomainSecure() {
13
- var url = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
14
-
15
- try {
16
- var parsed = new URL(url);
17
- var protocolMatches = parsed.protocol === 'http:' || parsed.protocol === 'https:';
18
- var domainMatches = !!parsed.host.match(isElasticHost);
19
- return protocolMatches && domainMatches;
20
- } catch (e) {
21
- return false;
22
- }
23
- };
@@ -1,32 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.isDomainSecure = void 0;
7
-
8
- /*
9
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
10
- * or more contributor license agreements. Licensed under the Elastic License
11
- * 2.0 and the Server Side Public License, v 1; you may not use this file except
12
- * in compliance with, at your election, the Elastic License 2.0 or the Server
13
- * Side Public License, v 1.
14
- */
15
- var isElasticHost = /^([a-zA-Z0-9]+\.)*elastic\.co$/; // In order for the domain to be secure it needs to be in a parsable format,
16
- // with the protocol of http: or https: and the host matching elastic.co or
17
- // of one its subdomains
18
-
19
- var isDomainSecure = function isDomainSecure() {
20
- var url = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
21
-
22
- try {
23
- var parsed = new URL(url);
24
- var protocolMatches = parsed.protocol === 'http:' || parsed.protocol === 'https:';
25
- var domainMatches = !!parsed.host.match(isElasticHost);
26
- return protocolMatches && domainMatches;
27
- } catch (e) {
28
- return false;
29
- }
30
- };
31
-
32
- exports.isDomainSecure = isDomainSecure;
@@ -1,23 +0,0 @@
1
- /*
2
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3
- * or more contributor license agreements. Licensed under the Elastic License
4
- * 2.0 and the Server Side Public License, v 1; you may not use this file except
5
- * in compliance with, at your election, the Elastic License 2.0 or the Server
6
- * Side Public License, v 1.
7
- */
8
- var isElasticHost = /^([a-zA-Z0-9]+\.)*elastic\.co$/; // In order for the domain to be secure it needs to be in a parsable format,
9
- // with the protocol of http: or https: and the host matching elastic.co or
10
- // of one its subdomains
11
-
12
- export var isDomainSecure = function isDomainSecure() {
13
- var url = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
14
-
15
- try {
16
- var parsed = new URL(url);
17
- var protocolMatches = parsed.protocol === 'http:' || parsed.protocol === 'https:';
18
- var domainMatches = !!parsed.host.match(isElasticHost);
19
- return protocolMatches && domainMatches;
20
- } catch (e) {
21
- return false;
22
- }
23
- };
@@ -1,32 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.isDomainSecure = void 0;
7
-
8
- /*
9
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
10
- * or more contributor license agreements. Licensed under the Elastic License
11
- * 2.0 and the Server Side Public License, v 1; you may not use this file except
12
- * in compliance with, at your election, the Elastic License 2.0 or the Server
13
- * Side Public License, v 1.
14
- */
15
- var isElasticHost = /^([a-zA-Z0-9]+\.)*elastic\.co$/; // In order for the domain to be secure it needs to be in a parsable format,
16
- // with the protocol of http: or https: and the host matching elastic.co or
17
- // of one its subdomains
18
-
19
- var isDomainSecure = function isDomainSecure() {
20
- var url = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
21
-
22
- try {
23
- var parsed = new URL(url);
24
- var protocolMatches = parsed.protocol === 'http:' || parsed.protocol === 'https:';
25
- var domainMatches = !!parsed.host.match(isElasticHost);
26
- return protocolMatches && domainMatches;
27
- } catch (e) {
28
- return false;
29
- }
30
- };
31
-
32
- exports.isDomainSecure = isDomainSecure;
@@ -1,41 +0,0 @@
1
- .euiBasicTable {
2
- &-loading {
3
- position: relative;
4
-
5
- tbody {
6
- overflow: hidden;
7
- }
8
-
9
- tbody::before {
10
- position: absolute;
11
- content: '';
12
- width: 100%;
13
- height: $euiBorderWidthThick;
14
- background-color: $euiColorPrimary;
15
- animation: euiBasicTableLoading 1000ms linear;
16
- animation-iteration-count: infinite;
17
- }
18
- }
19
- }
20
-
21
- @keyframes euiBasicTableLoading {
22
- from {
23
- left: 0;
24
- width: 0;
25
- }
26
-
27
- 20% {
28
- left: 0;
29
- width: 40%;
30
- }
31
-
32
- 80% {
33
- left: 60%;
34
- width: 40%;
35
- }
36
-
37
- 100% {
38
- left: 100%;
39
- width: 0;
40
- }
41
- }
@@ -1 +0,0 @@
1
- @import 'basic_table';
@@ -1,21 +0,0 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2018 HackerOne Inc and individual contributors
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
@@ -1,168 +0,0 @@
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,153 +0,0 @@
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
- ```
@@ -1,59 +0,0 @@
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
- ```
45
-
46
- ### testCustomHook
47
-
48
- Use this function to execute a custom hook and access its return value, which can be passed to `expect` for verification. The function also returns a `getUpdatedState` method which will always return the hook's current state, in case some interaction with the react component causes an update.
49
-
50
- ```js
51
- const {
52
- return: hookReturnValue,
53
- getUpdatedState,
54
- } = testCustomHook(() => useCellPopover());
55
-
56
- expect(hookReturnValue).to.equal(myExpectedValue);
57
- doSomeActions();
58
- expect(getUpdatedState()).to.equal(myExpectedValue);
59
- ```
@@ -1,32 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.isDomainSecure = void 0;
7
-
8
- /*
9
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
10
- * or more contributor license agreements. Licensed under the Elastic License
11
- * 2.0 and the Server Side Public License, v 1; you may not use this file except
12
- * in compliance with, at your election, the Elastic License 2.0 or the Server
13
- * Side Public License, v 1.
14
- */
15
- var isElasticHost = /^([a-zA-Z0-9]+\.)*elastic\.co$/; // In order for the domain to be secure it needs to be in a parsable format,
16
- // with the protocol of http: or https: and the host matching elastic.co or
17
- // of one its subdomains
18
-
19
- var isDomainSecure = function isDomainSecure() {
20
- var url = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
21
-
22
- try {
23
- var parsed = new URL(url);
24
- var protocolMatches = parsed.protocol === 'http:' || parsed.protocol === 'https:';
25
- var domainMatches = !!parsed.host.match(isElasticHost);
26
- return protocolMatches && domainMatches;
27
- } catch (e) {
28
- return false;
29
- }
30
- };
31
-
32
- exports.isDomainSecure = isDomainSecure;