@theseam/ui-common 1.0.2-beta.23 → 1.0.2-beta.29

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.
@@ -3,7 +3,7 @@ import { DocumentNode, ValueNode, Token } from 'graphql/language';
3
3
  import { DocumentNode as DocumentNode$1, ValueNode as ValueNode$1, OperationDefinitionNode, VariableDefinitionNode, VariableNode, ArgumentNode, FieldNode, Token as Token$1, GraphQLFormattedError } from 'graphql';
4
4
  import { Operation } from '@apollo/client';
5
5
  import { Observable } from 'rxjs';
6
- import { DatatableComponent, SortItem, TheSeamPageInfo, ColumnsDataFilterState, TheSeamColumnsDataFilterDateSearchFormState, TheSeamColumnsDataFilterDateSearchOptions, TheSeamColumnsDataFilterNumericSearchFormState, TheSeamColumnsDataFilterTextSearchFormState, SortEvent } from '@theseam/ui-common/datatable';
6
+ import { DatatableComponent, TheSeamDatatableColumn, SortItem, TheSeamPageInfo, ColumnsDataFilterState, TheSeamColumnsDataFilterDateSearchFormState, TheSeamColumnsDataFilterDateSearchOptions, TheSeamColumnsDataFilterNumericSearchFormState, TheSeamColumnsDataFilterTextSearchFormState, SortEvent } from '@theseam/ui-common/datatable';
7
7
  import * as apollo_angular from 'apollo-angular';
8
8
  import { QueryRef, WatchQueryOptions, Apollo } from 'apollo-angular';
9
9
  import { DataFilterState } from '@theseam/ui-common/data-filters';
@@ -124,7 +124,7 @@ declare class GQLVariable {
124
124
  constructor(name: string, type: string);
125
125
  }
126
126
 
