@ptsecurity/mosaic 17.2.13 → 17.2.14

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.
Files changed (42) hide show
  1. package/core/forms/index.d.ts +1 -0
  2. package/core/forms/validators.d.ts +22 -0
  3. package/core/pop-up/constants.d.ts +13 -0
  4. package/core/pop-up/pop-up-trigger.d.ts +14 -1
  5. package/core/styles/theming/_theming.scss +1 -0
  6. package/esm2022/core/forms/index.mjs +2 -1
  7. package/esm2022/core/forms/validators.mjs +33 -0
  8. package/esm2022/core/pop-up/constants.mjs +10 -1
  9. package/esm2022/core/pop-up/pop-up-trigger.mjs +45 -3
  10. package/esm2022/core/version.mjs +2 -2
  11. package/esm2022/file-upload/file-upload.mjs +39 -2
  12. package/esm2022/file-upload/file-upload.module.mjs +8 -1
  13. package/esm2022/file-upload/multiple-file-upload.component.mjs +129 -37
  14. package/esm2022/file-upload/single-file-upload.component.mjs +124 -46
  15. package/esm2022/popover/popover.component.mjs +2 -2
  16. package/esm2022/select/select.component.mjs +6 -4
  17. package/esm2022/tooltip/tooltip.component.mjs +5 -2
  18. package/esm2022/tree-select/tree-select.component.mjs +6 -4
  19. package/fesm2022/ptsecurity-mosaic-core.mjs +86 -3
  20. package/fesm2022/ptsecurity-mosaic-core.mjs.map +1 -1
  21. package/fesm2022/ptsecurity-mosaic-file-upload.mjs +282 -72
  22. package/fesm2022/ptsecurity-mosaic-file-upload.mjs.map +1 -1
  23. package/fesm2022/ptsecurity-mosaic-popover.mjs +1 -1
  24. package/fesm2022/ptsecurity-mosaic-popover.mjs.map +1 -1
  25. package/fesm2022/ptsecurity-mosaic-select.mjs +5 -3
  26. package/fesm2022/ptsecurity-mosaic-select.mjs.map +1 -1
  27. package/fesm2022/ptsecurity-mosaic-tooltip.mjs +5 -2
  28. package/fesm2022/ptsecurity-mosaic-tooltip.mjs.map +1 -1
  29. package/fesm2022/ptsecurity-mosaic-tree-select.mjs +5 -3
  30. package/fesm2022/ptsecurity-mosaic-tree-select.mjs.map +1 -1
  31. package/file-upload/_file-upload-theme.scss +21 -11
  32. package/file-upload/file-upload.d.ts +31 -3
  33. package/file-upload/file-upload.module.d.ts +11 -10
  34. package/file-upload/file-upload.scss +8 -1
  35. package/file-upload/multiple-file-upload.component.d.ts +54 -13
  36. package/file-upload/multiple-file-upload.component.scss +0 -8
  37. package/file-upload/single-file-upload.component.d.ts +49 -14
  38. package/file-upload/single-file-upload.component.scss +0 -8
  39. package/package.json +45 -45
  40. package/prebuilt-themes/dark-theme.css +1 -1
  41. package/prebuilt-themes/default-theme.css +1 -1
  42. package/tooltip/tooltip.component.d.ts +2 -1
@@ -1426,6 +1426,39 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.0", ngImpor
1426
1426
  }]
1427
1427
  }] });
1428
1428
 
1429
+ /** Provides a set of validators for file-related form controls. */
1430
+ class FileValidators {
1431
+ /**
1432
+ * Validator that checks if the file size is less than or equal to the provided `maxSize`.
1433
+ *
1434
+ * @param maxSize - The maximum allowed file size in bytes.
1435
+ *
1436
+ * @returns A ValidatorFn function that checks the file size.
1437
+ *
1438
+ * ## Usage:
1439
+ *
1440
+ * ```typescript
1441
+ * const control = new FormControl(null, [FileValidators.maxFileSize(1024 * 1024)]); // 1MB
1442
+ * control.setValue(FILE_LESS_OR_EQUAL_THAN_1MB);
1443
+ * console.log(control.errors); // null
1444
+ * control.setValue(FILE_MORE_THAN_1MB);
1445
+ * console.log(control.errors); // {maxFileSize: { max: 1048576, actual: FILE_MORE_THAN_1MB.size }}
1446
+ * ```
1447
+ */
1448
+ static maxFileSize(maxSize) {
1449
+ return ({ value }) => {
1450
+ if (!value) {
1451
+ return null;
1452
+ }
1453
+ const size = value instanceof File ? value.size : value.file.size;
1454
+ if (size > maxSize) {
1455
+ return { maxFileSize: { max: maxSize, actual: size } };
1456
+ }
1457
+ return null;
1458
+ };
1459
+ }
1460
+ }
1461
+
1429
1462
  /**
1430
1463
  * Injection token that can be used to inject an instances of `McFormField`. It serves
1431
1464
  * as alternative token to the actual `McFormField` class which would cause unnecessary
@@ -2300,6 +2333,10 @@ function objectValues(object) {
2300
2333
  return object === null ? [] : baseValues(object, Object.keys(object));
2301
2334
  }
2302
2335
 
2336
+ /**
2337
+ * InjectionToken for providing component with popup. Used in select and tree-select for tooltip.
2338
+ */
2339
+ const MC_PARENT_POPUP = new InjectionToken('mc-parent-popup');
2303
2340
  var PopUpPlacements;
