@elasticias/screens 1.0.40 → 1.0.42

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": "@elasticias/screens",
3
- "version": "1.0.40",
3
+ "version": "1.0.42",
4
4
  "peerDependencies": {
5
5
  "@angular/common": "^21.0.0",
6
6
  "@angular/core": "^21.0.0",
@@ -123,18 +123,19 @@ declare class SearchEntity extends AbstractEntity {
123
123
  * automatically; consumers can also pass a `string` for custom keys
124
124
  * paired with a compute callback in the picker's preset list.
125
125
  */
126
- type EfDatePresetKey = 'today' | 'this_week' | 'this_month' | 'last_30_days' | 'last_90_days' | 'this_quarter' | 'this_year' | 'custom' | string;
126
+ type EfDatePresetKey = 'all_time' | 'today' | 'this_week' | 'this_month' | 'last_30_days' | 'last_90_days' | 'this_quarter' | 'this_year' | 'custom' | string;
127
127
  /**
128
128
  * Active date-range filter, owned by `AbstractSearchScreenV2.dateRange`
129
129
  * and round-tripped through `ef-datepicker-advanced`. `start`/`end` are
130
- * inclusive day boundaries (both at 00:00 local time).
130
+ * inclusive day boundaries (both at 00:00 local time), or both `null`
131
+ * for the open `'all_time'` range, which filters nothing.
131
132
  */
132
133
  interface EfDateRange {
133
- /** Inclusive start. */
134
- start: Date;
135
- /** Inclusive end — 00:00 local on the last day. Strict comparisons
136
- * should treat this as `< end + 1 day`. */
137
- end: Date;
134
+ /** Inclusive start. `null` means no lower bound (`'all_time'`). */
135
+ start: Date | null;
136
+ /** Inclusive end, 00:00 local on the last day. Strict comparisons
137
+ * should treat this as `< end + 1 day`. `null` means no upper bound. */
138
+ end: Date | null;
138
139
  /** Which preset is active (`'custom'` for a manually picked range). */
139
140
  presetKey: EfDatePresetKey;
140
141
  /** Resolved literal label — formatted date range for `'custom'`,
@@ -146,6 +147,14 @@ interface EfDateRange {
146
147
  * translations finish loading or the language changes. */
147
148
  labelKey?: string;
148
149
  }
150
+ /**
151
+ * A range that always has both bounds. Report screens need one: every
152
+ * widget query is a period, so an open range has no meaning there.
153
+ */
154
+ type EfBoundedDateRange = EfDateRange & {
155
+ start: Date;
156
+ end: Date;
157
+ };
149
158
 
150
159
  interface DefaultSort {
151
160
  field: string;
@@ -543,6 +552,14 @@ interface EfDataCardColumn {
543
552
  sortable?: boolean;
544
553
  /** Backend sort field — defaults to `field` then `id`. */
545
554
  sortField?: string;
555
+ /**
556
+ * Direction of the first click on this column's header, when it is
557
+ * not already the active sort (later clicks toggle). Default `'desc'`,
558
+ * which suits dates and amounts; a name column usually wants `'asc'`.
559
+ * Check how the backend orders missing values first: Mongo sorts
560
+ * null and missing fields ahead of everything else in `asc`.
561
+ */
562
+ firstSortDirection?: 'asc' | 'desc';
546
563
  /** Date / datetime: pipe format string (default: `'shortDate'` / `'short'`). */
547
564
  dateFormat?: string;
548
565
  /** Money: ISO currency code (default: `'EUR'`). */
@@ -670,14 +687,27 @@ declare abstract class AbstractSearchScreenV2<TItem = any> extends AbstractScree
670
687
  readonly criteria: _angular_core.WritableSignal<SearchEntity>;
671
688
  /**
672
689
  * Active date-range filter shown in `ef-datepicker-advanced`'s
673
- * trigger. Display-only at construction time — actually filters
674
- * the search once `onDateRangeChange()` fires (or a screen wires
675
- * one in `ngOnInit`).
690
+ * trigger, and the single source of the criteria's `start`/`end`.
691
+ * The first search, `clear()` and a picked range all send exactly
692
+ * what this holds, and a cache restore rebuilds it from the restored
693
+ * dates, so the chip never reads one period while the list shows
694
+ * another.
676
695
  *
677
- * Override `buildDefaultDateRange()` per screen to ship a
678
- * different starting preset.
696
+ * Defaults to `'all_time'` (no dates sent). Override
697
+ * `buildDefaultDateRange()` per screen to open on a window instead.
679
698
  */
680
699
  readonly dateRange: _angular_core.WritableSignal<EfDateRange>;
700
+ /**
701
+ * Whether this screen offers the date chip at all. Set it to `false`
702
+ * (`override readonly showDateFilter = false;`) on a screen whose
703
+ * backend query has no date field, and guard the template's
704
+ * `<ef-datepicker-advanced>` with `@if (showDateFilter)` (or drop it).
705
+ * The base then never sends `start`/`end`: not on first load, not
706
+ * after `clear()`, not from criteria cached by an older session, and
707
+ * not from `onDateRangeChange()` / `setDateRange()`, which become
708
+ * no-ops, so a picker left in the template cannot filter either.
709
+ */
710
+ readonly showDateFilter: boolean;
681
711
  /** Free-text search input value — bound `[(searchText)]` on
682
712
  * ef-smart-bar; drives `runSearch()`. */
683
713
  readonly searchQuery: _angular_core.WritableSignal<string>;
@@ -743,11 +773,22 @@ declare abstract class AbstractSearchScreenV2<TItem = any> extends AbstractScree
743
773
  */
744
774
  protected resetDateRange(): void;
745
775
  /**
746
- * Build the default `EfDateRange`. Override per screen to ship a
747
- * different default — e.g., a 90-day window for low-velocity
748
- * catalogues. Default: last 30 days.
776
+ * Build the default `EfDateRange`. Default: `all_time`, no bounds,
777
+ * so a typed search finds an old record instead of silently missing
778
+ * it behind a window nobody chose. Override per screen to open on a
779
+ * window (e.g. `daysAgo(89)` to `startOfToday()` for `last_90_days`);
780
+ * the first search and `clear()` then send that window.
749
781
  */
750
782
  protected buildDefaultDateRange(): EfDateRange;
783
+ /** Copy the chip's range onto fresh criteria, so what is shown is
784
+ * what is sent. Sends nothing when the screen has no date chip. */
785
+ private seedDateCriteria;
786
+ /** Rebuild the chip from restored criteria: both dates are shown as
787
+ * the custom range they filter on; anything less is `all_time`, and
788
+ * `bootstrapInitialSearch()` drops a lone bound so nothing is sent.
789
+ * No literal label: the picker formats a custom range itself. */
790
+ private dateRangeFromCriteria;
791
+ private toDateOrNull;
751
792
  /** Today at 00:00 local time. */
752
793
  protected startOfToday(): Date;
753
794
  /** N days before today, at 00:00 local time. */
@@ -814,8 +855,9 @@ declare abstract class AbstractSearchScreenV2<TItem = any> extends AbstractScree
814
855
  * what the drawer / search box displays matches what the search will
815
856
  * actually send (otherwise a stale criteria filter keeps applying
816
857
  * while every control reads "Tous"). Base handles the free-text
817
- * input and the declared advanced filters; override (calling super)
818
- * to sync screen-specific state — status pill, custom switches, ….
858
+ * input, the date chip and the declared advanced filters; override
859
+ * (calling super) to sync screen-specific state, such as a status pill
860
+ * or custom switches.
819
861
  */
820
862
  protected restoreFilterUiFromCriteria(cached: Record<string, any>): void;
821
863
  /**
@@ -999,6 +1041,12 @@ declare abstract class AbstractDetailScreenV2<TItem extends object = any> extend
999
1041
  private readonly destroyRef;
1000
1042
  private readonly auditHistoryService;
1001
1043
  private readonly shortcuts;
1044
+ /** The in-flight entity / history requests. A newer load drops the
1045
+ * older one, so a slow response for an id the screen has moved off
1046
+ * can never overwrite the record it now shows, and destroying the
1047
+ * screen drops both. */
1048
+ private loadSub?;
1049
+ private auditSub?;
1002
1050
  /** Distinguishes this instance's registration from any other detail
1003
1051
  * screen alive at once (the outgoing and incoming routed component
1004
1052
  * can briefly coexist), the same convention ef-row-actions uses:
@@ -1235,18 +1283,25 @@ declare abstract class AbstractReportScreenV2 extends AbstractScreenComponent im
1235
1283
  private readonly registeredWidgets;
1236
1284
  /** Active period. Bound to `ef-datepicker-advanced`; every widget loader
1237
1285
  * receives its UTC-normalized start/end. */
1238
- readonly dateRange: _angular_core.WritableSignal<EfDateRange>;
1286
+ readonly dateRange: _angular_core.WritableSignal<EfBoundedDateRange>;
1239
1287
  ngOnInit(): void;
1240
1288
  /** Wired to `<ef-datepicker-advanced (rangeChange)>`. */
1241
1289
  onDateRangeChange(range: EfDateRange): void;
1290
+ /**
1291
+ * Every widget query is a period, so an open range (`all_time`) has no
1292
+ * meaning here. The picker only offers it with `allowAllTime`, which a
1293
+ * report should not set; if one arrives anyway, fall back to the
1294
+ * default period rather than send a null bound.
1295
+ */
1296
+ private boundedOrDefault;
1242
1297
  /** Default period from the config's `DEFAULT_PERIOD` preset. */
1243
- protected buildDefaultDateRange(): EfDateRange;
1298
+ protected buildDefaultDateRange(): EfBoundedDateRange;
1244
1299
  /**
1245
1300
  * Resolve a built-in {@link EfDatePresetKey} to an inclusive day range
1246
1301
  * (both boundaries at 00:00 local). Unknown keys normalize to
1247
1302
  * `last_30_days`. Weeks start Monday (matches `$dateTrunc`, ADR-015).
1248
1303
  */
1249
- protected rangeFromPreset(key: EfDatePresetKey): EfDateRange;
1304
+ protected rangeFromPreset(key: EfDatePresetKey): EfBoundedDateRange;
1250
1305
  private startOfToday;
1251
1306
  /**
1252
1307
  * Re-anchor a local-midnight Date to UTC midnight of the same calendar
@@ -1372,4 +1427,4 @@ declare class ViewModelEntity extends AbstractEntity {
1372
1427
  type EfSearchToolbarAction = EfDetailToolbarAction;
1373
1428
 
1374
1429
  export { AUDIT_HISTORY_SERVICE, AbstractComponent, AbstractDetailScreenComponent, AbstractDetailScreenV2, AbstractEntity, AbstractReportScreenV2, AbstractScreenComponent, AbstractSearchScreenComponent, AbstractSearchScreenV2, AbstractSubScreenComponent, AbstractSubScreenV2, PaginationEnum, SCREEN_REF_DATA_SERVICE, ScreenConfig, ScreenContext, ScreenStateEnum, SearchEntity, SortDirectionEnum, StateUtilsEnum, ViewModelEntity };
1375
- export type { ActiveFilter, AdvancedSelectFilter, AuditHistoryService, DefaultSort, EfDataCardColumn, EfDataCardColumnAlign, EfDataCardColumnMobileRole, EfDataCardColumnType, EfDataCardExportRequest, EfDataCardSort, EfDataCardSortDirection, EfDatePresetKey, EfDateRange, EfDetailToolbarAction, EfReferenceColumnOpts, EfSearchToolbarAction, LoadOptions, ReferenceDataProvider, ReportWidget, ReportWidgetStatus, ScreenDatatableColumn, ScreenReferenceDataService };
1430
+ export type { ActiveFilter, AdvancedSelectFilter, AuditHistoryService, DefaultSort, EfBoundedDateRange, EfDataCardColumn, EfDataCardColumnAlign, EfDataCardColumnMobileRole, EfDataCardColumnType, EfDataCardExportRequest, EfDataCardSort, EfDataCardSortDirection, EfDatePresetKey, EfDateRange, EfDetailToolbarAction, EfReferenceColumnOpts, EfSearchToolbarAction, LoadOptions, ReferenceDataProvider, ReportWidget, ReportWidgetStatus, ScreenDatatableColumn, ScreenReferenceDataService };