@ship-ui/core 0.15.28 → 0.15.30

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.
@@ -1023,6 +1023,7 @@ class ShipBlueprintComponent {
1023
1023
  }
1024
1024
  }
1025
1025
  onTouchMove(event) {
1026
+ event.preventDefault();
1026
1027
  if (this.isLocked())
1027
1028
  return;
1028
1029
  if (this.#isNodeDragging()) {
@@ -1035,6 +1036,11 @@ class ShipBlueprintComponent {
1035
1036
  this.handleTouchMove(event);
1036
1037
  }
1037
1038
  }
1039
+ onDocumentTouchEnd(event) {
1040
+ if (this.isLocked())
1041
+ return;
1042
+ this.handleTouchEnd();
1043
+ }
1038
1044
  startNodeDrag(event, nodeId) {
1039
1045
  event.stopPropagation();
1040
1046
  event.preventDefault();
@@ -1089,6 +1095,7 @@ class ShipBlueprintComponent {
1089
1095
  this.#lastMouseY.set(clientY);
1090
1096
  }
1091
1097
  startPortDrag(event, nodeId, portId) {
1098
+ event.preventDefault();
1092
1099
  event.stopPropagation();
1093
1100
  if (this.draggingConnection())
1094
1101
  this.cancelPortDrag();
@@ -1216,6 +1223,7 @@ class ShipBlueprintComponent {
1216
1223
  }
1217
1224
  }
1218
1225
  handleTouchMove(event) {
1226
+ event.preventDefault();
1219
1227
  if (event.touches.length === 1 && this.#isDragging()) {
1220
1228
  const dx = event.touches[0].clientX - this.#lastMouseX();
1221
1229
  const dy = event.touches[0].clientY - this.#lastMouseY();
@@ -1242,6 +1250,10 @@ class ShipBlueprintComponent {
1242
1250
  }
1243
1251
  handleTouchEnd() {
1244
1252
  this.#isDragging.set(false);
1253
+ this.endNodeDrag();
1254
+ if (this.draggingConnection()) {
1255
+ this.cancelPortDrag();
1256
+ }
1245
1257
  }
1246
1258
  closeMidpointDiv() {
1247
1259
  this.showMidpointDiv.set(false);
@@ -1422,7 +1434,7 @@ class ShipBlueprintComponent {
1422
1434
  return Math.max(min, Math.min(max, value));
1423
1435
  }
1424
1436
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: ShipBlueprintComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
1425
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.0", type: ShipBlueprintComponent, isStandalone: true, selector: "sh-blueprint", inputs: { forceUnique: { classPropertyName: "forceUnique", publicName: "forceUnique", isSignal: true, isRequired: false, transformFunction: null }, autoLayout: { classPropertyName: "autoLayout", publicName: "autoLayout", isSignal: true, isRequired: false, transformFunction: null }, gridSize: { classPropertyName: "gridSize", publicName: "gridSize", isSignal: true, isRequired: false, transformFunction: null }, snapToGrid: { classPropertyName: "snapToGrid", publicName: "snapToGrid", isSignal: true, isRequired: false, transformFunction: null }, gridColor: { classPropertyName: "gridColor", publicName: "gridColor", isSignal: true, isRequired: false, transformFunction: null }, nodes: { classPropertyName: "nodes", publicName: "nodes", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { nodes: "nodesChange" }, host: { listeners: { "document:mouseup": "onMouseUp($event)", "document:click": "onClick($event)", "document:keydown.escape": "onEscape($event)", "document:mousemove": "onMouseMove($event)", "document:touchmove": "onTouchMove($event)" } }, viewQueries: [{ propertyName: "canvasRef", first: true, predicate: ["blueprintCanvas"], descendants: true, static: true }], ngImport: i0, template: `
1437
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.0", type: ShipBlueprintComponent, isStandalone: true, selector: "sh-blueprint", inputs: { forceUnique: { classPropertyName: "forceUnique", publicName: "forceUnique", isSignal: true, isRequired: false, transformFunction: null }, autoLayout: { classPropertyName: "autoLayout", publicName: "autoLayout", isSignal: true, isRequired: false, transformFunction: null }, gridSize: { classPropertyName: "gridSize", publicName: "gridSize", isSignal: true, isRequired: false, transformFunction: null }, snapToGrid: { classPropertyName: "snapToGrid", publicName: "snapToGrid", isSignal: true, isRequired: false, transformFunction: null }, gridColor: { classPropertyName: "gridColor", publicName: "gridColor", isSignal: true, isRequired: false, transformFunction: null }, nodes: { classPropertyName: "nodes", publicName: "nodes", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { nodes: "nodesChange" }, host: { listeners: { "document:mouseup": "onMouseUp($event)", "document:click": "onClick($event)", "document:keydown.escape": "onEscape($event)", "document:mousemove": "onMouseMove($event)", "document:touchmove": "onTouchMove($event)", "document:touchend": "onDocumentTouchEnd($event)" } }, viewQueries: [{ propertyName: "canvasRef", first: true, predicate: ["blueprintCanvas"], descendants: true, static: true }], ngImport: i0, template: `
1426
1438
  <div
1427
1439
  class="canvas-container"
1428
1440
  [class.locked]="isLocked()"
@@ -1622,6 +1634,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImpor
1622
1634
  }], onTouchMove: [{
1623
1635
  type: HostListener,
1624
1636
  args: ['document:touchmove', ['$event']]
1637
+ }], onDocumentTouchEnd: [{
1638
+ type: HostListener,
1639
+ args: ['document:touchend', ['$event']]
1625
1640
  }] } });
