@elastic/eui 88.4.0 → 88.5.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/dist/eui_theme_dark.css +9 -2
- package/dist/eui_theme_dark.min.css +1 -1
- package/dist/eui_theme_light.css +9 -2
- package/dist/eui_theme_light.min.css +1 -1
- package/es/components/avatar/avatar.js +1 -1
- package/es/components/badge/badge.js +1 -1
- package/es/components/badge/beta_badge/beta_badge.js +1 -1
- package/es/components/basic_table/basic_table.a11y.js +4 -4
- package/es/components/basic_table/basic_table.js +1 -1
- package/es/components/basic_table/collapsed_item_actions.js +1 -1
- package/es/components/basic_table/in_memory_table.a11y.js +4 -4
- package/es/components/basic_table/in_memory_table.js +1 -1
- package/es/components/breadcrumbs/breadcrumb.js +12 -0
- package/es/components/breadcrumbs/breadcrumbs.js +12 -0
- package/es/components/button/button_display/_button_display.js +1 -1
- package/es/components/button/button_display/_button_display_content.js +1 -1
- package/es/components/button/button_empty/button_empty.js +1 -1
- package/es/components/button/button_group/button_group.js +1 -1
- package/es/components/button/button_group/button_group_button.js +1 -1
- package/es/components/button/button_icon/button_icon.js +1 -1
- package/es/components/call_out/call_out.js +54 -34
- package/es/components/call_out/call_out.styles.js +36 -7
- package/es/components/card/card.js +1 -1
- package/es/components/collapsible_nav/collapsible_nav_group/collapsible_nav_group.js +1 -1
- package/es/components/collapsible_nav_beta/collapsible_nav_item/collapsed/collapsed_nav_button.js +2 -2
- package/es/components/collapsible_nav_beta/collapsible_nav_item/collapsed/collapsed_nav_item.js +2 -2
- package/es/components/collapsible_nav_beta/collapsible_nav_item/collapsed/collapsed_nav_popover.js +3 -3
- package/es/components/collapsible_nav_beta/collapsible_nav_item/collapsible_nav_accordion.js +2 -2
- package/es/components/collapsible_nav_beta/collapsible_nav_item/collapsible_nav_item.js +3 -3
- package/es/components/combo_box/combo_box_options_list/combo_box_options_list.js +11 -6
- package/es/components/comment_list/comment.js +2 -2
- package/es/components/comment_list/comment_event.js +1 -1
- package/es/components/comment_list/comment_list.js +2 -2
- package/es/components/comment_list/comment_timeline.js +1 -1
- package/es/components/control_bar/control_bar.js +12 -0
- package/es/components/datagrid/body/data_grid_body.js +13 -13
- package/es/components/datagrid/body/data_grid_body_custom.js +13 -13
- package/es/components/datagrid/body/data_grid_body_virtualized.js +13 -13
- package/es/components/datagrid/body/data_grid_cell.js +24 -24
- package/es/components/datagrid/body/header/data_grid_header_cell.js +12 -12
- package/es/components/datagrid/body/header/data_grid_header_row.js +13 -13
- package/es/components/datagrid/controls/column_sorting_draggable.js +1 -1
- package/es/components/datagrid/controls/data_grid_toolbar.js +21 -5
- package/es/components/datagrid/controls/display_selector.js +16 -15
- package/es/components/datagrid/data_grid.a11y.js +2 -2
- package/es/components/datagrid/data_grid.js +35 -16
- package/es/components/datagrid/data_grid_types.js +3 -0
- package/es/components/datagrid/utils/in_memory.js +12 -12
- package/es/components/date_picker/date_picker.js +15 -8
- package/es/components/date_picker/date_picker_range.js +1 -1
- package/es/components/date_picker/super_date_picker/quick_select_popover/quick_select_popover.js +2 -2
- package/es/components/empty_prompt/empty_prompt.js +1 -1
- package/es/components/facet/facet_button.js +1 -1
- package/es/components/form/field_number/field_number.js +1 -1
- package/es/components/form/field_text/field_text.js +2 -2
- package/es/components/form/form_control_layout/form_control_layout.js +2 -2
- package/es/components/form/form_control_layout/form_control_layout_custom_icon.js +1 -1
- package/es/components/form/form_control_layout/form_control_layout_icons.js +2 -2
- package/es/components/header/header_breadcrumbs/header_breadcrumbs.js +12 -0
- package/es/components/header/header_links/header_link.js +1 -1
- package/es/components/header/header_links/header_links.js +13 -1
- package/es/components/header/header_logo/header_logo.js +1 -1
- package/es/components/header/header_section/header_section_item_button.js +1 -1
- package/es/components/icon/assets/gradient.js +34 -0
- package/es/components/icon/assets/palette.js +35 -0
- package/es/components/icon/icon.js +1 -1
- package/es/components/icon/icon_map.js +2 -0
- package/es/components/key_pad_menu/key_pad_menu_item.js +1 -1
- package/es/components/list_group/list_group.js +2 -2
- package/es/components/list_group/list_group_item.js +2 -2
- package/es/components/list_group/list_group_item_extra_action.js +1 -1
- package/es/components/list_group/pinnable_list_group/pinnable_list_group.js +4 -4
- package/es/components/loading/loading_logo.js +1 -1
- package/es/components/markdown_editor/markdown_editor.js +1 -1
- package/es/components/markdown_editor/markdown_editor_drop_zone.js +1 -1
- package/es/components/markdown_editor/markdown_editor_footer.js +1 -1
- package/es/components/markdown_editor/markdown_editor_toolbar.js +1 -1
- package/es/components/notification/notification_event.js +2 -2
- package/es/components/notification/notification_event_meta.js +1 -1
- package/es/components/page/page_header/page_header_content.js +13 -1
- package/es/components/pagination/pagination_button.js +1 -1
- package/es/components/popover/input_popover.js +1 -0
- package/es/components/popover/popover.js +20 -3
- package/es/components/popover/popover_panel/_popover_panel.js +15 -21
- package/es/components/popover/popover_panel/_popover_panel.styles.js +47 -27
- package/es/components/selectable/selectable_list/selectable_list.js +1 -1
- package/es/components/selectable/selectable_list/selectable_list_item.js +1 -1
- package/es/components/selectable/selectable_templates/selectable_template_sitewide.js +1 -1
- package/es/components/suggest/suggest.js +1 -1
- package/es/components/suggest/suggest_item.js +1 -1
- package/es/components/table/table_header_button.js +1 -1
- package/es/components/text_truncate/index.js +1 -1
- package/es/components/text_truncate/text_truncate.js +16 -26
- package/es/components/text_truncate/text_truncate.styles.js +10 -10
- package/es/components/text_truncate/utils.js +251 -282
- package/es/components/timeline/timeline_item_icon.js +1 -1
- package/es/components/toast/global_toast_list.js +1 -1
- package/es/components/toast/toast.js +1 -1
- package/es/components/tool_tip/icon_tip.js +1 -1
- package/es/components/tour/tour_step.js +12 -0
- package/eui.d.ts +191 -112
- package/i18ntokens.json +106 -88
- package/lib/components/avatar/avatar.js +1 -1
- package/lib/components/badge/badge.js +1 -1
- package/lib/components/badge/beta_badge/beta_badge.js +1 -1
- package/lib/components/basic_table/basic_table.a11y.js +4 -4
- package/lib/components/basic_table/basic_table.js +1 -1
- package/lib/components/basic_table/collapsed_item_actions.js +1 -1
- package/lib/components/basic_table/in_memory_table.a11y.js +4 -4
- package/lib/components/basic_table/in_memory_table.js +1 -1
- package/lib/components/breadcrumbs/breadcrumb.js +12 -0
- package/lib/components/button/button_display/_button_display.js +1 -1
- package/lib/components/button/button_display/_button_display_content.js +1 -1
- package/lib/components/button/button_empty/button_empty.js +1 -1
- package/lib/components/button/button_group/button_group.js +1 -1
- package/lib/components/button/button_group/button_group_button.js +1 -1
- package/lib/components/button/button_icon/button_icon.js +1 -1
- package/lib/components/call_out/call_out.js +54 -34
- package/lib/components/call_out/call_out.styles.js +42 -15
- package/lib/components/card/card.js +1 -1
- package/lib/components/collapsible_nav/collapsible_nav_group/collapsible_nav_group.js +1 -1
- package/lib/components/collapsible_nav_beta/collapsible_nav_item/collapsed/collapsed_nav_button.js +2 -2
- package/lib/components/collapsible_nav_beta/collapsible_nav_item/collapsed/collapsed_nav_item.js +2 -2
- package/lib/components/collapsible_nav_beta/collapsible_nav_item/collapsed/collapsed_nav_popover.js +3 -3
- package/lib/components/collapsible_nav_beta/collapsible_nav_item/collapsible_nav_accordion.js +2 -2
- package/lib/components/collapsible_nav_beta/collapsible_nav_item/collapsible_nav_item.js +3 -3
- package/lib/components/combo_box/combo_box_options_list/combo_box_options_list.js +11 -6
- package/lib/components/comment_list/comment.js +2 -2
- package/lib/components/comment_list/comment_event.js +1 -1
- package/lib/components/comment_list/comment_list.js +2 -2
- package/lib/components/comment_list/comment_timeline.js +1 -1
- package/lib/components/datagrid/body/data_grid_body.js +13 -13
- package/lib/components/datagrid/body/data_grid_body_custom.js +13 -13
- package/lib/components/datagrid/body/data_grid_body_virtualized.js +13 -13
- package/lib/components/datagrid/body/data_grid_cell.js +24 -24
- package/lib/components/datagrid/body/header/data_grid_header_cell.js +12 -12
- package/lib/components/datagrid/body/header/data_grid_header_row.js +13 -13
- package/lib/components/datagrid/controls/column_sorting_draggable.js +1 -1
- package/lib/components/datagrid/controls/data_grid_toolbar.js +21 -5
- package/lib/components/datagrid/controls/display_selector.js +16 -15
- package/lib/components/datagrid/data_grid.a11y.js +2 -2
- package/lib/components/datagrid/data_grid.js +35 -16
- package/lib/components/datagrid/data_grid_types.js +4 -0
- package/lib/components/datagrid/utils/in_memory.js +12 -12
- package/lib/components/date_picker/date_picker.js +15 -8
- package/lib/components/date_picker/date_picker_range.js +1 -1
- package/lib/components/date_picker/super_date_picker/quick_select_popover/quick_select_popover.js +2 -2
- package/lib/components/empty_prompt/empty_prompt.js +1 -1
- package/lib/components/facet/facet_button.js +1 -1
- package/lib/components/form/field_number/field_number.js +1 -1
- package/lib/components/form/field_text/field_text.js +2 -2
- package/lib/components/form/form_control_layout/form_control_layout.js +2 -2
- package/lib/components/form/form_control_layout/form_control_layout_custom_icon.js +1 -1
- package/lib/components/form/form_control_layout/form_control_layout_icons.js +2 -2
- package/lib/components/header/header_links/header_link.js +1 -1
- package/lib/components/header/header_links/header_links.js +1 -1
- package/lib/components/header/header_logo/header_logo.js +1 -1
- package/lib/components/header/header_section/header_section_item_button.js +1 -1
- package/lib/components/icon/assets/gradient.js +42 -0
- package/lib/components/icon/assets/palette.js +43 -0
- package/lib/components/icon/icon.js +1 -1
- package/lib/components/icon/icon_map.js +2 -0
- package/lib/components/icon/svgs/gradient.svg +3 -0
- package/lib/components/icon/svgs/palette.svg +4 -0
- package/lib/components/key_pad_menu/key_pad_menu_item.js +1 -1
- package/lib/components/list_group/list_group.js +2 -2
- package/lib/components/list_group/list_group_item.js +2 -2
- package/lib/components/list_group/list_group_item_extra_action.js +1 -1
- package/lib/components/list_group/pinnable_list_group/pinnable_list_group.js +4 -4
- package/lib/components/loading/loading_logo.js +1 -1
- package/lib/components/markdown_editor/markdown_editor.js +1 -1
- package/lib/components/markdown_editor/markdown_editor_drop_zone.js +1 -1
- package/lib/components/markdown_editor/markdown_editor_footer.js +1 -1
- package/lib/components/markdown_editor/markdown_editor_toolbar.js +1 -1
- package/lib/components/notification/notification_event.js +2 -2
- package/lib/components/notification/notification_event_meta.js +1 -1
- package/lib/components/page/page_header/page_header_content.js +1 -1
- package/lib/components/popover/input_popover.js +1 -0
- package/lib/components/popover/popover.js +20 -3
- package/lib/components/popover/popover_panel/_popover_panel.js +14 -20
- package/lib/components/popover/popover_panel/_popover_panel.styles.js +53 -35
- package/lib/components/selectable/selectable_list/selectable_list.js +1 -1
- package/lib/components/selectable/selectable_list/selectable_list_item.js +1 -1
- package/lib/components/selectable/selectable_templates/selectable_template_sitewide.js +1 -1
- package/lib/components/suggest/suggest.js +1 -1
- package/lib/components/suggest/suggest_item.js +1 -1
- package/lib/components/table/table_header_button.js +1 -1
- package/lib/components/text_truncate/index.js +6 -6
- package/lib/components/text_truncate/text_truncate.js +13 -23
- package/lib/components/text_truncate/text_truncate.styles.js +10 -10
- package/lib/components/text_truncate/utils.js +253 -284
- package/lib/components/timeline/timeline_item_icon.js +1 -1
- package/lib/components/toast/global_toast_list.js +1 -1
- package/lib/components/toast/toast.js +1 -1
- package/lib/components/tool_tip/icon_tip.js +1 -1
- package/optimize/es/components/basic_table/basic_table.a11y.js +4 -4
- package/optimize/es/components/basic_table/in_memory_table.a11y.js +4 -4
- package/optimize/es/components/call_out/call_out.js +44 -32
- package/optimize/es/components/call_out/call_out.styles.js +36 -7
- package/optimize/es/components/combo_box/combo_box_options_list/combo_box_options_list.js +11 -6
- package/optimize/es/components/datagrid/controls/data_grid_toolbar.js +21 -5
- package/optimize/es/components/datagrid/controls/display_selector.js +16 -15
- package/optimize/es/components/datagrid/data_grid.a11y.js +2 -2
- package/optimize/es/components/datagrid/data_grid.js +4 -2
- package/optimize/es/components/datagrid/data_grid_types.js +3 -0
- package/optimize/es/components/date_picker/date_picker.js +8 -5
- package/optimize/es/components/date_picker/super_date_picker/quick_select_popover/quick_select_popover.js +2 -2
- package/optimize/es/components/icon/assets/gradient.js +33 -0
- package/optimize/es/components/icon/assets/palette.js +34 -0
- package/optimize/es/components/icon/icon_map.js +2 -0
- package/optimize/es/components/popover/input_popover.js +1 -0
- package/optimize/es/components/popover/popover.js +8 -3
- package/optimize/es/components/popover/popover_panel/_popover_panel.js +15 -16
- package/optimize/es/components/popover/popover_panel/_popover_panel.styles.js +47 -27
- package/optimize/es/components/text_truncate/index.js +1 -1
- package/optimize/es/components/text_truncate/text_truncate.js +16 -16
- package/optimize/es/components/text_truncate/text_truncate.styles.js +10 -10
- package/optimize/es/components/text_truncate/utils.js +245 -277
- package/optimize/lib/components/basic_table/basic_table.a11y.js +4 -4
- package/optimize/lib/components/basic_table/in_memory_table.a11y.js +4 -4
- package/optimize/lib/components/call_out/call_out.js +44 -32
- package/optimize/lib/components/call_out/call_out.styles.js +42 -15
- package/optimize/lib/components/combo_box/combo_box_options_list/combo_box_options_list.js +11 -6
- package/optimize/lib/components/datagrid/controls/data_grid_toolbar.js +21 -5
- package/optimize/lib/components/datagrid/controls/display_selector.js +16 -15
- package/optimize/lib/components/datagrid/data_grid.a11y.js +2 -2
- package/optimize/lib/components/datagrid/data_grid.js +4 -2
- package/optimize/lib/components/datagrid/data_grid_types.js +4 -0
- package/optimize/lib/components/date_picker/date_picker.js +8 -5
- package/optimize/lib/components/date_picker/super_date_picker/quick_select_popover/quick_select_popover.js +2 -2
- package/optimize/lib/components/icon/assets/gradient.js +42 -0
- package/optimize/lib/components/icon/assets/palette.js +43 -0
- package/optimize/lib/components/icon/icon_map.js +2 -0
- package/optimize/lib/components/icon/svgs/gradient.svg +3 -0
- package/optimize/lib/components/icon/svgs/palette.svg +4 -0
- package/optimize/lib/components/popover/input_popover.js +1 -0
- package/optimize/lib/components/popover/popover.js +8 -3
- package/optimize/lib/components/popover/popover_panel/_popover_panel.js +14 -15
- package/optimize/lib/components/popover/popover_panel/_popover_panel.styles.js +53 -35
- package/optimize/lib/components/text_truncate/index.js +6 -6
- package/optimize/lib/components/text_truncate/text_truncate.js +13 -13
- package/optimize/lib/components/text_truncate/text_truncate.styles.js +10 -10
- package/optimize/lib/components/text_truncate/utils.js +247 -279
- package/package.json +1 -2
- package/src/components/combo_box/combo_box_options_list/_combo_box_options_list.scss +8 -0
- package/src/components/date_picker/super_date_picker/quick_select_popover/_quick_select_popover.scss +2 -4
- package/test-env/components/avatar/avatar.js +1 -1
- package/test-env/components/badge/badge.js +1 -1
- package/test-env/components/badge/beta_badge/beta_badge.js +1 -1
- package/test-env/components/basic_table/basic_table.a11y.js +4 -4
- package/test-env/components/basic_table/basic_table.js +1 -1
- package/test-env/components/basic_table/collapsed_item_actions.js +1 -1
- package/test-env/components/basic_table/in_memory_table.a11y.js +4 -4
- package/test-env/components/basic_table/in_memory_table.js +1 -1
- package/test-env/components/breadcrumbs/breadcrumb.js +12 -0
- package/test-env/components/button/button_display/_button_display.js +1 -1
- package/test-env/components/button/button_display/_button_display_content.js +1 -1
- package/test-env/components/button/button_empty/button_empty.js +1 -1
- package/test-env/components/button/button_group/button_group.js +1 -1
- package/test-env/components/button/button_group/button_group_button.js +1 -1
- package/test-env/components/button/button_icon/button_icon.js +1 -1
- package/test-env/components/call_out/call_out.js +54 -34
- package/test-env/components/call_out/call_out.styles.js +42 -15
- package/test-env/components/card/card.js +1 -1
- package/test-env/components/collapsible_nav/collapsible_nav_group/collapsible_nav_group.js +1 -1
- package/test-env/components/collapsible_nav_beta/collapsible_nav_item/collapsed/collapsed_nav_button.js +2 -2
- package/test-env/components/collapsible_nav_beta/collapsible_nav_item/collapsed/collapsed_nav_item.js +2 -2
- package/test-env/components/collapsible_nav_beta/collapsible_nav_item/collapsed/collapsed_nav_popover.js +3 -3
- package/test-env/components/collapsible_nav_beta/collapsible_nav_item/collapsible_nav_accordion.js +2 -2
- package/test-env/components/collapsible_nav_beta/collapsible_nav_item/collapsible_nav_item.js +3 -3
- package/test-env/components/combo_box/combo_box_options_list/combo_box_options_list.js +11 -6
- package/test-env/components/comment_list/comment.js +2 -2
- package/test-env/components/comment_list/comment_event.js +1 -1
- package/test-env/components/comment_list/comment_list.js +2 -2
- package/test-env/components/comment_list/comment_timeline.js +1 -1
- package/test-env/components/datagrid/body/data_grid_body.js +13 -13
- package/test-env/components/datagrid/body/data_grid_body_custom.js +13 -13
- package/test-env/components/datagrid/body/data_grid_body_virtualized.js +13 -13
- package/test-env/components/datagrid/body/data_grid_cell.js +24 -24
- package/test-env/components/datagrid/body/header/data_grid_header_cell.js +12 -12
- package/test-env/components/datagrid/body/header/data_grid_header_row.js +13 -13
- package/test-env/components/datagrid/controls/column_sorting_draggable.js +1 -1
- package/test-env/components/datagrid/controls/data_grid_toolbar.js +21 -5
- package/test-env/components/datagrid/controls/display_selector.js +16 -15
- package/test-env/components/datagrid/data_grid.a11y.js +2 -2
- package/test-env/components/datagrid/data_grid.js +35 -16
- package/test-env/components/datagrid/data_grid_types.js +4 -0
- package/test-env/components/datagrid/utils/in_memory.js +12 -12
- package/test-env/components/date_picker/date_picker.js +15 -8
- package/test-env/components/date_picker/date_picker_range.js +1 -1
- package/test-env/components/date_picker/super_date_picker/quick_select_popover/quick_select_popover.js +2 -2
- package/test-env/components/empty_prompt/empty_prompt.js +1 -1
- package/test-env/components/facet/facet_button.js +1 -1
- package/test-env/components/form/field_number/field_number.js +1 -1
- package/test-env/components/form/field_text/field_text.js +2 -2
- package/test-env/components/form/form_control_layout/form_control_layout.js +2 -2
- package/test-env/components/form/form_control_layout/form_control_layout_custom_icon.js +1 -1
- package/test-env/components/form/form_control_layout/form_control_layout_icons.js +2 -2
- package/test-env/components/header/header_links/header_link.js +1 -1
- package/test-env/components/header/header_links/header_links.js +1 -1
- package/test-env/components/header/header_logo/header_logo.js +1 -1
- package/test-env/components/header/header_section/header_section_item_button.js +1 -1
- package/test-env/components/icon/assets/gradient.js +42 -0
- package/test-env/components/icon/assets/palette.js +43 -0
- package/test-env/components/icon/icon_map.js +2 -0
- package/test-env/components/key_pad_menu/key_pad_menu_item.js +1 -1
- package/test-env/components/list_group/list_group.js +2 -2
- package/test-env/components/list_group/list_group_item.js +2 -2
- package/test-env/components/list_group/list_group_item_extra_action.js +1 -1
- package/test-env/components/list_group/pinnable_list_group/pinnable_list_group.js +4 -4
- package/test-env/components/loading/loading_logo.js +1 -1
- package/test-env/components/markdown_editor/markdown_editor.js +1 -1
- package/test-env/components/markdown_editor/markdown_editor_drop_zone.js +1 -1
- package/test-env/components/markdown_editor/markdown_editor_footer.js +1 -1
- package/test-env/components/markdown_editor/markdown_editor_toolbar.js +1 -1
- package/test-env/components/notification/notification_event.js +2 -2
- package/test-env/components/notification/notification_event_meta.js +1 -1
- package/test-env/components/page/page_header/page_header_content.js +1 -1
- package/test-env/components/popover/input_popover.js +1 -0
- package/test-env/components/popover/popover.js +20 -3
- package/test-env/components/popover/popover_panel/_popover_panel.js +14 -15
- package/test-env/components/popover/popover_panel/_popover_panel.styles.js +53 -35
- package/test-env/components/selectable/selectable_list/selectable_list.js +1 -1
- package/test-env/components/selectable/selectable_list/selectable_list_item.js +1 -1
- package/test-env/components/selectable/selectable_templates/selectable_template_sitewide.js +1 -1
- package/test-env/components/suggest/suggest.js +1 -1
- package/test-env/components/suggest/suggest_item.js +1 -1
- package/test-env/components/table/table_header_button.js +1 -1
- package/test-env/components/text_truncate/index.js +6 -6
- package/test-env/components/text_truncate/text_truncate.js +13 -23
- package/test-env/components/text_truncate/text_truncate.styles.js +10 -10
- package/test-env/components/text_truncate/utils.js +247 -279
- package/test-env/components/timeline/timeline_item_icon.js +1 -1
- package/test-env/components/toast/global_toast_list.js +1 -1
- package/test-env/components/toast/toast.js +1 -1
- package/test-env/components/tool_tip/icon_tip.js +1 -1
|
@@ -1,14 +1,14 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
1
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
2
3
|
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
|
|
4
|
+
import _get from "@babel/runtime/helpers/get";
|
|
3
5
|
import _inherits from "@babel/runtime/helpers/inherits";
|
|
4
6
|
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
5
7
|
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
6
|
-
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
7
|
-
import _createClass from "@babel/runtime/helpers/createClass";
|
|
8
8
|
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
9
|
+
import _createClass from "@babel/runtime/helpers/createClass";
|
|
9
10
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
10
|
-
var _excluded = ["
|
|
11
|
-
_excluded2 = ["font", "container"];
|
|
11
|
+
var _excluded = ["fullText", "ellipsis", "availableWidth"];
|
|
12
12
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
13
13
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
14
14
|
/*
|
|
@@ -18,296 +18,273 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
|
|
|
18
18
|
* in compliance with, at your election, the Elastic License 2.0 or the Server
|
|
19
19
|
* Side Public License, v 1.
|
|
20
20
|
*/
|
|
21
|
-
/**
|
|
22
|
-
* This internal shared/base class contains the actual logic for truncating text
|
|
23
|
-
* (as well as a few handy utilities for checking whether truncation is possible
|
|
24
|
-
* or even necessary).
|
|
25
|
-
*
|
|
26
|
-
* How the underlying mechanism works: the full text is rendered, and then
|
|
27
|
-
* characters are removed one by one until the width of the text fits within
|
|
28
|
-
* the specified available width.
|
|
29
|
-
*
|
|
30
|
-
* Side note: The exception to this is the `truncateStartEndAtPosition` method,
|
|
31
|
-
* which works by building up from an empty string / by adding characters
|
|
32
|
-
* instead of removing them.
|
|
33
|
-
*/
|
|
34
|
-
var _TruncationUtils = /*#__PURE__*/_createClass(function _TruncationUtils(_ref) {
|
|
35
|
-
var _this = this;
|
|
36
|
-
var fullText = _ref.fullText,
|
|
37
|
-
ellipsis = _ref.ellipsis,
|
|
38
|
-
availableWidth = _ref.availableWidth;
|
|
39
|
-
_classCallCheck(this, _TruncationUtils);
|
|
40
|
-
_defineProperty(this, "fullText", void 0);
|
|
41
|
-
_defineProperty(this, "ellipsis", void 0);
|
|
42
|
-
_defineProperty(this, "availableWidth", void 0);
|
|
43
|
-
/**
|
|
44
|
-
* Early return checks
|
|
45
|
-
*/
|
|
46
|
-
_defineProperty(this, "checkIfTruncationIsNeeded", function () {
|
|
47
|
-
_this.setTextToCheck(_this.fullText);
|
|
48
|
-
if (_this.availableWidth >= _this.textWidth) {
|
|
49
|
-
return false;
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
_defineProperty(this, "checkSufficientEllipsisWidth", function (truncation) {
|
|
53
|
-
var textToCheck = truncation === 'startEnd' ? "".concat(_this.ellipsis, " ").concat(_this.ellipsis) // startEnd needs a little more space
|
|
54
|
-
: _this.ellipsis;
|
|
55
|
-
_this.setTextToCheck(textToCheck);
|
|
56
|
-
if (_this.textWidth >= _this.availableWidth * 0.9) {
|
|
57
|
-
console.error('The truncation ellipsis is larger than the available width. No text can be rendered.');
|
|
58
|
-
return false;
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
_defineProperty(this, "checkTruncationOffsetWidth", function (text) {
|
|
62
|
-
_this.setTextToCheck(text);
|
|
63
|
-
if (_this.textWidth > _this.availableWidth) {
|
|
64
|
-
console.error("The passed truncationOffset is too large for the available width. Truncating the offset instead.");
|
|
65
|
-
return false;
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
/**
|
|
69
|
-
* Truncation types logic. This is where the magic happens
|
|
70
|
-
*/
|
|
71
|
-
_defineProperty(this, "truncateStart", function (truncationOffset) {
|
|
72
|
-
var truncatedText = _this.fullText;
|
|
73
|
-
var leadingText = '';
|
|
74
|
-
var combinedText = function combinedText() {
|
|
75
|
-
return "".concat(leadingText).concat(truncatedText);
|
|
76
|
-
};
|
|
77
|
-
if (truncationOffset) {
|
|
78
|
-
var _splitText$at = splitText(_this.fullText).at(truncationOffset);
|
|
79
|
-
var _splitText$at2 = _slicedToArray(_splitText$at, 2);
|
|
80
|
-
leadingText = _splitText$at2[0];
|
|
81
|
-
truncatedText = _splitText$at2[1];
|
|
82
|
-
var widthCheck = "".concat(leadingText).concat(_this.ellipsis);
|
|
83
|
-
if (_this.checkTruncationOffsetWidth(widthCheck) === false) {
|
|
84
|
-
truncatedText = leadingText;
|
|
85
|
-
leadingText = '';
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
leadingText += _this.ellipsis;
|
|
89
|
-
_this.setTextToCheck(combinedText());
|
|
90
|
-
while (_this.textWidth > _this.availableWidth) {
|
|
91
|
-
truncatedText = removeFirstCharacter(truncatedText);
|
|
92
|
-
_this.setTextToCheck(combinedText());
|
|
93
|
-
}
|
|
94
|
-
return combinedText();
|
|
95
|
-
});
|
|
96
|
-
_defineProperty(this, "truncateEnd", function (truncationOffset) {
|
|
97
|
-
var truncatedText = _this.fullText;
|
|
98
|
-
var trailingText = '';
|
|
99
|
-
var combinedText = function combinedText() {
|
|
100
|
-
return "".concat(truncatedText).concat(trailingText);
|
|
101
|
-
};
|
|
102
|
-
if (truncationOffset) {
|
|
103
|
-
var index = _this.fullText.length - truncationOffset;
|
|
104
|
-
var _splitText$at3 = splitText(_this.fullText).at(index);
|
|
105
|
-
var _splitText$at4 = _slicedToArray(_splitText$at3, 2);
|
|
106
|
-
truncatedText = _splitText$at4[0];
|
|
107
|
-
trailingText = _splitText$at4[1];
|
|
108
|
-
var widthCheck = "".concat(_this.ellipsis).concat(trailingText);
|
|
109
|
-
if (_this.checkTruncationOffsetWidth(widthCheck) === false) {
|
|
110
|
-
truncatedText = trailingText;
|
|
111
|
-
trailingText = '';
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
trailingText = _this.ellipsis + trailingText;
|
|
115
|
-
_this.setTextToCheck(combinedText());
|
|
116
|
-
while (_this.textWidth > _this.availableWidth) {
|
|
117
|
-
truncatedText = removeLastCharacter(truncatedText);
|
|
118
|
-
_this.setTextToCheck(combinedText());
|
|
119
|
-
}
|
|
120
|
-
return combinedText();
|
|
121
|
-
});
|
|
122
|
-
_defineProperty(this, "truncateStartEndAtPosition", function (truncationPosition) {
|
|
123
|
-
// If using a non-centered startEnd anchor position, we need to *build*
|
|
124
|
-
// the string from scratch instead of *removing* from the full text string,
|
|
125
|
-
// to make sure we don't go past the beginning or end of the text
|
|
126
|
-
var truncatedText = '';
|
|
127
|
-
_this.setTextToCheck(truncatedText);
|
|
128
|
-
|
|
129
|
-
// Ellipses are conditional - if the anchor is towards the beginning or end,
|
|
130
|
-
// it's possible they shouldn't render
|
|
131
|
-
var startingEllipsis = _this.ellipsis;
|
|
132
|
-
var endingEllipsis = _this.ellipsis;
|
|
133
|
-
|
|
134
|
-
// Split the text into two at the anchor position
|
|
135
|
-
var _splitText$at5 = splitText(_this.fullText).at(truncationPosition),
|
|
136
|
-
_splitText$at6 = _slicedToArray(_splitText$at5, 2),
|
|
137
|
-
firstPart = _splitText$at6[0],
|
|
138
|
-
secondPart = _splitText$at6[1];
|
|
139
|
-
var combinedText = function combinedText() {
|
|
140
|
-
return "".concat(startingEllipsis).concat(truncatedText).concat(endingEllipsis);
|
|
141
|
-
};
|
|
142
|
-
while (_this.textWidth <= _this.availableWidth) {
|
|
143
|
-
if (firstPart.length > 0) {
|
|
144
|
-
truncatedText = "".concat(getLastCharacter(firstPart)).concat(truncatedText);
|
|
145
|
-
firstPart = removeLastCharacter(firstPart);
|
|
146
|
-
} else {
|
|
147
|
-
startingEllipsis = '';
|
|
148
|
-
}
|
|
149
|
-
if (secondPart.length > 0) {
|
|
150
|
-
truncatedText = "".concat(truncatedText).concat(getFirstCharacter(secondPart));
|
|
151
|
-
secondPart = removeFirstCharacter(secondPart);
|
|
152
|
-
} else {
|
|
153
|
-
endingEllipsis = '';
|
|
154
|
-
}
|
|
155
|
-
_this.setTextToCheck(combinedText());
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
// Because this logic builds text outwards vs. removing inwards, the final
|
|
159
|
-
// text width ends up a little larger than the container, and we need to
|
|
160
|
-
// remove the last added character(s)
|
|
161
|
-
if (!startingEllipsis) {
|
|
162
|
-
truncatedText = removeLastCharacter(truncatedText);
|
|
163
|
-
} else if (!endingEllipsis) {
|
|
164
|
-
truncatedText = removeFirstCharacter(truncatedText);
|
|
165
|
-
} else {
|
|
166
|
-
truncatedText = removeFirstAndLastCharacters(truncatedText);
|
|
167
|
-
}
|
|
168
|
-
return combinedText();
|
|
169
|
-
});
|
|
170
|
-
_defineProperty(this, "truncateStartEndAtMiddle", function () {
|
|
171
|
-
var truncatedText = _this.fullText;
|
|
172
|
-
_this.setTextToCheck(truncatedText);
|
|
173
|
-
var combinedText = function combinedText() {
|
|
174
|
-
return "".concat(_this.ellipsis).concat(truncatedText).concat(_this.ellipsis);
|
|
175
|
-
};
|
|
176
|
-
while (_this.textWidth > _this.availableWidth) {
|
|
177
|
-
truncatedText = removeFirstAndLastCharacters(truncatedText);
|
|
178
|
-
_this.setTextToCheck(combinedText());
|
|
179
|
-
}
|
|
180
|
-
return combinedText();
|
|
181
|
-
});
|
|
182
|
-
_defineProperty(this, "truncateMiddle", function () {
|
|
183
|
-
var middlePosition = Math.floor(_this.fullText.length / 2);
|
|
184
|
-
var _splitText$at7 = splitText(_this.fullText).at(middlePosition),
|
|
185
|
-
_splitText$at8 = _slicedToArray(_splitText$at7, 2),
|
|
186
|
-
firstHalf = _splitText$at8[0],
|
|
187
|
-
secondHalf = _splitText$at8[1];
|
|
188
|
-
var trimfirstHalf;
|
|
189
|
-
var combinedText = function combinedText() {
|
|
190
|
-
return "".concat(firstHalf).concat(_this.ellipsis).concat(secondHalf);
|
|
191
|
-
};
|
|
192
|
-
_this.setTextToCheck(combinedText());
|
|
193
|
-
while (_this.textWidth > _this.availableWidth) {
|
|
194
|
-
trimfirstHalf = !trimfirstHalf;
|
|
195
|
-
if (trimfirstHalf) {
|
|
196
|
-
firstHalf = removeLastCharacter(firstHalf);
|
|
197
|
-
} else {
|
|
198
|
-
secondHalf = removeFirstCharacter(secondHalf);
|
|
199
|
-
}
|
|
200
|
-
_this.setTextToCheck(combinedText());
|
|
201
|
-
}
|
|
202
|
-
return combinedText();
|
|
203
|
-
});
|
|
204
|
-
this.fullText = fullText;
|
|
205
|
-
this.ellipsis = ellipsis;
|
|
206
|
-
this.availableWidth = availableWidth;
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
/**
|
|
210
|
-
* Internal measurement utils which will be overridden depending on the
|
|
211
|
-
* rendering approach used (e.g. DOM vs Canvas).
|
|
212
|
-
*/);
|
|
213
|
-
/**
|
|
214
|
-
* Creates a temporary vanilla JS DOM element for manipulating text and
|
|
215
|
-
* determining text width.
|
|
216
|
-
*
|
|
217
|
-
* Requires passing in a container element to which the temporary element
|
|
218
|
-
* will be appended. Any CSS/font styles that need to be accounted for should
|
|
219
|
-
* be automatically inherited from the container.
|
|
220
|
-
*
|
|
221
|
-
* NOTE: The consumer is responsible for calling the `cleanup()` method manually
|
|
222
|
-
* to remove the temporary DOM node once their usage of this utility is complete.
|
|
223
|
-
*/
|
|
224
|
-
|
|
225
|
-
export var TruncationUtilsWithDOM = /*#__PURE__*/function (_TruncationUtils2) {
|
|
226
|
-
_inherits(TruncationUtilsWithDOM, _TruncationUtils2);
|
|
227
|
-
var _super = _createSuper(TruncationUtilsWithDOM);
|
|
228
|
-
function TruncationUtilsWithDOM(_ref2) {
|
|
229
|
-
var _this2;
|
|
230
|
-
var container = _ref2.container,
|
|
231
|
-
rest = _objectWithoutProperties(_ref2, _excluded);
|
|
232
|
-
_classCallCheck(this, TruncationUtilsWithDOM);
|
|
233
|
-
_this2 = _super.call(this, rest);
|
|
234
|
-
_defineProperty(_assertThisInitialized(_this2), "container", void 0);
|
|
235
|
-
_defineProperty(_assertThisInitialized(_this2), "span", void 0);
|
|
236
|
-
_defineProperty(_assertThisInitialized(_this2), "setTextToCheck", function (text) {
|
|
237
|
-
_this2.span.textContent = text;
|
|
238
|
-
});
|
|
239
|
-
_defineProperty(_assertThisInitialized(_this2), "cleanup", function () {
|
|
240
|
-
_this2.container.removeChild(_this2.span);
|
|
241
|
-
});
|
|
242
|
-
_this2.container = container;
|
|
243
|
-
_this2.span = document.createElement('span');
|
|
244
|
-
_this2.span.style.position = 'absolute'; // Prevent page reflow/repaint for performance
|
|
245
|
-
_this2.span.style.whiteSpace = 'nowrap'; // EuiTextTruncate already sets this on the parent, but we'll set it here as well for consumers who use this util standalone
|
|
246
|
-
_this2.container.appendChild(_this2.span);
|
|
247
|
-
return _this2;
|
|
248
|
-
}
|
|
249
|
-
_createClass(TruncationUtilsWithDOM, [{
|
|
250
|
-
key: "textWidth",
|
|
251
|
-
get: function get() {
|
|
252
|
-
return this.span.offsetWidth;
|
|
253
|
-
}
|
|
254
|
-
}]);
|
|
255
|
-
return TruncationUtilsWithDOM;
|
|
256
|
-
}(_TruncationUtils);
|
|
257
21
|
|
|
258
22
|
/**
|
|
259
|
-
*
|
|
260
|
-
* text width.
|
|
261
|
-
* frameworks, and requires no cleanup method.
|
|
23
|
+
* Under the hood, a temporary Canvas element is created for manipulating text
|
|
24
|
+
* & determining text width.
|
|
262
25
|
*
|
|
263
26
|
* To accurately measure text, canvas rendering requires either a container to
|
|
264
27
|
* compute/derive font styles from, or a static font string (useful for usage
|
|
265
28
|
* outside the DOM). Particular care should be applied when fallback fonts are
|
|
266
29
|
* used, as more fallback fonts can lead to less precision.
|
|
267
30
|
*
|
|
268
|
-
* Please note that while canvas is more performant than DOM
|
|
269
|
-
* are subpixel to single digit pixel differences between
|
|
270
|
-
* measurement due to the different rendering engines used.
|
|
31
|
+
* Please note that while canvas is more significantly more performant than DOM
|
|
32
|
+
* measurement, there are subpixel to single digit pixel differences between
|
|
33
|
+
* DOM and canvas measurement due to the different rendering engines used.
|
|
271
34
|
*/
|
|
272
|
-
export var
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
_this3 = _super2.call(this, rest);
|
|
282
|
-
_defineProperty(_assertThisInitialized(_this3), "context", void 0);
|
|
283
|
-
_defineProperty(_assertThisInitialized(_this3), "currentText", '');
|
|
284
|
-
_defineProperty(_assertThisInitialized(_this3), "computeFontFromElement", function (element) {
|
|
35
|
+
export var CanvasTextUtils = /*#__PURE__*/function () {
|
|
36
|
+
function CanvasTextUtils(_ref) {
|
|
37
|
+
var _this = this;
|
|
38
|
+
var font = _ref.font,
|
|
39
|
+
container = _ref.container;
|
|
40
|
+
_classCallCheck(this, CanvasTextUtils);
|
|
41
|
+
_defineProperty(this, "context", void 0);
|
|
42
|
+
_defineProperty(this, "currentText", '');
|
|
43
|
+
_defineProperty(this, "computeFontFromElement", function (element) {
|
|
285
44
|
var computedStyles = window.getComputedStyle(element);
|
|
45
|
+
// TODO: font-stretch is not included even though it potentially should be
|
|
46
|
+
// @see https://developer.mozilla.org/en-US/docs/Web/CSS/font#constituent_properties
|
|
47
|
+
// It appears to be unsupported and/or breaks font computation in canvas
|
|
286
48
|
return ['font-style', 'font-variant', 'font-weight', 'font-size', 'font-family'].map(function (prop) {
|
|
287
49
|
return computedStyles.getPropertyValue(prop);
|
|
288
50
|
}).join(' ').trim();
|
|
289
51
|
});
|
|
290
|
-
_defineProperty(
|
|
291
|
-
|
|
52
|
+
_defineProperty(this, "setTextToCheck", function (text) {
|
|
53
|
+
_this.currentText = text;
|
|
292
54
|
});
|
|
293
|
-
|
|
55
|
+
this.context = document.createElement('canvas').getContext('2d');
|
|
294
56
|
|
|
295
57
|
// Set the canvas font to ensure text width calculations are correct
|
|
296
58
|
if (font) {
|
|
297
|
-
|
|
59
|
+
this.context.font = font;
|
|
298
60
|
} else if (container) {
|
|
299
|
-
|
|
61
|
+
this.context.font = this.computeFontFromElement(container);
|
|
300
62
|
}
|
|
301
|
-
return _this3;
|
|
302
63
|
}
|
|
303
|
-
_createClass(
|
|
64
|
+
_createClass(CanvasTextUtils, [{
|
|
304
65
|
key: "textWidth",
|
|
305
66
|
get: function get() {
|
|
306
67
|
return this.context.measureText(this.currentText).width;
|
|
307
68
|
}
|
|
308
69
|
}]);
|
|
309
|
-
return
|
|
310
|
-
}(
|
|
70
|
+
return CanvasTextUtils;
|
|
71
|
+
}();
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Utilities for truncating types at various positions, as well as
|
|
75
|
+
* determining whether truncation is possible or even necessary.
|
|
76
|
+
*/
|
|
77
|
+
export var TruncationUtils = /*#__PURE__*/function (_CanvasTextUtils) {
|
|
78
|
+
_inherits(TruncationUtils, _CanvasTextUtils);
|
|
79
|
+
var _super = _createSuper(TruncationUtils);
|
|
80
|
+
function TruncationUtils(_ref2) {
|
|
81
|
+
var _this2;
|
|
82
|
+
var fullText = _ref2.fullText,
|
|
83
|
+
ellipsis = _ref2.ellipsis,
|
|
84
|
+
_availableWidth = _ref2.availableWidth,
|
|
85
|
+
rest = _objectWithoutProperties(_ref2, _excluded);
|
|
86
|
+
_classCallCheck(this, TruncationUtils);
|
|
87
|
+
_this2 = _super.call(this, rest);
|
|
88
|
+
_defineProperty(_assertThisInitialized(_this2), "fullText", void 0);
|
|
89
|
+
_defineProperty(_assertThisInitialized(_this2), "ellipsis", void 0);
|
|
90
|
+
_defineProperty(_assertThisInitialized(_this2), "availableWidth", void 0);
|
|
91
|
+
/**
|
|
92
|
+
* Performance utilities
|
|
93
|
+
*/
|
|
94
|
+
_defineProperty(_assertThisInitialized(_this2), "debugPerformance", false);
|
|
95
|
+
_defineProperty(_assertThisInitialized(_this2), "debugCounter", 0);
|
|
96
|
+
/**
|
|
97
|
+
* Internal utils for calculating a ratio based on the passed available width
|
|
98
|
+
* vs the full text width.
|
|
99
|
+
* This ratio is used to get an initial _approximate_ text string that should
|
|
100
|
+
* be slightly over the available width, which we can then remove from
|
|
101
|
+
* character-by-character until the text just fits within the available width.
|
|
102
|
+
*/
|
|
103
|
+
_defineProperty(_assertThisInitialized(_this2), "widthRatio", 0);
|
|
104
|
+
_defineProperty(_assertThisInitialized(_this2), "setTextWidthRatio", function () {
|
|
105
|
+
var text = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _this2.fullText;
|
|
106
|
+
var textToOffset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
107
|
+
// Account for reduced available width due to (e.g.) truncation offset
|
|
108
|
+
var availableWidth = _this2.availableWidth;
|
|
109
|
+
if (textToOffset) {
|
|
110
|
+
_this2.setTextToCheck(textToOffset);
|
|
111
|
+
availableWidth = availableWidth - _this2.textWidth;
|
|
112
|
+
}
|
|
113
|
+
_this2.setTextToCheck(text);
|
|
114
|
+
_this2.widthRatio = availableWidth / _this2.textWidth;
|
|
115
|
+
});
|
|
116
|
+
_defineProperty(_assertThisInitialized(_this2), "getTextFromRatio", function (text, type) {
|
|
117
|
+
var characterRatio = Math.ceil(text.length * _this2.widthRatio);
|
|
118
|
+
var index = type === 'start' ? text.length - characterRatio : characterRatio;
|
|
119
|
+
var _splitText$at = splitText(text).at(index),
|
|
120
|
+
_splitText$at2 = _slicedToArray(_splitText$at, 2),
|
|
121
|
+
end = _splitText$at2[0],
|
|
122
|
+
start = _splitText$at2[1];
|
|
123
|
+
return type === 'start' ? start : end;
|
|
124
|
+
});
|
|
125
|
+
/**
|
|
126
|
+
* Early return checks
|
|
127
|
+
*/
|
|
128
|
+
_defineProperty(_assertThisInitialized(_this2), "checkIfTruncationIsNeeded", function () {
|
|
129
|
+
_this2.setTextToCheck(_this2.fullText);
|
|
130
|
+
if (_this2.availableWidth >= _this2.textWidth) {
|
|
131
|
+
return false;
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
_defineProperty(_assertThisInitialized(_this2), "checkSufficientEllipsisWidth", function (truncation) {
|
|
135
|
+
var textToCheck = truncation === 'startEnd' ? "".concat(_this2.ellipsis, " ").concat(_this2.ellipsis) // startEnd needs a little more space
|
|
136
|
+
: _this2.ellipsis;
|
|
137
|
+
_this2.setTextToCheck(textToCheck);
|
|
138
|
+
if (_this2.textWidth >= _this2.availableWidth * 0.9) {
|
|
139
|
+
console.error('The truncation ellipsis is larger than the available width. No text can be rendered.');
|
|
140
|
+
return false;
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
_defineProperty(_assertThisInitialized(_this2), "checkTruncationOffsetWidth", function (text) {
|
|
144
|
+
_this2.setTextToCheck(text);
|
|
145
|
+
if (_this2.textWidth > _this2.availableWidth) {
|
|
146
|
+
console.error('The passed truncationOffset is too large for the available width. Truncating the offset instead.');
|
|
147
|
+
return false;
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
/**
|
|
151
|
+
* Truncation types logic. This is where the magic happens
|
|
152
|
+
*/
|
|
153
|
+
_defineProperty(_assertThisInitialized(_this2), "truncateStart", function (truncationOffset) {
|
|
154
|
+
var truncatedText = _this2.fullText;
|
|
155
|
+
var leadingText = '';
|
|
156
|
+
var combinedText = function combinedText() {
|
|
157
|
+
return leadingText + truncatedText;
|
|
158
|
+
};
|
|
159
|
+
if (truncationOffset) {
|
|
160
|
+
var _splitText$at3 = splitText(_this2.fullText).at(truncationOffset);
|
|
161
|
+
var _splitText$at4 = _slicedToArray(_splitText$at3, 2);
|
|
162
|
+
leadingText = _splitText$at4[0];
|
|
163
|
+
truncatedText = _splitText$at4[1];
|
|
164
|
+
var widthCheck = leadingText + _this2.ellipsis;
|
|
165
|
+
if (_this2.checkTruncationOffsetWidth(widthCheck) === false) {
|
|
166
|
+
truncatedText = leadingText;
|
|
167
|
+
leadingText = '';
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
// Get text width ratio width accounting for any truncation offset text,
|
|
172
|
+
// and guesstimate an initial truncated string
|
|
173
|
+
_this2.setTextWidthRatio(truncatedText, leadingText);
|
|
174
|
+
truncatedText = _this2.getTextFromRatio(truncatedText, 'start');
|
|
175
|
+
leadingText += _this2.ellipsis;
|
|
176
|
+
_this2.setTextToCheck(combinedText());
|
|
177
|
+
while (_this2.textWidth > _this2.availableWidth) {
|
|
178
|
+
truncatedText = removeFirstCharacter(truncatedText);
|
|
179
|
+
_this2.setTextToCheck(combinedText());
|
|
180
|
+
}
|
|
181
|
+
return combinedText();
|
|
182
|
+
});
|
|
183
|
+
_defineProperty(_assertThisInitialized(_this2), "truncateEnd", function (truncationOffset) {
|
|
184
|
+
var truncatedText = _this2.fullText;
|
|
185
|
+
var trailingText = '';
|
|
186
|
+
var combinedText = function combinedText() {
|
|
187
|
+
return truncatedText + trailingText;
|
|
188
|
+
};
|
|
189
|
+
if (truncationOffset) {
|
|
190
|
+
var index = _this2.fullText.length - truncationOffset;
|
|
191
|
+
var _splitText$at5 = splitText(_this2.fullText).at(index);
|
|
192
|
+
var _splitText$at6 = _slicedToArray(_splitText$at5, 2);
|
|
193
|
+
truncatedText = _splitText$at6[0];
|
|
194
|
+
trailingText = _splitText$at6[1];
|
|
195
|
+
var widthCheck = _this2.ellipsis + trailingText;
|
|
196
|
+
if (_this2.checkTruncationOffsetWidth(widthCheck) === false) {
|
|
197
|
+
truncatedText = trailingText;
|
|
198
|
+
trailingText = '';
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
// Get text width ratio width accounting for any truncation offset text,
|
|
203
|
+
// and guesstimate an initial truncated string
|
|
204
|
+
_this2.setTextWidthRatio(truncatedText, trailingText);
|
|
205
|
+
truncatedText = _this2.getTextFromRatio(truncatedText, 'end');
|
|
206
|
+
trailingText = _this2.ellipsis + trailingText;
|
|
207
|
+
_this2.setTextToCheck(combinedText());
|
|
208
|
+
while (_this2.textWidth > _this2.availableWidth) {
|
|
209
|
+
truncatedText = removeLastCharacter(truncatedText);
|
|
210
|
+
_this2.setTextToCheck(combinedText());
|
|
211
|
+
}
|
|
212
|
+
return combinedText();
|
|
213
|
+
});
|
|
214
|
+
_defineProperty(_assertThisInitialized(_this2), "truncateStartEndAtPosition", function (truncationPosition) {
|
|
215
|
+
// Split the text from the anchor position, using the width ratio
|
|
216
|
+
// to get the starting and ending indices from the position
|
|
217
|
+
_this2.setTextWidthRatio();
|
|
218
|
+
var characterRatio = Math.floor(_this2.fullText.length * _this2.widthRatio / 2);
|
|
219
|
+
var truncateStart = truncationPosition - characterRatio;
|
|
220
|
+
var truncateEnd = truncationPosition + characterRatio;
|
|
221
|
+
|
|
222
|
+
// If either of the approximate start/end truncation indices go beyond the
|
|
223
|
+
// bounds of the actual text, we can simply use end or start truncation instead
|
|
224
|
+
if (truncateStart < 0) {
|
|
225
|
+
return _this2.truncateEnd();
|
|
226
|
+
}
|
|
227
|
+
if (truncateEnd >= _this2.fullText.length) {
|
|
228
|
+
return _this2.truncateStart();
|
|
229
|
+
}
|
|
230
|
+
var truncatedText = _this2.fullText.substring(truncateStart, truncateEnd);
|
|
231
|
+
var combinedText = function combinedText() {
|
|
232
|
+
return _this2.ellipsis + truncatedText + _this2.ellipsis;
|
|
233
|
+
};
|
|
234
|
+
_this2.setTextToCheck(combinedText());
|
|
235
|
+
var alternating;
|
|
236
|
+
while (_this2.textWidth > _this2.availableWidth) {
|
|
237
|
+
truncatedText = alternating ? removeLastCharacter(truncatedText) : removeFirstCharacter(truncatedText);
|
|
238
|
+
alternating = !alternating;
|
|
239
|
+
_this2.setTextToCheck(combinedText());
|
|
240
|
+
}
|
|
241
|
+
return combinedText();
|
|
242
|
+
});
|
|
243
|
+
_defineProperty(_assertThisInitialized(_this2), "truncateStartEndAtMiddle", function () {
|
|
244
|
+
var middlePosition = Math.floor(_this2.fullText.length / 2);
|
|
245
|
+
return _this2.truncateStartEndAtPosition(middlePosition);
|
|
246
|
+
});
|
|
247
|
+
_defineProperty(_assertThisInitialized(_this2), "truncateMiddle", function () {
|
|
248
|
+
var middlePosition = Math.floor(_this2.fullText.length / 2);
|
|
249
|
+
var _splitText$at7 = splitText(_this2.fullText).at(middlePosition),
|
|
250
|
+
_splitText$at8 = _slicedToArray(_splitText$at7, 2),
|
|
251
|
+
firstHalf = _splitText$at8[0],
|
|
252
|
+
secondHalf = _splitText$at8[1];
|
|
253
|
+
_this2.setTextWidthRatio();
|
|
254
|
+
firstHalf = _this2.getTextFromRatio(firstHalf, 'end');
|
|
255
|
+
secondHalf = _this2.getTextFromRatio(secondHalf, 'start');
|
|
256
|
+
var combinedText = function combinedText() {
|
|
257
|
+
return firstHalf + _this2.ellipsis + secondHalf;
|
|
258
|
+
};
|
|
259
|
+
_this2.setTextToCheck(combinedText());
|
|
260
|
+
var alternating;
|
|
261
|
+
while (_this2.textWidth > _this2.availableWidth) {
|
|
262
|
+
alternating = !alternating;
|
|
263
|
+
if (alternating) {
|
|
264
|
+
firstHalf = removeLastCharacter(firstHalf);
|
|
265
|
+
} else {
|
|
266
|
+
secondHalf = removeFirstCharacter(secondHalf);
|
|
267
|
+
}
|
|
268
|
+
_this2.setTextToCheck(combinedText());
|
|
269
|
+
}
|
|
270
|
+
return combinedText();
|
|
271
|
+
});
|
|
272
|
+
_this2.fullText = fullText;
|
|
273
|
+
_this2.ellipsis = ellipsis;
|
|
274
|
+
_this2.availableWidth = _availableWidth;
|
|
275
|
+
return _this2;
|
|
276
|
+
}
|
|
277
|
+
_createClass(TruncationUtils, [{
|
|
278
|
+
key: "textWidth",
|
|
279
|
+
get: function get() {
|
|
280
|
+
if (this.debugPerformance) {
|
|
281
|
+
this.debugCounter++;
|
|
282
|
+
}
|
|
283
|
+
return _get(_getPrototypeOf(TruncationUtils.prototype), "textWidth", this);
|
|
284
|
+
}
|
|
285
|
+
}]);
|
|
286
|
+
return TruncationUtils;
|
|
287
|
+
}(CanvasTextUtils);
|
|
311
288
|
|
|
312
289
|
/**
|
|
313
290
|
* DRY character/substring utils
|
|
@@ -316,18 +293,9 @@ export var TruncationUtilsWithCanvas = /*#__PURE__*/function (_TruncationUtils3)
|
|
|
316
293
|
var removeLastCharacter = function removeLastCharacter(text) {
|
|
317
294
|
return text.substring(0, text.length - 1);
|
|
318
295
|
};
|
|
319
|
-
var getLastCharacter = function getLastCharacter(text) {
|
|
320
|
-
return text.substring(text.length - 1);
|
|
321
|
-
};
|
|
322
296
|
var removeFirstCharacter = function removeFirstCharacter(text) {
|
|
323
297
|
return text.substring(1);
|
|
324
298
|
};
|
|
325
|
-
var getFirstCharacter = function getFirstCharacter(text) {
|
|
326
|
-
return text.substring(0, 1);
|
|
327
|
-
};
|
|
328
|
-
var removeFirstAndLastCharacters = function removeFirstAndLastCharacters(text) {
|
|
329
|
-
return text.substring(1, text.length - 1);
|
|
330
|
-
};
|
|
331
299
|
var splitText = function splitText(text) {
|
|
332
300
|
return {
|
|
333
301
|
at: function at(index) {
|
|
@@ -29,14 +29,14 @@ var users = [];
|
|
|
29
29
|
for (var i = 0; i < 20; i++) {
|
|
30
30
|
users.push({
|
|
31
31
|
id: i + 1,
|
|
32
|
-
firstName: _faker.faker.
|
|
33
|
-
lastName: _faker.faker.
|
|
32
|
+
firstName: _faker.faker.person.firstName(),
|
|
33
|
+
lastName: _faker.faker.person.lastName(),
|
|
34
34
|
github: _faker.faker.internet.userName(),
|
|
35
35
|
dateOfBirth: _faker.faker.date.past(),
|
|
36
36
|
online: _faker.faker.datatype.boolean(),
|
|
37
37
|
location: {
|
|
38
|
-
city: _faker.faker.
|
|
39
|
-
country: _faker.faker.
|
|
38
|
+
city: _faker.faker.location.city(),
|
|
39
|
+
country: _faker.faker.location.country()
|
|
40
40
|
}
|
|
41
41
|
});
|
|
42
42
|
}
|
|
@@ -24,14 +24,14 @@ var users = [];
|
|
|
24
24
|
for (var i = 0; i < 20; i++) {
|
|
25
25
|
users.push({
|
|
26
26
|
id: i + 1,
|
|
27
|
-
firstName: _faker.faker.
|
|
28
|
-
lastName: _faker.faker.
|
|
27
|
+
firstName: _faker.faker.person.firstName(),
|
|
28
|
+
lastName: _faker.faker.person.lastName(),
|
|
29
29
|
github: _faker.faker.internet.userName(),
|
|
30
30
|
dateOfBirth: _faker.faker.date.past(),
|
|
31
31
|
online: _faker.faker.datatype.boolean(),
|
|
32
32
|
location: {
|
|
33
|
-
city: _faker.faker.
|
|
34
|
-
country: _faker.faker.
|
|
33
|
+
city: _faker.faker.location.city(),
|
|
34
|
+
country: _faker.faker.location.country()
|
|
35
35
|
}
|
|
36
36
|
});
|
|
37
37
|
}
|