UNPKG

@elastic/eui

Version:

Elastic UI Component Library

66 lines (61 loc) 2.74 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.useEuiNumberFormat = exports.useEuiFontSize = exports.euiTextTruncate = exports.euiTextBreakWord = exports.euiNumberFormat = exports.euiFontSize = void 0; var _typography = require("../functions/typography"); var _hooks = require("../../services/theme/hooks"); var _functions = require("../functions"); /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one * or more contributor license agreements. Licensed under the Elastic License * 2.0 and the Server Side Public License, v 1; you may not use this file except * in compliance with, at your election, the Elastic License 2.0 or the Server * Side Public License, v 1. */ /** * Returns font-size and line-height */ var euiFontSize = function euiFontSize(_ref, scale, options) { var euiTheme = _ref.euiTheme; return { fontSize: (0, _typography.euiFontSizeFromScale)(scale, euiTheme, options), lineHeight: (0, _typography.euiLineHeightFromBaseline)(scale, euiTheme, options) }; }; exports.euiFontSize = euiFontSize; var useEuiFontSize = function useEuiFontSize(scale, options) { var euiTheme = (0, _hooks.useEuiTheme)(); return euiFontSize(euiTheme, scale, options); }; /** * Force text to wrap on natural word breaks (e.g. spaces & hyphens) * https://css-tricks.com/snippets/css/prevent-long-urls-from-breaking-out-of-container/ */ exports.useEuiFontSize = useEuiFontSize; var euiTextBreakWord = function euiTextBreakWord() { return "\n overflow-wrap: break-word !important; // makes sure the long string will wrap and not bust out of the container\n word-break: break-word;\n"; }; /** * Prevent text from wrapping onto multiple lines, and truncate with an ellipsis. */ exports.euiTextBreakWord = euiTextBreakWord; var euiTextTruncate = function euiTextTruncate() { var maxWidth = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '100%'; return "\n ".concat((0, _functions.logicalCSS)('max-width', maxWidth) // Ensure that the node has a maximum width after which truncation can occur , "\n overflow: hidden !important;\n text-overflow: ellipsis !important;\n white-space: nowrap !important;\n"); }; /** * Fixed-width numbers for tabular data */ exports.euiTextTruncate = euiTextTruncate; var euiNumberFormat = function euiNumberFormat(_ref2) { var euiTheme = _ref2.euiTheme; return "\n font-feature-settings: ".concat(euiTheme.font.featureSettings, ", 'tnum' 1;\n"); }; exports.euiNumberFormat = euiNumberFormat; var useEuiNumberFormat = function useEuiNumberFormat() { var euiTheme = (0, _hooks.useEuiTheme)(); return euiNumberFormat(euiTheme); }; exports.useEuiNumberFormat = useEuiNumberFormat;