@ember-eui/core 5.5.0 → 5.8.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 (225) hide show
  1. package/addon/components/eui-card/index.hbs +3 -3
  2. package/addon/components/eui-card/index.ts +26 -0
  3. package/addon/components/eui-described-form-group/index.hbs +5 -1
  4. package/addon/components/eui-i18n/index.hbs +33 -0
  5. package/addon/components/eui-i18n/index.ts +73 -0
  6. package/addon/components/eui-i18n/render.hbs +1 -0
  7. package/addon/components/eui-i18n/util.ts +127 -0
  8. package/addon/components/eui-pagination/button-wrapper/index.hbs +21 -0
  9. package/addon/components/eui-pagination/index.hbs +115 -0
  10. package/addon/components/eui-pagination/index.ts +177 -0
  11. package/addon/components/eui-pagination/next-button/index.hbs +27 -0
  12. package/addon/components/eui-pagination/previous-button/index.hbs +27 -0
  13. package/addon/components/eui-pagination-button/index.hbs +36 -0
  14. package/addon/i18n/index.ts +8 -0
  15. package/addon/utils/predicate/common_predicates.ts +37 -0
  16. package/addon/utils/predicate/index.ts +10 -0
  17. package/addon/utils/predicate/lodash_predicates.ts +27 -0
  18. package/app/components/eui-i18n/index.js +1 -0
  19. package/app/components/eui-i18n/render.js +1 -0
  20. package/app/components/eui-pagination/button-wrapper.js +1 -0
  21. package/app/components/eui-pagination/index.js +1 -0
  22. package/app/components/eui-pagination/next-button.js +1 -0
  23. package/app/components/eui-pagination/previous-button.js +1 -0
  24. package/app/components/eui-pagination-button/index.js +1 -0
  25. package/app/i18n/index.js +1 -0
  26. package/docs/display/{avatar-demo/demo1.md → avatar/demo/d01-basic.md} +0 -2
  27. package/docs/display/{avatar-demo/demo2.md → avatar/demo/d02-initials.md} +0 -0
  28. package/docs/display/{avatar-demo/demo3.md → avatar/demo/d03-types.md} +0 -0
  29. package/docs/display/{avatar-demo/demo4.md → avatar/demo/d04-icons.md} +0 -0
  30. package/docs/display/{avatar-demo/demo5.md → avatar/demo/d05-disabled.md} +0 -0
  31. package/docs/display/{avatar.md → avatar/index.md} +5 -0
  32. package/docs/display/{badge-demo/demo1.md → badge/demo/d01-badge.md} +0 -0
  33. package/docs/display/{badge-demo/demo2.md → badge/demo/d02-badge-with-icon.md} +0 -0
  34. package/docs/display/{badge-demo/demo3.md → badge/demo/d03-badge-with-onclick-events.md} +0 -0
  35. package/docs/display/{badge-demo/demo4.md → badge/demo/d04-badge-for-health-status.md} +0 -0
  36. package/docs/display/{badge-demo/demo5.md → badge/demo/d05-badge-with-href.md} +0 -0
  37. package/docs/display/{badge-demo/demo7.md → badge/demo/d06-badge-groups-and-truncation.md} +0 -0
  38. package/docs/display/{badge-demo/demo6.md → badge/demo/d07-beta-badge-type.md} +0 -0
  39. package/docs/display/{badge-demo/demo8.md → badge/demo/d08-notification-badge-type.md} +0 -0
  40. package/docs/display/{badge.md → badge/index.md} +5 -0
  41. package/docs/display/{callout-demo/demo1.md → callout/demo/d01-info.md} +0 -0
  42. package/docs/display/{callout-demo/demo2.md → callout/demo/d02-success.md} +0 -0
  43. package/docs/display/{callout-demo/demo3.md → callout/demo/d03-warning.md} +0 -0
  44. package/docs/display/{callout-demo/demo4.md → callout/demo/d04-danger.md} +0 -0
  45. package/docs/display/{callout.md → callout/index.md} +6 -1
  46. package/docs/display/card/{basic-card-demo/demo1.md → demo/d01-basic-card.md} +5 -1
  47. package/docs/display/card/{layout-demo/demo1.md → demo/d02-layout.md} +4 -0
  48. package/docs/display/card/{images-demo/demo1.md → demo/d03-images.md} +1 -1
  49. package/docs/display/card/{footer-demo/demo1.md → demo/d04-footer.md} +4 -0
  50. package/docs/display/card/{beta-badge-demo/demo1.md → demo/d05-beta-badge.md} +4 -0
  51. package/docs/display/card/{selectable-demo/demo1.md → demo/d06-selectable.md} +5 -1
  52. package/docs/display/card/{checkable-demo/demo1.md → demo/d07-checkable.md} +1 -1
  53. package/docs/display/card/{checkable-demo/demo2.md → demo/d07.1-cheekable.md} +1 -1
  54. package/docs/display/card/{custom-children-demo/demo1.md → demo/d08-custom-children.md} +5 -1
  55. package/docs/display/card/index.md +14 -0
  56. package/docs/display/{comment-list-demo/demo1.md → comment-list/demo/d01-comment-list.md} +28 -22
  57. package/docs/display/{comment-list.md → comment-list/index.md} +6 -0
  58. package/docs/display/{description-list-demo/demo1.md → description-list/demo/d01-description-list.md} +0 -0
  59. package/docs/display/{description-list-demo/demo2.md → description-list/demo/d02-reverse-style.md} +0 -0
  60. package/docs/display/{description-list-demo/demo3.md → description-list/demo/d03-as-columns.md} +0 -0
  61. package/docs/display/{description-list-demo/demo4.md → description-list/demo/d04-inline.md} +0 -0
  62. package/docs/display/{description-list-demo/demo5.md → description-list/demo/d05-centered-and-compressed.md} +0 -0
  63. package/docs/display/{description-list-demo/demo6.md → description-list/demo/d06-passing-classname.md} +0 -0
  64. package/docs/display/{description-list.md → description-list/index.md} +6 -0
  65. package/docs/display/{empty-prompt-demo/demo1.md → empty-prompt/demo/d01-empty-prompt.md} +0 -0
  66. package/docs/display/{empty-prompt-demo/demo2.md → empty-prompt/demo/d02-less-content-more-actions.md} +0 -0
  67. package/docs/display/{empty-prompt-demo/demo3.md → empty-prompt/demo/d03-panel-options.md} +0 -0
  68. package/docs/display/{empty-prompt-demo/demo4.md → empty-prompt/demo/d04-title-sizes-and-icon-colors.md} +0 -0
  69. package/docs/display/{empty-prompt-demo/demo5.md → empty-prompt/demo/d05-loading-and-error-prompts.md} +0 -0
  70. package/docs/display/{empty-prompt-demo/demo6.md → empty-prompt/demo/d06-layout.md} +0 -0
  71. package/docs/display/{empty-prompt-demo/demo7.md → empty-prompt/demo/d07-more-types-of-empty-states.md} +0 -0
  72. package/docs/display/{empty-prompt-demo/demo8.md → empty-prompt/demo/d08-using-in-a-page-template.md} +0 -0
  73. package/docs/display/empty-prompt/index.md +13 -0
  74. package/docs/display/{health-demo/demo1.md → health/demo/d01-health.md} +0 -0
  75. package/docs/display/{health-demo/demo2.md → health/demo/d02-text-sizes.md} +0 -0
  76. package/docs/display/health/index.md +13 -0
  77. package/docs/display/{icons-demo/demo1.md → icons/demo/d01-glyphs.md} +0 -0
  78. package/docs/display/{icons-demo/demo2.md → icons/demo/d02-editor-controls.md} +0 -0
  79. package/docs/display/{icons-demo/demo3.md → icons/demo/d03-elastic-logos.md} +0 -0
  80. package/docs/display/{icons-demo/demo4.md → icons/demo/d04-apps.md} +0 -0
  81. package/docs/display/{icons-demo/demo5.md → icons/demo/d05-tokens.md} +0 -0
  82. package/docs/display/{icons-demo/demo6.md → icons/demo/d06-sizes.md} +0 -0
  83. package/docs/display/{icons-demo/demo7.md → icons/demo/d07-colors.md} +0 -0
  84. package/docs/display/{icons-demo/demo8.md → icons/demo/d08-custom-svgs.md} +0 -0
  85. package/docs/display/{icons.md → icons/index.md} +5 -0
  86. package/docs/display/{image-demo/demo1.md → image/demo/d01-image.md} +0 -0
  87. package/docs/display/{image-demo/demo2.md → image/demo/d02-click-an-image-for-a-fullscreen-version.md} +0 -0
  88. package/docs/display/{image-demo/demo3.md → image/demo/d03-images-can-be-sized.md} +0 -0
  89. package/docs/display/{image-demo/demo4.md → image/demo/d04-float-images-within-text.md} +0 -0
  90. package/docs/display/{image.md → image/index.md} +5 -1
  91. package/docs/display/list-group/demo/d01-list-group.md +236 -0
  92. package/docs/display/list-group/index.md +8 -0
  93. package/docs/display/loading/logo-demo/{demo1.md → d01-logos.md} +0 -0
  94. package/docs/display/loading/spinner-demo/d02-spinner.md +6 -0
  95. package/docs/display/loading/text-content-demo/{demo1.md → d3-text-content.md} +0 -2
  96. package/docs/display/notification-event/demo/{demo1.md → d01-notification-event.md} +15 -24
  97. package/docs/display/notification-event/demo/{demo2.md → d02-read-state.md} +0 -0
  98. package/docs/display/notification-event/demo/{demo3.md → d03-feed.md} +0 -0
  99. package/docs/display/notification-event/index.md +2 -2
  100. package/docs/display/{progress-demo → progress/demo}/demo1.md +0 -0
  101. package/docs/display/{progress-demo → progress/demo}/demo2.md +0 -0
  102. package/docs/display/{progress-demo → progress/demo}/demo3.md +0 -0
  103. package/docs/display/{progress-demo → progress/demo}/demo4.md +0 -0
  104. package/docs/display/progress/index.md +7 -0
  105. package/docs/display/stat-demo/{demo1.md → demo/d01-stat.md} +0 -0
  106. package/docs/display/stat-demo/{demo2.md → demo/d02-applying-color.md} +0 -0
  107. package/docs/display/stat-demo/{demo3.md → demo/d03-text-alignment.md} +0 -0
  108. package/docs/display/stat-demo/{demo4.md → demo/d04-title-size.md} +0 -0
  109. package/docs/display/stat-demo/{demo5.md → demo/d05-reverse-the-order.md} +0 -0
  110. package/docs/display/stat-demo/{demo6.md → demo/d06-stat-loading.md} +0 -0
  111. package/docs/display/stat-demo/{demo7.md → demo/d07-putting-it-all-together.md} +0 -0
  112. package/docs/display/{stat.md → stat-demo/index.md} +5 -0
  113. package/docs/display/{text-demo/demo1.md → text/demo/d01-text.md} +0 -0
  114. package/docs/display/{text-demo/demo2.md → text/demo/d02-coloring-text.md} +0 -0
  115. package/docs/display/{text-demo/demo3.md → text/demo/d03-alignment.md} +0 -0
  116. package/docs/display/{text.md → text/index.md} +6 -1
  117. package/docs/display/{title-demo/demo1.md → title/demo/d01-title.md} +0 -0
  118. package/docs/display/title/index.md +6 -0
  119. package/docs/display/toast/{toast-list-demo/demo1.md → demo/d01-toast.md} +11 -13
  120. package/docs/display/{tool-tip.md → toast/index.md} +6 -1
  121. package/docs/display/{tool-tip-demo/demo1.md → tool-tip/demo/d01-tool-tip.md} +0 -3
  122. package/docs/display/{tool-tip-demo/demo2.md → tool-tip/demo/d02-wrapping-components.md} +0 -0
  123. package/docs/display/{tool-tip-demo/demo3.md → tool-tip/demo/d03-icontip.md} +0 -0
  124. package/docs/display/{tool-tip-demo/demo4.md → tool-tip/demo/d04-attaching-to.md} +0 -0
  125. package/docs/display/tool-tip/index.md +10 -0
  126. package/docs/editors/code/{inline-demo/demo1.md → demo/d01-inline.md} +1 -1
  127. package/docs/editors/code/{code-block-demo/demo1.md → demo/d02-code-block.md} +1 -1
  128. package/docs/editors/code/{code-block-demo/demo5.md → demo/d03-line-numbers.md} +1 -1
  129. package/docs/editors/code/{code-block-demo/demo2.md → demo/d04-copy.md} +1 -1
  130. package/docs/editors/code/{code-block-demo/demo3.md → demo/d05-overflow-height.md} +1 -1
  131. package/docs/editors/code/{code-block-demo/demo4.md → demo/d06-white-space.md} +1 -1
  132. package/docs/editors/code/{code-block-demo/demo6.md → demo/d07-line-numbers-highlighted.md} +1 -1
  133. package/docs/editors/code/{code-block-demo/demo7.md → demo/d08-code-block-virtualization.md} +1 -1
  134. package/docs/editors/code/{code-block-demo/demo8.md → demo/d09-flyout.md} +1 -1
  135. package/docs/editors/code/{code-block.md → index.md} +8 -3
  136. package/docs/editors/markdown-editor/base-editor-demo/demo1.md +1 -4
  137. package/docs/editors/markdown-editor/base-editor.md +2 -1
  138. package/docs/forms/{form-controls/combo-box → combo-box}/demo/demo1.md +0 -2
  139. package/docs/forms/{form-controls/combo-box → combo-box}/demo/demo2.md +0 -0
  140. package/docs/forms/{form-controls/combo-box → combo-box}/demo/demo3.md +0 -0
  141. package/docs/forms/{form-controls/combo-box → combo-box}/demo/demo4.md +0 -0
  142. package/docs/forms/{form-controls/combo-box → combo-box}/demo/demo5.md +0 -0
  143. package/docs/forms/{form-controls/combo-box → combo-box}/index.md +1 -0
  144. package/docs/forms/form-controls/checkbox/index.md +1 -0
  145. package/docs/forms/form-controls/checkbox-group/index.md +1 -0
  146. package/docs/forms/form-controls/file-picker/index.md +1 -1
  147. package/docs/forms/form-controls/form-control-layout/demo/demo1.md +85 -69
  148. package/docs/forms/form-controls/form-control-layout/index.md +1 -0
  149. package/docs/forms/form-controls/form-control-layout-delimited/demo/demo1.md +0 -2
  150. package/docs/forms/form-controls/form-control-layout-delimited/index.md +1 -0
  151. package/docs/forms/form-controls/number-field/index.md +1 -0
  152. package/docs/forms/form-controls/password-field/index.md +1 -0
  153. package/docs/forms/form-controls/radio/index.md +1 -0
  154. package/docs/forms/form-controls/radio-group/index.md +1 -1
  155. package/docs/forms/form-controls/range/index.md +1 -0
  156. package/docs/forms/form-controls/search-field/index.md +1 -1
  157. package/docs/forms/form-controls/select/index.md +1 -1
  158. package/docs/forms/form-controls/switch/index.md +1 -0
  159. package/docs/forms/form-controls/text-field/index.md +1 -1
  160. package/docs/forms/form-controls/textarea/index.md +2 -0
  161. package/docs/forms/form-layouts/described-form-groups.md +2 -1
  162. package/docs/layout/accordion/index.md +14 -13
  163. package/docs/layout/bottom-bar/index.md +2 -1
  164. package/docs/layout/flex/index.md +8 -7
  165. package/docs/layout/flyout/index.md +2 -1
  166. package/docs/layout/header/index.md +2 -1
  167. package/docs/layout/horizontal-rule/horizontal-rule.md +2 -1
  168. package/docs/layout/modal/index.md +1 -1
  169. package/docs/layout/page-header/index.md +2 -1
  170. package/docs/layout/panel/index.md +1 -0
  171. package/docs/layout/popover/index.md +2 -1
  172. package/docs/layout/resizable-container/index.md +2 -1
  173. package/docs/layout/spacer/index.md +2 -1
  174. package/docs/navigation/breadcrumbs/demo/d01-basic.md +5 -7
  175. package/docs/navigation/button/index.md +2 -1
  176. package/docs/navigation/collapsible-nav.md +2 -1
  177. package/docs/navigation/key-pad-menu-demo/demo1.md +0 -2
  178. package/docs/navigation/key-pad-menu.md +2 -1
  179. package/docs/navigation/link-demo/demo1.md +0 -2
  180. package/docs/navigation/link.md +2 -1
  181. package/docs/navigation/pagination/demo/d01-basic.md +27 -0
  182. package/docs/navigation/pagination/index.md +8 -0
  183. package/docs/navigation/side-nav-demo/demo1.md +6 -5
  184. package/docs/navigation/side-nav.md +2 -1
  185. package/docs/navigation/steps.md +2 -1
  186. package/docs/navigation/tabs.md +1 -0
  187. package/docs/templates/page-template/index.md +4 -2
  188. package/docs/templates/sitewide-search/index.md +2 -1
  189. package/docs/templates/super-date-picker/index.md +1 -1
  190. package/docs/utilities/auto-sizer-demo/demo1.md +0 -2
  191. package/docs/utilities/auto-sizer.md +2 -1
  192. package/docs/utilities/copy-demo/demo1.md +0 -2
  193. package/docs/utilities/copy.md +2 -1
  194. package/docs/utilities/i18n/demo/d01-basic.md +32 -0
  195. package/docs/utilities/i18n/index.md +8 -0
  196. package/docs/utilities/mutation-observer-demo/demo1.md +9 -6
  197. package/docs/utilities/mutation-observer.md +2 -1
  198. package/docs/utilities/outside-click-detector-demo/demo1.md +1 -3
  199. package/docs/utilities/outside-click-detector.md +2 -1
  200. package/docs/utilities/overlay-mask-demo/demo1.md +3 -5
  201. package/docs/utilities/overlay-mask.md +2 -1
  202. package/docs/utilities/portal-demo/demo1.md +1 -1
  203. package/docs/utilities/portal-demo/demo2.md +15 -14
  204. package/docs/utilities/portal.md +2 -1
  205. package/docs/utilities/resize-observer-demo/demo1.md +26 -15
  206. package/docs/utilities/resize-observer.md +2 -1
  207. package/docs/utilities/responsive.md +2 -1
  208. package/package.json +3 -3
  209. package/docs/display/card/basic-card.md +0 -9
  210. package/docs/display/card/beta-badge.md +0 -9
  211. package/docs/display/card/checkable.md +0 -9
  212. package/docs/display/card/custom-children.md +0 -9
  213. package/docs/display/card/footer.md +0 -9
  214. package/docs/display/card/images.md +0 -9
  215. package/docs/display/card/layout.md +0 -9
  216. package/docs/display/card/selectable.md +0 -9
  217. package/docs/display/empty-prompt.md +0 -2
  218. package/docs/display/health.md +0 -9
  219. package/docs/display/list-group-demo/demo1.md +0 -171
  220. package/docs/display/list-group.md +0 -1
  221. package/docs/display/loading/spinner-demo/demo1.md +0 -8
  222. package/docs/display/progress.md +0 -1
  223. package/docs/display/title.md +0 -1
  224. package/docs/display/toast/toast-list.md +0 -1
  225. package/docs/editors/code/inline.md +0 -1
