UNPKG

747 BPlain TextView Raw
1<script>
2import { intersperse } from '../../../utils/data_utils';
3import { splitAfterSymbols } from '../../../utils/string_utils';
4
5export default {
6 functional: true,
7 props: {
8 /**
9 * Text to be wrapped.
10 */
11 text: {
12 type: String,
13 required: true,
14 },
15 /**
16 * A list of strings representing the break-words.
17 */
18 symbols: {
19 type: Array,
20 required: false,
21 default: () => ['/'],
22 },
23 },
24 render(createElement, { props }) {
25 const { symbols, text } = props;
26 const textParts = splitAfterSymbols(symbols, text ?? '');
27 const content = intersperse(() => createElement('wbr'), textParts);
28
29 return createElement('span', { class: 'text-break' }, content);
30 },
31};
32</script>