@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, __awaiter } 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';
@@ -518,7 +518,16 @@ function isResizeableElement(element) {
518
518
  class ResizeObserverService {
519
519
  observe(element, callback, options) {
520
520
  if (!this.resizeObserver) {
521
- this.resizeObserver = new ResizeObserver(this.resizeObserverCallback.bind(this));
521
+ try {
522
+ this.resizeObserver = new ResizeObserver(this.resizeObserverCallback.bind(this));
523
+ }
524
+ catch (_a) {
525
+ // All the browsers we support implement the ResizeObserver API.
526
+ // For unsupported browsers, there's this "one time artifical resize event".
527
+ // They will not get the functionality tied to later resize events.
528
+ timer(500).subscribe(() => callback(this.getMockOneTimeResizeEventForUnsupportedBrowsers(element)));
529
+ return;
530
+ }
522
531
  }
523
532
  element.handleResize = callback;
524
533
  this.resizeObserver.observe(element, options);
@@ -536,6 +545,42 @@ class ResizeObserverService {
536
545
  }
537
546
  });
538
547
  }
548
+ /**
549
+ * All browsers we officially support implement the ResizeObserver API.
550
+ * Still as a curtesy do customers who for some reason have older browsers
551
+ * we call the callback once with the initial dimensions of the element
552
+ * and then do not react on resize events afterwards.
553
+ * This should still make them happier than a "browser not supported" warning.
554
+ */
555
+ getMockOneTimeResizeEventForUnsupportedBrowsers(element) {
556
+ const contentRect = {
557
+ bottom: element.clientHeight,
558
+ height: element.clientHeight,
559
+ left: 0,
560
+ right: element.clientWidth,
561
+ top: 0,
562
+ width: element.clientWidth,
563
+ x: 0,
564
+ y: 0
565
+ };
566
+ return {
567
+ borderBoxSize: [{ blockSize: element.clientHeight, inlineSize: element.clientWidth }],
568
+ contentBoxSize: [
569
+ {
570
+ blockSize: element.clientHeight,
571
+ inlineSize: element.clientWidth
572
+ }
573
+ ],
574
+ contentRect: Object.assign(Object.assign({}, contentRect), { toJSON: () => JSON.stringify(contentRect) }),
575
+ devicePixelContentBoxSize: [
576
+ {
577
+ blockSize: element.clientWidth,
578
+ inlineSize: element.clientWidth
579
+ }
580
+ ],
581
+ target: element
582
+ };
583
+ }
539
584
  }
540
585
  ResizeObserverService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.5", ngImport: i0, type: ResizeObserverService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
541
586
  ResizeObserverService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.2.5", ngImport: i0, type: ResizeObserverService, providedIn: 'root' });
@@ -1154,6 +1199,179 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.5", ngImpor
1154
1199
  args: [{ name: 'lxHighlightTerm' }]
1155
1200
  }] });
1156
1201
 