127
- type GqlDatatableAccessor = Pick<DatatableComponent, 'page' | 'sort' | 'sorts' | 'filterStates' | 'pageInfo' | 'externalSorting'> & {
127
+ type GqlDatatableAccessor = Pick<DatatableComponent, 'page' | 'sort' | 'sorts' | 'filterStates' | 'pageInfo' | 'externalSorting' | 'columns$'> & {
128
128
  ngxDatatable: {
129
129
  offset: number;
130
130
  pageSize: number;
@@ -273,6 +273,7 @@ declare class DatatableGraphQLQueryRef<TData, TVariables extends DatatableGraphQ
273
273
 
274
274
  type MapperContext<TExtraVariables = EmptyObject> = {
275
275
  extraVariables: TExtraVariables;
276
+ columns?: TheSeamDatatableColumn[];
276
277
  } & {
277
278
  [name: string]: any;
278
279
  };
@@ -361,37 +362,57 @@ type SortsMapperFieldEntry = string | null | ((prop: string, context: MapperCont
361
362
  type SortsMapperFieldMap<TRow extends Record<string, any>> = {
362
363
  [K in keyof TRow & string]?: SortsMapperFieldEntry;
363
364
  };
365
+ /**
366
+ * Options for {@link createSortsMapper}.
367
+ */
368
+ interface CreateSortsMapperOptions {
369
+ /**
370
+ * When `true` (the default), sort items whose `prop` is not listed in
371
+ * the field map are automatically mapped using the prop value as the
372
+ * GQL field name, provided a column with that prop exists in the
373
+ * current datatable and has `sortable` not explicitly set to `false`.
374
+ *
375
+ * This eliminates boilerplate for the common case where column props
376
+ * match GQL field names. The field map becomes an override/exclusion
377
+ * map: list only columns that need a different GQL name or `null` to
378
+ * suppress sorting.
379
+ *
380
+ * Set to `false` to require every sortable column to be explicitly
381
+ * listed in the field map (with a dev-mode error for unmapped props).
382
+ */
383
+ autoMap?: boolean;
384
+ }
364
385
  /**
365
386
  * Creates a {@link SortsMapper} from a declarative field-name map.
366
387
  *
367
- * Each key must correspond to a datatable column `prop` value. The value
368
- * controls how that column's sort is translated to a GQL sort object:
388
+ * By default, `autoMap` is enabled: columns not listed in the field map
389
+ * are automatically mapped using their `prop` as the GQL field name,
390
+ * provided the column exists in the datatable and has `sortable` not
391
+ * explicitly set to `false`. This guards against stale sort preferences
392
+ * for removed columns.
393
+ *
394
+ * Each key in `fieldMap` must correspond to a datatable column `prop`
395
+ * value. The value controls how that column's sort is translated:
369
396
  *
370
397
  * - `string` – emits `{ [gqlField]: 'ASC' | 'DESC' }`
371
398
  * - `null` – column is not sortable; the sort item is dropped
372
399
  * - `function` – called with `(prop, context)` and may return a field
373
400
  * name or `null` to drop the item dynamically
374
401
  *
375
- * In dev mode an error is thrown when a sort item's `prop` is not present
376
- * in the map. In production the item is silently dropped.
377
- *
378
402
  * @example
379
- * // Simple static mapping
403
+ * // Auto-map all columns, override one
380
404
  * const mapSorts = createSortsMapper<MyRow>({
381
- * id: 'id',
382
- * name: 'name',
405
+ * computedField: 'gql_computed_field',
383
406
  * })
384
407
  *
385
408
  * @example
386
- * // Dynamic mapping with context access
409
+ * // Opt out of auto-mapping (explicit field map required)
387
410
  * const mapSorts = createSortsMapper<MyRow>({
388
411
  * id: 'id',
389
412
  * name: 'name',
390
- * computed: (prop, context) =>
391
- * context.extraVariables.useAlt ? 'altField' : prop,
392
- * })
413
+ * }, { autoMap: false })
393
414
  */
394
- declare function createSortsMapper<TRow extends Record<string, any>>(fieldMap: SortsMapperFieldMap<TRow>): SortsMapper;
415
+ declare function createSortsMapper<TRow extends Record<string, any>>(fieldMap: SortsMapperFieldMap<TRow>, options?: CreateSortsMapperOptions): SortsMapper;
395
416
 
396
417
  /**
397
418
  * NOTE: Any of ApolloClient's WatchQueryOptions properties can be set, but I
@@ -505,6 +526,8 @@ interface FilteredResults<T> {
505
526
  declare function filteredResults<T>(items: T[], args: any): FilteredResults<T>;
506
527
 
507
528
  declare class MockDatatable implements GqlDatatableAccessor {
529
+ private readonly _columnsSubject;
530
+ readonly columns$: Observable<TheSeamDatatableColumn[]>;
508
531
  private readonly _filterStatesSubject;
509
532
  private _sorts;
510
533
  private _rows;
@@ -527,6 +550,7 @@ declare class MockDatatable implements GqlDatatableAccessor {
527
550
  limit?: number;
528
551
  count: number;
529
552
  };
553
+ setColumns(v: TheSeamDatatableColumn[]): void;
530
554
  setSorts(v: SortItem[]): void;
531
555
  setFilterStates(v: DataFilterState[]): void;
532
556
  getNumPages(): number;
@@ -592,4 +616,4 @@ interface SimpleGqlTestVariables extends SimpleGqlTestExtraVariables {
592
616
  }
593
617
 
594
618
  export { DATATABLE_GRAPHQL_SERVICE_CONFIG, DEFAULT_PAGE_SIZE, DEFAULT_TO_REMOVE_ON_UNDEFINED, DatatableGraphQLQueryRef, DatatableGraphqlService, GQLDirection, GQLVariable, HINT_NAMES_CAPTURE_REGEX, HINT_PREFIX_REGEX, HintsKind, MAX_ERROR_RECOVERY_ATTEMPTS, MockDatatable, SIMPLE_GQL_TEST_QUERY, SIMPLE_GQL_TEST_SEARCH_QUERY, baseSchemaFragment, checkRecordsHaveValue, containsVariable, createHintsToken, createMockApolloTestingProvider, createSimpleGqlTestRecord, createSimpleGqlTestRoot, createSortsMapper, filterWhere, filteredResults, getHintsToken, getPageInfo, getTokenAppliesTo, gqlVar, hintNamesFromHintToken, hintsTokensContainingHint, inlineVariable, inlineVariableHintDef, inlineVariableTransformer, isCommentToken, isHintToken, isInlineComment, logQueryLink, mapFilterStates, mapSearchDateColumnsDataFilterStateToGql, mapSearchNumericColumnsDataFilterStateToGql, mapSearchTextColumnsDataFilterStateToGql, mockGraphQLLink, observeRowsWithGqlInputsHandling, parseAst, parseComments, parseHints, queryProcessingLink, removeNotDefinedHintDef, removeNotDefinedTransformer, removeVariable, removeVariableDefinition, removeVariableDefinitionsNotDefined, skipAndTake, sortItems, toGQL };
595
- export type { DatatableGraphQLDataMapper, DatatableGraphQLDataMapperResult, DatatableGraphQLErrorHandler, DatatableGraphQLVariables, DatatableGraphqlServiceConfig, DatatableQueryOptions, EmptyObject, FilterStateMapper, FilterStateMapperFilter, FilterStateMapperResult, FilterStateMapperVariables, FilterStateMappers, FilteredResults, FilteredResultsPageInfo, GqlDatatableAccessor, HintDefinition, HintTransformOperation, HintTransformer, HintsToken, LogQueryLinkOptions, MapperContext, MockApolloTestingProviderOptions, MockGraphQLLinkOptions, QueryProcessingConfig, QueryProcessingVariablesConfig, SimpleGqlTestExtraVariables, SimpleGqlTestRecord, SimpleGqlTestVariables, SortClause, SortsMapper, SortsMapperFieldEntry, SortsMapperFieldMap, SortsMapperResult, TypedFilterInput, TypedFilterStateMapperResult, WhereArg };
619
+ export type { CreateSortsMapperOptions, DatatableGraphQLDataMapper, DatatableGraphQLDataMapperResult, DatatableGraphQLErrorHandler, DatatableGraphQLVariables, DatatableGraphqlServiceConfig, DatatableQueryOptions, EmptyObject, FilterStateMapper, FilterStateMapperFilter, FilterStateMapperResult, FilterStateMapperVariables, FilterStateMappers, FilteredResults, FilteredResultsPageInfo, GqlDatatableAccessor, HintDefinition, HintTransformOperation, HintTransformer, HintsToken, LogQueryLinkOptions, MapperContext, MockApolloTestingProviderOptions, MockGraphQLLinkOptions, QueryProcessingConfig, QueryProcessingVariablesConfig, SimpleGqlTestExtraVariables, SimpleGqlTestRecord, SimpleGqlTestVariables, SortClause, SortsMapper, SortsMapperFieldEntry, SortsMapperFieldMap, SortsMapperResult, TypedFilterInput, TypedFilterStateMapperResult, WhereArg };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@theseam/ui-common",
3
- "version": "1.0.2-beta.23",
3
+ "version": "1.0.2-beta.29",
4
4
  "peerDependencies": {
5
5
  "@angular/cdk": "^20.2.3",
6
6
  "@angular/common": "^20.3.0",
@@ -16,7 +16,7 @@
16
16
  "@fortawesome/free-solid-svg-icons": "^5.15.3"
17
17
  },
18
18
  "dependencies": {
19
- "@marklb/file-type": "~10.6.5",
19
+ "file-type": "~22.0.0",
20
20
  "@marklb/ngx-datatable": "21.0.0-alpha.2",
21
21
  "ngx-loading": "^17.0.0",
22
22
  "@ng-select/ng-select": "^20.2.2",
@@ -43,7 +43,7 @@
43
43
  "@turf/boolean-contains": "^7.2.0",
44
44
  "@turf/helpers": "^7.2.0",
45
45
  "@turf/kinks": "^7.2.0",
46
- "shpjs": "^4.0.2",
46
+ "shpjs": "^6.2.0",
47
47
  "@types/geojson": "^7946.0.8",
48
48
  "tslib": "^2.3.0"
49
49
  },
package/utils/index.d.ts CHANGED
@@ -5,7 +5,6 @@ import { Observable } from 'rxjs';
5
5
  import { ActivatedRoute, Data, ActivatedRouteSnapshot } from '@angular/router';
6
6
  import { FeatureCollection, GeoJSON, Feature, GeoJsonProperties, Geometry, Polygon, MultiPolygon } from 'geojson';
7
7
  import { AreaUnits } from '@turf/helpers';
8
- import { Buffer } from 'buffer/';
9
8
 
10
9
  /**
11
10
  * Finds the closest CdkDrag to an element by looking at the DOM.
@@ -224,7 +223,7 @@ declare function noKinksValidator(): ValidatorFn;
224
223
  * Reads a File, or buffer of file content, in GeoJSON or ESRI Shapefile format
225
224
  * and returns a GeoJSON `FeatureCollection`.
226
225
  */
227
- declare function readGeoFile(fileOrBuffer: File | ArrayBuffer | Buffer): Promise<FeatureCollection>;
226
+ declare function readGeoFile(fileOrBuffer: File | ArrayBuffer): Promise<FeatureCollection>;
228
227
 
229
228
  /**
230
229
  * Split all MultiPolygon into Polygon. Any properties, other than
@@ -336,16 +335,16 @@ declare function deleteProperty<T extends object, K extends keyof T>(obj: T, pro
336
335
  /** Delete properties of object */
337
336
  declare function deleteProperties<T extends object, K extends keyof T>(obj: T, propNames: K[]): void;
338
337
 
339
- declare function readFileAsync(file: any): Promise<ArrayBuffer | null>;
338
+ declare function readFileAsync(file: Blob): Promise<ArrayBuffer | null>;
340
339
  declare function readFileAsDataUrlAsync(file: Blob): Promise<string | null>;
341
- declare function fileBufferToBlob(fileBuffer: Buffer, defaultMime?: string): Promise<Blob>;
342
- declare function fileBufferToObjectUrl(fileBuffer: Buffer, defaultMime?: string): Promise<string>;
340
+ declare function fileBufferToBlob(buffer: Uint8Array | ArrayBuffer, defaultMime?: string): Promise<Blob>;
341
+ declare function fileBufferToObjectUrl(buffer: Uint8Array | ArrayBuffer, defaultMime?: string): Promise<string>;
343
342
  interface IFileData {
344
343
  ext?: string;
345
344
  mime?: string;
346
345
  blob: Blob;
347
346
  }
348
- declare function fileDataFromBuffer(fileBuffer: Buffer | Uint8Array | ArrayBuffer, defaultMime?: string): Promise<IFileData>;
347
+ declare function fileDataFromBuffer(buffer: Uint8Array | ArrayBuffer, defaultMime?: string): Promise<IFileData>;
349
348
  declare function openBlob(blob: Blob, target?: string, filename?: string): void;
350
349
 
351
350
  declare function notNullOrUndefined<T>(value: T | null | undefined): value is T;