@leanix/components 0.2.239 → 0.2.242

Sign up to get free protection for your applications and to get access to all the features.
@@ -8,7 +8,7 @@ import * as i1 from '@angular/cdk/overlay';
8
8
  import { OverlayModule, CdkConnectedOverlay } from '@angular/cdk/overlay';
9
9
  import { __decorate } from 'tslib';
10
10
  import * as i6 from 'rxjs';
11
- import { BehaviorSubject, Subject, combineLatest, merge, concat, fromEvent, Observable, ReplaySubject, of, timer } from 'rxjs';
11
+ import { BehaviorSubject, timer, Subject, combineLatest, merge, concat, fromEvent, Observable, ReplaySubject, of } from 'rxjs';
12
12
  import { skipWhile, map, switchMap, startWith, pairwise, filter, take, debounceTime, skip, withLatestFrom, distinctUntilChanged, takeUntil, first, delay, mapTo, tap } from 'rxjs/operators';
13
13
  import * as i1$1 from '@ngx-translate/core';
14
14
  import { TranslatePipe, TranslateModule } from '@ngx-translate/core';
@@ -513,7 +513,16 @@ function isResizeableElement(element) {
513
513
  class ResizeObserverService {
514
514
  observe(element, callback, options) {
515
515
  if (!this.resizeObserver) {
516
- this.resizeObserver = new ResizeObserver(this.resizeObserverCallback.bind(this));
516
+ try {
517
+ this.resizeObserver = new ResizeObserver(this.resizeObserverCallback.bind(this));
518
+ }
519
+ catch {
520
+ // All the browsers we support implement the ResizeObserver API.
521
+ // For unsupported browsers, there's this "one time artifical resize event".
522
+ // They will not get the functionality tied to later resize events.
523
+ timer(500).subscribe(() => callback(this.getMockOneTimeResizeEventForUnsupportedBrowsers(element)));
524
+ return;
525
+ }
517
526
  }
518
527
  element.handleResize = callback;
519
528
  this.resizeObserver.observe(element, options);
@@ -531,6 +540,45 @@ class ResizeObserverService {
531
540
  }
532
541
  });
533
542
  }
543
+ /**
544
+ * All browsers we officially support implement the ResizeObserver API.
545
+ * Still as a curtesy do customers who for some reason have older browsers
546
+ * we call the callback once with the initial dimensions of the element
547
+ * and then do not react on resize events afterwards.
548
+ * This should still make them happier than a "browser not supported" warning.
549
+ */
550
+ getMockOneTimeResizeEventForUnsupportedBrowsers(element) {
551
+ const contentRect = {
552
+ bottom: element.clientHeight,
553
+ height: element.clientHeight,
554
+ left: 0,
555
+ right: element.clientWidth,
556
+ top: 0,
557
+ width: element.clientWidth,
558
+ x: 0,
559
+ y: 0
560
+ };
561
+ return {
562
+ borderBoxSize: [{ blockSize: element.clientHeight, inlineSize: element.clientWidth }],
563
+ contentBoxSize: [
564
+ {
565
+ blockSize: element.clientHeight,
566
+ inlineSize: element.clientWidth
567
+ }
568
+ ],
569
+ contentRect: {
570
+ ...contentRect,
571
+ toJSON: () => JSON.stringify(contentRect)
572
+ },
573
+ devicePixelContentBoxSize: [
574
+ {
575
+ blockSize: element.clientWidth,
576
+ inlineSize: element.clientWidth
577
+ }
578
+ ],
579
+ target: element
580
+ };
581
+ }
534
582
  }
535
583
  ResizeObserverService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.5", ngImport: i0, type: ResizeObserverService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
536
584
  ResizeObserverService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.2.5", ngImport: i0, type: ResizeObserverService, providedIn: 'root' });
@@ -1142,6 +1190,179 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.5", ngImpor
1142
1190
  args: [{ name: 'lxHighlightTerm' }]
1143
1191
  }] });
1144
1192
 
