@ember-eui/core 5.8.4 → 5.10.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.
- package/addon/components/eui-checkbox-group/index.hbs +8 -0
- package/addon/components/eui-combo-box/options/index.hbs +0 -1
- package/addon/components/eui-field-text/index.hbs +1 -0
- package/addon/components/eui-global-toast-list/index.ts +1 -1
- package/addon/components/eui-i18n/index.ts +9 -41
- package/addon/components/eui-super-date-picker/date-popover/absolute-tab.hbs +42 -0
- package/addon/components/eui-super-date-picker/date-popover/absolute-tab.ts +79 -0
- package/addon/components/eui-super-date-picker/date-popover/datetime-picker.hbs +125 -0
- package/addon/components/eui-super-date-picker/date-popover/datetime-picker.ts +258 -0
- package/addon/components/eui-super-date-picker/date-popover/eui-date-popover-button.hbs +49 -0
- package/addon/components/eui-super-date-picker/date-popover/eui-date-popover-button.ts +49 -0
- package/addon/components/eui-super-date-picker/date-popover/eui-date-popover-content.hbs +42 -0
- package/addon/components/eui-super-date-picker/date-popover/eui-date-popover-content.ts +73 -0
- package/addon/components/eui-super-date-picker/date-popover/now-tab.hbs +45 -0
- package/addon/components/eui-super-date-picker/date-popover/relative-tab.hbs +47 -0
- package/addon/components/eui-super-date-picker/date-popover/relative-tab.ts +89 -0
- package/addon/components/eui-super-date-picker/eui-date-picker-range.hbs +22 -0
- package/addon/components/eui-super-date-picker/eui-quick-select-popover/eui-commonly-used-time-ranges.hbs +42 -0
- package/addon/components/eui-super-date-picker/eui-quick-select-popover/eui-quick-select.hbs +154 -0
- package/addon/components/eui-super-date-picker/eui-quick-select-popover/eui-quick-select.ts +103 -0
- package/addon/components/eui-super-date-picker/eui-quick-select-popover/eui-recently-used.hbs +48 -0
- package/addon/components/eui-super-date-picker/eui-quick-select-popover/index.hbs +60 -0
- package/addon/components/eui-super-date-picker/eui-quick-select-popover/index.ts +34 -0
- package/addon/components/eui-super-date-picker/eui-super-update-button.hbs +43 -0
- package/addon/components/eui-super-date-picker/index.hbs +123 -0
- package/addon/components/eui-super-date-picker/index.ts +220 -0
- package/addon/components/eui-super-date-picker/types/global.d.ts +52 -0
- package/addon/components/eui-super-date-picker/utils/date-utils.ts +59 -0
- package/addon/components/eui-super-date-picker/utils/index.ts +181 -0
- package/addon/components/eui-super-date-picker/utils/pretty-duration.ts +131 -0
- package/addon/components/eui-super-date-picker/utils/quick-select.ts +75 -0
- package/addon/components/eui-super-date-picker/utils/time-options.ts +216 -0
- package/addon/components/text-block/index.hbs +25 -21
- package/addon/{components/eui-i18n → i18n}/util.ts +1 -6
- package/addon/services/eui-i18n.ts +89 -0
- package/addon/utils/markdown/markdown-unified-plugins.d.ts +0 -14
- package/app/components/eui-super-date-picker/date-popover/absolute-tab.js +1 -0
- package/app/components/eui-super-date-picker/date-popover/datetime-picker.js +1 -0
- package/app/components/eui-super-date-picker/date-popover/eui-date-popover-button.js +1 -0
- package/app/components/eui-super-date-picker/date-popover/eui-date-popover-content.js +1 -0
- package/app/components/eui-super-date-picker/date-popover/now-tab.js +1 -0
- package/app/components/eui-super-date-picker/date-popover/relative-tab.js +1 -0
- package/app/components/eui-super-date-picker/eui-date-picker-range.js +1 -0
- package/app/components/eui-super-date-picker/eui-quick-select-popover/eui-commonly-used-time-ranges.js +1 -0
- package/app/components/eui-super-date-picker/eui-quick-select-popover/eui-quick-select.js +1 -0
- package/app/components/eui-super-date-picker/eui-quick-select-popover/eui-recently-used.js +1 -0
- package/app/components/eui-super-date-picker/eui-quick-select-popover/index.js +1 -0
- package/app/components/eui-super-date-picker/eui-super-update-button.js +1 -0
- package/app/components/eui-super-date-picker/index.js +1 -0
- package/app/services/eui-i18n.js +1 -0
- package/docs/forms/super-date-picker/demo/d01-picker.md +90 -0
- package/docs/forms/super-date-picker/index.md +16 -0
- package/package.json +6 -3
- package/tsconfig.json +1 -0
- package/addon/i18n/index.ts +0 -8
- package/app/i18n/index.js +0 -1
- package/docs/templates/super-date-picker/demo/d01-update-button.md +0 -10
- package/docs/templates/super-date-picker/demo/d02-quick-select-panels.md +0 -10
- package/docs/templates/super-date-picker/demo/d03-sizing.md +0 -10
- package/docs/templates/super-date-picker/demo/d04-auto-refresh.md +0 -11
- package/docs/templates/super-date-picker/demo/d05-elastic-pattern-with-kql.md +0 -10
- package/docs/templates/super-date-picker/index.md +0 -12
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import Service from '@ember/service';
|
|
2
|
+
import { action } from '@ember/object';
|
|
3
|
+
import { processStringToChildren } from '../i18n/util';
|
|
4
|
+
|
|
5
|
+
interface LookupTokenOptions {
|
|
6
|
+
token: string;
|
|
7
|
+
i18nMapping?: Record<string, string>;
|
|
8
|
+
valueDefault: string | ((values: Record<string, unknown>) => string);
|
|
9
|
+
values?: Record<string, unknown>;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function flatten(
|
|
13
|
+
acc: Record<string, unknown> = {},
|
|
14
|
+
obj: Record<string, unknown>,
|
|
15
|
+
path = ''
|
|
16
|
+
) {
|
|
17
|
+
path = path.length > 0 ? path + '.' : path;
|
|
18
|
+
|
|
19
|
+
for (const key in obj) {
|
|
20
|
+
if (typeof obj[key] === 'object' && obj[key] !== null) {
|
|
21
|
+
flatten(acc, obj[key] as Record<string, unknown>, path + key);
|
|
22
|
+
} else {
|
|
23
|
+
acc[path + key] = obj[key];
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return acc;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export default class EuiI18n extends Service {
|
|
30
|
+
translations = {};
|
|
31
|
+
@action addTranslations(translations: Record<string, unknown>) {
|
|
32
|
+
// TODO: deep merge?
|
|
33
|
+
this.translations = {
|
|
34
|
+
...this.translations,
|
|
35
|
+
...flatten({}, translations)
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
get mapping() {
|
|
40
|
+
return this.translations;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
@action
|
|
44
|
+
lookupToken(
|
|
45
|
+
token: string,
|
|
46
|
+
valueDefault: string | ((values: Record<string, unknown>) => string),
|
|
47
|
+
values?: Record<string, any>
|
|
48
|
+
): string | string[] {
|
|
49
|
+
return this._lookupToken({
|
|
50
|
+
token,
|
|
51
|
+
valueDefault,
|
|
52
|
+
values
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
getTokenFromMapping(
|
|
57
|
+
token: LookupTokenOptions['token'],
|
|
58
|
+
valueDefault: LookupTokenOptions['valueDefault'],
|
|
59
|
+
i18nMapping: LookupTokenOptions['i18nMapping']
|
|
60
|
+
) {
|
|
61
|
+
return (i18nMapping && i18nMapping[token]) || valueDefault;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
@action
|
|
65
|
+
_lookupToken(options: LookupTokenOptions) {
|
|
66
|
+
const {
|
|
67
|
+
token,
|
|
68
|
+
i18nMapping = this.mapping,
|
|
69
|
+
valueDefault,
|
|
70
|
+
values = {}
|
|
71
|
+
} = options;
|
|
72
|
+
|
|
73
|
+
let renderable = this.getTokenFromMapping(token, valueDefault, i18nMapping);
|
|
74
|
+
|
|
75
|
+
if (typeof renderable === 'function') {
|
|
76
|
+
renderable = renderable(values);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const children = processStringToChildren(renderable, values);
|
|
80
|
+
|
|
81
|
+
return children as string;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
declare module '@ember/service' {
|
|
86
|
+
interface Registry {
|
|
87
|
+
'eui-i18n': EuiI18n;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
@@ -6,22 +6,8 @@
|
|
|
6
6
|
* Side Public License, v 1.
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
declare module 'remark-emoji' {
|
|
10
|
-
import { Plugin } from 'unified';
|
|
11
|
-
const RemarkEmoji: Plugin;
|
|
12
|
-
export = RemarkEmoji;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
9
|
declare module 'remark-highlight.js' {
|
|
16
10
|
import { Plugin } from 'unified';
|
|
17
11
|
const RemarkHighlight: Plugin;
|
|
18
12
|
export = RemarkHighlight;
|
|
19
13
|
}
|
|
20
|
-
|
|
21
|
-
declare module 'mdast-util-to-hast/lib/all' {
|
|
22
|
-
import { Node } from 'unist';
|
|
23
|
-
import { H } from 'mdast-util-to-hast';
|
|
24
|
-
|
|
25
|
-
const all: (h: H, node: Node) => Node[];
|
|
26
|
-
export = all;
|
|
27
|
-
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@ember-eui/core/components/eui-super-date-picker/date-popover/absolute-tab';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@ember-eui/core/components/eui-super-date-picker/date-popover/datetime-picker';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@ember-eui/core/components/eui-super-date-picker/date-popover/eui-date-popover-button';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@ember-eui/core/components/eui-super-date-picker/date-popover/eui-date-popover-content';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@ember-eui/core/components/eui-super-date-picker/date-popover/now-tab';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@ember-eui/core/components/eui-super-date-picker/date-popover/relative-tab';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@ember-eui/core/components/eui-super-date-picker/eui-date-picker-range';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@ember-eui/core/components/eui-super-date-picker/eui-quick-select-popover/eui-commonly-used-time-ranges';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@ember-eui/core/components/eui-super-date-picker/eui-quick-select-popover/eui-quick-select';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@ember-eui/core/components/eui-super-date-picker/eui-quick-select-popover/eui-recently-used';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@ember-eui/core/components/eui-super-date-picker/eui-quick-select-popover/index';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@ember-eui/core/components/eui-super-date-picker/eui-super-update-button';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@ember-eui/core/components/eui-super-date-picker/index';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@ember-eui/core/services/eui-i18n';
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
---
|
|
2
|
+
order: 1
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
```hbs template
|
|
6
|
+
<EuiText size="s">
|
|
7
|
+
EuiSuperDatePicker should be resilient to invalid date values. You can try to break it with unexpected values here.
|
|
8
|
+
</EuiText>
|
|
9
|
+
|
|
10
|
+
<EuiSpacer />
|
|
11
|
+
|
|
12
|
+
<EuiFormControlLayoutDelimited>
|
|
13
|
+
<:prepend as |classes|>
|
|
14
|
+
<EuiFormLabel class={{classes}}>Dates</EuiFormLabel>
|
|
15
|
+
</:prepend>
|
|
16
|
+
|
|
17
|
+
<:startControl as |classes|>
|
|
18
|
+
<input
|
|
19
|
+
class={{concat classes " euiFieldText"}}
|
|
20
|
+
type="text"
|
|
21
|
+
placeholder="start"
|
|
22
|
+
value={{this.start}}
|
|
23
|
+
{{on "change" this.onStartInputChange}}
|
|
24
|
+
/>
|
|
25
|
+
</:startControl>
|
|
26
|
+
|
|
27
|
+
<:endControl as |classes|>
|
|
28
|
+
<input
|
|
29
|
+
class={{concat classes " euiFieldText"}}
|
|
30
|
+
type="text"
|
|
31
|
+
placeholder="end"
|
|
32
|
+
value={{this.end}}
|
|
33
|
+
{{on "change" this.onEndInputChange}}
|
|
34
|
+
/>
|
|
35
|
+
</:endControl>
|
|
36
|
+
</EuiFormControlLayoutDelimited>
|
|
37
|
+
|
|
38
|
+
<EuiSpacer />
|
|
39
|
+
|
|
40
|
+
<EuiSuperDatePicker
|
|
41
|
+
@onTimeChange={{this.onTimeChange}}
|
|
42
|
+
@start={{this.start}}
|
|
43
|
+
@end={{this.end}}
|
|
44
|
+
@isLoading={{this.isLoading}}
|
|
45
|
+
@onRefresh={{this.onRefresh}}
|
|
46
|
+
/>
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
```javascript component
|
|
50
|
+
import Component from '@glimmer/component';
|
|
51
|
+
import { tracked } from '@glimmer/tracking';
|
|
52
|
+
import { action } from '@ember/object';
|
|
53
|
+
|
|
54
|
+
export default class extends Component {
|
|
55
|
+
@tracked start = 'now-30m';
|
|
56
|
+
@tracked end = 'now';
|
|
57
|
+
@tracked isLoading = false;
|
|
58
|
+
|
|
59
|
+
@action onTimeChange({ start, end }) {
|
|
60
|
+
this.start = start;
|
|
61
|
+
this.end = end;
|
|
62
|
+
this.isLoading = true;
|
|
63
|
+
this.startLoading();
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
@action onRefresh({ start, end, refreshInterval }) {
|
|
67
|
+
return new Promise((resolve) => {
|
|
68
|
+
setTimeout(resolve, 100);
|
|
69
|
+
}).then(() => {
|
|
70
|
+
console.log(start, end, refreshInterval);
|
|
71
|
+
});
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
@action onStartInputChange(e) {
|
|
75
|
+
this.start = e.target.value;
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
@action onEndInputChange(e) {
|
|
79
|
+
this.end = e.target.value;
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
@action startLoading() {
|
|
83
|
+
setTimeout(this.stopLoading, 1000);
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
@action stopLoading() {
|
|
87
|
+
this.isLoading = false;
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
```
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Super date picker
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
<EuiSpacer/>
|
|
6
|
+
<EuiPageHeader @pageTitle="Super date picker"/>
|
|
7
|
+
|
|
8
|
+
<EuiSpacer />
|
|
9
|
+
|
|
10
|
+
<EuiText>
|
|
11
|
+
<p>
|
|
12
|
+
<strong>EuiSuperDatePicker</strong> is a complex date picker that supports relative and absolute dates.
|
|
13
|
+
It offers a convenient <EuiIcon type="calendar" color="primary" /> <strong>Quick select menu</strong> which includes
|
|
14
|
+
<strong>Commonly used dates</strong>, <strong>Recently used date ranges</strong> and <strong>Auto refresh</strong> features.
|
|
15
|
+
</p>
|
|
16
|
+
</EuiText>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ember-eui/core",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.10.0",
|
|
4
4
|
"description": "Ember Components for Elastic UI",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ember-addon",
|
|
@@ -52,6 +52,7 @@
|
|
|
52
52
|
]
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
55
|
+
"@elastic/datemath": "^5.0.3",
|
|
55
56
|
"@elastic/eui": "41.4.0",
|
|
56
57
|
"@ember/render-modifiers": "^2.0.4",
|
|
57
58
|
"@html-next/vertical-collection": "3.0.0",
|
|
@@ -94,7 +95,8 @@
|
|
|
94
95
|
},
|
|
95
96
|
"peerDependencies": {
|
|
96
97
|
"ember-auto-import": "^2.2.4",
|
|
97
|
-
"ember-focus-trap": "^1.0.1"
|
|
98
|
+
"ember-focus-trap": "^1.0.1",
|
|
99
|
+
"moment": "^2.29.3"
|
|
98
100
|
},
|
|
99
101
|
"devDependencies": {
|
|
100
102
|
"@ember/optional-features": "^2.0.0",
|
|
@@ -159,6 +161,7 @@
|
|
|
159
161
|
"loader.js": "^4.7.0",
|
|
160
162
|
"lodash-es": "^4.17.21",
|
|
161
163
|
"mdast-util-to-hast": "^10.0.0",
|
|
164
|
+
"moment": "^2.29.3",
|
|
162
165
|
"npm-run-all": "^4.1.5",
|
|
163
166
|
"prettier": "^2.5.1",
|
|
164
167
|
"qunit": "^2.17.2",
|
|
@@ -182,5 +185,5 @@
|
|
|
182
185
|
"volta": {
|
|
183
186
|
"extends": "../../package.json"
|
|
184
187
|
},
|
|
185
|
-
"gitHead": "
|
|
188
|
+
"gitHead": "f362b88c26b899191769be04f0a65e04eccc75ac"
|
|
186
189
|
}
|
package/tsconfig.json
CHANGED
package/addon/i18n/index.ts
DELETED
package/app/i18n/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from '@ember-eui/core/i18n';
|