@ember-eui/core 4.2.6 → 5.0.0-alpha.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.
- package/addon/components/common.ts +1 -0
- package/addon/components/eui-accordion/index.hbs +106 -85
- package/addon/components/eui-accordion/index.ts +58 -19
- package/addon/components/eui-auto-sizer/index.hbs +3 -0
- package/addon/components/eui-auto-sizer/index.ts +175 -0
- package/addon/components/eui-avatar/index.hbs +7 -3
- package/addon/components/eui-badge/index.hbs +9 -3
- package/addon/components/eui-beta-badge/index.hbs +171 -19
- package/addon/components/eui-bottom-bar/index.hbs +43 -12
- package/addon/components/eui-bottom-bar/index.ts +75 -32
- package/addon/components/eui-breadcrumbs/index.hbs +98 -0
- package/addon/components/eui-breadcrumbs/index.ts +194 -0
- package/addon/components/eui-button/index.hbs +4 -4
- package/addon/components/eui-button-content/index.hbs +6 -2
- package/addon/components/eui-button-empty/index.hbs +60 -52
- package/addon/components/eui-button-icon/index.hbs +17 -3
- package/addon/components/eui-call-out/index.hbs +1 -0
- package/addon/components/eui-card/index.hbs +61 -47
- package/addon/components/eui-card/index.ts +27 -0
- package/addon/components/{eui-card/eui-card-select → eui-card-select}/index.hbs +2 -5
- package/addon/components/eui-card-select/index.ts +35 -0
- package/addon/components/eui-checkable-card/index.hbs +17 -11
- package/addon/components/eui-checkbox/index.hbs +11 -5
- package/addon/components/eui-checkbox/index.ts +15 -0
- package/addon/components/eui-code/index.hbs +14 -8
- package/addon/components/eui-code/index.ts +73 -0
- package/addon/components/eui-code-block/controls/index.hbs +26 -0
- package/addon/components/eui-code-block/full-screen-display/index.hbs +12 -0
- package/addon/components/eui-code-block/index.hbs +144 -9
- package/addon/components/eui-code-block/index.ts +290 -0
- package/addon/components/eui-code-block/virtualized/index.hbs +30 -0
- package/addon/components/eui-code-block/virtualized/index.ts +22 -0
- package/addon/components/eui-collapsible-nav/index.hbs +35 -44
- package/addon/components/eui-collapsible-nav/index.ts +161 -0
- package/addon/components/eui-collapsible-nav-group/index.hbs +114 -66
- package/addon/components/eui-combo-box/group/index.hbs +3 -3
- package/addon/components/eui-combo-box/index.hbs +8 -5
- package/addon/components/eui-combo-box/index.ts +89 -4
- package/addon/components/eui-combo-box/options/index.hbs +14 -2
- package/addon/components/eui-combo-box/options/index.js +22 -9
- package/addon/components/eui-combo-box/trigger/index.hbs +3 -1
- package/addon/components/eui-confirm-modal/index.hbs +1 -1
- package/addon/components/eui-copy/index.hbs +1 -4
- package/addon/components/eui-described-form-group/index.hbs +3 -2
- package/addon/components/eui-description-list/index.hbs +23 -0
- package/addon/components/eui-description-list-description/index.hbs +3 -0
- package/addon/components/eui-description-list-title/index.hbs +3 -0
- package/addon/components/eui-dual-range/index.hbs +30 -18
- package/addon/components/eui-dual-range/index.ts +36 -10
- package/addon/components/eui-empty-prompt/index.hbs +77 -0
- package/addon/components/eui-field-number/index.hbs +3 -3
- package/addon/components/eui-field-search/index.hbs +2 -1
- package/addon/components/eui-field-text/index.hbs +3 -1
- package/addon/components/eui-file-picker/index.hbs +15 -11
- package/addon/components/eui-file-picker/index.ts +26 -8
- package/addon/components/eui-flyout/index.hbs +130 -43
- package/addon/components/eui-flyout/index.ts +233 -0
- package/addon/components/eui-flyout-body/index.hbs +21 -7
- package/addon/components/eui-form-label/index.hbs +1 -1
- package/addon/components/eui-form-row/index.hbs +13 -9
- package/addon/components/eui-header/index.hbs +18 -3
- package/addon/{modifiers/fixed-header.ts → components/eui-header/index.ts} +10 -1
- package/addon/components/eui-header-alert/index.hbs +25 -0
- package/addon/components/eui-header-breadcrumbs/index.hbs +7 -0
- package/addon/components/eui-header-links/index.hbs +41 -0
- package/addon/components/eui-header-links/index.ts +14 -0
- package/addon/components/eui-header-section-item-button/index.hbs +30 -12
- package/addon/components/eui-header-section-item-button/index.ts +131 -0
- package/addon/components/eui-health/index.hbs +15 -13
- package/addon/components/eui-hide-for/index.hbs +3 -0
- package/addon/components/eui-hide-for/index.ts +33 -0
- package/addon/components/eui-icon/index.hbs +6 -3
- package/addon/components/eui-icon/index.ts +4 -0
- package/addon/components/eui-image/index.hbs +63 -25
- package/addon/components/eui-input-popover/index.ts +6 -4
- package/addon/components/eui-key-pad-menu/index.hbs +16 -0
- package/addon/components/eui-key-pad-menu/key/index.hbs +1 -0
- package/addon/components/eui-key-pad-menu-item/index.hbs +66 -0
- package/addon/components/eui-key-pad-menu-item/index.ts +11 -0
- package/addon/components/eui-link/index.hbs +50 -0
- package/addon/components/eui-list-group-item/index.hbs +10 -2
- package/addon/components/eui-markdown-editor/index.hbs +4 -1
- package/addon/components/eui-markdown-editor/index.ts +54 -0
- package/addon/components/eui-markdown-editor-footer/index.hbs +39 -40
- package/addon/components/eui-markdown-format/index.ts +1 -1
- package/addon/components/eui-markdown-format/markdown-code/index.hbs +2 -2
- package/addon/components/eui-markdown-format/markdown-code-block/index.hbs +1 -0
- package/addon/components/eui-modal/index.hbs +28 -24
- package/addon/components/eui-overlay-mask/index.hbs +4 -4
- package/addon/components/eui-overlay-mask/index.ts +14 -1
- package/addon/components/eui-page/index.hbs +3 -6
- package/addon/components/eui-page-body/index.hbs +47 -15
- package/addon/components/eui-page-content/index.hbs +6 -8
- package/addon/components/eui-page-content-body/index.hbs +13 -1
- package/addon/components/eui-page-content-header/index.hbs +6 -0
- package/addon/components/eui-page-header/index.hbs +31 -6
- package/addon/components/eui-page-header-content/index.hbs +219 -0
- package/addon/components/eui-page-header-content/index.ts +49 -0
- package/addon/components/eui-page-side-bar/index.hbs +8 -1
- package/addon/components/eui-page-template/index.hbs +417 -0
- package/addon/components/eui-page-template/index.ts +89 -0
- package/addon/components/eui-panel/index.hbs +58 -12
- package/addon/components/eui-popover/index.hbs +8 -4
- package/addon/components/eui-popover/index.ts +28 -12
- package/addon/components/eui-progress/index.hbs +16 -13
- package/addon/components/eui-radio/index.hbs +9 -3
- package/addon/components/eui-range/index.hbs +33 -11
- package/addon/components/eui-range/index.ts +7 -4
- package/addon/components/eui-range-input/index.hbs +37 -31
- package/addon/components/eui-range-input/types.ts +2 -1
- package/addon/components/eui-range-levels/index.hbs +3 -3
- package/addon/components/eui-range-ticks/index.hbs +2 -2
- package/addon/components/eui-range-track/index.hbs +10 -2
- package/addon/components/eui-range-track/index.ts +23 -6
- package/addon/components/eui-show-for/index.hbs +3 -0
- package/addon/components/eui-show-for/index.ts +79 -0
- package/addon/components/eui-side-nav/index.hbs +161 -36
- package/addon/components/eui-side-nav/index.ts +28 -0
- package/addon/components/eui-side-nav-item/button/index.hbs +26 -14
- package/addon/components/eui-side-nav-item/index.hbs +52 -25
- package/addon/components/eui-split-panel/inner/index.hbs +10 -0
- package/addon/components/eui-split-panel/outer/index.hbs +27 -0
- package/addon/components/eui-split-panel/outer/index.ts +37 -0
- package/addon/components/eui-step/eui-step-number/index.hbs +21 -4
- package/addon/components/eui-steps/index.hbs +7 -1
- package/addon/components/eui-tab/index.hbs +28 -3
- package/addon/{modifiers/focus-tab.ts → components/eui-tab/index.ts} +6 -1
- package/addon/components/eui-tabs/index.hbs +6 -1
- package/addon/components/eui-tool-tip/index.hbs +6 -7
- package/addon/components/eui-tool-tip/index.ts +27 -11
- package/addon/helpers/class-names.ts +2 -0
- package/addon/helpers/get-range-tick.ts +53 -8
- package/addon/helpers/unique-id.ts +4 -1
- package/addon/styles/ember-eui.css +2 -10
- package/addon/utils/breakpoint.ts +114 -0
- package/addon/utils/code/utils.ts +304 -0
- package/addon/utils/css-mappings/eui-avatar.ts +51 -9
- package/addon/utils/css-mappings/eui-badge.ts +6 -2
- package/addon/utils/css-mappings/eui-beta-badge.ts +22 -0
- package/addon/utils/css-mappings/eui-bottom-bar.ts +8 -1
- package/addon/utils/css-mappings/eui-button-empty.ts +4 -4
- package/addon/utils/css-mappings/eui-button-icon.ts +19 -6
- package/addon/utils/css-mappings/eui-button.ts +2 -1
- package/addon/utils/css-mappings/eui-card-select.ts +1 -11
- package/addon/utils/css-mappings/eui-card.ts +1 -18
- package/addon/utils/css-mappings/{eui-code-block-impl.ts → eui-code-block.ts} +0 -0
- package/addon/utils/css-mappings/eui-description-list.ts +29 -0
- package/addon/utils/css-mappings/eui-empty-prompt.ts +17 -0
- package/addon/utils/css-mappings/eui-flyout.ts +21 -1
- package/addon/utils/css-mappings/eui-header-links.ts +27 -0
- package/addon/utils/css-mappings/eui-health.ts +20 -0
- package/addon/utils/css-mappings/eui-icon.ts +94 -70
- package/addon/utils/css-mappings/eui-image.ts +17 -2
- package/addon/utils/css-mappings/eui-link.ts +21 -0
- package/addon/utils/css-mappings/eui-page-body.ts +25 -0
- package/addon/utils/css-mappings/eui-page-content-body.ts +17 -0
- package/addon/utils/css-mappings/eui-page-content.ts +7 -1
- package/addon/utils/css-mappings/eui-page-header.ts +17 -0
- package/addon/utils/css-mappings/eui-page-side-bar.ts +17 -0
- package/addon/utils/css-mappings/eui-panel.ts +1 -0
- package/addon/utils/css-mappings/eui-progress-data.ts +0 -1
- package/addon/utils/css-mappings/eui-progress.ts +0 -2
- package/addon/utils/css-mappings/eui-range-levels.ts +22 -4
- package/addon/utils/css-mappings/eui-tabs.ts +3 -1
- package/addon/utils/css-mappings/eui-text-color.ts +3 -2
- package/addon/utils/css-mappings/index.ts +23 -3
- package/addon/utils/detect-element-resize.js +248 -0
- package/addon/utils/markdown/plugins/markdown-add-components/index.ts +1 -0
- package/addon/utils/markdown/plugins/{markdown-add-components.ts → markdown-add-components/processor.ts} +14 -7
- package/addon/utils/markdown/plugins/markdown-checkbox/index.ts +9 -0
- package/addon/utils/markdown/plugins/{markdown-checkbox.ts → markdown-checkbox/parser.ts} +3 -5
- package/addon/utils/markdown/plugins/markdown-default-plugins/index.ts +12 -0
- package/addon/utils/markdown/plugins/{markdown-default-plugins.ts → markdown-default-plugins/parsing-plugins.ts} +13 -25
- package/addon/utils/markdown/plugins/markdown-default-plugins/plugins.ts +32 -0
- package/addon/utils/markdown/plugins/markdown-default-plugins/processing-plugins.ts +67 -0
- package/addon/utils/markdown/plugins/markdown-default-plugins/ui-plugins.ts +27 -0
- package/addon/utils/markdown/plugins/markdown-tooltip/index.ts +2 -0
- package/addon/utils/markdown/plugins/{markdown-tooltip.ts → markdown-tooltip/parser.ts} +3 -23
- package/addon/utils/markdown/plugins/markdown-tooltip/plugin.ts +17 -0
- package/addon/utils/markdown/plugins/to-dom.ts +3 -1
- package/addon/utils/markdown/remark/remark-prismjs.ts +41 -0
- package/addon/utils/popover/index.ts +87 -35
- package/addon/utils/range/index.ts +1 -0
- package/app/components/eui-auto-sizer/index.js +1 -0
- package/app/components/eui-breadcrumbs/index.js +1 -0
- package/app/components/eui-card-select/index.js +1 -0
- package/app/components/{eui-code-block-impl → eui-code-block/controls}/index.js +1 -1
- package/app/components/{eui-code-block-impl/code-block-controls → eui-code-block/full-screen-display}/index.js +1 -1
- package/app/components/eui-code-block/virtualized/index.js +1 -0
- package/app/components/eui-description-list/index.js +1 -0
- package/app/components/eui-description-list-description/index.js +1 -0
- package/app/components/eui-description-list-title/index.js +1 -0
- package/app/components/eui-empty-prompt/index.js +1 -0
- package/app/components/eui-header-alert/index.js +1 -0
- package/app/components/eui-header-breadcrumbs/index.js +1 -0
- package/app/components/eui-header-links/index.js +1 -0
- package/app/components/eui-hide-for/index.js +1 -0
- package/app/components/eui-key-pad-menu/index.js +1 -0
- package/app/components/eui-key-pad-menu/key/index.js +1 -0
- package/app/components/eui-key-pad-menu-item/index.js +1 -0
- package/app/components/eui-link/index.js +1 -0
- package/app/components/eui-page-header-content/index.js +1 -0
- package/app/components/eui-page-template/index.js +1 -0
- package/app/components/eui-show-for/index.js +1 -0
- package/app/components/eui-split-panel/inner/index.js +1 -0
- package/app/components/eui-split-panel/outer/index.js +1 -0
- package/app/utils/copy-to-clipboard.js +1 -0
- package/docs/display/avatar-demo/demo1.md +43 -49
- package/docs/display/avatar-demo/demo2.md +42 -0
- package/docs/display/avatar-demo/demo3.md +33 -0
- package/docs/display/avatar-demo/demo4.md +53 -0
- package/docs/display/avatar-demo/demo5.md +38 -0
- package/docs/display/avatar.md +9 -1
- package/docs/display/badge-demo/demo1.md +111 -168
- package/docs/display/badge-demo/demo2.md +34 -0
- package/docs/display/badge-demo/demo3.md +73 -0
- package/docs/display/badge-demo/demo4.md +29 -0
- package/docs/display/badge-demo/demo5.md +33 -0
- package/docs/display/badge-demo/demo6.md +71 -0
- package/docs/display/badge-demo/demo7.md +101 -0
- package/docs/display/badge-demo/demo8.md +22 -0
- package/docs/display/badge.md +9 -1
- package/docs/display/callout-demo/demo1.md +29 -81
- package/docs/display/callout-demo/demo2.md +28 -0
- package/docs/display/callout-demo/demo3.md +29 -0
- package/docs/display/callout-demo/demo4.md +26 -0
- package/docs/display/callout.md +15 -1
- package/docs/display/card/basic-card-demo/demo1.md +22 -316
- package/docs/display/card/basic-card.md +9 -1
- package/docs/display/card/beta-badge-demo/demo1.md +47 -0
- package/docs/display/card/beta-badge.md +9 -0
- package/docs/display/card/checkable-demo/demo1.md +20 -94
- package/docs/display/card/checkable-demo/demo2.md +63 -0
- package/docs/display/card/checkable.md +9 -1
- package/docs/display/card/custom-children-demo/demo1.md +93 -0
- package/docs/display/card/custom-children.md +9 -0
- package/docs/display/card/footer-demo/demo1.md +77 -0
- package/docs/display/card/footer.md +9 -0
- package/docs/display/card/images-demo/demo1.md +57 -0
- package/docs/display/card/images.md +9 -0
- package/docs/display/card/layout-demo/demo1.md +40 -0
- package/docs/display/card/layout.md +9 -0
- package/docs/display/card/selectable-demo/demo1.md +60 -53
- package/docs/display/card/selectable.md +9 -1
- package/docs/display/comment-list.md +9 -1
- package/docs/display/description-list-demo/demo1.md +54 -0
- package/docs/display/description-list-demo/demo2.md +43 -0
- package/docs/display/description-list-demo/demo3.md +58 -0
- package/docs/display/description-list-demo/demo4.md +42 -0
- package/docs/display/description-list-demo/demo5.md +62 -0
- package/docs/display/description-list-demo/demo6.md +46 -0
- package/docs/display/description-list.md +9 -0
- package/docs/display/empty-prompt-demo/demo1.md +49 -0
- package/docs/display/empty-prompt.md +11 -0
- package/docs/display/health-demo/demo1.md +11 -7
- package/docs/display/health-demo/demo2.md +31 -0
- package/docs/display/health.md +15 -1
- package/docs/display/icons-demo/demo1.md +270 -57
- package/docs/display/icons-demo/demo2.md +76 -0
- package/docs/display/icons-demo/demo3.md +76 -0
- package/docs/display/icons-demo/demo4.md +104 -0
- package/docs/display/icons-demo/demo5.md +64 -0
- package/docs/display/icons-demo/demo6.md +63 -0
- package/docs/display/icons-demo/demo7.md +101 -0
- package/docs/display/icons-demo/demo8.md +47 -0
- package/docs/display/icons.md +9 -1
- package/docs/display/image-demo/demo1.md +15 -50
- package/docs/display/image-demo/demo2.md +35 -0
- package/docs/display/image-demo/demo3.md +75 -0
- package/docs/display/image-demo/demo4.md +80 -0
- package/docs/display/image.md +13 -1
- package/docs/display/list-group.md +9 -1
- package/docs/display/progress-demo/demo1.md +10 -5
- package/docs/display/progress-demo/demo2.md +11 -26
- package/docs/display/progress-demo/demo3.md +27 -0
- package/docs/display/progress-demo/demo4.md +77 -0
- package/docs/display/progress.md +9 -1
- package/docs/display/stat-demo/demo1.md +0 -118
- package/docs/display/stat-demo/demo2.md +24 -22
- package/docs/display/stat-demo/demo3.md +39 -0
- package/docs/display/stat-demo/demo4.md +50 -0
- package/docs/display/stat-demo/demo5.md +25 -0
- package/docs/display/stat-demo/demo6.md +40 -0
- package/docs/display/stat-demo/demo7.md +84 -0
- package/docs/display/stat.md +15 -1
- package/docs/display/text-demo/demo1.md +79 -130
- package/docs/display/text-demo/demo2.md +71 -0
- package/docs/display/text-demo/demo3.md +39 -0
- package/docs/display/text.md +20 -1
- package/docs/display/title-demo/demo1.md +50 -26
- package/docs/display/title.md +9 -1
- package/docs/display/tool-tip-demo/demo1.md +57 -100
- package/docs/display/tool-tip-demo/demo2.md +35 -29
- package/docs/display/tool-tip-demo/demo3.md +52 -0
- package/docs/display/tool-tip-demo/demo4.md +77 -0
- package/docs/display/tool-tip.md +15 -1
- package/docs/editors/code/code-block-demo/demo1.md +21 -40
- package/docs/editors/code/code-block-demo/demo2.md +35 -0
- package/docs/editors/code/code-block-demo/demo3.md +43 -0
- package/docs/editors/code/code-block-demo/demo4.md +28 -0
- package/docs/editors/code/code-block-demo/demo5.md +42 -0
- package/docs/editors/code/code-block-demo/demo6.md +42 -0
- package/docs/editors/code/code-block-demo/demo7.md +853 -0
- package/docs/editors/code/code-block-demo/demo8.md +855 -0
- package/docs/editors/code/code-block.md +27 -1
- package/docs/editors/code/inline-demo/demo1.md +6 -3
- package/docs/editors/code/inline.md +9 -1
- package/docs/editors/markdown-editor/base-editor-demo/demo1.md +9 -28
- package/docs/editors/markdown-editor/base-editor.md +9 -1
- package/docs/forms/form-controls/checkbox/demo/demo1.md +49 -0
- package/docs/forms/form-controls/checkbox/index.md +34 -0
- package/docs/forms/form-controls/{checkbox-group-demo → checkbox-group/demo}/demo1.md +4 -13
- package/docs/forms/form-controls/checkbox-group/index.md +35 -0
- package/docs/forms/form-controls/{combo-box-demo → combo-box/demo}/demo1.md +8 -2
- package/docs/forms/form-controls/{combo-box-demo → combo-box/demo}/demo2.md +10 -8
- package/docs/forms/form-controls/combo-box/demo/demo3.md +60 -0
- package/docs/forms/form-controls/{combo-box-demo/demo3.md → combo-box/demo/demo4.md} +17 -14
- package/docs/forms/form-controls/combo-box/demo/demo5.md +151 -0
- package/docs/forms/form-controls/combo-box/index.md +14 -0
- package/docs/forms/form-controls/file-picker/demo/demo1.md +29 -0
- package/docs/forms/form-controls/file-picker/demo/demo2.md +44 -0
- package/docs/forms/form-controls/file-picker/demo/demo3.md +45 -0
- package/docs/forms/form-controls/file-picker/demo/demo4.md +63 -0
- package/docs/forms/form-controls/file-picker/index.md +30 -0
- package/docs/forms/form-controls/{form-control-layout-demo → form-control-layout/demo}/demo1.md +0 -0
- package/docs/forms/form-controls/form-control-layout/index.md +38 -0
- package/docs/forms/form-controls/{form-control-layout-delimited-demo → form-control-layout-delimited/demo}/demo1.md +41 -37
- package/docs/forms/form-controls/form-control-layout-delimited/index.md +32 -0
- package/docs/forms/form-controls/number-field/demo/demo1.md +20 -0
- package/docs/forms/form-controls/{number-field-demo/demo1.md → number-field/demo/demo2.md} +23 -11
- package/docs/forms/form-controls/number-field/index.md +20 -0
- package/docs/forms/form-controls/password-field/demo/demo1.md +19 -0
- package/docs/forms/form-controls/{password-field-demo/demo1.md → password-field/demo/demo2.md} +12 -8
- package/docs/forms/form-controls/password-field/index.md +27 -0
- package/docs/forms/form-controls/radio/demo/demo1.md +43 -0
- package/docs/forms/form-controls/radio/index.md +32 -0
- package/docs/forms/form-controls/radio-group/demo/demo1.md +50 -0
- package/docs/forms/form-controls/radio-group/index.md +26 -0
- package/docs/forms/form-controls/range/demo/demo1.md +96 -0
- package/docs/forms/form-controls/range/demo/demo2.md +62 -0
- package/docs/forms/form-controls/{range-demo → range/demo}/demo3.md +10 -12
- package/docs/forms/form-controls/{range-demo → range/demo}/demo4.md +16 -18
- package/docs/forms/form-controls/{range-demo → range/demo}/demo5.md +18 -20
- package/docs/forms/form-controls/range/demo/demo6.md +57 -0
- package/docs/forms/form-controls/range/demo/demo7.md +350 -0
- package/docs/forms/form-controls/range/index.md +26 -0
- package/docs/forms/form-controls/search-field/demo/demo1.md +29 -0
- package/docs/forms/form-controls/search-field/index.md +22 -0
- package/docs/forms/form-controls/select/demo/demo1.md +29 -0
- package/docs/forms/form-controls/select/demo/demo2.md +44 -0
- package/docs/forms/form-controls/{select-demo/demo1.md → select/demo/demo3.md} +20 -10
- package/docs/forms/form-controls/select/index.md +27 -0
- package/docs/forms/form-controls/{switch-demo → switch/demo}/demo1.md +10 -10
- package/docs/forms/form-controls/switch/index.md +21 -0
- package/docs/forms/form-controls/text-field/demo/demo1.md +35 -0
- package/docs/forms/form-controls/text-field/demo/demo2.md +40 -0
- package/docs/forms/form-controls/{text-field-demo/demo2.md → text-field/demo/demo3.md} +14 -17
- package/docs/forms/form-controls/{text-field-demo/demo1.md → text-field/demo/demo4.md} +18 -32
- package/docs/forms/form-controls/text-field/index.md +22 -0
- package/docs/forms/form-controls/textarea/demo/demo1.md +21 -0
- package/docs/forms/form-controls/textarea/demo/demo2.md +24 -0
- package/docs/forms/form-controls/textarea/index.md +22 -0
- package/docs/forms/form-layouts/described-form-groups-demo/demo1.md +13 -4
- package/docs/forms/form-layouts/described-form-groups.md +9 -1
- package/docs/layout/accordion-demo/demo1.md +21 -102
- package/docs/layout/accordion-demo/demo2.md +76 -0
- package/docs/layout/accordion-demo/demo3.md +25 -0
- package/docs/layout/accordion-demo/demo4.md +26 -0
- package/docs/layout/accordion-demo/demo5.md +65 -0
- package/docs/layout/accordion-demo/demo6.md +78 -0
- package/docs/layout/accordion-demo/demo7.md +66 -0
- package/docs/layout/accordion-demo/demo8.md +64 -0
- package/docs/layout/accordion-demo/demo9.md +114 -0
- package/docs/layout/accordion.md +40 -1
- package/docs/layout/bottom-bar-demo/demo1.md +32 -49
- package/docs/layout/bottom-bar-demo/demo2.md +54 -0
- package/docs/layout/bottom-bar-demo/demo3.md +81 -0
- package/docs/layout/bottom-bar.md +9 -1
- package/docs/layout/flex.md +9 -1
- package/docs/layout/flyout-demo/demo1.md +19 -11
- package/docs/layout/flyout-demo/demo2.md +43 -28
- package/docs/layout/flyout-demo/demo3.md +99 -0
- package/docs/layout/flyout-demo/demo4.md +115 -0
- package/docs/layout/flyout-demo/demo5.md +59 -0
- package/docs/layout/flyout-demo/demo6.md +57 -0
- package/docs/layout/flyout-demo/demo7.md +51 -0
- package/docs/layout/flyout.md +9 -1
- package/docs/layout/header-demo/demo1.md +284 -35
- package/docs/layout/header-demo/demo2.md +42 -0
- package/docs/layout/header-demo/demo3.md +48 -0
- package/docs/layout/header-demo/demo4.md +57 -0
- package/docs/layout/header-demo/demo5.md +232 -0
- package/docs/layout/header-demo/demo6.md +85 -0
- package/docs/layout/header-demo/demo7.md +94 -0
- package/docs/layout/header.md +9 -1
- package/docs/layout/horizontal-rule.md +9 -1
- package/docs/layout/modal-demo/demo1.md +64 -167
- package/docs/layout/modal-demo/demo2.md +126 -0
- package/docs/layout/modal-demo/demo3.md +55 -0
- package/docs/layout/modal-demo/demo4.md +65 -0
- package/docs/layout/modal-demo/demo5.md +96 -0
- package/docs/layout/modal.md +9 -1
- package/docs/layout/page-demo/demo1.md +96 -3
- package/docs/layout/page-demo/demo10.md +42 -0
- package/docs/layout/page-demo/demo2.md +46 -0
- package/docs/layout/page-demo/demo3.md +50 -0
- package/docs/layout/page-demo/demo4.md +38 -0
- package/docs/layout/page-demo/demo5.md +30 -0
- package/docs/layout/page-demo/demo6.md +51 -0
- package/docs/layout/page-demo/demo7.md +59 -0
- package/docs/layout/page-demo/demo8.md +19 -0
- package/docs/layout/page-demo/demo9.md +29 -0
- package/docs/layout/page.md +9 -1
- package/docs/layout/panel-demo/demo1.md +28 -19
- package/docs/layout/panel-demo/demo2.md +22 -0
- package/docs/layout/panel-demo/demo3.md +27 -0
- package/docs/layout/panel-demo/demo4.md +46 -0
- package/docs/layout/panel-demo/demo5.md +81 -0
- package/docs/layout/panel.md +15 -1
- package/docs/layout/popover-demo/demo1.md +42 -300
- package/docs/layout/popover-demo/demo10.md +72 -0
- package/docs/layout/popover-demo/demo2.md +306 -96
- package/docs/layout/popover-demo/demo3.md +20 -12
- package/docs/layout/popover-demo/demo4.md +118 -0
- package/docs/layout/popover-demo/demo5.md +252 -0
- package/docs/layout/popover-demo/demo6.md +44 -0
- package/docs/layout/popover-demo/demo7.md +44 -0
- package/docs/layout/popover-demo/demo8.md +50 -0
- package/docs/layout/popover-demo/demo9.md +80 -0
- package/docs/layout/popover.md +9 -1
- package/docs/navigation/breadcrumbs-demo/demo1.md +77 -0
- package/docs/navigation/breadcrumbs-demo/demo2.md +61 -0
- package/docs/navigation/breadcrumbs-demo/demo3.md +61 -0
- package/docs/navigation/breadcrumbs-demo/demo4.md +61 -0
- package/docs/navigation/breadcrumbs-demo/demo5.md +61 -0
- package/docs/navigation/breadcrumbs-demo/demo6.md +61 -0
- package/docs/navigation/breadcrumbs.md +9 -0
- package/docs/navigation/button-demo/demo1.md +210 -158
- package/docs/navigation/button.md +9 -1
- package/docs/navigation/collapsible-nav-demo/demo1.md +21 -44
- package/docs/navigation/collapsible-nav-demo/demo2.md +108 -0
- package/docs/navigation/collapsible-nav.md +9 -1
- package/docs/navigation/key-pad-menu-demo/demo1.md +77 -0
- package/docs/navigation/key-pad-menu-demo/demo2.md +102 -0
- package/docs/navigation/key-pad-menu-demo/demo3.md +54 -0
- package/docs/navigation/key-pad-menu-demo/demo4.md +71 -0
- package/docs/navigation/key-pad-menu-demo/demo5.md +65 -0
- package/docs/navigation/key-pad-menu.md +9 -0
- package/docs/navigation/link-demo/demo1.md +44 -0
- package/docs/navigation/link-demo/demo2.md +41 -0
- package/docs/navigation/link-demo/demo3.md +45 -0
- package/docs/navigation/link-demo/demo4.md +61 -0
- package/docs/navigation/link.md +9 -0
- package/docs/navigation/side-nav-demo/demo1.md +34 -18
- package/docs/navigation/side-nav.md +9 -1
- package/docs/navigation/steps-demo/demo1.md +16 -18
- package/docs/navigation/steps-demo/demo2.md +18 -21
- package/docs/navigation/steps-demo/demo3.md +12 -10
- package/docs/navigation/steps-demo/demo4.md +84 -0
- package/docs/navigation/steps-demo/demo5.md +29 -0
- package/docs/navigation/steps.md +9 -1
- package/docs/navigation/tabs.md +9 -1
- package/docs/utilities/auto-sizer-demo/demo1.md +34 -0
- package/docs/utilities/auto-sizer.md +9 -0
- package/docs/utilities/copy-demo/demo1.md +37 -0
- package/docs/utilities/copy-demo/demo2.md +70 -0
- package/docs/utilities/copy.md +9 -0
- package/docs/utilities/mutation-observer.md +9 -1
- package/docs/utilities/outside-click-detector.md +9 -1
- package/docs/utilities/overlay-mask.md +9 -1
- package/docs/utilities/portal.md +9 -1
- package/docs/utilities/resize-observer.md +9 -1
- package/docs/utilities/responsive-demo/demo1.md +108 -0
- package/docs/utilities/responsive.md +9 -0
- package/index.js +4 -2
- package/package.json +13 -7
- package/CHANGELOG.md +0 -1335
- package/addon/components/eui-code-block-impl/code-block-controls/index.hbs +0 -33
- package/addon/components/eui-code-block-impl/index.hbs +0 -111
- package/addon/components/eui-code-block-impl/index.ts +0 -121
- package/addon/components/eui-flyout-body/banner/index.hbs +0 -3
- package/addon/components/eui-flyout-body/content/index.hbs +0 -3
- package/addon/helpers/create-event.ts +0 -30
- package/addon/modifiers/get-cursor-node.ts +0 -54
- package/addon/modifiers/invalidate-indeterminate.ts +0 -10
- package/addon/modifiers/on-event-simulate-event.ts +0 -32
- package/app/components/eui-card/eui-card-select/index.js +0 -1
- package/app/components/eui-flyout-body/banner/index.js +0 -1
- package/app/components/eui-flyout-body/content/index.js +0 -1
- package/app/helpers/create-event.js +0 -1
- package/app/modifiers/fixed-header.js +0 -1
- package/app/modifiers/focus-tab.js +0 -1
- package/app/modifiers/get-cursor-node.js +0 -1
- package/app/modifiers/invalidate-indeterminate.js +0 -1
- package/app/modifiers/on-event-simulate-event.js +0 -1
- package/docs/forms/form-controls/checkbox-demo/demo1.md +0 -40
- package/docs/forms/form-controls/checkbox-group.md +0 -1
- package/docs/forms/form-controls/checkbox.md +0 -1
- package/docs/forms/form-controls/combo-box.md +0 -1
- package/docs/forms/form-controls/file-picker-demo/demo1.md +0 -28
- package/docs/forms/form-controls/file-picker.md +0 -1
- package/docs/forms/form-controls/form-control-layout-delimited.md +0 -1
- package/docs/forms/form-controls/form-control-layout.md +0 -1
- package/docs/forms/form-controls/number-field.md +0 -1
- package/docs/forms/form-controls/password-field.md +0 -1
- package/docs/forms/form-controls/radio-demo/demo1.md +0 -39
- package/docs/forms/form-controls/radio-group-demo/demo1.md +0 -60
- package/docs/forms/form-controls/radio-group.md +0 -1
- package/docs/forms/form-controls/radio.md +0 -1
- package/docs/forms/form-controls/range-demo/demo1.md +0 -61
- package/docs/forms/form-controls/range-demo/demo2.md +0 -59
- package/docs/forms/form-controls/range-demo/demo6.md +0 -59
- package/docs/forms/form-controls/range.md +0 -1
- package/docs/forms/form-controls/search-field-demo/demo1.md +0 -31
- package/docs/forms/form-controls/search-field.md +0 -1
- package/docs/forms/form-controls/select.md +0 -1
- package/docs/forms/form-controls/switch.md +0 -1
- package/docs/forms/form-controls/text-field.md +0 -1
- package/docs/forms/form-controls/textarea-demo/demo1.md +0 -36
- package/docs/forms/form-controls/textarea.md +0 -1
|
@@ -22,6 +22,7 @@ interface ToolTipStyles {
|
|
|
22
22
|
right?: string | 'auto';
|
|
23
23
|
opacity?: string;
|
|
24
24
|
visibility?: 'hidden';
|
|
25
|
+
display?: 'inlineBlock';
|
|
25
26
|
}
|
|
26
27
|
|
|
27
28
|
const displayToClassNameMap = {
|
|
@@ -39,7 +40,8 @@ const DEFAULT_TOOLTIP_STYLES: ToolTipStyles = {
|
|
|
39
40
|
// the tooltip before it is positioned
|
|
40
41
|
opacity: '0',
|
|
41
42
|
// prevent accidental mouse interaction while positioning
|
|
42
|
-
visibility: 'hidden'
|
|
43
|
+
visibility: 'hidden',
|
|
44
|
+
display: 'inlineBlock'
|
|
43
45
|
};
|
|
44
46
|
|
|
45
47
|
type EuiTooltipArgs = {
|
|
@@ -85,6 +87,8 @@ type EuiTooltipArgs = {
|
|
|
85
87
|
* hidden.
|
|
86
88
|
*/
|
|
87
89
|
onMouseOut?: (event: MouseEvent) => void;
|
|
90
|
+
onFocus?: () => void;
|
|
91
|
+
onBlur?: () => void;
|
|
88
92
|
};
|
|
89
93
|
|
|
90
94
|
export default class EuiToolTip extends Component<EuiTooltipArgs> {
|
|
@@ -96,6 +100,7 @@ export default class EuiToolTip extends Component<EuiTooltipArgs> {
|
|
|
96
100
|
|
|
97
101
|
//STATE
|
|
98
102
|
@tracked visible = false;
|
|
103
|
+
@tracked hasFocus = false;
|
|
99
104
|
@tracked calculatedPosition: ToolTipPositions = this.position;
|
|
100
105
|
@tracked toolTipStyles: ToolTipStyles = DEFAULT_TOOLTIP_STYLES;
|
|
101
106
|
@tracked arrowStyles: undefined | { left: string; top: string };
|
|
@@ -123,24 +128,22 @@ export default class EuiToolTip extends Component<EuiTooltipArgs> {
|
|
|
123
128
|
|
|
124
129
|
@action
|
|
125
130
|
setupAttachToHandlers(): void {
|
|
126
|
-
if (this.
|
|
131
|
+
if (this._attachTo) {
|
|
127
132
|
this.attachTo?.addEventListener('mousemove', this.showToolTip);
|
|
128
|
-
this.attachTo?.addEventListener('
|
|
129
|
-
this.attachTo?.addEventListener('focusin', this.showToolTip);
|
|
133
|
+
this.attachTo?.addEventListener('focusin', this.onFocus);
|
|
130
134
|
this.attachTo?.addEventListener('mouseout', this.onMouseOut);
|
|
131
|
-
this.attachTo?.addEventListener('focusout', this.
|
|
135
|
+
this.attachTo?.addEventListener('focusout', this.onBlur);
|
|
132
136
|
this.positionToolTip();
|
|
133
137
|
}
|
|
134
138
|
}
|
|
135
139
|
|
|
136
140
|
@action
|
|
137
141
|
removeAttachToHandlers(): void {
|
|
138
|
-
if (this.
|
|
142
|
+
if (this._attachTo) {
|
|
139
143
|
this.attachTo?.removeEventListener('mousemove', this.showToolTip);
|
|
140
|
-
this.attachTo?.removeEventListener('
|
|
141
|
-
this.attachTo?.removeEventListener('focusin', this.showToolTip);
|
|
144
|
+
this.attachTo?.removeEventListener('focusin', this.onFocus);
|
|
142
145
|
this.attachTo?.removeEventListener('mouseout', this.onMouseOut);
|
|
143
|
-
this.attachTo?.removeEventListener('focusout', this.
|
|
146
|
+
this.attachTo?.removeEventListener('focusout', this.onBlur);
|
|
144
147
|
}
|
|
145
148
|
}
|
|
146
149
|
|
|
@@ -163,7 +166,6 @@ export default class EuiToolTip extends Component<EuiTooltipArgs> {
|
|
|
163
166
|
super.willDestroy();
|
|
164
167
|
this.clearAnimationTimeout();
|
|
165
168
|
this.removeAttachToHandlers();
|
|
166
|
-
window.removeEventListener('mousemove', this.hasFocusMouseMoveListener);
|
|
167
169
|
}
|
|
168
170
|
|
|
169
171
|
@action
|
|
@@ -298,6 +300,18 @@ export default class EuiToolTip extends Component<EuiTooltipArgs> {
|
|
|
298
300
|
}
|
|
299
301
|
}
|
|
300
302
|
|
|
303
|
+
@action
|
|
304
|
+
onFocus(): void {
|
|
305
|
+
this.hasFocus = true;
|
|
306
|
+
this.showToolTip();
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
@action
|
|
310
|
+
onBlur(): void {
|
|
311
|
+
this.hasFocus = false;
|
|
312
|
+
this.hideToolTip();
|
|
313
|
+
}
|
|
314
|
+
|
|
301
315
|
@action
|
|
302
316
|
onMouseOut(event: MouseEvent): void {
|
|
303
317
|
// Prevent mousing over children from hiding the tooltip by testing for whether the mouse has
|
|
@@ -307,7 +321,9 @@ export default class EuiToolTip extends Component<EuiTooltipArgs> {
|
|
|
307
321
|
(this._anchor != null &&
|
|
308
322
|
!this._anchor.contains(event.relatedTarget as Node))
|
|
309
323
|
) {
|
|
310
|
-
this.
|
|
324
|
+
if (!this.hasFocus) {
|
|
325
|
+
this.hideToolTip();
|
|
326
|
+
}
|
|
311
327
|
}
|
|
312
328
|
|
|
313
329
|
if (this.args.onMouseOut) {
|
|
@@ -1,19 +1,61 @@
|
|
|
1
1
|
import { helper } from '@ember/component/helper';
|
|
2
|
+
import { EUI_THUMB_SIZE } from '../utils/range';
|
|
2
3
|
|
|
3
4
|
export interface EuiRangeTick {
|
|
4
5
|
value: number;
|
|
5
6
|
label: string;
|
|
6
7
|
}
|
|
7
8
|
|
|
8
|
-
export function
|
|
9
|
-
|
|
10
|
-
number,
|
|
11
|
-
number
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
export function calculateOffset(
|
|
10
|
+
position: number,
|
|
11
|
+
value: number,
|
|
12
|
+
bound: number
|
|
13
|
+
) {
|
|
14
|
+
const threshold = 30;
|
|
15
|
+
let offset = value === bound ? 0 : EUI_THUMB_SIZE / 2;
|
|
16
|
+
if (offset !== 0) {
|
|
17
|
+
// Estimating offset by eye. Trying to account for range scaling at both ends.
|
|
18
|
+
offset =
|
|
19
|
+
position <= threshold ? offset + (1 / position) * threshold : offset;
|
|
20
|
+
offset =
|
|
21
|
+
position >= 100 - threshold
|
|
22
|
+
? offset - (1 / (100 - position)) * threshold
|
|
23
|
+
: offset;
|
|
24
|
+
}
|
|
25
|
+
return offset;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function calculateThumbPosition(
|
|
29
|
+
value: number,
|
|
30
|
+
min: number,
|
|
31
|
+
max: number,
|
|
32
|
+
width: number,
|
|
33
|
+
thumbSize: number = EUI_THUMB_SIZE
|
|
34
|
+
): number {
|
|
35
|
+
// Calculate the left position based on value
|
|
36
|
+
const decimal = (value - min) / (max - min);
|
|
37
|
+
// Must be between 0-100%
|
|
38
|
+
let valuePosition = decimal <= 1 ? decimal : 1;
|
|
39
|
+
valuePosition = valuePosition >= 0 ? valuePosition : 0;
|
|
40
|
+
|
|
41
|
+
const trackWidth = width ?? 0;
|
|
42
|
+
const thumbToTrackRatio = thumbSize / trackWidth;
|
|
43
|
+
const trackPositionScale = (1 - thumbToTrackRatio) * 100;
|
|
44
|
+
|
|
45
|
+
return valuePosition * trackPositionScale;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export function getRangeTick([
|
|
49
|
+
ticks,
|
|
50
|
+
tickValue,
|
|
51
|
+
min,
|
|
52
|
+
max,
|
|
53
|
+
percentageWidth,
|
|
54
|
+
trackWidth = 0
|
|
55
|
+
]: [EuiRangeTick[], number, number, number, number, number]) {
|
|
15
56
|
let tickStyle: string = '';
|
|
16
57
|
let customTick;
|
|
58
|
+
|
|
17
59
|
if (ticks) {
|
|
18
60
|
customTick = ticks.find((o) => o.value === tickValue);
|
|
19
61
|
|
|
@@ -21,7 +63,10 @@ export function getRangeTick([ticks, tickValue, min, max, percentageWidth]: [
|
|
|
21
63
|
tickStyle = `left: ${((customTick.value - min) / (max - min)) * 100}%;`;
|
|
22
64
|
}
|
|
23
65
|
} else {
|
|
24
|
-
|
|
66
|
+
let position = calculateThumbPosition(tickValue, min, max, trackWidth);
|
|
67
|
+
|
|
68
|
+
tickStyle = `left: calc(${position}% + ${EUI_THUMB_SIZE / 2}px);`;
|
|
69
|
+
tickStyle += `width: ${percentageWidth}%;`;
|
|
25
70
|
}
|
|
26
71
|
|
|
27
72
|
return {
|
|
@@ -13,7 +13,10 @@ interface Identifiable {
|
|
|
13
13
|
*
|
|
14
14
|
* @param { any } ref
|
|
15
15
|
*/
|
|
16
|
-
export function uniqueId(
|
|
16
|
+
export function uniqueId(
|
|
17
|
+
_?: any[],
|
|
18
|
+
{ ref }: { ref?: Identifiable } = {}
|
|
19
|
+
): string {
|
|
17
20
|
return isPresent(ref) ? guidFor(ref) : guidFor({});
|
|
18
21
|
}
|
|
19
22
|
|
|
@@ -18,14 +18,6 @@
|
|
|
18
18
|
font-weight: 500;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
.
|
|
22
|
-
|
|
23
|
-
display: flex;
|
|
24
|
-
-webkit-flex-direction: column;
|
|
25
|
-
flex-direction: column;
|
|
26
|
-
height: 100%;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
.euiMarkdownEditor--isPreviewing .euiMarkdownEditor__toggleContainer {
|
|
30
|
-
display: none;
|
|
21
|
+
.ember-basic-dropdown-content {
|
|
22
|
+
z-index: 99999
|
|
31
23
|
}
|
|
@@ -0,0 +1,114 @@
|
|
|
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 { keysOf } from '../components/common';
|
|
10
|
+
|
|
11
|
+
export type EuiBreakpointSize = 'xs' | 's' | 'm' | 'l' | 'xl';
|
|
12
|
+
|
|
13
|
+
export type EuiBreakpoints = {
|
|
14
|
+
/**
|
|
15
|
+
* Set the minimum window width at which to start to the breakpoint
|
|
16
|
+
*/
|
|
17
|
+
[key in EuiBreakpointSize]: number;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export const BREAKPOINTS: EuiBreakpoints = {
|
|
21
|
+
xl: 1200,
|
|
22
|
+
l: 992,
|
|
23
|
+
m: 768,
|
|
24
|
+
s: 575,
|
|
25
|
+
xs: 0
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export const BREAKPOINT_KEYS = keysOf(BREAKPOINTS);
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Given the current `width` and an object of `EuiBreakpoints`,
|
|
32
|
+
* this function returns the string that is the name of the breakpoint key
|
|
33
|
+
* that is less than or equal to the width
|
|
34
|
+
*
|
|
35
|
+
* @param {number} width Can either be the full window width or any width
|
|
36
|
+
* @param {EuiBreakpoints} breakpoints An object with keys for sizing and values for minimum width
|
|
37
|
+
* @returns {string | undefined} Name of the breakpoint key or `undefined` if a key doesn't exist
|
|
38
|
+
*/
|
|
39
|
+
export function getBreakpoint(
|
|
40
|
+
width: number,
|
|
41
|
+
breakpoints: EuiBreakpoints = BREAKPOINTS
|
|
42
|
+
): EuiBreakpointSize | undefined {
|
|
43
|
+
// Find the breakpoint (key) whose value is <= windowWidth starting with largest first
|
|
44
|
+
return keysOf(BREAKPOINTS).find((key) => breakpoints[key] <= width);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Given the current `width` and a max breakpoint key,
|
|
49
|
+
* this function returns true or false if the `width` falls within the max
|
|
50
|
+
* breakpoint or any breakpoints below
|
|
51
|
+
*
|
|
52
|
+
* @param {number} width Can either be the full window width or any width
|
|
53
|
+
* @param {EuiBreakpointSize | number} max The named breakpoint or custom number to check against
|
|
54
|
+
* @param {EuiBreakpoints} breakpoints An object with keys for sizing and values for minimum width
|
|
55
|
+
* @returns {boolean} Will return `false` if it can't find a value for the `max` breakpoint
|
|
56
|
+
*/
|
|
57
|
+
export function isWithinMaxBreakpoint(
|
|
58
|
+
width: number,
|
|
59
|
+
max: EuiBreakpointSize | number,
|
|
60
|
+
breakpoints: EuiBreakpoints = BREAKPOINTS
|
|
61
|
+
): boolean {
|
|
62
|
+
if (typeof max === 'number') {
|
|
63
|
+
return width <= max;
|
|
64
|
+
} else {
|
|
65
|
+
const currentBreakpoint = getBreakpoint(width, breakpoints);
|
|
66
|
+
return currentBreakpoint
|
|
67
|
+
? breakpoints[currentBreakpoint] <= breakpoints[max]
|
|
68
|
+
: false;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Given the current `width` and a min breakpoint key,
|
|
74
|
+
* this function returns true or false if the `width` falls within the min
|
|
75
|
+
* breakpoint or any breakpoints above
|
|
76
|
+
*
|
|
77
|
+
* @param {number} width Can either be the full window width or any width
|
|
78
|
+
* @param {EuiBreakpointSize | number} min The named breakpoint or custom number to check against
|
|
79
|
+
* @param {EuiBreakpoints} breakpoints An object with keys for sizing and values for minimum width
|
|
80
|
+
* @returns {boolean} Will return `false` if it can't find a value for the `min` breakpoint
|
|
81
|
+
*/
|
|
82
|
+
export function isWithinMinBreakpoint(
|
|
83
|
+
width: number,
|
|
84
|
+
min: EuiBreakpointSize | number,
|
|
85
|
+
breakpoints: EuiBreakpoints = BREAKPOINTS
|
|
86
|
+
): boolean {
|
|
87
|
+
if (typeof min === 'number') {
|
|
88
|
+
return width >= min;
|
|
89
|
+
} else {
|
|
90
|
+
const currentBreakpoint = getBreakpoint(width, breakpoints);
|
|
91
|
+
return currentBreakpoint
|
|
92
|
+
? breakpoints[currentBreakpoint] >= breakpoints[min]
|
|
93
|
+
: false;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Given the current `width` and an array of breakpoint keys,
|
|
99
|
+
* this function returns true or false if the `width` falls within
|
|
100
|
+
* any of the named breakpoints
|
|
101
|
+
*
|
|
102
|
+
* @param {number} width Can either be the full window width or any width
|
|
103
|
+
* @param {EuiBreakpointSize[]} sizes An array of named breakpoints
|
|
104
|
+
* @param {EuiBreakpoints} breakpoints An object with keys for sizing and values for minimum width
|
|
105
|
+
* @returns {boolean} Returns `true` if current breakpoint name is included in `sizes`
|
|
106
|
+
*/
|
|
107
|
+
export function isWithinBreakpoints(
|
|
108
|
+
width: number,
|
|
109
|
+
sizes: EuiBreakpointSize[],
|
|
110
|
+
breakpoints: EuiBreakpoints = BREAKPOINTS
|
|
111
|
+
): boolean {
|
|
112
|
+
const currentBreakpoint = getBreakpoint(width, breakpoints);
|
|
113
|
+
return currentBreakpoint ? sizes.includes(currentBreakpoint) : false;
|
|
114
|
+
}
|
|
@@ -0,0 +1,304 @@
|
|
|
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 { listLanguages, highlight, AST, RefractorNode } from 'refractor';
|
|
10
|
+
import { CommonArgs } from '../../components/common';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Utils shared between EuiCode and EuiCodeBlock
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
export type EuiCodeSharedProps = CommonArgs & {
|
|
17
|
+
/**
|
|
18
|
+
* Sets the syntax highlighting for a specific language
|
|
19
|
+
* @see [https://prismjs.com/#supported-languages](https://prismjs.com/#supported-languages) for options
|
|
20
|
+
*/
|
|
21
|
+
language?: string;
|
|
22
|
+
transparentBackground?: boolean;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export const SUPPORTED_LANGUAGES = listLanguages();
|
|
26
|
+
export const DEFAULT_LANGUAGE = 'text';
|
|
27
|
+
|
|
28
|
+
export const checkSupportedLanguage = (language: string): string => {
|
|
29
|
+
return SUPPORTED_LANGUAGES.includes(language) ? language : DEFAULT_LANGUAGE;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const createDocument = () => {
|
|
33
|
+
return document;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
const attributes = [
|
|
37
|
+
'src',
|
|
38
|
+
'alt',
|
|
39
|
+
'href',
|
|
40
|
+
'target',
|
|
41
|
+
'title',
|
|
42
|
+
'data-line-number',
|
|
43
|
+
'aria-hidden',
|
|
44
|
+
'style'
|
|
45
|
+
];
|
|
46
|
+
export interface DynamicComponent {}
|
|
47
|
+
|
|
48
|
+
export const getHtmlContent = (nodes: RefractorNode[]) => {
|
|
49
|
+
const document = createDocument();
|
|
50
|
+
let components: DynamicComponent[] = [];
|
|
51
|
+
|
|
52
|
+
const toElements = (parent: HTMLElement, nodes: RefractorNode[] = []) => {
|
|
53
|
+
nodes?.forEach((node) => {
|
|
54
|
+
let el = toElement(node);
|
|
55
|
+
if (el) {
|
|
56
|
+
parent.appendChild(el);
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
return parent;
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
const createElement = (
|
|
63
|
+
name: string,
|
|
64
|
+
node: RefractorNode,
|
|
65
|
+
className?: string
|
|
66
|
+
) => {
|
|
67
|
+
let element = document.createElement(name);
|
|
68
|
+
if (isAstElement(node)) {
|
|
69
|
+
let properties = node.properties;
|
|
70
|
+
let classNames = [];
|
|
71
|
+
if (properties) {
|
|
72
|
+
if (properties.className) {
|
|
73
|
+
classNames.push(...(properties.className as string[]));
|
|
74
|
+
}
|
|
75
|
+
for (let key in properties) {
|
|
76
|
+
if (attributes.includes(key)) {
|
|
77
|
+
let value = properties[key];
|
|
78
|
+
if (key === 'style') {
|
|
79
|
+
Object.keys(value).forEach((k: string) => {
|
|
80
|
+
//@ts-ignore
|
|
81
|
+
element.style[k] = `${value[k]}`;
|
|
82
|
+
});
|
|
83
|
+
} else {
|
|
84
|
+
element.setAttribute(key, value as string);
|
|
85
|
+
}
|
|
86
|
+
} else {
|
|
87
|
+
// temporary
|
|
88
|
+
if (key !== 'className') {
|
|
89
|
+
console.warn('Unmapped node property', key);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
if (className) {
|
|
95
|
+
classNames.push(className);
|
|
96
|
+
}
|
|
97
|
+
if (classNames.length) {
|
|
98
|
+
element.setAttribute('class', classNames.join(' '));
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
return element;
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
const toElement = (node: RefractorNode) => {
|
|
105
|
+
if (isAstElement(node)) {
|
|
106
|
+
let { type } = node;
|
|
107
|
+
if (type === 'element') {
|
|
108
|
+
let element = createElement(node.tagName, node);
|
|
109
|
+
return toElements(element, node.children);
|
|
110
|
+
} else if (type === 'text') {
|
|
111
|
+
//@ts-ignore
|
|
112
|
+
return document.createTextNode(node.value);
|
|
113
|
+
} else if (type === 'component') {
|
|
114
|
+
let { inline } = node.properties;
|
|
115
|
+
let element = createElement(inline ? 'span' : 'div', node, 'component');
|
|
116
|
+
let { _children, ...properties } = node.properties;
|
|
117
|
+
let content = toElements(document.createElement('span'), node.children);
|
|
118
|
+
components.push({
|
|
119
|
+
element,
|
|
120
|
+
content,
|
|
121
|
+
...properties
|
|
122
|
+
});
|
|
123
|
+
return element;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
return;
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
const element = toElements(document.createElement('div'), nodes);
|
|
130
|
+
|
|
131
|
+
return {
|
|
132
|
+
element: element,
|
|
133
|
+
components
|
|
134
|
+
};
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
export const isAstElement = (node: RefractorNode): node is AST.Element =>
|
|
138
|
+
node.hasOwnProperty('type') &&
|
|
139
|
+
(node.type === 'element' || node.type === 'text');
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Line utils specific to EuiCodeBlock
|
|
143
|
+
*/
|
|
144
|
+
|
|
145
|
+
type ExtendedRefractorNode = RefractorNode & {
|
|
146
|
+
lineStart?: number;
|
|
147
|
+
lineEnd?: number;
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
interface LineNumbersConfig {
|
|
151
|
+
start: number;
|
|
152
|
+
show: boolean;
|
|
153
|
+
highlight?: string;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// Approximate width of a single digit/character
|
|
157
|
+
const CHAR_SIZE = 8;
|
|
158
|
+
const $euiSizeS = 8;
|
|
159
|
+
|
|
160
|
+
// Creates an array of numbers from comma-separeated
|
|
161
|
+
// string of numbers or number ranges using `-`
|
|
162
|
+
// (e.g., "1, 3-10, 15")
|
|
163
|
+
export const parseLineRanges = (ranges: string) => {
|
|
164
|
+
const highlights: number[] = [];
|
|
165
|
+
ranges
|
|
166
|
+
.replace(/\s/g, '')
|
|
167
|
+
.split(',')
|
|
168
|
+
.forEach((line: string) => {
|
|
169
|
+
if (line.includes('-')) {
|
|
170
|
+
const range = line.split('-').map(Number);
|
|
171
|
+
for (let i = range[0]; i <= range[1]; i++) {
|
|
172
|
+
highlights.push(i);
|
|
173
|
+
}
|
|
174
|
+
} else {
|
|
175
|
+
highlights.push(Number(line));
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
return highlights;
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
const addLineData = (
|
|
182
|
+
nodes: ExtendedRefractorNode[],
|
|
183
|
+
data: { lineNumber: number }
|
|
184
|
+
): ExtendedRefractorNode[] => {
|
|
185
|
+
return nodes.reduce<ExtendedRefractorNode[]>((result, node) => {
|
|
186
|
+
const lineStart = data.lineNumber;
|
|
187
|
+
if (node.type === 'text') {
|
|
188
|
+
if (!node.value.match(/\r\n?|\n/)) {
|
|
189
|
+
node.lineStart = lineStart;
|
|
190
|
+
node.lineEnd = lineStart;
|
|
191
|
+
result.push(node);
|
|
192
|
+
} else {
|
|
193
|
+
const lines = node.value.split(/\r\n?|\n/);
|
|
194
|
+
lines.forEach((line, i) => {
|
|
195
|
+
const num = i === 0 ? data.lineNumber : ++data.lineNumber;
|
|
196
|
+
result.push({
|
|
197
|
+
type: 'text',
|
|
198
|
+
value: i === lines.length - 1 ? line : `${line}\n`,
|
|
199
|
+
lineStart: num,
|
|
200
|
+
lineEnd: num
|
|
201
|
+
});
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
return result;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
if (node.children && node.children.length) {
|
|
208
|
+
const children = addLineData(node.children, data);
|
|
209
|
+
const first = children[0];
|
|
210
|
+
const last = children[children.length - 1];
|
|
211
|
+
const start = first.lineStart ?? lineStart;
|
|
212
|
+
const end = last.lineEnd ?? lineStart;
|
|
213
|
+
if (start !== end) {
|
|
214
|
+
children.forEach((node) => {
|
|
215
|
+
result.push(node);
|
|
216
|
+
});
|
|
217
|
+
} else {
|
|
218
|
+
node.lineStart = start;
|
|
219
|
+
node.lineEnd = end;
|
|
220
|
+
node.children = children;
|
|
221
|
+
result.push(node);
|
|
222
|
+
}
|
|
223
|
+
return result;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
result.push(node);
|
|
227
|
+
return result;
|
|
228
|
+
}, []);
|
|
229
|
+
};
|
|
230
|
+
|
|
231
|
+
function wrapLines(
|
|
232
|
+
nodes: ExtendedRefractorNode[],
|
|
233
|
+
options: { showLineNumbers: boolean; highlight?: string }
|
|
234
|
+
) {
|
|
235
|
+
const highlights = options.highlight
|
|
236
|
+
? parseLineRanges(options.highlight)
|
|
237
|
+
: [];
|
|
238
|
+
const grouped: ExtendedRefractorNode[][] = [];
|
|
239
|
+
nodes.forEach((node) => {
|
|
240
|
+
const lineStart = node.lineStart! - 1;
|
|
241
|
+
if (grouped[lineStart]) {
|
|
242
|
+
grouped[lineStart].push(node);
|
|
243
|
+
} else {
|
|
244
|
+
grouped[lineStart] = [node];
|
|
245
|
+
}
|
|
246
|
+
});
|
|
247
|
+
const wrapped: RefractorNode[] = [];
|
|
248
|
+
const digits = grouped.length.toString().length;
|
|
249
|
+
const width = digits * CHAR_SIZE;
|
|
250
|
+
grouped.forEach((node, i) => {
|
|
251
|
+
const lineNumber = i + 1;
|
|
252
|
+
const classes = ['euiCodeBlock__line'];
|
|
253
|
+
if (highlights.includes(lineNumber)) {
|
|
254
|
+
classes.push('euiCodeBlock__line--isHighlighted');
|
|
255
|
+
}
|
|
256
|
+
const children: RefractorNode[] = options.showLineNumbers
|
|
257
|
+
? [
|
|
258
|
+
{
|
|
259
|
+
type: 'element',
|
|
260
|
+
tagName: 'span',
|
|
261
|
+
properties: {
|
|
262
|
+
style: { width: `${width}px` },
|
|
263
|
+
['data-line-number']: lineNumber,
|
|
264
|
+
['aria-hidden']: true,
|
|
265
|
+
className: ['euiCodeBlock__lineNumber']
|
|
266
|
+
},
|
|
267
|
+
children: []
|
|
268
|
+
},
|
|
269
|
+
{
|
|
270
|
+
type: 'element',
|
|
271
|
+
tagName: 'span',
|
|
272
|
+
properties: {
|
|
273
|
+
style: {
|
|
274
|
+
marginLeft: `${width + $euiSizeS}px`,
|
|
275
|
+
width: `calc(100% - ${width}px)`
|
|
276
|
+
},
|
|
277
|
+
className: ['euiCodeBlock__lineText']
|
|
278
|
+
},
|
|
279
|
+
children: node
|
|
280
|
+
}
|
|
281
|
+
]
|
|
282
|
+
: node;
|
|
283
|
+
wrapped.push({
|
|
284
|
+
type: 'element',
|
|
285
|
+
tagName: 'span',
|
|
286
|
+
properties: {
|
|
287
|
+
className: [classes.join(' ')]
|
|
288
|
+
},
|
|
289
|
+
children
|
|
290
|
+
});
|
|
291
|
+
});
|
|
292
|
+
return wrapped;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
export const highlightByLine = (
|
|
296
|
+
children: string,
|
|
297
|
+
language: string,
|
|
298
|
+
data: LineNumbersConfig
|
|
299
|
+
) => {
|
|
300
|
+
return wrapLines(
|
|
301
|
+
addLineData(highlight(children, language), { lineNumber: data.start }),
|
|
302
|
+
{ showLineNumbers: data.show, highlight: data.highlight }
|
|
303
|
+
);
|
|
304
|
+
};
|