@@ -30,7 +30,7 @@
30
30
  >
31
31
 
32
32
  {{#if (or (has-block "icon") (or @image @icon))}}
33
- <div class="euiCard__top">
33
+ <div class={{this.topClasses}}>
34
34
  {{#if (has-block "icon")}}
35
35
  {{yield "euiCard__icon" to="icon"}}
36
36
  {{else}}
@@ -53,7 +53,7 @@
53
53
  {{/if}}
54
54
 
55
55
 
56
- <div class="euiCard__content">
56
+ <div class={{this.contentClasses}}>
57
57
  <EuiTitle class="euiCard__title" @size={{arg-or-default @titleSize "s"}}>
58
58
  {{#if (has-block "title")}}
59
59
  {{yield (set this "link") to="title"}}
@@ -122,7 +122,7 @@
122
122
  </span>
123
123
  {{/if}}
124
124
  {{#if (and (eq layout "vertical") (or (has-block "footer") @footer))}}
125
- <div class="euiCard__footer">
125
+ <div class={{this.footerClasses}}>
126
126
  {{#if (has-block "footer")}}
127
127
  {{yield to="footer"}}
128
128
  {{else}}
@@ -4,6 +4,20 @@ import { EuiCardSelectProps, euiCardSelectableColor } from '../eui-card-select';
4
4
 
5
5
  type EuiCardComponentArgs = {
6
6
  selectable?: EuiCardSelectProps;
7
+ /**
8
+ * Class that will apply to the card top section.
9
+ */
10
+ topClassName?: string;
11
+
12
+ /**
13
+ * Class that will apply to the card content section.
14
+ */
15
+ contentClassName?: string;
16
+
17
+ /**
18
+ * Class that will apply to the card footer section.
19
+ */
20
+ footerClassName?: string;
7
21
  };
8
22
 
9
23
  export default class EuiCardComponent extends Component<EuiCardComponentArgs> {
@@ -24,4 +38,16 @@ export default class EuiCardComponent extends Component<EuiCardComponentArgs> {
24
38
  )}`
25
39
  : undefined;
26
40
  }
41
+
42
+ get topClasses(): string {
43
+ return ['euiCard__top', this.args.topClassName].join(' ');
44
+ }
45
+
46
+ get contentClasses(): string {
47
+ return ['euiCard__content', this.args.contentClassName].join(' ');
48
+ }
49
+
50
+ get footerClasses(): string {
51
+ return ['euiCard__footer', this.args.footerClassName].join(' ');
52
+ }
27
53
  }
@@ -8,7 +8,11 @@
8
8
  >
9
9
  <EuiFlexGroup @gutterSize={{arg-or-default @gutterSize "l"}}>
10
10
  <EuiFlexItem @grow={{@descriptionFlexItemProps.grow}}>
11
- <EuiTitle class="euiDescribedFormGroup__title" @size={{@titleSize}}>
11
+ <EuiTitle
12
+ class="euiDescribedFormGroup__title"
13
+ @size={{@titleSize}}
14
+ @tagName={{@titleTagName}}
15
+ >
12
16
  {{yield to="title"}}
13
17
  </EuiTitle>
14
18
  <EuiText
@@ -0,0 +1,33 @@
1
+ {{#let this.lookupedTokens as |result|}}
2
+ {{#if this.isI18nTokensShape}}
3
+ {{#if this.i18n.renderComponent}}
4
+ {{yield
5
+ (component
6
+ (ensure-safe-component this.i18n.renderComponent) tokens=result
7
+ )
8
+ }}
9
+ {{else}}
10
+ {{#each
11
+ (if (not-eq (type-of result) "array") (array result) result)
12
+ as |token index|
13
+ }}
14
+ {{yield (component "eui-i18n/render" token=token) index result}}
15
+ {{/each}}
16
+ {{/if}}
17
+ {{else}}
18
+ {{#if this.i18n.renderComponent}}
19
+ {{yield
20
+ (component
21
+ (ensure-safe-component this.i18n.renderComponent) tokens=result
22
+ )
23
+ }}
24
+ {{else}}
25
+ {{#each
26
+ (if (not-eq (type-of result) "array") (array result) result)
27
+ as |token index|
28
+ }}
29
+ {{yield (component "eui-i18n/render" token=token) index result}}
30
+ {{/each}}
31
+ {{/if}}
32
+ {{/if}}
33
+ {{/let}}
@@ -0,0 +1,73 @@
1
+ import Component from '@glimmer/component';
2
+ import { processStringToChildren } from './util';
3
+ //@ts-ignore
4
+ import { i18n, I18nShape } from '@ember-eui/core/i18n';
5
+
6
+ interface Args {
7
+ tokens?: string[];
8
+ defaults?: string[];
9
+ token?: string;
10
+ default?: string;
11
+ values?: { [key: string]: any };
12
+ i18n?: I18nShape;
13
+ }
14
+
15
+ interface lookupTokenOptions {
16
+ token: string;
17
+ i18nMapping: I18nShape['mapping'];
18
+ valueDefault: string;
19
+ i18nMappingFunc?: (token: string) => string;
20
+ values?: { [key: string]: any };
21
+ render?: I18nShape['render'];
22
+ }
23
+
24
+ function lookupToken(options: lookupTokenOptions) {
25
+ const {
26
+ token,
27
+ i18nMapping,
28
+ valueDefault,
29
+ i18nMappingFunc,
30
+ values = {}
31
+ } = options;
32
+
33
+ let renderable = (i18nMapping && i18nMapping[token]) || valueDefault;
34
+
35
+ const children = processStringToChildren(renderable, values, i18nMappingFunc);
36
+ if (typeof children === 'string') {
37
+ // likewise, `processStringToChildren` returns a string or ReactChild[] depending on
38
+ // the type of `values`, so we will make the assumption that the default value is correct.
39
+ return children;
40
+ }
41
+
42
+ // same reasons as above, we can't promise the transforms match the default's type
43
+ return children;
44
+ }
45
+
46
+ export default class EuiI18nComponent extends Component<Args> {
47
+ get isI18nTokensShape() {
48
+ return this.args.tokens != null;
49
+ }
50
+
51
+ get i18n() {
52
+ return this.args.i18n || i18n;
53
+ }
54
+
55
+ get lookupedTokens() {
56
+ if (this.isI18nTokensShape) {
57
+ return this.args.tokens?.map((token, idx) =>
58
+ lookupToken({
59
+ token,
60
+ i18nMapping: i18n.mapping,
61
+ valueDefault: this.args.defaults![idx]
62
+ })
63
+ );
64
+ } else {
65
+ return lookupToken({
66
+ token: this.args.token!,
67
+ i18nMapping: i18n.mapping,
68
+ valueDefault: this.args.default!,
69
+ values: this.args.values
70
+ });
71
+ }
72
+ }
73
+ }
@@ -0,0 +1 @@
1
+ {{yield @token}}
@@ -0,0 +1,127 @@
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
+
9
+ import {
10
+ isBoolean,
11
+ isString,
12
+ isNumber,
13
+ isUndefined
14
+ } from '../../utils/predicate';
15
+ import { get } from '@ember/object';
16
+ import { assert } from '@ember/debug';
17
+
18
+ function isPrimitive(value: any) {
19
+ return (
20
+ isBoolean(value) || isString(value) || isNumber(value) || isUndefined(value)
21
+ );
22
+ }
23
+
24
+ type Child = string | { propName: string };
25
+
26
+ function hasPropName(child: Child): child is { propName: string } {
27
+ return child
28
+ ? typeof child === 'object' && child.hasOwnProperty('propName')
29
+ : false;
30
+ }
31
+
32
+ function isElement(value: any) {
33
+ return value.hasOwnProperty('propName') && !isPrimitive(value);
34
+ }
35
+
36
+ /**
37
+ * Replaces placeholder values in `input` with their matching value in `values`
38
+ * e.g. input:'Hello, {name}' will replace `{name}` with `values[name]`
39
+ * @param {string} input
40
+ * @param {RenderableValues} values
41
+ * @param {Function} i18nMappingFunc
42
+ * @returns {string | React.ReactChild[]}
43
+ */
44
+ export function processStringToChildren(
45
+ input: string,
46
+ values: { [key: string]: any },
47
+ i18nMappingFunc?: (token: string) => string
48
+ ): any[] | string {
49
+ const children: any[] = [];
50
+
51
+ let child: Child | undefined = { propName: '' };
52
+
53
+ function appendCharToChild(char: string) {
54
+ if (child === undefined) {
55
+ // starting a new string literal
56
+ child = char;
57
+ } else if (typeof child === 'string') {
58
+ // existing string literal
59
+ child = child + char;
60
+ } else if (hasPropName(child)) {
61
+ // adding to the propName of a values lookup
62
+ child.propName = child.propName + char;
63
+ }
64
+ }
65
+
66
+ function appendValueToChildren(value?: Child) {
67
+ if (value === undefined) {
68
+ return;
69
+ } else if (hasPropName(value)) {
70
+ // an array with any ReactElements will be kept as an array
71
+ // so they need to be assigned a key
72
+ // children.push(cloneElement(value, { key: children.length }));
73
+ children.push(value.propName);
74
+ } else if (isElement(value)) {
75
+ // this won't be called, propName children are converted to a ReactChild before calling this
76
+ } else {
77
+ // everything else can go straight in
78
+ if (i18nMappingFunc !== undefined && typeof value === 'string') {
79
+ value = i18nMappingFunc(value);
80
+ }
81
+ children.push(value);
82
+ }
83
+ }
84
+
85
+ // if we don't encounter a non-primitive
86
+ // then `children` can be concatenated together at the end
87
+ let encounteredNonPrimitive = false;
88
+ for (let i = 0; i < input.length; i++) {
89
+ const char = input[i];
90
+
91
+ if (char === '\\') {
92
+ // peek at the next character to know if this is an escape
93
+ const nextChar = input[i + 1];
94
+ let charToAdd = char; // if this isn't an escape sequence then we will add the backslash
95
+
96
+ if (nextChar === '{' || nextChar === '}') {
97
+ // escaping a brace
98
+ i += 1; // advance passed the brace
99
+ charToAdd = input[i];
100
+ }
101
+ appendCharToChild(charToAdd);
102
+ } else if (char === '{') {
103
+ appendValueToChildren(child);
104
+ child = { propName: '' };
105
+ } else if (char === '}') {
106
+ const propName = (child as { propName: string }).propName as string;
107
+ if (get(values, propName) === undefined) {
108
+ assert(
109
+ `Key "${propName}" not found in ${JSON.stringify(values, null, 2)}`,
110
+ true
111
+ );
112
+ }
113
+ const propValue = values[propName];
114
+ encounteredNonPrimitive =
115
+ encounteredNonPrimitive || !isPrimitive(propValue);
116
+ appendValueToChildren(propValue);
117
+ child = undefined;
118
+ } else {
119
+ appendCharToChild(char);
120
+ }
121
+ }
122
+
123
+ // include any remaining child value
124
+ appendValueToChildren(child);
125
+
126
+ return encounteredNonPrimitive ? children : children.join('');
127
+ }
@@ -0,0 +1,21 @@
1
+ {{#if (arg-or-default @inList true)}}
2
+ <li>
3
+ <EuiPaginationButton
4
+ @isActive={{eq @pageIndex @props.activePage}}
5
+ @totalPages={{@props.pageCount}}
6
+ @pageIndex={{@pageIndex}}
7
+ aria-controls={{@props.ariaControls}}
8
+ @hideOnMobile={{true}}
9
+ {{on "click" (fn @props.safeClick @pageIndex)}}
10
+ />
11
+ </li>
12
+ {{else}}
13
+ <EuiPaginationButton
14
+ @isActive={{eq @pageIndex @props.activePage}}
15
+ @totalPages={{@props.pageCount}}
16
+ @pageIndex={{@pageIndex}}
17
+ aria-controls={{@props.ariaControls}}
18
+ @hideOnMobile={{true}}
19
+ {{on "click" (fn @props.safeClick @pageIndex)}}
20
+ />
21
+ {{/if}}
@@ -0,0 +1,115 @@
1
+ {{#if @compressed}}
2
+ <nav class="euiPagination" ...attributes>
3
+ <EuiPagination::PreviousButton
4
+ @activePage={{this.activePage}}
5
+ @safeClick={{this.safeClick}}
6
+ @props={{this.prevPageButtonProps}}
7
+ />
8
+ <EuiHideFor @sizes={{array "xs" "s"}}>
9
+ <EuiText @size="s" class="euiPagination__compressedText">
10
+ <EuiI18n
11
+ @token="euiPagination.pageOfTotalCompressed"
12
+ @default="{page} of {total}"
13
+ @values={{hash
14
+ page=(component
15
+ "eui-pagination/button-wrapper"
16
+ pageIndex=this.activePage
17
+ props=this.sharedButtonProps
18
+ inList=false
19
+ )
20
+ total=(component
21
+ "eui-pagination/button-wrapper"
22
+ pageIndex=(sub this.pageCount 1)
23
+ props=this.sharedButtonProps
24
+ inList=false
25
+ )
26
+ }}
27
+ as |Token|
28
+ >
29
+ <Token as |value|>
30
+ {{value}}
31
+ </Token>
32
+ </EuiI18n>
33
+ </EuiText>
34
+ </EuiHideFor>
35
+ <EuiPagination::NextButton
36
+ @activePage={{this.activePage}}
37
+ @safeClick={{this.safeClick}}
38
+ @props={{this.nextPageButtonProps}}
39
+ />
40
+ </nav>
41
+ {{else}}
42
+ {{!template-lint-disable no-duplicate-landmark-elements}}
43
+ <nav class="euiPagination" ...attributes>
44
+ <EuiPagination::PreviousButton
45
+ @activePage={{this.activePage}}
46
+ @safeClick={{this.safeClick}}
47
+ @props={{this.prevPageButtonProps}}
48
+ />
49
+ <ul class="euiPagination__list">
50
+ {{#each this.firstPageButtons as |page|}}
51
+ {{#if page.i18n}}
52
+ <EuiI18n
53
+ @token="euiPagination.firstRangeAriaLabel"
54
+ @default="Skipping pages 2 to {lastPage}"
55
+ @values={{hash lastPage=this.firstPageInRange}}
56
+ as |Token|
57
+ >
58
+ <Token as |firstRangeAriaLabel|>
59
+ <li
60
+ aria-label={{firstRangeAriaLabel}}
61
+ class="euiPaginationButton-isPlaceholder euiPagination__item"
62
+ >
63
+ &hellip;
64
+ </li>
65
+ </Token>
66
+ </EuiI18n>
67
+ {{else}}
68
+ <EuiPagination::ButtonWrapper
69
+ @pageIndex={{page.pageIndex}}
70
+ @props={{this.sharedButtonProps}}
71
+ />
72
+ {{/if}}
73
+ {{/each}}
74
+ {{#each this.pages as |page|}}
75
+ <EuiPagination::ButtonWrapper
76
+ @pageIndex={{page.pageIndex}}
77
+ @props={{this.sharedButtonProps}}
78
+ />
79
+ {{/each}}
80
+ {{#each this.lastPageButtons as |page|}}
81
+ {{#if page.i18n}}
82
+ <EuiI18n
83
+ @token="euiPagination.lastRangeAriaLabel"
84
+ @default="Skipping pages {firstPage} to {lastPage}"
85
+ @values={{hash
86
+ firstPage=(add this.lastPageInRange 1)
87
+ lastPage=(sub this.pageCount 1)
88
+ }}
89
+ as |Token|
90
+ >
91
+ <Token as |lastRangeAriaLabel|>
92
+ <li
93
+ aria-label={{lastRangeAriaLabel}}
94
+ class="euiPaginationButton-isPlaceholder euiPagination__item"
95
+ >
96
+ &hellip;
97
+ </li>
98
+ </Token>
99
+ </EuiI18n>
100
+ {{else}}
101
+ <EuiPagination::ButtonWrapper
102
+ @pageIndex={{page.pageIndex}}
103
+ @props={{this.sharedButtonProps}}
104
+ />
105
+ {{/if}}
106
+ {{/each}}
107
+ </ul>
108
+ <EuiPagination::NextButton
109
+ @activePage={{this.activePage}}
110
+ @safeClick={{this.safeClick}}
111
+ @props={{this.nextPageButtonProps}}
112
+ />
113
+ </nav>
114
+
115
+ {{/if}}
@@ -0,0 +1,177 @@
1
+ import Component from '@glimmer/component';
2
+
3
+ export type PageClickHandler = (pageIndex: number) => void;
4
+ type SafeClickHandler = (pageIndex: number) => void;
5
+
6
+ interface Args {
7
+ /**
8
+ * The total number of pages.
9
+ */
10
+ pageCount?: number;
11
+
12
+ /**
13
+ * The current page using a zero based index.
14
+ * So if you set the activePage to 1, it will activate the second page.
15
+ */
16
+ activePage?: number;
17
+
18
+ onPageClick?: PageClickHandler;
19
+
20
+ /**
21
+ * If true, will only show next/prev arrows instead of page numbers.
22
+ */
23
+ compressed?: boolean;
24
+
25
+ /**
26
+ * If passed in, passes value through to each button to set aria-controls
27
+ */
28
+ 'aria-controls'?: string;
29
+ ariaControls?: string;
30
+ }
31
+ const MAX_VISIBLE_PAGES = 5;
32
+ const NUMBER_SURROUNDING_PAGES = Math.floor(MAX_VISIBLE_PAGES * 0.5);
33
+
34
+ export default class EuiPaginationComponent extends Component<Args> {
35
+ get pageCount() {
36
+ return this.args.pageCount ?? 1;
37
+ }
38
+
39
+ get activePage() {
40
+ return this.args.activePage ?? 0;
41
+ }
42
+
43
+ get ariaControls() {
44
+ return this.args['aria-controls'] || this.args.ariaControls;
45
+ }
46
+
47
+ get hasControl() {
48
+ return this.ariaControls !== undefined;
49
+ }
50
+
51
+ get pages() {
52
+ let pages = [];
53
+ const { firstPageInRange, lastPageInRange } = this;
54
+ for (
55
+ let i = firstPageInRange, index = 0;
56
+ i < lastPageInRange;
57
+ i++, index++
58
+ ) {
59
+ pages.push({
60
+ pageIndex: i
61
+ });
62
+ }
63
+
64
+ return pages;
65
+ }
66
+
67
+ get firstPageButtons() {
68
+ let firstPageButtons = [];
69
+ if (this.firstPageInRange > 0) {
70
+ firstPageButtons.push({
71
+ pageIndex: 0
72
+ });
73
+
74
+ if (this.firstPageInRange > 1 && this.firstPageInRange !== 2) {
75
+ firstPageButtons.push({
76
+ i18n: {
77
+ key: 'startingEllipses',
78
+ token: 'euiPagination.firstRangeAriaLabel',
79
+ default: 'Skipping pages 2 to {lastPage}',
80
+ values: { lastPage: this.firstPageInRange }
81
+ }
82
+ });
83
+ } else if (this.firstPageInRange === 2) {
84
+ firstPageButtons.push({ pageIndex: 1 });
85
+ }
86
+ }
87
+
88
+ return firstPageButtons;
89
+ }
90
+
91
+ get lastPageButtons() {
92
+ let lastPageButtons = [];
93
+ let pageCount = this.pageCount;
94
+ let lastPageInRange = this.lastPageInRange;
95
+
96
+ if (lastPageInRange < pageCount) {
97
+ if (lastPageInRange + 1 === pageCount - 1) {
98
+ lastPageButtons.push({ pageIndex: lastPageInRange });
99
+ } else if (lastPageInRange < pageCount - 1) {
100
+ lastPageButtons.push({
101
+ i18n: {
102
+ key: 'endingEllipses',
103
+ token: 'euiPagination.lastRangeAriaLabel',
104
+ default: 'Skipping pages {firstPage} to {lastPage}',
105
+ values: { firstPage: lastPageInRange + 1, lastPage: pageCount - 1 }
106
+ }
107
+ });
108
+ }
109
+ lastPageButtons.push({ pageIndex: pageCount - 1 });
110
+ }
111
+
112
+ return lastPageButtons;
113
+ }
114
+
115
+ get sharedButtonProps() {
116
+ return {
117
+ activePage: this.activePage,
118
+ pageCount: this.pageCount,
119
+ ariaControls: this.ariaControls,
120
+ safeClick: this.safeClick
121
+ };
122
+ }
123
+
124
+ get prevPageButtonProps() {
125
+ let prevPageButtonProps = {};
126
+ if (this.hasControl && this.activePage !== 0) {
127
+ prevPageButtonProps = {
128
+ 'aria-controls': this.ariaControls,
129
+ href: `#${this.ariaControls}`
130
+ };
131
+ } else {
132
+ prevPageButtonProps = { disabled: this.activePage === 0 };
133
+ }
134
+ return prevPageButtonProps;
135
+ }
136
+
137
+ get nextPageButtonProps() {
138
+ let nextPageButtonProps = {};
139
+ if (this.hasControl && this.activePage !== this.pageCount - 1) {
140
+ nextPageButtonProps = {
141
+ 'aria-controls': this.ariaControls,
142
+ href: `#${this.ariaControls}`
143
+ };
144
+ } else {
145
+ nextPageButtonProps = {
146
+ disabled: this.activePage === this.pageCount - 1
147
+ };
148
+ }
149
+ return nextPageButtonProps;
150
+ }
151
+
152
+ safeClick: SafeClickHandler = (pageIndex) => {
153
+ if (this.ariaControls) {
154
+ const controlledElement = document.getElementById(this.ariaControls);
155
+
156
+ if (controlledElement) {
157
+ controlledElement.focus();
158
+ }
159
+ }
160
+
161
+ this.args.onPageClick?.(pageIndex);
162
+ };
163
+
164
+ get firstPageInRange() {
165
+ return Math.max(
166
+ 0,
167
+ Math.min(
168
+ this.activePage - NUMBER_SURROUNDING_PAGES,
169
+ this.pageCount - MAX_VISIBLE_PAGES
170
+ )
171
+ );
172
+ }
173
+
174
+ get lastPageInRange() {
175
+ return Math.min(this.pageCount, this.firstPageInRange + MAX_VISIBLE_PAGES);
176
+ }
177
+ }
@@ -0,0 +1,27 @@
1
+ <EuiI18n
2
+ @token="euiPagination.nextPage"
3
+ @default="Next page, {page}"
4
+ @values={{hash page=(add @activePage 2)}}
5
+ as |Token|
6
+ >
7
+ <Token as |nextPage|>
8
+ <EuiI18n
9
+ @token="euiPagination.disabledNextPage"
10
+ @default="Next page"
11
+ as |InnerToken|
12
+ >
13
+ <InnerToken as |disabledNextPage|>
14
+ <EuiButtonIcon
15
+ {{on "click" (fn @safeClick (add @activePage 1))}}
16
+ @iconType="arrowRight"
17
+ @color="text"
18
+ aria-label={{if (eq (sub @activePage -1)) disabledNextPage nextPage}}
19
+ aria-controls={{if @props.aria-controls @props.aria-controls}}
20
+ href={{if @props.href @props.href}}
21
+ disabled={{eq @props.disabled true}}
22
+ ...attributes
23
+ />
24
+ </InnerToken>
25
+ </EuiI18n>
26
+ </Token>
27
+ </EuiI18n>
@@ -0,0 +1,27 @@
1
+ <EuiI18n
2
+ @token="euiPagination.previousPage"
3
+ @default="Previous page, {page}"
4
+ @values={{hash page=@activePage}}
5
+ as |Token|
6
+ >
7
+ <Token as |previousPage|>
8
+ <EuiI18n
9
+ @token="euiPagination.disabledPreviousPage"
10
+ @default="Previous page"
11
+ as |InnerToken|
12
+ >
13
+ <InnerToken as |disabledPreviousPage|>
14
+ <EuiButtonIcon
15
+ {{on "click" (fn @safeClick (sub @activePage 1))}}
16
+ @iconType="arrowLeft"
17
+ @color="text"
18
+ aria-label={{if (eq @activePage 0) disabledPreviousPage previousPage}}
19
+ aria-controls={{if @props.aria-controls @props.aria-controls}}
20
+ href={{if @props.href @props.href}}
21
+ disabled={{eq @props.disabled true}}
22
+ ...attributes
23
+ />
24
+ </InnerToken>
25
+ </EuiI18n>
26
+ </Token>
27
+ </EuiI18n>