1193
+ /**
1194
+ * This pipe transforms...
1195
+ * - "raw" http(s) links
1196
+ * - markdown link syntax
1197
+ * ... into clickable anchor elements.
1198
+ *
1199
+ * You have an user interface where you don't want clickable links but also
1200
+ * don't want users to see the "ugly" markdown link syntax?
1201
+ * -> Use the 'lxUnlikify' pipe to replace markdown link syntax with just the link name
1202
+ */
1203
+ class LxLinkifyPipe {
1204
+ transform(text) {
1205
+ if (text && typeof text === 'string') {
1206
+ const textWithRawLinks = this.wrapRawHttpLinksWithAnchorTags(text);
1207
+ const textWithRawAndNamedLinks = this.turnMarkdownStyleLinksIntoAnchorTags(textWithRawLinks);
1208
+ return textWithRawAndNamedLinks;
1209
+ }
1210
+ else {
1211
+ return text;
1212
+ }
1213
+ }
1214
+ turnMarkdownStyleLinksIntoAnchorTags(text) {
1215
+ let textWithRawAndNamedLinks = text;
1216
+ const namedLinkMatches = this.getAllRegexMatches(LxLinkifyPipe.NAMED_LINK_REGEX, text);
1217
+ namedLinkMatches.forEach((namedLinkMatch) => {
1218
+ const [source, name, url] = namedLinkMatch;
1219
+ const urlIsValid = url && !/javascript\:/i.test(url);
1220
+ if (source && name && urlIsValid) {
1221
+ textWithRawAndNamedLinks = textWithRawAndNamedLinks.replace(source, `<a href="${url}" target="_blank" rel="noopener noreferrer">${name}</a>`);
1222
+ }
1223
+ });
1224
+ return textWithRawAndNamedLinks;
1225
+ }
1226
+ wrapRawHttpLinksWithAnchorTags(text) {
1227
+ let textWithRawLinks = text;
1228
+ /**
1229
+ * Keeping track of this index prevents infinite loops
1230
+ * where a previously processed link starts with the same characters
1231
+ * as a second link.
1232
+ * e.g. https://angular.io/docs followed by https://angular.io
1233
+ */
1234
+ let nextIndexToStartReplacingFrom = 0;
1235
+ const rawLinkMatches = this.getAllRegexMatches(LxLinkifyPipe.HTTP_LINK_REGEX, text);
1236
+ rawLinkMatches.forEach((rawLinkMatch) => {
1237
+ const [url] = rawLinkMatch;
1238
+ const wrapUrlInAnchor = (sanitizedUrlMatch) => {
1239
+ const firstPart = textWithRawLinks.substring(0, nextIndexToStartReplacingFrom);
1240
+ const anchorTagHtml = `<a href="${sanitizedUrlMatch}" target="_blank" rel="noopener noreferrer">${sanitizedUrlMatch}</a>`;
1241
+ const secondPart = textWithRawLinks.substring(nextIndexToStartReplacingFrom).replace(sanitizedUrlMatch, anchorTagHtml);
1242
+ textWithRawLinks = firstPart + secondPart;
1243
+ nextIndexToStartReplacingFrom = rawLinkMatch.index + anchorTagHtml.length;
1244
+ };
1245
+ if (url) {
1246
+ /*
1247
+ * TODO: get rid of all this code once Safari supports negative lookbehinds in regular expressions
1248
+ * The following is RegExp that handles the same stuff as the JS code below:
1249
+ *
1250
+ * /(?:(?:(?<!\]\())(?:https|http):\/\/)(?:[^\s/$.?#][^\s]*(?<![\.)]))/gi;
1251
+ *
1252
+ * Demo on regex101: https://regex101.com/r/7Vl9bg/1
1253
+ *
1254
+ * Check lookbehind support here: https://caniuse.com/?search=lookbehind
1255
+ */
1256
+ const lastUrlCharacterIndex = rawLinkMatch.index + url.length - 1;
1257
+ const textUsedToPerformMatching = rawLinkMatch.input;
1258
+ const lastCharacterInUrl = textUsedToPerformMatching[lastUrlCharacterIndex];
1259
+ const twoCharactersInFrontOfTheLink = rawLinkMatch.index > 3
1260
+ ? `${textUsedToPerformMatching[rawLinkMatch.index - 2]}${textUsedToPerformMatching[rawLinkMatch.index - 1]}`
1261
+ : '';
1262
+ const isMarkdownSyntaxLink = twoCharactersInFrontOfTheLink === '](';
1263
+ if (!isMarkdownSyntaxLink && lastCharacterInUrl === '.') {
1264
+ const characterAfterUrl = textUsedToPerformMatching[lastUrlCharacterIndex + 1];
1265
+ if (!characterAfterUrl || characterAfterUrl === ' ' || characterAfterUrl === '\n') {
1266
+ const urlWithoutDotAtTheEnd = url.slice(0, -1);
1267
+ wrapUrlInAnchor(urlWithoutDotAtTheEnd);
1268
+ }
1269
+ }
1270
+ else if (!isMarkdownSyntaxLink) {
1271
+ wrapUrlInAnchor(url);
1272
+ }
1273
+ }
1274
+ });
1275
+ return textWithRawLinks;
1276
+ }
1277
+ getAllRegexMatches(regex, input) {
1278
+ let match;
1279
+ const matches = [];
1280
+ while ((match = regex.exec(input)) !== null) {
1281
+ matches.push(match);
1282
+ }
1283
+ return matches;
1284
+ }
1285
+ }
1286
+ /**
1287
+ * This is not the "one URL regex to rule them all", but a more realistic one which should work
1288
+ * for any URLs that our customers include in text fields on a Fact Sheet.
1289
+ *
1290
+ * Regex rules explained in plain text:
1291
+ *
1292
+ * (?:(?:https?):\/\/) -> Links must start with "https://" or "http://"
1293
+ *
1294
+ * (?:[^\s/$.?#][^\s]*(?<![\.)])) LET'S SPLIT THIS ONE UP
1295
+ *
1296
+ * [^\s/$.?#][^\s]* -> Match any legal URL character until the next whitespace
1297
+ * (?<![\.)] -> A negative lookahead to prevent matching a dot or parenthesis following a URL
1298
+ *
1299
+ * Link to regex101: https://regex101.com/r/d3KtfH/1 (NOTE: please update this link when changing the regex)
1300
+ */
1301
+ LxLinkifyPipe.HTTP_LINK_REGEX = /(?:(?:https?):\/\/)(?:[^\s/$.?#][^\s]*)/gi;
1302
+ /**
1303
+ * This will match the markdown link syntax: [link name](url)
1304
+ * Regex rules explained in plain text:
1305
+ *
1306
+ * (?:\[([^\]]*)\]) -> Match any characters inside square brackets
1307
+ * \(([^\s\/$.?#][^\s]*)\) -> Notice that this is the same regex as the HTTP_LINK_REGEX above,
1308
+ * but without the requirement for the http protocol.
1309
+ * This allows for links without including the protocol or also "mailto:hello@world.de" links
1310
+ *
1311
+ * Link to regex101: https://regex101.com/r/5UMUH8/1
1312
+ */
1313
+ LxLinkifyPipe.NAMED_LINK_REGEX = /(?:\[([^\]]*)\])\(([^\s\/$.?#][^\s]*)\)/gi;
1314
+ LxLinkifyPipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.5", ngImport: i0, type: LxLinkifyPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
1315
+ LxLinkifyPipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "12.0.0", version: "13.2.5", ngImport: i0, type: LxLinkifyPipe, name: "lxLinkify" });
1316
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.5", ngImport: i0, type: LxLinkifyPipe, decorators: [{
1317
+ type: Pipe,
1318
+ args: [{ name: 'lxLinkify' }]
1319
+ }] });
1320
+
1321
+ /**
1322
+ * This pipe replaces markdown link syntax with just the link name (omits the link altogether).
1323
+ * Example: [Angular documentation](http://angular.io/docs) -> Angular documentation
1324
+ *
1325
+ * It can also be used for "bridging the gap" until your view is ready to use "lxLinkify"
1326
+ * and you just want to get rid of the "useless" markdown syntax fast.
1327
+ *
1328
+ * While there are views where we want markdown style links to be clickable anchor tags,
1329
+ * there are other views where this can degrade the UX.
1330
+ * Example: in the Fact Sheet list on the inventory list view, having an arbitrary number
1331
+ * of links on the page can slow down the keyboard navigation while navigating through the list.
1332
+ */
1333
+ class LxUnlinkifyPipe {
1334
+ transform(text) {
1335
+ if (text && typeof text === 'string') {
1336
+ let textWhereMarkdownLinkSyntaxIsReplacedWithJustTheLinkName = text;
1337
+ const markdownLinkSyntaxMatches = this.getAllRegexMatches(LxLinkifyPipe.NAMED_LINK_REGEX, text);
1338
+ markdownLinkSyntaxMatches.forEach((markdownLinkSyntaxMatch) => {
1339
+ const [source, name] = markdownLinkSyntaxMatch;
1340
+ if (source && name) {
1341
+ textWhereMarkdownLinkSyntaxIsReplacedWithJustTheLinkName = textWhereMarkdownLinkSyntaxIsReplacedWithJustTheLinkName.replace(source, name);
1342
+ }
1343
+ });
1344
+ return textWhereMarkdownLinkSyntaxIsReplacedWithJustTheLinkName;
1345
+ }
1346
+ else {
1347
+ return text;
1348
+ }
1349
+ }
1350
+ getAllRegexMatches(regex, input) {
1351
+ let match;
1352
+ const matches = [];
1353
+ while ((match = regex.exec(input)) !== null) {
1354
+ matches.push(match);
1355
+ }
1356
+ return matches;
1357
+ }
1358
+ }
1359
+ LxUnlinkifyPipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.5", ngImport: i0, type: LxUnlinkifyPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
1360
+ LxUnlinkifyPipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "12.0.0", version: "13.2.5", ngImport: i0, type: LxUnlinkifyPipe, name: "lxUnlinkify" });
1361
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.5", ngImport: i0, type: LxUnlinkifyPipe, decorators: [{
1362
+ type: Pipe,
1363
+ args: [{ name: 'lxUnlinkify' }]
1364
+ }] });
1365
+
1145
1366
  function isUuid(s) {
1146
1367
  const uuidRegEx = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
1147
1368
  return uuidRegEx.test(s);
@@ -1491,6 +1712,8 @@ LxCoreUiModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version:
1491
1712
  HighlightTermPipe,
1492
1713
  HtmlDirective,
1493
1714
  IconScaleComponent,
1715
+ LxLinkifyPipe,
1716
+ LxUnlinkifyPipe,
1494
1717
  LxTimeAgo,
1495
1718
  LxTranslatePipe,
1496
1719
  MarkdownPipe,
@@ -1521,6 +1744,8 @@ LxCoreUiModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version:
1521
1744
  HighlightTermPipe,
1522
1745
  HtmlDirective,
1523
1746
  IconScaleComponent,
1747
+ LxLinkifyPipe,
1748
+ LxUnlinkifyPipe,
1524
1749
  LxTimeAgo,
1525
1750
  LxTranslatePipe,
1526
1751
  MarkdownPipe,
@@ -1558,6 +1783,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.5", ngImpor
1558
1783
  HighlightTermPipe,
1559
1784
  HtmlDirective,
1560
1785
  IconScaleComponent,
1786
+ LxLinkifyPipe,
1787
+ LxUnlinkifyPipe,
1561
1788
  LxTimeAgo,
1562
1789
  LxTranslatePipe,
1563
1790
  MarkdownPipe,
@@ -1592,6 +1819,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.5", ngImpor
1592
1819
  HighlightTermPipe,
1593
1820
  HtmlDirective,
1594
1821
  IconScaleComponent,
1822
+ LxLinkifyPipe,
1823
+ LxUnlinkifyPipe,
1595
1824
  LxTimeAgo,
1596
1825
  LxTranslatePipe,
1597
1826
  MarkdownPipe,
@@ -6301,5 +6530,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.5", ngImpor
6301
6530
  * Generated bundle index. Do not edit.
6302
6531
  */
6303
6532
 
6304
- export { ARROW_DOWN, ARROW_LEFT, ARROW_RIGHT, ARROW_UP, AfterViewInitDirective, AutocloseDirective, AutofocusDirective, BACKSPACE, BadgeComponent, BaseSelectDirective, BasicDropdownComponent, BasicDropdownItemComponent, BrPipe, ButtonComponent, ButtonGroupComponent, CURRENCY_SYMBOL_MAP, CardComponent, CdkOptionsDropdownComponent, CdkOptionsSubDropdownComponent, CollapsibleComponent, ColoredLabelComponent, ContrastColorPipe, CurrencyInputComponent, CurrencySymbolComponent, CustomDatePipe, DATE_FN_LOCALE, DATE_FORMATS, DateInputComponent, DragAndDropListComponent, DragAndDropListItemComponent, ENTER, ESCAPE, EllipsisComponent, ErrorMessageComponent, FORM_CONTROL_ERROR_DISPLAY_STRATEGY, FORM_CONTROL_ERROR_NAMESPACE, FilterSelectionPipe, FilterTermPipe, FormErrorComponent, FormErrorDirective, FormSubmitDirective, FormatNumberPipe, GLOBAL_TRANSLATION_OPTIONS, HighlightRangePipe, HighlightTermPipe, HtmlDirective, IconComponent, IconScaleComponent, KeyboardActionSourceDirective, KeyboardSelectAction, KeyboardSelectDirective, LOCALE_FN, LX_ELLIPSIS_DEBOUNCE_ON_RESIZE, LxCoreUiModule, LxDragAndDropListModule, LxFormsModule, LxIsUuidPipe, LxModalModule, LxPopoverUiModule, LxTabUiModule, LxTimeAgo, LxTooltipModule, LxTranslatePipe, MODAL_CLOSE, MarkInvalidDirective, MarkdownPipe, ModalComponent, ModalContentDirective, ModalFooterComponent, ModalHeaderComponent, MultiSelectComponent, NbspPipe, OptionComponent, OptionGroupComponent, OptionGroupDropdownComponent, OptionsDropdownComponent, OptionsSubDropdownComponent, PickerComponent, PickerOptionComponent, PickerTriggerDirective, PillItemComponent, PillListComponent, PopoverClickDirective, PopoverComponent, PopoverContentDirective, PopoverHoverDirective, Required, ResizeObserverService, ResponsiveInputComponent, SPACE, SelectDropdownDirective, SelectableItemDirective, SelectedOptionDirective, SingleSelectComponent, SliderToggleComponent, SortPipe, Sorting, SortingDropdownComponent, SortingDropdownTriggerComponent, SpinnerComponent, TAB, TabComponent, TabGroupComponent, TableComponent, TableHeaderComponent, TinySpinnerComponent, TooltipComponent, TooltipDirective, TranslationAfterPipe, TranslationBeforePipe, TranslationBetweenPipe, UnescapeCurlyBracesPipe, ValidateDateInForeseeableFuture, getContrastColor, getTranslationParts, isValidHexColor, isValidX, isValidY, provideFormControlErrorDisplayStrategy, provideFormControlErrorNamespace, shorthandHexHandle };
6533
+ export { ARROW_DOWN, ARROW_LEFT, ARROW_RIGHT, ARROW_UP, AfterViewInitDirective, AutocloseDirective, AutofocusDirective, BACKSPACE, BadgeComponent, BaseSelectDirective, BasicDropdownComponent, BasicDropdownItemComponent, BrPipe, ButtonComponent, ButtonGroupComponent, CURRENCY_SYMBOL_MAP, CardComponent, CdkOptionsDropdownComponent, CdkOptionsSubDropdownComponent, CollapsibleComponent, ColoredLabelComponent, ContrastColorPipe, CurrencyInputComponent, CurrencySymbolComponent, CustomDatePipe, DATE_FN_LOCALE, DATE_FORMATS, DateInputComponent, DragAndDropListComponent, DragAndDropListItemComponent, ENTER, ESCAPE, EllipsisComponent, ErrorMessageComponent, FORM_CONTROL_ERROR_DISPLAY_STRATEGY, FORM_CONTROL_ERROR_NAMESPACE, FilterSelectionPipe, FilterTermPipe, FormErrorComponent, FormErrorDirective, FormSubmitDirective, FormatNumberPipe, GLOBAL_TRANSLATION_OPTIONS, HighlightRangePipe, HighlightTermPipe, HtmlDirective, IconComponent, IconScaleComponent, KeyboardActionSourceDirective, KeyboardSelectAction, KeyboardSelectDirective, LOCALE_FN, LX_ELLIPSIS_DEBOUNCE_ON_RESIZE, LxCoreUiModule, LxDragAndDropListModule, LxFormsModule, LxIsUuidPipe, LxLinkifyPipe, LxModalModule, LxPopoverUiModule, LxTabUiModule, LxTimeAgo, LxTooltipModule, LxTranslatePipe, LxUnlinkifyPipe, MODAL_CLOSE, MarkInvalidDirective, MarkdownPipe, ModalComponent, ModalContentDirective, ModalFooterComponent, ModalHeaderComponent, MultiSelectComponent, NbspPipe, OptionComponent, OptionGroupComponent, OptionGroupDropdownComponent, OptionsDropdownComponent, OptionsSubDropdownComponent, PickerComponent, PickerOptionComponent, PickerTriggerDirective, PillItemComponent, PillListComponent, PopoverClickDirective, PopoverComponent, PopoverContentDirective, PopoverHoverDirective, Required, ResizeObserverService, ResponsiveInputComponent, SPACE, SelectDropdownDirective, SelectableItemDirective, SelectedOptionDirective, SingleSelectComponent, SliderToggleComponent, SortPipe, Sorting, SortingDropdownComponent, SortingDropdownTriggerComponent, SpinnerComponent, TAB, TabComponent, TabGroupComponent, TableComponent, TableHeaderComponent, TinySpinnerComponent, TooltipComponent, TooltipDirective, TranslationAfterPipe, TranslationBeforePipe, TranslationBetweenPipe, UnescapeCurlyBracesPipe, ValidateDateInForeseeableFuture, getContrastColor, getTranslationParts, isValidHexColor, isValidX, isValidY, provideFormControlErrorDisplayStrategy, provideFormControlErrorNamespace, shorthandHexHandle };
6305
6534
  //# sourceMappingURL=leanix-components.mjs.map