1626
1641
 
1627
1642
  class ShipButtonGroupComponent {
@@ -6562,6 +6577,82 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImpor
6562
6577
  args: ['drop', ['$event']]
6563
6578
  }] } });
6564
6579
 
6580
+ class ShipInputMaskDirective {
6581
+ constructor() {
6582
+ this.#selfRef = inject(ElementRef);
6583
+ this.#renderer = inject(Renderer2);
6584
+ this.shInputMask = input('(999) 999-9999', ...(ngDevMode ? [{ debugName: "shInputMask" }] : []));
6585
+ }
6586
+ #selfRef;
6587
+ #renderer;
6588
+ onInput(event) {
6589
+ const inputElement = this.#selfRef.nativeElement;
6590
+ const oldRawValue = inputElement.value;
6591
+ const newRawValue = event.target.value;
6592
+ const oldCursorPos = inputElement.selectionStart ?? 0;
6593
+ const newCleanValue = this.#cleanValue(newRawValue);
6594
+ const maskedValue = this.#applyMask(newCleanValue);
6595
+ this.#renderer.setProperty(inputElement, 'value', maskedValue);
6596
+ const newCursorPos = this.#getNewCursorPosition(maskedValue, oldRawValue, oldCursorPos);
6597
+ inputElement.setSelectionRange(newCursorPos, newCursorPos);
6598
+ }
6599
+ #getNewCursorPosition(maskedValue, oldRawValue, oldCursorPos) {
6600
+ let digitsBeforeCursor = 0;
6601
+ for (let i = 0; i < oldCursorPos; i++) {
6602
+ if (oldRawValue[i] && oldRawValue[i].match(/\d/)) {
6603
+ digitsBeforeCursor++;
6604
+ }
6605
+ }
6606
+ let newCursorPos = 0;
6607
+ let digitsFound = 0;
6608
+ while (newCursorPos < maskedValue.length && digitsFound < digitsBeforeCursor) {
6609
+ if (maskedValue[newCursorPos].match(/\d/)) {
6610
+ digitsFound++;
6611
+ }
6612
+ newCursorPos++;
6613
+ }
6614
+ return newCursorPos;
6615
+ }
6616
+ #cleanValue(value) {
6617
+ if (!value)
6618
+ return '';
6619
+ return value.replace(/\D/g, '');
6620
+ }
6621
+ #applyMask(cleanValue) {
6622
+ const inputMask = this.shInputMask();
6623
+ if (typeof inputMask === 'function') {
6624
+ return inputMask(cleanValue) ?? '';
6625
+ }
6626
+ const pattern = inputMask;
6627
+ let masked = '';
6628
+ let digitIndex = 0;
6629
+ for (let i = 0; i < pattern.length && digitIndex < cleanValue.length; i++) {
6630
+ const maskChar = pattern[i];
6631
+ const digitChar = cleanValue[digitIndex];
6632
+ if (maskChar === '9') {
6633
+ masked += digitChar;
6634
+ digitIndex++;
6635
+ }
6636
+ else {
6637
+ masked += maskChar;
6638
+ }
6639
+ }
6640
+ return masked;
6641
+ }
6642
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: ShipInputMaskDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
6643
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "20.3.0", type: ShipInputMaskDirective, isStandalone: true, selector: "[shInputMask]", inputs: { shInputMask: { classPropertyName: "shInputMask", publicName: "shInputMask", isSignal: true, isRequired: false, transformFunction: null } }, host: { listeners: { "input": "onInput($event)" } }, ngImport: i0 }); }
6644
+ }
6645
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: ShipInputMaskDirective, decorators: [{
6646
+ type: Directive,
6647
+ args: [{
6648
+ selector: '[shInputMask]',
6649
+ standalone: true,
6650
+ }]
6651
+ }], propDecorators: { onInput: [{
6652
+ type: HostListener,
6653
+ args: ['input', ['$event']]
6654
+ }] } });
6655
+
6565
6656
  class ShipPreventWheelDirective {
6566
6657
  wheel(event) {
6567
6658
  event.preventDefault();
@@ -6792,5 +6883,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImpor
6792
6883
  * Generated bundle index. Do not edit.
6793
6884
  */
6794
6885
 
6795
- export { GridSortableDirective, SHIP_CONFIG, ShipAlertComponent, ShipAlertContainerComponent, ShipAlertModule, ShipAlertService, ShipBlueprintComponent, ShipButtonComponent, ShipButtonGroupComponent, ShipCardComponent, ShipCheckboxComponent, ShipChipComponent, ShipColorPickerComponent, ShipDatepickerComponent, ShipDatepickerInputComponent, ShipDaterangeInputComponent, ShipDialogComponent, ShipDialogService, ShipDividerComponent, ShipEventCardComponent, ShipFileDragDropDirective, ShipFileUploadComponent, ShipFormFieldComponent, ShipIconComponent, ShipListComponent, ShipMenuComponent, ShipPopoverComponent, ShipPreventWheelDirective, ShipProgressBarComponent, ShipRadioComponent, ShipRangeSliderComponent, ShipResizeDirective, ShipSelectComponent, ShipSidenavComponent, ShipSortDirective, ShipSortableComponent, ShipSortableDirective, ShipSpinnerComponent, ShipStepperComponent, ShipStickyColumnsDirective, ShipTableComponent, ShipTabsComponent, ShipToggleCardComponent, ShipToggleComponent, ShipTooltipComponent, ShipTooltipDirective, ShipTooltipWrapper, ShipVirtualScrollComponent, TEST_NODES, moveIndex, watchHostClass };
6886
+ export { GridSortableDirective, SHIP_CONFIG, ShipAlertComponent, ShipAlertContainerComponent, ShipAlertModule, ShipAlertService, ShipBlueprintComponent, ShipButtonComponent, ShipButtonGroupComponent, ShipCardComponent, ShipCheckboxComponent, ShipChipComponent, ShipColorPickerComponent, ShipDatepickerComponent, ShipDatepickerInputComponent, ShipDaterangeInputComponent, ShipDialogComponent, ShipDialogService, ShipDividerComponent, ShipEventCardComponent, ShipFileDragDropDirective, ShipFileUploadComponent, ShipFormFieldComponent, ShipIconComponent, ShipInputMaskDirective, ShipListComponent, ShipMenuComponent, ShipPopoverComponent, ShipPreventWheelDirective, ShipProgressBarComponent, ShipRadioComponent, ShipRangeSliderComponent, ShipResizeDirective, ShipSelectComponent, ShipSidenavComponent, ShipSortDirective, ShipSortableComponent, ShipSortableDirective, ShipSpinnerComponent, ShipStepperComponent, ShipStickyColumnsDirective, ShipTableComponent, ShipTabsComponent, ShipToggleCardComponent, ShipToggleComponent, ShipTooltipComponent, ShipTooltipDirective, ShipTooltipWrapper, ShipVirtualScrollComponent, TEST_NODES, moveIndex, watchHostClass };
6796
6887
  //# sourceMappingURL=ship-ui-core.mjs.map