@stemy/ngx-utils 19.8.6 → 19.8.7

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.
@@ -1887,73 +1887,6 @@ class RulerCanvasRenderer {
1887
1887
  }
1888
1888
  }
1889
1889
 
1890
- function dotProduct(a, b) {
1891
- return a.x * b.x + a.y * b.y;
1892
- }
1893
- function tripleProduct(a, b, c) {
1894
- const ac = a.x * c.x + a.y * c.y;
1895
- const bc = b.x * c.x + b.y * c.y;
1896
- return { x: b.x * ac - a.x * bc, y: b.y * ac - a.y * bc };
1897
- }
1898
- function isPoint(v) {
1899
- return typeof v === "object" && Number.isFinite(v.x) && Number.isFinite(v.y);
1900
- }
1901
- function ensurePoint(p, fallback = { x: 0, y: 0 }) {
1902
- return isPoint(p) ? { x: +p.x, y: +p.y } : fallback;
1903
- }
1904
- function perpendicular(p) {
1905
- return { x: -p.y, y: +p.x };
1906
- }
1907
- function negatePt(p) {
1908
- return { x: -p.x, y: -p.y };
1909
- }
1910
- function normalizePt(p) {
1911
- const length = lengthOfPt(p);
1912
- return dividePts(p, length);
1913
- }
1914
- function addPts(a, b) {
1915
- return { x: a.x + b.x, y: a.y + b.y };
1916
- }
1917
- function distanceSq(a, b) {
1918
- const x = b.x - a.x;
1919
- const y = b.y - a.y;
1920
- return x * x + y * y;
1921
- }
1922
- function distance(a, b) {
1923
- return Math.sqrt(distanceSq(a, b));
1924
- }
1925
- function lerpPts(a, b, t) {
1926
- const diff = subPts(b, a);
1927
- return addPts(a, multiplyPts(diff, t));
1928
- }
1929
- function lengthOfPt(p) {
1930
- return Math.hypot(p.x, p.y);
1931
- }
1932
- function multiplyPts(a, b) {
1933
- const s = isPoint(b) ? b : { x: b, y: b };
1934
- return { x: a.x * s.x, y: a.y * s.y };
1935
- }
1936
- function dividePts(a, b) {
1937
- const s = isPoint(b) ? b : { x: b, y: b };
1938
- return { x: a.x / s.x, y: a.y / s.y };
1939
- }
1940
- function subPts(a, b) {
1941
- return { x: a.x - b.x, y: a.y - b.y };
1942
- }
1943
- function rotateDeg(p, ang) {
1944
- return rotateRad(p, toRadians(ang));
1945
- }
1946
- function rotateRad(p, ang) {
1947
- const c = Math.cos(ang), s = Math.sin(ang);
1948
- return { x: p.x * c - p.y * s, y: p.x * s + p.y * c };
1949
- }
1950
- function toDegrees(rad) {
1951
- return rad * 180 / Math.PI;
1952
- }
1953
- function toRadians(deg) {
1954
- return deg * Math.PI / 180;
1955
- }
1956
-
1957
1890
  const EPSILON = 1e-9;
