@theseam/ui-common 2.0.1 → 2.1.0

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@theseam/ui-common",
3
- "version": "2.0.1",
3
+ "version": "2.1.0",
4
4
  "peerDependencies": {
5
5
  "@angular/cdk": "^20.2.3",
6
6
  "@angular/common": "^20.3.0",
@@ -8,6 +8,7 @@
8
8
  "@angular/forms": "^20.3.0",
9
9
  "@angular/animations": "^20.3.0",
10
10
  "@angular/router": "^20.3.0",
11
+ "@angular/google-maps": "^20.2.3",
11
12
  "rxjs": "~7.8.0",
12
13
  "@fortawesome/angular-fontawesome": "^0.13.0",
13
14
  "@fortawesome/fontawesome-svg-core": "^1.2.35",
@@ -43,6 +44,8 @@
43
44
  "@turf/kinks": "^7.2.0",
44
45
  "shpjs": "^6.2.0",
45
46
  "@types/geojson": "^7946.0.8",
47
+ "terra-draw": "^1.31.2",
48
+ "terra-draw-google-maps-adapter": "^1.6.1",
46
49
  "tslib": "^2.3.0"
47
50
  },
48
51
  "repository": {
@@ -1,41 +1,46 @@
1
1
  import * as i0 from '@angular/core';
2
- import { EventEmitter, OnDestroy, AfterViewInit, QueryList } from '@angular/core';
2
+ import { InjectionToken, EventEmitter, QueryList } from '@angular/core';
3
3
  import { BooleanInput } from '@angular/cdk/coercion';
4
4
  import { ControlValueAccessor } from '@angular/forms';
5
- import { Observable } from 'rxjs';
6
5
 
7
6
  declare class ToggleGroupOptionDirective {
8
- private readonly _cdr;
7
+ private readonly _group;
9
8
  seamToggleGroupOption: string | undefined | null;
10
- get selected(): boolean;
11
- set selected(value: boolean);
12
- private _selected;
13
- /** Internal use only for now. */
14
- _canUnselect: boolean;
15
- selectionChange: EventEmitter<boolean>;
16
9
  get _checkioSelectedClass(): boolean;
17
10
  get value(): string | undefined | null;
18
11
  static ɵfac: i0.ɵɵFactoryDeclaration<ToggleGroupOptionDirective, never>;
19
- static ɵdir: i0.ɵɵDirectiveDeclaration<ToggleGroupOptionDirective, "[seamToggleGroupOption]", ["seamToggleGroupOption"], { "seamToggleGroupOption": { "alias": "seamToggleGroupOption"; "required": false; }; "selected": { "alias": "selected"; "required": false; }; }, { "selectionChange": "selectionChange"; }, never, never, true, never>;
12
+ static ɵdir: i0.ɵɵDirectiveDeclaration<ToggleGroupOptionDirective, "[seamToggleGroupOption]", ["seamToggleGroupOption"], { "seamToggleGroupOption": { "alias": "seamToggleGroupOption"; "required": false; }; }, {}, never, never, true, never>;
20
13
  }
21
14
 
15
+ /**
16
+ * The part of the toggle group that an option needs in order to resolve its own
17
+ * selected state.
18
+ *
19
+ * This exists as a separate token so `ToggleGroupOptionDirective` can reach its
20
+ * parent group without importing `ToggleGroupDirective`, which would create a
21
+ * circular import between the two directives.
22
+ */
23
+ interface TheSeamToggleGroupParent {
24
+ isSelected(value: string | undefined | null): boolean;
25
+ }
26
+ declare const THESEAM_TOGGLE_GROUP_PARENT: InjectionToken<TheSeamToggleGroupParent>;
27
+
22
28
  declare const TOGGLE_GROUP_VALUE_ACCESSOR: any;
23
- declare class ToggleGroupDirective implements OnDestroy, AfterViewInit, ControlValueAccessor {
29
+ declare class ToggleGroupDirective implements ControlValueAccessor {
24
30
  static ngAcceptInputType_disabled: BooleanInput;
25
31
  static ngAcceptInputType_multiple: BooleanInput;
26
32
  static ngAcceptInputType_selectionToggleable: BooleanInput;
27
- private readonly _ngUnsubscribe;
28
33
  val: string | string[] | undefined | null;
29
34
  disabled: boolean;
30
35
  multiple: boolean;
31
36
  selectionToggleable: boolean;
32
37
  readonly change: EventEmitter<string | string[] | null | undefined>;
33
38
  optionDirectives?: QueryList<ToggleGroupOptionDirective>;
34
- options?: Observable<ToggleGroupOptionDirective[]>;
35
39
  onChange: any;
36
40
  onTouched: any;
37
- ngOnDestroy(): void;
38
- ngAfterViewInit(): void;
41
+ private _selectedSet;
42
+ private _selectedSetSource;
43
+ private _selectedSetMultiple;
39
44
  get value(): string | string[] | undefined | null;
40
45
  set value(value: string | string[] | undefined | null);
41
46
  writeValue(value: any): void;
@@ -43,11 +48,29 @@ declare class ToggleGroupDirective implements OnDestroy, AfterViewInit, ControlV
43
48
  registerOnTouched(fn: any): void;
44
49
  setDisabledState(isDisabled: boolean): void;
45
50
  isSelected(value: string | undefined | null): boolean;
51
+ /**
52
+ * The current selection as a set, rebuilt only when the value (or `multiple`)
53
+ * changes.
54
+ *
55
+ * `isSelected` is called from templates and from every option's host binding,
56
+ * so it runs several times per option per change detection pass. Hashing the
57
+ * selection once keeps those lookups O(1) instead of scanning the value array
58
+ * on every call.
59
+ *
60
+ * Invalidation is keyed on the `val` reference rather than done in the `value`
61
+ * setter, because `val` is also written directly by the `[value]` input, which
62
+ * does not go through the setter.
63
+ */
64
+ private _selected;
65
+ private _buildSelectedSet;
66
+ /**
67
+ * Toggles an option's selected state by value.
68
+ */
69
+ toggleOptionSelect(value: string | undefined | null): void;
70
+ private _selectedCount;
46
71
  unselectValue(value: string | undefined | null): void;
47
72
  selectValue(value: string | undefined | null): void;
48
73
  getOptionDirectiveByValue(value: string): ToggleGroupOptionDirective | null | undefined;
49
- private _updateDirectiveStates;
50
- private _updateDirectiveState;
51
74
  static ɵfac: i0.ɵɵFactoryDeclaration<ToggleGroupDirective, never>;
52
75
  static ɵdir: i0.ɵɵDirectiveDeclaration<ToggleGroupDirective, "[seamToggleGroup]", ["seamToggleGroup"], { "val": { "alias": "value"; "required": false; }; "disabled": { "alias": "disabled"; "required": false; }; "multiple": { "alias": "multiple"; "required": false; }; "selectionToggleable": { "alias": "selectionToggleable"; "required": false; }; }, { "change": "change"; }, ["optionDirectives"], never, true, never>;
53
76
  }
@@ -58,4 +81,5 @@ declare class TheSeamToggleGroupModule {
58
81
  static ɵinj: i0.ɵɵInjectorDeclaration<TheSeamToggleGroupModule>;
59
82
  }
60
83
 
61
- export { TOGGLE_GROUP_VALUE_ACCESSOR, TheSeamToggleGroupModule, ToggleGroupDirective, ToggleGroupOptionDirective };
84
+ export { THESEAM_TOGGLE_GROUP_PARENT, TOGGLE_GROUP_VALUE_ACCESSOR, TheSeamToggleGroupModule, ToggleGroupDirective, ToggleGroupOptionDirective };
85
+ export type { TheSeamToggleGroupParent };
package/utils/index.d.ts CHANGED
@@ -3,7 +3,7 @@ import { ElementRef, QueryList } from '@angular/core';
3
3
  import { AbstractControl, ValidatorFn } from '@angular/forms';
4
4
  import { Observable } from 'rxjs';
5
5
  import { ActivatedRoute, Data, ActivatedRouteSnapshot } from '@angular/router';
6
- import { FeatureCollection, GeoJSON, Feature, GeoJsonProperties, Geometry, Polygon, MultiPolygon } from 'geojson';
6
+ import { FeatureCollection, GeoJSON, Feature, GeoJsonProperties, Geometry, Polygon, MultiPolygon, Position } from 'geojson';
7
7
  import { AreaUnits } from '@turf/helpers';
8
8
 
9
9
  /**
@@ -234,14 +234,46 @@ declare function readGeoFile(fileOrBuffer: File | ArrayBuffer): Promise<FeatureC
234
234
  declare function splitMultiPolygons(featureCollection: FeatureCollection): void;
235
235
 
236
236
  /**
237
- * Close all polygons in the GeoJSON.
237
+ * Close all polygons in the GeoJSON so the first and last position of every
238
+ * ring are identical.
238
239
  *
239
- * Google Maps requires that polygons be closed, but not all libraries have that
240
- * requirement. This may add redundent points to the GeoJSON, but it will ensure
241
- * that the GeoJSON is valid for Google Maps.
240
+ * Google Maps requires closed polygon rings, but not all libraries produce
241
+ * them. This is idempotent: rings that are already closed are left unchanged.
242
242
  */
243
243
  declare function closePolygons(geoJson: FeatureCollection | Feature | Polygon | MultiPolygon): void;
244
244
 
245
+ /**
246
+ * Checks if a single polygon ring's coordinate count violates the given
247
+ * min/max point bounds. `max` is only applied when it is greater than `min`.
248
+ */
249
+ declare function polygonViolatesMinMax(coordinateLength: number, min: number, max?: number | undefined): boolean;
250
+
251
+ /**
252
+ * Whether a polygon's outer ring has at least `min` distinct vertices.
253
+ * Ring closure (a repeated first/last point) does not count toward the total,
254
+ * so this behaves the same for closed and unclosed rings.
255
+ */
256
+ declare function polygonHasMinDistinctVertices(polygon: Polygon, min?: number): boolean;
257
+
258
+ /**
259
+ * Whether `outer` fully contains `inner`, using turf's boolean-contains on the
260
+ * GeoJSON geometries directly (no Google Maps dependency).
261
+ */
262
+ declare function polygonContains(outer: Polygon, inner: Polygon): boolean;
263
+
264
+ /**
265
+ * Whether a ring is wound clockwise, via the shoelace signed-area sign.
266
+ * Sum of (x2 - x1) * (y2 + y1) is positive for clockwise rings in standard
267
+ * (x = lng, y = lat) orientation.
268
+ */
269
+ declare function ringIsClockwise(ring: Position[]): boolean;
270
+ /**
271
+ * Append the outer ring of `hole` to `exterior` as an interior ring (a
272
+ * cutout), wound opposite the exterior ring so it renders as a hole. Returns a
273
+ * new Polygon; inputs are not mutated.
274
+ */
275
+ declare function addHoleToPolygon(exterior: Polygon, hole: Polygon): Polygon;
276
+
245
277
  /**
246
278
  Moves the item to the new position in the input array. Useful for huge arrays
247
279
  where absolute performance is needed.
@@ -452,5 +484,5 @@ interface SanitizeFilenameOptions {
452
484
  }
453
485
  declare function sanitizeFilename(filename: string, options?: SanitizeFilenameOptions): string;
454
486
 
455
- export { IS_FEATURE_COLLECTION_VALIDATOR_NAME, IS_ONLY_GEOMETRY_TYPES_VALIDATOR_NAME, MIN_MAX_POINTS_VALIDATOR_NAME, NO_EMPTY_FEATURE_COLLECTION_VALIDATOR_NAME, NO_INNER_RINGS_VALIDATOR_NAME, NO_KINKS_VALIDATOR_NAME, PollingTickerOptions, Refreshable, activatedRoutesWithDataProperty, arrayMoveImmutable, arrayMoveMutable, calcPercentage, closePolygons, coerceFeatureCollection, createPadding, deleteProperties, deleteProperty, fileBufferToBlob, fileBufferToObjectUrl, fileDataFromBuffer, fractionalDigitsCount, geoJsonToArea, getAttribute, getClosestWidgetCdkDrag, getControlName, getControlPath, hasAttribute, hasProperty, hasRequiredControl, isAbsoluteUrl, isEmptyInputValue, isEmptyUrlRoute, isFeatureCollectionValidator, isNullOrUndefined, isNullOrUndefinedOrEmpty, isNumeric, isOnlyGeometryTypes, isOnlyGeometryTypesValidator, leafChildRoute, loadStyle, loadStyleSheet, mapEach, mergePolygons, minMaxPointsValidator, noEmptyFeatureCollectionValidator, noInnerRingsValidator, noKinksValidator, notNullOrUndefined, notNullOrUndefinedOrEmpty, observeControlIsDifferent, observeControlStatus, observeControlValid, observeControlValue, observeControlValueChange, observeQueryList, openBlob, padEnd, padStart, phoneNumberMask, pollingTicker, readFileAsDataUrlAsync, readFileAsync, readGeoFile, routeSnapshotPathFull, routeSnapshotPathRelative, sanitizeFilename, splitMultiPolygons, stripOuter, subscriberCount, tapFirst, toggleAttribute, trimRepeated, waitOnConditionAsync, waitOnNonPendingStatus, willHaveDataProp, withoutProperties, withoutProperty, wrapIntoObservable };
487
+ export { IS_FEATURE_COLLECTION_VALIDATOR_NAME, IS_ONLY_GEOMETRY_TYPES_VALIDATOR_NAME, MIN_MAX_POINTS_VALIDATOR_NAME, NO_EMPTY_FEATURE_COLLECTION_VALIDATOR_NAME, NO_INNER_RINGS_VALIDATOR_NAME, NO_KINKS_VALIDATOR_NAME, PollingTickerOptions, Refreshable, activatedRoutesWithDataProperty, addHoleToPolygon, arrayMoveImmutable, arrayMoveMutable, calcPercentage, closePolygons, coerceFeatureCollection, createPadding, deleteProperties, deleteProperty, fileBufferToBlob, fileBufferToObjectUrl, fileDataFromBuffer, fractionalDigitsCount, geoJsonToArea, getAttribute, getClosestWidgetCdkDrag, getControlName, getControlPath, hasAttribute, hasProperty, hasRequiredControl, isAbsoluteUrl, isEmptyInputValue, isEmptyUrlRoute, isFeatureCollectionValidator, isNullOrUndefined, isNullOrUndefinedOrEmpty, isNumeric, isOnlyGeometryTypes, isOnlyGeometryTypesValidator, leafChildRoute, loadStyle, loadStyleSheet, mapEach, mergePolygons, minMaxPointsValidator, noEmptyFeatureCollectionValidator, noInnerRingsValidator, noKinksValidator, notNullOrUndefined, notNullOrUndefinedOrEmpty, observeControlIsDifferent, observeControlStatus, observeControlValid, observeControlValue, observeControlValueChange, observeQueryList, openBlob, padEnd, padStart, phoneNumberMask, pollingTicker, polygonContains, polygonHasMinDistinctVertices, polygonViolatesMinMax, readFileAsDataUrlAsync, readFileAsync, readGeoFile, ringIsClockwise, routeSnapshotPathFull, routeSnapshotPathRelative, sanitizeFilename, splitMultiPolygons, stripOuter, subscriberCount, tapFirst, toggleAttribute, trimRepeated, waitOnConditionAsync, waitOnNonPendingStatus, willHaveDataProp, withoutProperties, withoutProperty, wrapIntoObservable };
456
488
  export type { IActivatedRouteWithData, IFileData, PollingActionFn, RefreshableOptions, SanitizeFilenameOptions, SubscriberCountChangedFn };