2304
2341
  (function (PopUpPlacements) {
2305
2342
  PopUpPlacements["Top"] = "top";
@@ -2336,6 +2373,10 @@ var PopUpSizes;
2336
2373
  PopUpSizes["Normal"] = "medium";
2337
2374
  PopUpSizes["Large"] = "large";
2338
2375
  })(PopUpSizes || (PopUpSizes = {}));
2376
+ /**
2377
+ * Variable used for offsetY(X) calculations when applying Angular Overlay
2378
+ */
2379
+ const arrowBottomMarginAndHalfHeight = 18;
2339
2380
 
2340
2381
  // tslint:disable-next-line:naming-convention
2341
2382
  class McPopUp {
@@ -2436,6 +2477,38 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.0", ngImpor
2436
2477
  }] });
2437
2478
 
2438
2479
  // tslint:disable: no-unbound-method
2480
+ const getOffset = ({ originX, overlayX, originY, overlayY }, { width, height }) => {
2481
+ const offset = {};
2482
+ // tslint:disable-next-line:no-magic-numbers
2483
+ const elementWidthHalf = width / 2;
2484
+ // tslint:disable-next-line:no-magic-numbers
2485
+ const elementHeightHalf = height / 2;
2486
+ // alignment should be applied only if the element is small
2487
+ if (arrowBottomMarginAndHalfHeight > elementWidthHalf) {
2488
+ const PADDING = arrowBottomMarginAndHalfHeight - elementWidthHalf;
2489
+ if (originX === overlayX) {
2490
+ if (originX === 'start') {
2491
+ offset.offsetX = -PADDING;
2492
+ }
2493
+ if (originX === 'end') {
2494
+ offset.offsetX = PADDING;
2495
+ }
2496
+ }
2497
+ }
2498
+ // alignment should be applied only if the element is small
2499
+ if (arrowBottomMarginAndHalfHeight > elementHeightHalf) {
2500
+ const PADDING = arrowBottomMarginAndHalfHeight - elementHeightHalf;
2501
+ if (originY === overlayY) {
2502
+ if (originY === 'top') {
2503
+ offset.offsetY = -PADDING;
2504
+ }
2505
+ if (originY === 'bottom') {
2506
+ offset.offsetY = PADDING;
2507
+ }
2508
+ }
2509
+ }
2510
+ return offset;
2511
+ };
2439
2512
  // tslint:disable-next-line:naming-convention