1958
1891
  /**
1959
1892
  * Normalize a range
@@ -2045,6 +1978,76 @@ class MathUtils {
2045
1978
  }
2046
1979
  }
2047
1980
 
1981
+ function dotProduct(a, b) {
1982
+ return a.x * b.x + a.y * b.y;
1983
+ }
1984
+ function tripleProduct(a, b, c) {
1985
+ const ac = a.x * c.x + a.y * c.y;
1986
+ const bc = b.x * c.x + b.y * c.y;
1987
+ return { x: b.x * ac - a.x * bc, y: b.y * ac - a.y * bc };
1988
+ }
1989
+ function isPoint(v) {
1990
+ return typeof v === "object" && Number.isFinite(v.x) && Number.isFinite(v.y);
1991
+ }
1992
+ function ensurePoint(p, fallback = { x: 0, y: 0 }) {
1993
+ return isPoint(p) ? { x: +p.x, y: +p.y } : fallback;
1994
+ }
1995
+ function perpendicular(p) {
1996
+ return { x: -p.y, y: +p.x };
1997
+ }
1998
+ function negatePt(p) {
1999
+ return { x: -p.x, y: -p.y };
2000
+ }
2001
+ function normalizePt(p) {
2002
+ const length = lengthOfPt(p);
2003
+ return dividePts(p, length);
2004
+ }
2005
+ function addPts(a, b) {
2006
+ return { x: a.x + b.x, y: a.y + b.y };
2007
+ }
2008
+ function distanceSq(a, b) {
2009
+ const x = b.x - a.x;
2010
+ const y = b.y - a.y;
2011
+ return x * x + y * y;
2012
+ }
2013
+ function distance(a, b) {
2014
+ return Math.sqrt(distanceSq(a, b));
2015
+ }
2016
+ function lerpPts(a, b, t) {
2017
+ const diff = subPts(b, a);
2018
+ return addPts(a, multiplyPts(diff, t));
2019
+ }
2020
+ function lengthOfPt(p) {
2021
+ return Math.hypot(p.x, p.y);
2022
+ }
2023
+ function multiplyPts(a, b) {
2024
+ const s = isPoint(b) ? b : { x: b, y: b };
2025
+ return { x: a.x * s.x, y: a.y * s.y };
2026
+ }
2027
+ function dividePts(a, b) {
2028
+ const s = isPoint(b) ? b : { x: b, y: b };
2029
+ return { x: a.x / s.x, y: a.y / s.y };
2030
+ }
2031
+ function subPts(a, b) {
2032
+ return { x: a.x - b.x, y: a.y - b.y };
2033
+ }
2034
+ function eqPts(a, b) {
2035
+ return isEqual(a.x, b.x) && isEqual(a.y, b.y);
2036
+ }
2037
+ function rotateDeg(p, ang) {
2038
+ return rotateRad(p, toRadians(ang));
2039
+ }
2040
+ function rotateRad(p, ang) {
2041
+ const c = Math.cos(ang), s = Math.sin(ang);
2042
+ return { x: p.x * c - p.y * s, y: p.x * s + p.y * c };
2043
+ }
2044
+ function toDegrees(rad) {
2045
+ return rad * 180 / Math.PI;
2046
+ }
2047
+ function toRadians(deg) {
2048
+ return deg * Math.PI / 180;
2049
+ }
2050
+
2048
2051
  const MAX_ITERS = 40;
2049
2052
  // =========================
2050
2053
  // GJK distance (robust)
@@ -8250,8 +8253,18 @@ class InteractiveItemComponent {
8250
8253
  this.pos = new Point(value.x, value.y);
8251
8254
  this.validPosition = this.pos;
8252
8255
  }
8256
+ get rotation() {
8257
+ return this.rot;
8258
+ }
8259
+ set rotation(value) {
8260
+ if (isNaN(value))
8261
+ return;
8262
+ console.log("set rotation", this.rotation, value);
8263
+ this.rot = value;
8264
+ this.validRotation = this.rot;
8265
+ }
8253
8266
  get isValid() {
8254
- return this.valid;
8267
+ return eqPts(this.pos, this.validPos) && isEqual(this.rot, this.validRot);
8255
8268
  }
8256
8269
  get validPosition() {
8257
8270
  return this.validPos;
@@ -8260,7 +8273,14 @@ class InteractiveItemComponent {
8260
8273
  if (typeof value !== "object" || isNaN(value.x) || isNaN(value.y) || value === this.validPos)
8261
8274
  return;
8262
8275
  this.validPos = new Point(value.x, value.y);
8263
- this.valid = true;
8276
+ }
8277
+ get validRotation() {
8278
+ return this.validRot;
8279
+ }
8280
+ set validRotation(value) {
8281
+ if (isNaN(value))
8282
+ return;
8283
+ this.validRot = value;
8264
8284
  }
8265
8285
  get hovered() {
8266
8286
  return this.canvas?.hoveredItem === this;
@@ -8282,8 +8302,10 @@ class InteractiveItemComponent {
8282
8302
  this.active = false;
8283
8303
  this.index = -1;
8284
8304
  this.canvasParams = {};
8285
- this.valid = true;
8286
8305
  this.pos = Point.Zero;
8306
+ this.validPos = Point.Zero;
8307
+ this.rot = 0;
8308
+ this.validRot = 0;
8287
8309
  this.direction = "none";
8288
8310
  this.mFrame = new Rect(0, 0, 3, 3);
8289
8311
  this.mShapes = [];
@@ -8312,15 +8334,6 @@ class InteractiveItemComponent {
8312
8334
  }
8313
8335
  return false;
8314
8336
  }
8315
- moveTo(x, y) {
8316
- if (!this.canvas || this.direction === "none")
8317
- return;
8318
- const target = this.restrictPosition(this.direction === "vertical" ? this.pos.x : x, this.direction === "horizontal" ? this.pos.y : y);
8319
- this.pos = new Point(target);
8320
- this.calcShapes();
8321
- this.valid = this.checkIsValid();
8322
- this.validPos = this.valid ? this.pos : this.validPos;
8323
- }
8324
8337
  moveBy(dx, dy) {
8325
8338
  const { x, y } = this.pos;
8326
8339
  this.moveTo(x + dx, y + dy);
@@ -8331,12 +8344,32 @@ class InteractiveItemComponent {
8331
8344
  moveY(y) {
8332
8345
  this.moveTo(this.pos.x, y);
8333
8346
  }
8347
+ moveTo(x, y) {
8348
+ if (!this.canvas || this.direction === "none")
8349
+ return;
8350
+ const target = this.restrictPosition(this.direction === "vertical" ? this.pos.x : x, this.direction === "horizontal" ? this.pos.y : y);
8351
+ this.pos = new Point(target);
8352
+ this.calcShapes();
8353
+ this.validPos = this.checkIsValid() ? this.pos : this.validPos;
8354
+ }
8334
8355
  moveEnd() {
8335
8356
  this.mDistances.clear();
8336
- if (this.valid)
8357
+ if (this.isValid)
8337
8358
  return;
8338
8359
  this.pos = this.validPos;
8339
- this.valid = true;
8360
+ this.calcShapes();
8361
+ }
8362
+ rotateTo(value) {
8363
+ this.rot = isNaN(value) ? this.rot : value;
8364
+ this.calcShapes();
8365
+ this.validRot = this.checkIsValid() ? this.rot : this.validRot;
8366
+ console.log("rotateTo", this.rot, this.validRot);
8367
+ }
8368
+ rotateEnd() {
8369
+ this.mDistances.clear();
8370
+ if (this.isValid)
8371
+ return;
8372
+ this.rot = this.validRot;
8340
8373
  this.calcShapes();
8341
8374
  }
8342
8375
  restrictPosition(x, y) {
@@ -8379,7 +8412,7 @@ class InteractiveItemComponent {
8379
8412
  return new Point(x, y);
8380
8413
  }
8381
8414
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.19", ngImport: i0, type: InteractiveItemComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
8382
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.2.19", type: InteractiveItemComponent, isStandalone: false, selector: "__interactive-item__", inputs: { x: "x", y: "y", position: "position", direction: "direction", disabled: "disabled" }, usesOnChanges: true, ngImport: i0, template: "", isInline: true }); }
8415
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.2.19", type: InteractiveItemComponent, isStandalone: false, selector: "__interactive-item__", inputs: { x: "x", y: "y", position: "position", rotation: "rotation", direction: "direction", disabled: "disabled" }, usesOnChanges: true, ngImport: i0, template: "", isInline: true }); }
8383
8416
  }
8384
8417
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.19", ngImport: i0, type: InteractiveItemComponent, decorators: [{
8385
8418
  type: Component,
@@ -8394,6 +8427,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.19", ngImpo
8394
8427
  type: Input
8395
8428
  }], position: [{
8396
8429
  type: Input
8430
+ }], rotation: [{
8431
+ type: Input
8397
8432
  }], direction: [{
8398
8433
  type: Input
8399
8434
  }], disabled: [{
@@ -8847,20 +8882,18 @@ class InteractiveRectComponent extends InteractiveItemComponent {
8847
8882
  super();
8848
8883
  this.width = input(10);
8849
8884
  this.height = input(10);
8850
- this.rotation = input(0);
8851
8885
  effect(() => {
8852
- this.mFrame = new Rect(0, 0, this.width(), this.height(), this.rotation());
8886
+ this.mFrame = new Rect(0, 0, this.width(), this.height());
8853
8887
  });
8854
8888
  }
8855
8889
  calcShape(x, y) {
8856
8890
  const ratio = this.canvas.ratio;
8857
8891
  const width = untracked(() => this.width());
8858
8892
  const height = untracked(() => this.height());
8859
- const rotation = untracked(() => this.rotation());
8860
- return new Rect(x, y, width * ratio, height * ratio, rotation);
8893
+ return new Rect(x, y, width * ratio, height * ratio, this.rotation);
8861
8894
  }
8862
8895
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.19", ngImport: i0, type: InteractiveRectComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
8863
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "19.2.19", type: InteractiveRectComponent, isStandalone: false, selector: "interactive-rect", inputs: { width: { classPropertyName: "width", publicName: "width", isSignal: true, isRequired: false, transformFunction: null }, height: { classPropertyName: "height", publicName: "height", isSignal: true, isRequired: false, transformFunction: null }, rotation: { classPropertyName: "rotation", publicName: "rotation", isSignal: true, isRequired: false, transformFunction: null } }, providers: [
8896
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "19.2.19", type: InteractiveRectComponent, isStandalone: false, selector: "interactive-rect", inputs: { width: { classPropertyName: "width", publicName: "width", isSignal: true, isRequired: false, transformFunction: null }, height: { classPropertyName: "height", publicName: "height", isSignal: true, isRequired: false, transformFunction: null } }, providers: [
8864
8897
  { provide: InteractiveItemComponent, useExisting: InteractiveRectComponent },
8865
8898
  ], usesInheritance: true, ngImport: i0, template: "", isInline: true }); }
8866
8899
  }
@@ -9671,5 +9704,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.19", ngImpo
9671
9704
  * Generated bundle index. Do not edit.
9672
9705
  */