1202
+ /**
1203
+ * This pipe transforms...
1204
+ * - "raw" http(s) links
1205
+ * - markdown link syntax
1206
+ * ... into clickable anchor elements.
1207
+ *
1208
+ * You have an user interface where you don't want clickable links but also
1209
+ * don't want users to see the "ugly" markdown link syntax?
1210
+ * -> Use the 'lxUnlikify' pipe to replace markdown link syntax with just the link name
1211
+ */
1212
+ class LxLinkifyPipe {
1213
+ transform(text) {
1214
+ if (text && typeof text === 'string') {
1215
+ const textWithRawLinks = this.wrapRawHttpLinksWithAnchorTags(text);
1216
+ const textWithRawAndNamedLinks = this.turnMarkdownStyleLinksIntoAnchorTags(textWithRawLinks);
1217
+ return textWithRawAndNamedLinks;
1218
+ }
1219
+ else {
1220
+ return text;
1221
+ }
1222
+ }
1223
+ turnMarkdownStyleLinksIntoAnchorTags(text) {
1224
+ let textWithRawAndNamedLinks = text;
1225
+ const namedLinkMatches = this.getAllRegexMatches(LxLinkifyPipe.NAMED_LINK_REGEX, text);
1226
+ namedLinkMatches.forEach((namedLinkMatch) => {
1227
+ const [source, name, url] = namedLinkMatch;
1228
+ const urlIsValid = url && !/javascript\:/i.test(url);
1229
+ if (source && name && urlIsValid) {
1230
+ textWithRawAndNamedLinks = textWithRawAndNamedLinks.replace(source, `<a href="${url}" target="_blank" rel="noopener noreferrer">${name}</a>`);
1231
+ }
1232
+ });
1233
+ return textWithRawAndNamedLinks;
1234
+ }
1235
+ wrapRawHttpLinksWithAnchorTags(text) {
1236
+ let textWithRawLinks = text;
1237
+ /**
1238
+ * Keeping track of this index prevents infinite loops
1239
+ * where a previously processed link starts with the same characters
1240
+ * as a second link.
1241
+ * e.g. https://angular.io/docs followed by https://angular.io
1242
+ */
1243
+ let nextIndexToStartReplacingFrom = 0;
1244
+ const rawLinkMatches = this.getAllRegexMatches(LxLinkifyPipe.HTTP_LINK_REGEX, text);
1245
+ rawLinkMatches.forEach((rawLinkMatch) => {
1246
+ const [url] = rawLinkMatch;
1247
+ const wrapUrlInAnchor = (sanitizedUrlMatch) => {
1248
+ const firstPart = textWithRawLinks.substring(0, nextIndexToStartReplacingFrom);
1249
+ const anchorTagHtml = `<a href="${sanitizedUrlMatch}" target="_blank" rel="noopener noreferrer">${sanitizedUrlMatch}</a>`;
1250
+ const secondPart = textWithRawLinks.substring(nextIndexToStartReplacingFrom).replace(sanitizedUrlMatch, anchorTagHtml);
1251
+ textWithRawLinks = firstPart + secondPart;
1252
+ nextIndexToStartReplacingFrom = rawLinkMatch.index + anchorTagHtml.length;
1253
+ };
1254
+ if (url) {
1255
+ /*
1256
+ * TODO: get rid of all this code once Safari supports negative lookbehinds in regular expressions
1257
+ * The following is RegExp that handles the same stuff as the JS code below:
1258
+ *
1259
+ * /(?:(?:(?<!\]\())(?:https|http):\/\/)(?:[^\s/$.?#][^\s]*(?<![\.)]))/gi;
1260
+ *
1261
+ * Demo on regex101: https://regex101.com/r/7Vl9bg/1
1262
+ *
1263
+ * Check lookbehind support here: https://caniuse.com/?search=lookbehind
1264
+ */
1265
+ const lastUrlCharacterIndex = rawLinkMatch.index + url.length - 1;
1266
+ const textUsedToPerformMatching = rawLinkMatch.input;
1267
+ const lastCharacterInUrl = textUsedToPerformMatching[lastUrlCharacterIndex];
1268
+ const twoCharactersInFrontOfTheLink = rawLinkMatch.index > 3
1269
+ ? `${textUsedToPerformMatching[rawLinkMatch.index - 2]}${textUsedToPerformMatching[rawLinkMatch.index - 1]}`
1270
+ : '';
1271
+ const isMarkdownSyntaxLink = twoCharactersInFrontOfTheLink === '](';
1272
+ if (!isMarkdownSyntaxLink && lastCharacterInUrl === '.') {
1273
+ const characterAfterUrl = textUsedToPerformMatching[lastUrlCharacterIndex + 1];
1274
+ if (!characterAfterUrl || characterAfterUrl === ' ' || characterAfterUrl === '\n') {
1275
+ const urlWithoutDotAtTheEnd = url.slice(0, -1);
1276
+ wrapUrlInAnchor(urlWithoutDotAtTheEnd);
1277
+ }
1278
+ }
1279
+ else if (!isMarkdownSyntaxLink) {
1280
+ wrapUrlInAnchor(url);
1281
+ }
1282
+ }
1283
+ });
1284
+ return textWithRawLinks;
1285
+ }
1286
+ getAllRegexMatches(regex, input) {
1287
+ let match;
1288
+ const matches = [];
1289
+ while ((match = regex.exec(input)) !== null) {
1290
+ matches.push(match);
1291
+ }
1292
+ return matches;
1293
+ }
1294
+ }
1295
+ /**
1296
+ * This is not the "one URL regex to rule them all", but a more realistic one which should work
1297
+ * for any URLs that our customers include in text fields on a Fact Sheet.
1298
+ *
1299
+ * Regex rules explained in plain text:
1300
+ *
1301
+ * (?:(?:https?):\/\/) -> Links must start with "https://" or "http://"
1302
+ *
1303
+ * (?:[^\s/$.?#][^\s]*(?<![\.)])) LET'S SPLIT THIS ONE UP
1304
+ *
1305
+ * [^\s/$.?#][^\s]* -> Match any legal URL character until the next whitespace
1306
+ * (?<![\.)] -> A negative lookahead to prevent matching a dot or parenthesis following a URL
1307
+ *
1308
+ * Link to regex101: https://regex101.com/r/d3KtfH/1 (NOTE: please update this link when changing the regex)
1309
+ */
1310
+ LxLinkifyPipe.HTTP_LINK_REGEX = /(?:(?:https?):\/\/)(?:[^\s/$.?#][^\s]*)/gi;
1311
+ /**
1312
+ * This will match the markdown link syntax: [link name](url)
1313
+ * Regex rules explained in plain text:
1314
+ *
1315
+ * (?:\[([^\]]*)\]) -> Match any characters inside square brackets
1316
+ * \(([^\s\/$.?#][^\s]*)\) -> Notice that this is the same regex as the HTTP_LINK_REGEX above,
1317
+ * but without the requirement for the http protocol.
1318
+ * This allows for links without including the protocol or also "mailto:hello@world.de" links
1319
+ *
1320
+ * Link to regex101: https://regex101.com/r/5UMUH8/1
1321
+ */
1322
+ LxLinkifyPipe.NAMED_LINK_REGEX = /(?:\[([^\]]*)\])\(([^\s\/$.?#][^\s]*)\)/gi;
1323
+ LxLinkifyPipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.5", ngImport: i0, type: LxLinkifyPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
1324
+ LxLinkifyPipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "12.0.0", version: "13.2.5", ngImport: i0, type: LxLinkifyPipe, name: "lxLinkify" });
1325
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.5", ngImport: i0, type: LxLinkifyPipe, decorators: [{
1326
+ type: Pipe,
1327
+ args: [{ name: 'lxLinkify' }]
1328
+ }] });
1329
+
1330
+ /**
1331
+ * This pipe replaces markdown link syntax with just the link name (omits the link altogether).
1332
+ * Example: [Angular documentation](http://angular.io/docs) -> Angular documentation
1333
+ *
1334
+ * It can also be used for "bridging the gap" until your view is ready to use "lxLinkify"
1335
+ * and you just want to get rid of the "useless" markdown syntax fast.
1336
+ *
1337
+ * While there are views where we want markdown style links to be clickable anchor tags,
1338
+ * there are other views where this can degrade the UX.
1339
+ * Example: in the Fact Sheet list on the inventory list view, having an arbitrary number
1340
+ * of links on the page can slow down the keyboard navigation while navigating through the list.
1341
+ */
1342
+ class LxUnlinkifyPipe {
1343
+ transform(text) {
1344
+ if (text && typeof text === 'string') {
1345
+ let textWhereMarkdownLinkSyntaxIsReplacedWithJustTheLinkName = text;
1346
+ const markdownLinkSyntaxMatches = this.getAllRegexMatches(LxLinkifyPipe.NAMED_LINK_REGEX, text);
1347
+ markdownLinkSyntaxMatches.forEach((markdownLinkSyntaxMatch) => {
1348
+ const [source, name] = markdownLinkSyntaxMatch;
1349
+ if (source && name) {
1350
+ textWhereMarkdownLinkSyntaxIsReplacedWithJustTheLinkName = textWhereMarkdownLinkSyntaxIsReplacedWithJustTheLinkName.replace(source, name);
1351
+ }
1352
+ });
1353
+ return textWhereMarkdownLinkSyntaxIsReplacedWithJustTheLinkName;
1354
+ }
1355
+ else {
1356
+ return text;
1357
+ }
1358
+ }
1359
+ getAllRegexMatches(regex, input) {
1360
+ let match;
1361
+ const matches = [];
1362
+ while ((match = regex.exec(input)) !== null) {
1363
+ matches.push(match);
1364
+ }
1365
+ return matches;
1366
+ }
1367
+ }
1368
+ LxUnlinkifyPipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.5", ngImport: i0, type: LxUnlinkifyPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
1369
+ LxUnlinkifyPipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "12.0.0", version: "13.2.5", ngImport: i0, type: LxUnlinkifyPipe, name: "lxUnlinkify" });
1370
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.5", ngImport: i0, type: LxUnlinkifyPipe, decorators: [{
1371
+ type: Pipe,
1372
+ args: [{ name: 'lxUnlinkify' }]
1373
+ }] });
1374
+
1157
1375
  function isUuid(s) {
1158
1376
  const uuidRegEx = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
1159
1377
  return uuidRegEx.test(s);
@@ -1508,6 +1726,8 @@ LxCoreUiModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version:
1508
1726
  HighlightTermPipe,
1509
1727
  HtmlDirective,
1510
1728
  IconScaleComponent,
1729
+ LxLinkifyPipe,
1730
+ LxUnlinkifyPipe,
1511
1731
  LxTimeAgo,
1512
1732
  LxTranslatePipe,
1513
1733
  MarkdownPipe,
@@ -1538,6 +1758,8 @@ LxCoreUiModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version:
1538
1758
  HighlightTermPipe,
1539
1759
  HtmlDirective,
1540
1760
  IconScaleComponent,
1761
+ LxLinkifyPipe,
1762
+ LxUnlinkifyPipe,
1541
1763
  LxTimeAgo,
1542
1764
  LxTranslatePipe,
1543
1765
  MarkdownPipe,
@@ -1575,6 +1797,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.5", ngImpor
1575
1797
  HighlightTermPipe,
1576
1798
  HtmlDirective,
1577
1799
  IconScaleComponent,
1800
+ LxLinkifyPipe,
1801
+ LxUnlinkifyPipe,
1578
1802
  LxTimeAgo,
1579
1803
  LxTranslatePipe,
1580
1804
  MarkdownPipe,
@@ -1609,6 +1833,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.5", ngImpor
1609
1833
  HighlightTermPipe,
1610
1834
  HtmlDirective,
1611
1835
  IconScaleComponent,
1836
+ LxLinkifyPipe,
1837
+ LxUnlinkifyPipe,
1612
1838
  LxTimeAgo,
1613
1839
  LxTranslatePipe,
1614
1840
  MarkdownPipe,
@@ -6350,5 +6576,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.5", ngImpor
6350
6576
  * Generated bundle index. Do not edit.
6351
6577
  */
6352
6578
 
6353
- 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 };
6579
+ 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 };
6354
6580
  //# sourceMappingURL=leanix-components.mjs.map