2440
2513
  class McPopUpTrigger {
2441
2514
  constructor() {
@@ -2629,12 +2702,22 @@ class McPopUpTrigger {
2629
2702
  this.overlayRef = this.createOverlay();
2630
2703
  this.subscribeOnClosingActions();
2631
2704
  const position = this.overlayRef.getConfig().positionStrategy
2632
- .withPositions(this.getPrioritizedPositions())
2705
+ .withPositions(this.getAdjustedPositions())
2633
2706
  .withPush(true);
2634
2707
  if (reapplyPosition) {
2635
2708
  setTimeout(() => position.reapplyLastPosition());
2636
2709
  }
2637
2710
  }
2711
+ /**
2712
+ * Returns a list of positions that are aligned with the element's dimensions and offsets.
2713
+ * @protected
2714
+ */
2715
+ getAdjustedPositions() {
2716
+ return this.getPrioritizedPositions().map((pos) => ({
2717
+ ...pos,
2718
+ ...getOffset(pos, this.elementRef.nativeElement.getBoundingClientRect())
2719
+ }));
2720
+ }
2638
2721
  getPriorityPlacementStrategy(value) {
2639
2722
  const result = [];
2640
2723
  const possiblePositions = Object.keys(this.availablePositions);
@@ -3014,11 +3097,11 @@ const validationTooltipShowDelay = 10;
3014
3097
  const validationTooltipHideDelay = 3000;
3015
3098
  const MC_VALIDATION = new InjectionToken('McUseValidation', { factory: () => ({ useValidation: true }) });
3016
3099
 
3017
- const VERSION = new Version('17.2.13+sha-0003505');
3100
+ const VERSION = new Version('17.2.14+sha-0d88356');
3018
3101
 
3019
3102
  /**
3020
3103
  * Generated bundle index. Do not edit.
3021
3104
  */
3022
3105
 
3023
- export { AbsoluteDateFormatterPipe, AbsoluteDateShortFormatterPipe, AbsoluteDateTimeFormatterPipe, AbsoluteShortDateTimeFormatterPipe, AnimationCurves, BOTTOM_LEFT_POSITION_PRIORITY, BOTTOM_POSITION_PRIORITY, BOTTOM_RIGHT_POSITION_PRIORITY, DateAdapter, DateFormatter, EXTENDED_OVERLAY_POSITIONS, ErrorStateMatcher, LEFT_BOTTOM_POSITION_PRIORITY, LEFT_POSITION_PRIORITY, LEFT_TOP_POSITION_PRIORITY, MC_CUSTOM_SCROLL_STRATEGY_PROVIDER, MC_DATE_FORMATS, MC_DATE_LOCALE, MC_DATE_LOCALE_FACTORY, MC_DEFAULT_LOCALE_DATA_FACTORY, MC_DEFAULT_LOCALE_ID, MC_FORM_FIELD_REF, MC_LABEL_GLOBAL_OPTIONS, MC_LOCALE_DATA, MC_LOCALE_ID, MC_LOCALE_SERVICE, MC_NUMBER_FORMATTER_DEFAULT_OPTIONS, MC_NUMBER_FORMATTER_OPTIONS, MC_OPTION_ACTION_PARENT, MC_OPTION_PARENT_COMPONENT, MC_PARENT_ANIMATION_COMPONENT, MC_SANITY_CHECKS, MC_SELECT_SCROLL_STRATEGY, MC_SELECT_SCROLL_STRATEGY_PROVIDER, MC_TITLE_TEXT_REF, MC_VALIDATION, McCommonModule, McDataSizeModule, McDataSizePipe, McDecimalPipe, McForm, McFormElement, McFormattersModule, McFormsModule, McHighlightModule, McHighlightPipe, McLine, McLineModule, McLineSetter, McLocaleService, McLocaleServiceModule, McMeasureScrollbarService, McOptgroup, McOptgroupBase, McOptgroupMixinBase, McOption, McOptionActionBase, McOptionActionComponent, McOptionActionMixinBase, McOptionBase, McOptionModule, McOptionSelectionChange, McPopUp, McPopUpTrigger, McPseudoCheckbox, McPseudoCheckboxBase, McPseudoCheckboxMixinBase, McPseudoCheckboxModule, McRoundDecimalPipe, McSelectFooter, McSelectMatcher, McSelectSearch, McSelectSearchEmptyResult, McSelectTrigger, McTableNumberPipe, McVirtualOption, MeasurementSystem, MultipleMode, NUMBER_FORMAT_REGEXP, POSITION_MAP, POSITION_PRIORITY_STRATEGY, POSITION_TO_CSS_MAP, PopUpPlacements, PopUpSizes, PopUpTriggers, PopUpVisibility, RIGHT_BOTTOM_POSITION_PRIORITY, RIGHT_POSITION_PRIORITY, RIGHT_TOP_POSITION_PRIORITY, RangeDateFormatterPipe, RangeDateTimeFormatterPipe, RangeMiddleDateTimeFormatterPipe, RangeShortDateFormatterPipe, RangeShortDateTimeFormatterPipe, RelativeDateFormatterPipe, RelativeDateTimeFormatterPipe, RelativeShortDateFormatterPipe, RelativeShortDateTimeFormatterPipe, SELECT_PANEL_INDENT_PADDING_X, SELECT_PANEL_MAX_HEIGHT, SELECT_PANEL_PADDING_X, SELECT_PANEL_VIEWPORT_PADDING, ShowOnDirtyErrorStateMatcher, TOP_LEFT_POSITION_PRIORITY, TOP_POSITION_PRIORITY, TOP_RIGHT_POSITION_PRIORITY, ThemePalette, VERSION, checkAndNormalizeLocalizedNumber, countGroupLabelsBeforeOption, enUSLocaleData, esLALocaleData, escapeRegExp, faIRLocaleData, fadeAnimation, formatDataSize, getHumanizedBytes, getMcSelectDynamicMultipleError, getMcSelectNonArrayValueError, getMcSelectNonFunctionValueError, getOptionScrollPosition, isBoolean, isWithin, mcSelectAnimations, mcSelectScrollStrategyProviderFactory, mixinColor, mixinDisabled, mixinErrorState, mixinTabIndex, normalizeNumber, ptBRLocaleData, ruRULocaleData, selectEvents, sizeUnitsConfig, toBoolean, validationTooltipHideDelay, validationTooltipShowDelay, znCNLocaleData };
3106
+ export { AbsoluteDateFormatterPipe, AbsoluteDateShortFormatterPipe, AbsoluteDateTimeFormatterPipe, AbsoluteShortDateTimeFormatterPipe, AnimationCurves, BOTTOM_LEFT_POSITION_PRIORITY, BOTTOM_POSITION_PRIORITY, BOTTOM_RIGHT_POSITION_PRIORITY, DateAdapter, DateFormatter, EXTENDED_OVERLAY_POSITIONS, ErrorStateMatcher, FileValidators, LEFT_BOTTOM_POSITION_PRIORITY, LEFT_POSITION_PRIORITY, LEFT_TOP_POSITION_PRIORITY, MC_CUSTOM_SCROLL_STRATEGY_PROVIDER, MC_DATE_FORMATS, MC_DATE_LOCALE, MC_DATE_LOCALE_FACTORY, MC_DEFAULT_LOCALE_DATA_FACTORY, MC_DEFAULT_LOCALE_ID, MC_FORM_FIELD_REF, MC_LABEL_GLOBAL_OPTIONS, MC_LOCALE_DATA, MC_LOCALE_ID, MC_LOCALE_SERVICE, MC_NUMBER_FORMATTER_DEFAULT_OPTIONS, MC_NUMBER_FORMATTER_OPTIONS, MC_OPTION_ACTION_PARENT, MC_OPTION_PARENT_COMPONENT, MC_PARENT_ANIMATION_COMPONENT, MC_PARENT_POPUP, MC_SANITY_CHECKS, MC_SELECT_SCROLL_STRATEGY, MC_SELECT_SCROLL_STRATEGY_PROVIDER, MC_TITLE_TEXT_REF, MC_VALIDATION, McCommonModule, McDataSizeModule, McDataSizePipe, McDecimalPipe, McForm, McFormElement, McFormattersModule, McFormsModule, McHighlightModule, McHighlightPipe, McLine, McLineModule, McLineSetter, McLocaleService, McLocaleServiceModule, McMeasureScrollbarService, McOptgroup, McOptgroupBase, McOptgroupMixinBase, McOption, McOptionActionBase, McOptionActionComponent, McOptionActionMixinBase, McOptionBase, McOptionModule, McOptionSelectionChange, McPopUp, McPopUpTrigger, McPseudoCheckbox, McPseudoCheckboxBase, McPseudoCheckboxMixinBase, McPseudoCheckboxModule, McRoundDecimalPipe, McSelectFooter, McSelectMatcher, McSelectSearch, McSelectSearchEmptyResult, McSelectTrigger, McTableNumberPipe, McVirtualOption, MeasurementSystem, MultipleMode, NUMBER_FORMAT_REGEXP, POSITION_MAP, POSITION_PRIORITY_STRATEGY, POSITION_TO_CSS_MAP, PopUpPlacements, PopUpSizes, PopUpTriggers, PopUpVisibility, RIGHT_BOTTOM_POSITION_PRIORITY, RIGHT_POSITION_PRIORITY, RIGHT_TOP_POSITION_PRIORITY, RangeDateFormatterPipe, RangeDateTimeFormatterPipe, RangeMiddleDateTimeFormatterPipe, RangeShortDateFormatterPipe, RangeShortDateTimeFormatterPipe, RelativeDateFormatterPipe, RelativeDateTimeFormatterPipe, RelativeShortDateFormatterPipe, RelativeShortDateTimeFormatterPipe, SELECT_PANEL_INDENT_PADDING_X, SELECT_PANEL_MAX_HEIGHT, SELECT_PANEL_PADDING_X, SELECT_PANEL_VIEWPORT_PADDING, ShowOnDirtyErrorStateMatcher, TOP_LEFT_POSITION_PRIORITY, TOP_POSITION_PRIORITY, TOP_RIGHT_POSITION_PRIORITY, ThemePalette, VERSION, arrowBottomMarginAndHalfHeight, checkAndNormalizeLocalizedNumber, countGroupLabelsBeforeOption, enUSLocaleData, esLALocaleData, escapeRegExp, faIRLocaleData, fadeAnimation, formatDataSize, getHumanizedBytes, getMcSelectDynamicMultipleError, getMcSelectNonArrayValueError, getMcSelectNonFunctionValueError, getOptionScrollPosition, isBoolean, isWithin, mcSelectAnimations, mcSelectScrollStrategyProviderFactory, mixinColor, mixinDisabled, mixinErrorState, mixinTabIndex, normalizeNumber, ptBRLocaleData, ruRULocaleData, selectEvents, sizeUnitsConfig, toBoolean, validationTooltipHideDelay, validationTooltipShowDelay, znCNLocaleData };
3024
3107
  //# sourceMappingURL=ptsecurity-mosaic-core.mjs.map