9673
9706
 
9674
- export { API_SERVICE, APP_BASE_URL, AUTH_SERVICE, AclService, AjaxRequestHandler, ApiService, ArrayUtils, AsyncMethodBase, AsyncMethodDirective, AsyncMethodTargetDirective, AuthGuard, BASE_CONFIG, BUTTON_TYPE, BackgroundDirective, BaseDialogService, BaseHttpClient, BaseHttpService, BaseToasterService, BtnComponent, BtnDefaultComponent, CONFIG_SERVICE, CacheService, CanvasColor, CanvasUtils, ChipsComponent, ChunkPipe, Circle, CloseBtnComponent, ComponentLoaderDirective, ComponentLoaderService, ConfigService, DIALOG_SERVICE, DateUtils, DragDropEventPlugin, DropListComponent, DropdownBoxComponent, DropdownContentDirective, DropdownDirective, DropdownToggleDirective, DynamicTableComponent, DynamicTableTemplateDirective, EPSILON, ERROR_HANDLER, EXPRESS_REQUEST, EntriesPipe, ErrorHandlerService, EventsService, ExclusionsRenderer, ExtraItemPropertiesPipe, FactoryDependencies, FakeModuleComponent, FileSystemEntry, FileUtils, FilterPipe, FindPipe, ForbiddenZone, FormatNumberPipe, FormatterService, GenericValue, GetOffsetPipe, GetTypePipe, GetValuePipe, GlobalTemplateDirective, GlobalTemplatePipe, GlobalTemplateService, GroupByPipe, ICON_MAP, ICON_SERVICE, ICON_TYPE, IConfiguration, IconComponent, IconDefaultComponent, IconDirective, IconService, IncludesPipe, Initializer, InteractiveCanvasComponent, InteractiveCircleComponent, InteractiveItemComponent, InteractiveRectComponent, IsTypePipe, JoinPipe, KeysPipe, LANGUAGE_SERVICE, LanguageService, LoaderUtils, LocalHttpService, MapPipe, MathUtils, MaxPipe, MinPipe, NgxTemplateOutletDirective, NgxUtilsModule, OPTIONS_TOKEN, ObjectType, ObjectUtils, ObservableUtils, OpenApiService, Oval, PROMISE_SERVICE, PaginationDirective, PaginationItemContext, PaginationItemDirective, PaginationMenuComponent, Point, PopPipe, PromiseService, RESIZE_DELAY, RESIZE_STRATEGY, ROOT_ELEMENT, Rect, ReducePipe, ReflectUtils, RemapPipe, ReplacePipe, RequestBag, ResizeEventPlugin, ResourceIfContext, ResourceIfDirective, ReversePipe, RoundPipe, RulerCanvasRenderer, SCHEMA_SELECTOR, SCRIPT_PARAMS, STATIC_SCHEMAS, SafeHtmlPipe, ScrollEventPlugin, SetUtils, ShapeGroup, ShiftPipe, SocketClient, SocketService, SplitPipe, StateService, StaticAuthService, StaticLanguageService, StickyClassDirective, StickyDirective, StorageMode, StorageService, StringUtils, SyncAsyncPipe, TOASTER_SERVICE, TabsComponent, TabsItemDirective, TabsTemplateDirective, TimerUtils, TranslatePipe, TranslatedUrlSerializer, UniqueUtils, UniversalService, UnorderedListComponent, UnorderedListItemDirective, UnorderedListTemplateDirective, UploadComponent, ValuedPromise, ValuesPipe, WysiwygComponent, addPts, cachedFactory, cancelablePromise, checkTransitions, clamp, computedPrevious, createTypedProvider, cssStyles, cssVariables, distance, distanceSq, dividePts, dotProduct, ensurePoint, getComponentDef, getCssVariables, getRoot, gjkDistance, gjkIntersection, impatientPromise, injectOptions, isBrowser, isPoint, lengthOfPt, lerpPts, md5, multiplyPts, negatePt, normalizePt, normalizeRange, overflow, parseSelector, perpendicular, provideEntryComponents, provideOptions, provideWithOptions, rotateDeg, rotateRad, selectorMatchesList, stringify, subPts, svgToDataUri, switchClass, toDegrees, toRadians, tripleProduct };
9707
+ export { API_SERVICE, APP_BASE_URL, AUTH_SERVICE, AclService, AjaxRequestHandler, ApiService, ArrayUtils, AsyncMethodBase, AsyncMethodDirective, AsyncMethodTargetDirective, AuthGuard, BASE_CONFIG, BUTTON_TYPE, BackgroundDirective, BaseDialogService, BaseHttpClient, BaseHttpService, BaseToasterService, BtnComponent, BtnDefaultComponent, CONFIG_SERVICE, CacheService, CanvasColor, CanvasUtils, ChipsComponent, ChunkPipe, Circle, CloseBtnComponent, ComponentLoaderDirective, ComponentLoaderService, ConfigService, DIALOG_SERVICE, DateUtils, DragDropEventPlugin, DropListComponent, DropdownBoxComponent, DropdownContentDirective, DropdownDirective, DropdownToggleDirective, DynamicTableComponent, DynamicTableTemplateDirective, EPSILON, ERROR_HANDLER, EXPRESS_REQUEST, EntriesPipe, ErrorHandlerService, EventsService, ExclusionsRenderer, ExtraItemPropertiesPipe, FactoryDependencies, FakeModuleComponent, FileSystemEntry, FileUtils, FilterPipe, FindPipe, ForbiddenZone, FormatNumberPipe, FormatterService, GenericValue, GetOffsetPipe, GetTypePipe, GetValuePipe, GlobalTemplateDirective, GlobalTemplatePipe, GlobalTemplateService, GroupByPipe, ICON_MAP, ICON_SERVICE, ICON_TYPE, IConfiguration, IconComponent, IconDefaultComponent, IconDirective, IconService, IncludesPipe, Initializer, InteractiveCanvasComponent, InteractiveCircleComponent, InteractiveItemComponent, InteractiveRectComponent, IsTypePipe, JoinPipe, KeysPipe, LANGUAGE_SERVICE, LanguageService, LoaderUtils, LocalHttpService, MapPipe, MathUtils, MaxPipe, MinPipe, NgxTemplateOutletDirective, NgxUtilsModule, OPTIONS_TOKEN, ObjectType, ObjectUtils, ObservableUtils, OpenApiService, Oval, PROMISE_SERVICE, PaginationDirective, PaginationItemContext, PaginationItemDirective, PaginationMenuComponent, Point, PopPipe, PromiseService, RESIZE_DELAY, RESIZE_STRATEGY, ROOT_ELEMENT, Rect, ReducePipe, ReflectUtils, RemapPipe, ReplacePipe, RequestBag, ResizeEventPlugin, ResourceIfContext, ResourceIfDirective, ReversePipe, RoundPipe, RulerCanvasRenderer, SCHEMA_SELECTOR, SCRIPT_PARAMS, STATIC_SCHEMAS, SafeHtmlPipe, ScrollEventPlugin, SetUtils, ShapeGroup, ShiftPipe, SocketClient, SocketService, SplitPipe, StateService, StaticAuthService, StaticLanguageService, StickyClassDirective, StickyDirective, StorageMode, StorageService, StringUtils, SyncAsyncPipe, TOASTER_SERVICE, TabsComponent, TabsItemDirective, TabsTemplateDirective, TimerUtils, TranslatePipe, TranslatedUrlSerializer, UniqueUtils, UniversalService, UnorderedListComponent, UnorderedListItemDirective, UnorderedListTemplateDirective, UploadComponent, ValuedPromise, ValuesPipe, WysiwygComponent, addPts, cachedFactory, cancelablePromise, checkTransitions, clamp, computedPrevious, createTypedProvider, cssStyles, cssVariables, distance, distanceSq, dividePts, dotProduct, ensurePoint, eqPts, getComponentDef, getCssVariables, getRoot, gjkDistance, gjkIntersection, impatientPromise, injectOptions, isBrowser, isEqual, isPoint, isZero, lengthOfPt, lerpPts, md5, multiplyPts, negatePt, normalizePt, normalizeRange, overflow, parseSelector, perpendicular, provideEntryComponents, provideOptions, provideWithOptions, rotateDeg, rotateRad, selectorMatchesList, stringify, subPts, svgToDataUri, switchClass, toDegrees, toRadians, tripleProduct };
9675
9708
  //# sourceMappingURL=stemy-ngx-utils.mjs.map