@smartsoft001/react 2.201.0 → 2.203.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 +4 -4
- package/src/lib/components/command-palette/preset/command-palette-preset.d.ts +1 -1
- package/src/lib/components/command-palette/preset/command-palette-preset.js +3 -1
- package/src/lib/components/command-palette/preset/command-palette-preset.js.map +1 -1
- package/src/lib/components/command-palette/standard/command-palette-standard.d.ts +2 -2
- package/src/lib/components/command-palette/standard/command-palette-standard.js +4 -2
- package/src/lib/components/command-palette/standard/command-palette-standard.js.map +1 -1
- package/src/lib/components/command-palette/use-close-on-escape.d.ts +6 -0
- package/src/lib/components/command-palette/use-close-on-escape.js +22 -0
- package/src/lib/components/command-palette/use-close-on-escape.js.map +1 -0
- package/src/lib/components/input/error/input-error-messages.d.ts +2 -1
- package/src/lib/components/input/error/input-error-messages.js +5 -2
- package/src/lib/components/input/error/input-error-messages.js.map +1 -1
- package/src/lib/components/input/long-text/index.d.ts +2 -0
- package/src/lib/components/input/long-text/index.js +3 -1
- package/src/lib/components/input/long-text/index.js.map +1 -1
- package/src/lib/components/list/desktop/list-desktop.d.ts +3 -3
- package/src/lib/components/list/desktop/list-desktop.js +8 -5
- package/src/lib/components/list/desktop/list-desktop.js.map +1 -1
- package/src/lib/components/list/desktop/preset/list-desktop-preset.d.ts +2 -1
- package/src/lib/components/list/desktop/preset/list-desktop-preset.js +7 -3
- package/src/lib/components/list/desktop/preset/list-desktop-preset.js.map +1 -1
- package/src/lib/components/list/desktop/preset/preset-classes.d.ts +4 -0
- package/src/lib/components/list/desktop/preset/preset-classes.js +24 -0
- package/src/lib/components/list/desktop/preset/preset-classes.js.map +1 -1
- package/src/lib/components/list/desktop/use-list-desktop.d.ts +9 -1
- package/src/lib/components/list/desktop/use-list-desktop.js +5 -3
- package/src/lib/components/list/desktop/use-list-desktop.js.map +1 -1
- package/src/lib/components/list/index.d.ts +2 -0
- package/src/lib/components/list/index.js +2 -0
- package/src/lib/components/list/index.js.map +1 -1
- package/src/lib/components/list/list-details-modal.d.ts +19 -0
- package/src/lib/components/list/list-details-modal.js +16 -0
- package/src/lib/components/list/list-details-modal.js.map +1 -0
- package/src/lib/components/list/list-sort.d.ts +31 -0
- package/src/lib/components/list/list-sort.js +43 -0
- package/src/lib/components/list/list-sort.js.map +1 -0
- package/src/lib/components/list/masonry-grid/list-masonry-grid.d.ts +2 -1
- package/src/lib/components/list/masonry-grid/list-masonry-grid.js +7 -6
- package/src/lib/components/list/masonry-grid/list-masonry-grid.js.map +1 -1
- package/src/lib/components/list/masonry-grid/preset/list-masonry-grid-preset.js +7 -7
- package/src/lib/components/list/masonry-grid/preset/list-masonry-grid-preset.js.map +1 -1
- package/src/lib/components/list/masonry-grid/use-list-masonry-grid.d.ts +7 -0
- package/src/lib/components/list/mobile/list-mobile.d.ts +2 -2
- package/src/lib/components/list/mobile/list-mobile.js +4 -4
- package/src/lib/components/list/mobile/list-mobile.js.map +1 -1
- package/src/lib/components/list/mobile/preset/list-mobile-preset.js +2 -2
- package/src/lib/components/list/mobile/preset/list-mobile-preset.js.map +1 -1
- package/src/lib/components/list/use-list.d.ts +15 -0
- package/src/lib/components/list/use-list.js +74 -2
- package/src/lib/components/list/use-list.js.map +1 -1
- package/src/lib/components/modal/preset/modal-preset.js +15 -2
- package/src/lib/components/modal/preset/modal-preset.js.map +1 -1
- package/src/lib/components/overlays/overlays.d.ts +5 -3
- package/src/lib/components/overlays/overlays.js +24 -4
- package/src/lib/components/overlays/overlays.js.map +1 -1
- package/src/lib/components/page/standard/page-standard.d.ts +3 -5
- package/src/lib/components/page/standard/page-standard.js +4 -6
- package/src/lib/components/page/standard/page-standard.js.map +1 -1
- package/src/lib/components/page-heading/preset/page-heading-preset.d.ts +6 -4
- package/src/lib/components/page-heading/preset/page-heading-preset.js +9 -6
- package/src/lib/components/page-heading/preset/page-heading-preset.js.map +1 -1
- package/src/lib/components/searchbar/standard/searchbar-standard.js +6 -2
- package/src/lib/components/searchbar/standard/searchbar-standard.js.map +1 -1
- package/src/lib/components/toggle/preset/toggle-preset.d.ts +4 -1
- package/src/lib/components/toggle/preset/toggle-preset.js +10 -3
- package/src/lib/components/toggle/preset/toggle-preset.js.map +1 -1
- package/src/lib/components/vertical-navigation/preset/preset-classes.d.ts +1 -0
- package/src/lib/components/vertical-navigation/preset/preset-classes.js +13 -0
- package/src/lib/components/vertical-navigation/preset/preset-classes.js.map +1 -1
- package/src/lib/components/vertical-navigation/preset/vertical-navigation-preset.d.ts +3 -2
- package/src/lib/components/vertical-navigation/preset/vertical-navigation-preset.js +8 -3
- package/src/lib/components/vertical-navigation/preset/vertical-navigation-preset.js.map +1 -1
- package/src/lib/components/vertical-navigation/standard/vertical-navigation-standard.d.ts +5 -1
- package/src/lib/components/vertical-navigation/standard/vertical-navigation-standard.js +11 -2
- package/src/lib/components/vertical-navigation/standard/vertical-navigation-standard.js.map +1 -1
- package/src/lib/i18n/translations-default.js +2 -2
- package/src/lib/i18n/translations-default.js.map +1 -1
- package/src/lib/models/interfaces.d.ts +51 -0
- package/src/lib/models/interfaces.js.map +1 -1
- package/src/lib/providers/model-possibilities.provider.d.ts +1 -1
- package/src/lib/providers/model-possibilities.provider.js +1 -1
- package/src/lib/services/modal/modal.service.d.ts +18 -1
- package/src/lib/services/modal/modal.service.js +31 -1
- package/src/lib/services/modal/modal.service.js.map +1 -1
- package/styles.css +6 -0
|
@@ -47,6 +47,7 @@ export interface IIconButtonOptions {
|
|
|
47
47
|
icon: string;
|
|
48
48
|
text?: string;
|
|
49
49
|
handler?: () => void;
|
|
50
|
+
/** Not read by the built-in implementations (standard or preset); available to a custom implementation registered for the component. */
|
|
50
51
|
component?: any;
|
|
51
52
|
type?: 'default' | 'popover';
|
|
52
53
|
disabled?: boolean;
|
|
@@ -60,6 +61,7 @@ export interface IDynamicComponentData {
|
|
|
60
61
|
}
|
|
61
62
|
export interface IFormOptions<T> {
|
|
62
63
|
model: T;
|
|
64
|
+
/** Not read by the built-in implementations (standard or preset); available to a custom implementation registered for the component. */
|
|
63
65
|
show: boolean;
|
|
64
66
|
treeLevel?: number;
|
|
65
67
|
/** A ready form; without it the form is built from `model` by the form factory. */
|
|
@@ -74,6 +76,7 @@ export interface IFormOptions<T> {
|
|
|
74
76
|
inputComponents?: {
|
|
75
77
|
[key: string]: InputComponentType<T>;
|
|
76
78
|
};
|
|
79
|
+
/** Not read by the built-in implementations (standard or preset); available to a custom implementation registered for the component. */
|
|
77
80
|
fieldOptions?: IFieldOptions;
|
|
78
81
|
modelOptions?: IModelOptions;
|
|
79
82
|
}
|
|
@@ -98,6 +101,7 @@ export interface IDetailsOptions<T extends IEntity<string>> {
|
|
|
98
101
|
cellPipe?: ICellPipe<T>;
|
|
99
102
|
type: any;
|
|
100
103
|
item: T | null | undefined;
|
|
104
|
+
/** Not read by the built-in implementations (standard or preset); available to a custom implementation registered for the component. */
|
|
101
105
|
loading?: boolean;
|
|
102
106
|
itemHandler?: ((id: string) => void) | null;
|
|
103
107
|
removeHandler?: ((item: T) => void) | null;
|
|
@@ -172,6 +176,7 @@ export interface IEmptyStateItem {
|
|
|
172
176
|
export interface IEmptyStateOptions {
|
|
173
177
|
title?: string;
|
|
174
178
|
description?: string;
|
|
179
|
+
/** Not read by the built-in implementations (standard or preset); available to a custom implementation registered for the component. */
|
|
175
180
|
layout?: SmartEmptyStateLayout;
|
|
176
181
|
iconTpl?: ReactNode;
|
|
177
182
|
actions?: IEmptyStateAction[];
|
|
@@ -190,6 +195,7 @@ export interface INavbarItem {
|
|
|
190
195
|
iconTpl?: ReactNode;
|
|
191
196
|
}
|
|
192
197
|
export interface INavbarOptions {
|
|
198
|
+
/** Not read by the built-in implementations (standard or preset); available to a custom implementation registered for the component. */
|
|
193
199
|
layout?: SmartNavbarLayout;
|
|
194
200
|
dark?: boolean;
|
|
195
201
|
menuButtonOnLeft?: boolean;
|
|
@@ -242,6 +248,10 @@ export interface IProgressBarsOptions {
|
|
|
242
248
|
value?: number;
|
|
243
249
|
columns?: IProgressBarColumn[];
|
|
244
250
|
}
|
|
251
|
+
/**
|
|
252
|
+
* The preset's layouts. `'simple-with-chevrons'` looks the same as the default
|
|
253
|
+
* layout, since the chevron is already the default separator.
|
|
254
|
+
*/
|
|
245
255
|
export type SmartBreadcrumbsLayout = 'contained' | 'full-width-bar' | 'simple-with-chevrons' | 'simple-with-slashes';
|
|
246
256
|
export type SmartBreadcrumbsSeparator = 'chevron' | 'slash' | 'arrow';
|
|
247
257
|
export interface IBreadcrumbItem {
|
|
@@ -274,6 +284,7 @@ export interface IVerticalNavGroup {
|
|
|
274
284
|
items: IVerticalNavItem[];
|
|
275
285
|
}
|
|
276
286
|
export interface IVerticalNavOptions {
|
|
287
|
+
/** Not read by the built-in implementations (standard or preset); available to a custom implementation registered for the component. */
|
|
277
288
|
layout?: SmartVerticalNavLayout;
|
|
278
289
|
ariaLabel?: string;
|
|
279
290
|
items?: IVerticalNavItem[];
|
|
@@ -289,6 +300,7 @@ export interface IButtonOptions {
|
|
|
289
300
|
color?: SmartColor;
|
|
290
301
|
rounded?: boolean;
|
|
291
302
|
circular?: boolean;
|
|
303
|
+
/** Not read by the built-in implementations (standard or preset); available to a custom implementation registered for the component. */
|
|
292
304
|
iconPosition?: 'leading' | 'trailing';
|
|
293
305
|
}
|
|
294
306
|
export interface IInfoOptions {
|
|
@@ -296,6 +308,7 @@ export interface IInfoOptions {
|
|
|
296
308
|
}
|
|
297
309
|
export interface ISearchbarOptions {
|
|
298
310
|
placeholder?: string;
|
|
311
|
+
/** Not read by the built-in implementations (standard or preset); available to a custom implementation registered for the component. */
|
|
299
312
|
label?: string;
|
|
300
313
|
debounceTime?: number;
|
|
301
314
|
showToggleButton?: boolean;
|
|
@@ -314,6 +327,7 @@ export interface ICommand {
|
|
|
314
327
|
label: string;
|
|
315
328
|
icon?: string;
|
|
316
329
|
group?: string;
|
|
330
|
+
/** Not read by the built-in implementations (standard or preset); available to a custom implementation registered for the component. */
|
|
317
331
|
href?: string;
|
|
318
332
|
description?: string;
|
|
319
333
|
imageUrl?: string;
|
|
@@ -358,6 +372,7 @@ export interface IDrawerOptions {
|
|
|
358
372
|
wide?: boolean;
|
|
359
373
|
withOverlay?: boolean;
|
|
360
374
|
brandedHeader?: boolean;
|
|
375
|
+
/** Not read by the built-in implementations (standard or preset); available to a custom implementation registered for the component. */
|
|
361
376
|
stickyFooter?: boolean;
|
|
362
377
|
variant?: SmartDrawerVariant;
|
|
363
378
|
}
|
|
@@ -421,6 +436,7 @@ export interface IDropdownItem {
|
|
|
421
436
|
id: string;
|
|
422
437
|
label: string;
|
|
423
438
|
icon?: string;
|
|
439
|
+
/** Not read by the built-in implementations (standard or preset); available to a custom implementation registered for the component. */
|
|
424
440
|
href?: string;
|
|
425
441
|
disabled?: boolean;
|
|
426
442
|
divider?: boolean;
|
|
@@ -449,6 +465,7 @@ export interface IContainerOptions {
|
|
|
449
465
|
export type SmartListContainerVariant = 'simple-dividers' | 'card-dividers' | 'separate-cards' | 'flat-card-dividers';
|
|
450
466
|
export interface IListContainerOptions {
|
|
451
467
|
variant?: SmartListContainerVariant;
|
|
468
|
+
/** Not read by the built-in implementations (standard or preset); available to a custom implementation registered for the component. */
|
|
452
469
|
fullWidthOnMobile?: boolean;
|
|
453
470
|
}
|
|
454
471
|
export interface IMediaObjectOptions {
|
|
@@ -551,8 +568,11 @@ export type SmartCalendarView = 'month' | 'week' | 'day' | 'year';
|
|
|
551
568
|
export interface ICalendarEvent {
|
|
552
569
|
id: string | number;
|
|
553
570
|
start: Date;
|
|
571
|
+
/** Not rendered by the built-in implementations (they show a dot or a count per day); available to `dayCellTpl` and to a custom implementation. */
|
|
554
572
|
end?: Date;
|
|
573
|
+
/** Not rendered by the built-in implementations (they show a dot or a count per day); available to `dayCellTpl` and to a custom implementation. */
|
|
555
574
|
title?: string;
|
|
575
|
+
/** Not rendered by the built-in implementations (they show a dot or a count per day); available to `dayCellTpl` and to a custom implementation. */
|
|
556
576
|
meta?: Record<string, unknown>;
|
|
557
577
|
}
|
|
558
578
|
export interface ICalendarDayCell {
|
|
@@ -563,6 +583,7 @@ export interface ICalendarDayCell {
|
|
|
563
583
|
}
|
|
564
584
|
export interface ICalendarOptions {
|
|
565
585
|
view?: SmartCalendarView;
|
|
586
|
+
/** Not read by the built-in implementations (standard or preset); available to a custom implementation registered for the component. */
|
|
566
587
|
monthsCount?: 1 | 2 | 12;
|
|
567
588
|
weekStart?: 0 | 1;
|
|
568
589
|
showToolbar?: boolean;
|
|
@@ -570,6 +591,7 @@ export interface ICalendarOptions {
|
|
|
570
591
|
eventListTpl?: ReactNode;
|
|
571
592
|
sidePanelTpl?: ReactNode;
|
|
572
593
|
dayCellTpl?: ReactNode;
|
|
594
|
+
/** Not read by the built-in implementations (standard or preset); available to a custom implementation registered for the component. */
|
|
573
595
|
eventTpl?: ReactNode;
|
|
574
596
|
}
|
|
575
597
|
export interface IStackedListItem {
|
|
@@ -650,6 +672,7 @@ export type SmartSelectMenuVariant = 'native' | 'custom' | 'with-check' | 'with-
|
|
|
650
672
|
export interface ISelectMenuItem {
|
|
651
673
|
value: string | number;
|
|
652
674
|
label: string;
|
|
675
|
+
/** Not read by the built-in implementations (standard or preset); available to a custom implementation registered for the component. */
|
|
653
676
|
avatarUrl?: string;
|
|
654
677
|
iconTpl?: ReactNode;
|
|
655
678
|
secondary?: string;
|
|
@@ -660,6 +683,7 @@ export interface ISelectMenuItem {
|
|
|
660
683
|
export interface ISelectMenuOptions {
|
|
661
684
|
items?: ISelectMenuItem[];
|
|
662
685
|
placeholder?: string;
|
|
686
|
+
/** Not read by the built-in implementations (standard or preset); available to a custom implementation registered for the component. */
|
|
663
687
|
variant?: SmartSelectMenuVariant;
|
|
664
688
|
emptyTpl?: ReactNode;
|
|
665
689
|
ariaLabel?: string;
|
|
@@ -680,6 +704,7 @@ export interface IFeedEvent {
|
|
|
680
704
|
iconTpl?: ReactNode;
|
|
681
705
|
avatarUrl?: string;
|
|
682
706
|
href?: string;
|
|
707
|
+
/** Not read by the built-in implementations (standard or preset); available to a custom implementation registered for the component. */
|
|
683
708
|
type?: string;
|
|
684
709
|
comments?: IFeedComment[];
|
|
685
710
|
ariaLabel?: string;
|
|
@@ -688,6 +713,7 @@ export interface IFeedOptions {
|
|
|
688
713
|
title?: string;
|
|
689
714
|
description?: string;
|
|
690
715
|
events?: IFeedEvent[];
|
|
716
|
+
/** Not read by the built-in implementations (standard or preset); available to a custom implementation registered for the component. */
|
|
691
717
|
variant?: SmartFeedVariant;
|
|
692
718
|
commentSubmitTpl?: ReactNode;
|
|
693
719
|
emptyTpl?: ReactNode;
|
|
@@ -773,6 +799,7 @@ export interface ISidebarNavProfile {
|
|
|
773
799
|
srOnlyText?: string;
|
|
774
800
|
}
|
|
775
801
|
export interface ISidebarNavOptions {
|
|
802
|
+
/** Not read by the built-in implementations (standard or preset); available to a custom implementation registered for the component. */
|
|
776
803
|
layout?: SmartSidebarNavLayout;
|
|
777
804
|
ariaLabel?: string;
|
|
778
805
|
logo?: ISidebarNavLogo;
|
|
@@ -786,6 +813,7 @@ export interface ISidebarLayoutOptions {
|
|
|
786
813
|
sidebarTpl?: ReactNode;
|
|
787
814
|
headerTpl?: ReactNode;
|
|
788
815
|
sidebarPosition?: 'left' | 'right';
|
|
816
|
+
/** Not read by the built-in implementations (standard or preset); available to a custom implementation registered for the component. */
|
|
789
817
|
mobileBreakpoint?: SmartSidebarLayoutMobileBreakpoint;
|
|
790
818
|
condensed?: boolean;
|
|
791
819
|
}
|
|
@@ -794,6 +822,7 @@ export interface IDetailOptions<T> {
|
|
|
794
822
|
item?: T | null;
|
|
795
823
|
options: IFieldOptions;
|
|
796
824
|
cellPipe?: ICellPipe<T>;
|
|
825
|
+
/** Not read by the built-in implementations (standard or preset); available to a custom implementation registered for the component. */
|
|
797
826
|
loading?: boolean;
|
|
798
827
|
}
|
|
799
828
|
export interface ICellPipe<T> {
|
|
@@ -824,10 +853,16 @@ export interface IPageOptions {
|
|
|
824
853
|
logoTpl?: ReactNode;
|
|
825
854
|
statsTpl?: ReactNode;
|
|
826
855
|
subtitleTpl?: ReactNode;
|
|
856
|
+
/** Not read by the built-in implementations (standard or preset); available to a custom implementation registered for the component. */
|
|
827
857
|
navTpl?: ReactNode;
|
|
828
858
|
sidebarTpl?: ReactNode;
|
|
829
859
|
}
|
|
830
860
|
export interface IListProvider<T> {
|
|
861
|
+
/**
|
|
862
|
+
* Reads the data again with `filter` merged into the current one. The list
|
|
863
|
+
* calls it with `{ offset: 0, sortBy, sortDesc }` when a sortable header is
|
|
864
|
+
* clicked (`IListOptions.sort` set).
|
|
865
|
+
*/
|
|
831
866
|
getData: (filter: any) => void;
|
|
832
867
|
onChangeMultiSelected?: (list: Array<T>) => void;
|
|
833
868
|
/** Clears the multi-selection whenever it emits. */
|
|
@@ -836,7 +871,13 @@ export interface IListProvider<T> {
|
|
|
836
871
|
loading: boolean;
|
|
837
872
|
}
|
|
838
873
|
export interface IListPaginationOptions {
|
|
874
|
+
/**
|
|
875
|
+
* `PaginationMode.singlePage` renders the pager below the items;
|
|
876
|
+
* `PaginationMode.infiniteScroll` calls `loadNextPage` when the end of the
|
|
877
|
+
* items scrolls into view, while `page < totalPages`.
|
|
878
|
+
*/
|
|
839
879
|
mode?: PaginationMode;
|
|
880
|
+
/** Not read by the built-in implementations (standard or preset); available to a custom implementation registered for the component. */
|
|
840
881
|
limit: number;
|
|
841
882
|
loadNextPage: () => Promise<boolean>;
|
|
842
883
|
loadPrevPage: () => Promise<boolean>;
|
|
@@ -877,10 +918,20 @@ export interface IListOptions<T> {
|
|
|
877
918
|
pagination?: IListPaginationOptions;
|
|
878
919
|
cellPipe?: ICellPipe<T>;
|
|
879
920
|
componentFactories?: IListComponentFactories<T>;
|
|
921
|
+
/**
|
|
922
|
+
* Makes the field headers of the desktop modes sort buttons: a click reads
|
|
923
|
+
* the data through `provider.getData({ offset: 0, sortBy, sortDesc })`.
|
|
924
|
+
* `default` / `defaultDesc` is the sort the headers show at first.
|
|
925
|
+
*/
|
|
880
926
|
sort?: boolean | {
|
|
881
927
|
default?: string;
|
|
882
928
|
defaultDesc?: boolean;
|
|
883
929
|
};
|
|
930
|
+
/**
|
|
931
|
+
* Adds a details action to every item: it opens `component`
|
|
932
|
+
* (`SmartDetailsPage` by default) in a modal with the `IDetailsOptions` of
|
|
933
|
+
* `provider` as its `value`, and asks `provider.getData(id)` for the item.
|
|
934
|
+
*/
|
|
884
935
|
details?: boolean | {
|
|
885
936
|
provider?: IDetailsProvider<T>;
|
|
886
937
|
componentFactories?: IDetailsComponentFactories<T>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../../../../../packages/shared/react/src/lib/models/interfaces.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../../../../../packages/shared/react/src/lib/models/interfaces.ts"],"names":[],"mappings":";;;AA2qCA,IAAY,cAGX;AAHD,WAAY,cAAc;IACxB,mDAAiC,CAAA;IACjC,2CAAyB,CAAA;AAC3B,CAAC,EAHW,cAAc,8BAAd,cAAc,QAGzB;AAED,IAAY,QAIX;AAJD,WAAY,QAAQ;IAClB,6BAAiB,CAAA;IACjB,+BAAmB,CAAA;IACnB,uCAA2B,CAAA;AAC7B,CAAC,EAJW,QAAQ,wBAAR,QAAQ,QAInB"}
|
|
@@ -5,7 +5,7 @@ export interface IModelPossibilitiesOptions {
|
|
|
5
5
|
type?: any;
|
|
6
6
|
}
|
|
7
7
|
/**
|
|
8
|
-
* Supplies the options of
|
|
8
|
+
* Supplies the options of a `radio` or `check` field and of the preset `enum` field,
|
|
9
9
|
* e.g. loaded from the API. It is asked again whenever the form's value
|
|
10
10
|
* changes, so the options can depend on other fields. Return nothing to keep
|
|
11
11
|
* the field's own `possibilities`.
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.IModelPossibilitiesProvider = void 0;
|
|
4
4
|
/**
|
|
5
|
-
* Supplies the options of
|
|
5
|
+
* Supplies the options of a `radio` or `check` field and of the preset `enum` field,
|
|
6
6
|
* e.g. loaded from the API. It is asked again whenever the form's value
|
|
7
7
|
* changes, so the options can depend on other fields. Return nothing to keep
|
|
8
8
|
* the field's own `possibilities`.
|
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
import type { ComponentType } from 'react';
|
|
2
2
|
import { SmartStore } from '../../store';
|
|
3
3
|
export interface IModalServiceOptions {
|
|
4
|
+
/** Rendered in the modal with `props` and a `dismiss(data)` prop. */
|
|
4
5
|
component: ComponentType<any>;
|
|
5
6
|
props?: Record<string, unknown>;
|
|
7
|
+
/** `'bottom'` adds the `smart-modal-bottom` class to the modal. */
|
|
6
8
|
mode?: 'default' | 'bottom';
|
|
9
|
+
/** Classes added to the modal (`<SmartModal className>`). */
|
|
7
10
|
cssClass?: string[];
|
|
11
|
+
/**
|
|
12
|
+
* `false` keeps the modal open on a click on its backdrop and on Escape;
|
|
13
|
+
* its close button and `dismiss()` still close it. Defaults to `true`.
|
|
14
|
+
*/
|
|
8
15
|
backdropDismiss?: boolean;
|
|
9
16
|
}
|
|
10
17
|
export interface IModal {
|
|
@@ -20,12 +27,22 @@ export interface IModalRequest extends IModalServiceOptions {
|
|
|
20
27
|
/**
|
|
21
28
|
* Opens a component in a modal dialog. The component receives `props` and can
|
|
22
29
|
* close the dialog, with a result, through `useModalService().dismiss(data)`
|
|
23
|
-
* or the `dismiss` prop it is given.
|
|
30
|
+
* or the `dismiss` prop it is given. The modals stack: the last one opened is
|
|
31
|
+
* on top, and `dismiss()` closes it.
|
|
24
32
|
*/
|
|
25
33
|
export declare class ModalService {
|
|
26
34
|
readonly modals: SmartStore<IModalRequest[]>;
|
|
27
35
|
private nextId;
|
|
36
|
+
private listening;
|
|
37
|
+
/**
|
|
38
|
+
* Stops Escape before the modal's own document listener (added after this
|
|
39
|
+
* one) while the top modal has `backdropDismiss: false`. Elements inside the
|
|
40
|
+
* modal still receive the key.
|
|
41
|
+
*/
|
|
42
|
+
private readonly onKeydown;
|
|
28
43
|
show(options: IModalServiceOptions): Promise<IModal>;
|
|
29
44
|
/** Closes the modal opened last. */
|
|
30
45
|
dismiss<T>(data?: T | null): Promise<void>;
|
|
46
|
+
/** Listens to Escape on the document while a modal is open. */
|
|
47
|
+
private listenToEscape;
|
|
31
48
|
}
|
|
@@ -5,11 +5,26 @@ const store_1 = require("../../store");
|
|
|
5
5
|
/**
|
|
6
6
|
* Opens a component in a modal dialog. The component receives `props` and can
|
|
7
7
|
* close the dialog, with a result, through `useModalService().dismiss(data)`
|
|
8
|
-
* or the `dismiss` prop it is given.
|
|
8
|
+
* or the `dismiss` prop it is given. The modals stack: the last one opened is
|
|
9
|
+
* on top, and `dismiss()` closes it.
|
|
9
10
|
*/
|
|
10
11
|
class ModalService {
|
|
11
12
|
modals = new store_1.SmartStore([]);
|
|
12
13
|
nextId = 1;
|
|
14
|
+
listening = false;
|
|
15
|
+
/**
|
|
16
|
+
* Stops Escape before the modal's own document listener (added after this
|
|
17
|
+
* one) while the top modal has `backdropDismiss: false`. Elements inside the
|
|
18
|
+
* modal still receive the key.
|
|
19
|
+
*/
|
|
20
|
+
onKeydown = (event) => {
|
|
21
|
+
if (event.key !== 'Escape' && event.key !== 'Esc')
|
|
22
|
+
return;
|
|
23
|
+
const modals = this.modals.get();
|
|
24
|
+
if (modals[modals.length - 1]?.backdropDismiss === false) {
|
|
25
|
+
event.stopImmediatePropagation();
|
|
26
|
+
}
|
|
27
|
+
};
|
|
13
28
|
async show(options) {
|
|
14
29
|
const id = this.nextId++;
|
|
15
30
|
let resolveDismiss;
|
|
@@ -20,9 +35,11 @@ class ModalService {
|
|
|
20
35
|
if (!this.modals.get().some((m) => m.id === id))
|
|
21
36
|
return;
|
|
22
37
|
this.modals.update((modals) => modals.filter((m) => m.id !== id));
|
|
38
|
+
this.listenToEscape();
|
|
23
39
|
resolveDismiss({ data });
|
|
24
40
|
};
|
|
25
41
|
this.modals.update((modals) => [...modals, { ...options, id, dismiss }]);
|
|
42
|
+
this.listenToEscape();
|
|
26
43
|
return { dismiss, onDidDismiss: () => dismissed };
|
|
27
44
|
}
|
|
28
45
|
/** Closes the modal opened last. */
|
|
@@ -30,6 +47,19 @@ class ModalService {
|
|
|
30
47
|
const modals = this.modals.get();
|
|
31
48
|
modals[modals.length - 1]?.dismiss(data);
|
|
32
49
|
}
|
|
50
|
+
/** Listens to Escape on the document while a modal is open. */
|
|
51
|
+
listenToEscape() {
|
|
52
|
+
if (typeof document === 'undefined')
|
|
53
|
+
return;
|
|
54
|
+
const open = this.modals.get().length > 0;
|
|
55
|
+
if (open && !this.listening) {
|
|
56
|
+
document.addEventListener('keydown', this.onKeydown);
|
|
57
|
+
}
|
|
58
|
+
else if (!open && this.listening) {
|
|
59
|
+
document.removeEventListener('keydown', this.onKeydown);
|
|
60
|
+
}
|
|
61
|
+
this.listening = open;
|
|
62
|
+
}
|
|
33
63
|
}
|
|
34
64
|
exports.ModalService = ModalService;
|
|
35
65
|
//# sourceMappingURL=modal.service.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modal.service.js","sourceRoot":"","sources":["../../../../../../../../packages/shared/react/src/lib/services/modal/modal.service.ts"],"names":[],"mappings":";;;AAEA,uCAAyC;
|
|
1
|
+
{"version":3,"file":"modal.service.js","sourceRoot":"","sources":["../../../../../../../../packages/shared/react/src/lib/services/modal/modal.service.ts"],"names":[],"mappings":";;;AAEA,uCAAyC;AA2BzC;;;;;GAKG;AACH,MAAa,YAAY;IACd,MAAM,GAAG,IAAI,kBAAU,CAAkB,EAAE,CAAC,CAAC;IAE9C,MAAM,GAAG,CAAC,CAAC;IACX,SAAS,GAAG,KAAK,CAAC;IAE1B;;;;OAIG;IACc,SAAS,GAAG,CAAC,KAAoB,EAAQ,EAAE;QAC1D,IAAI,KAAK,CAAC,GAAG,KAAK,QAAQ,IAAI,KAAK,CAAC,GAAG,KAAK,KAAK;YAAE,OAAO;QAE1D,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC;QAEjC,IAAI,MAAM,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,EAAE,eAAe,KAAK,KAAK,EAAE,CAAC;YACzD,KAAK,CAAC,wBAAwB,EAAE,CAAC;QACnC,CAAC;IACH,CAAC,CAAC;IAEF,KAAK,CAAC,IAAI,CAAC,OAA6B;QACtC,MAAM,EAAE,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;QACzB,IAAI,cAAgD,CAAC;QACrD,MAAM,SAAS,GAAG,IAAI,OAAO,CAAgB,CAAC,OAAO,EAAE,EAAE;YACvD,cAAc,GAAG,OAAO,CAAC;QAC3B,CAAC,CAAC,CAAC;QAEH,MAAM,OAAO,GAAG,CAAC,OAAY,IAAI,EAAE,EAAE;YACnC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC;gBAAE,OAAO;YAExD,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC;YAClE,IAAI,CAAC,cAAc,EAAE,CAAC;YACtB,cAAc,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC;QAC3B,CAAC,CAAC;QAEF,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,GAAG,MAAM,EAAE,EAAE,GAAG,OAAO,EAAE,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC;QACzE,IAAI,CAAC,cAAc,EAAE,CAAC;QAEtB,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,GAAG,EAAE,CAAC,SAAS,EAAE,CAAC;IACpD,CAAC;IAED,oCAAoC;IACpC,KAAK,CAAC,OAAO,CAAI,OAAiB,IAAI;QACpC,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC;QAEjC,MAAM,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3C,CAAC;IAED,+DAA+D;IACvD,cAAc;QACpB,IAAI,OAAO,QAAQ,KAAK,WAAW;YAAE,OAAO;QAE5C,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC;QAE1C,IAAI,IAAI,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC;YAC5B,QAAQ,CAAC,gBAAgB,CAAC,SAAS,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;QACvD,CAAC;aAAM,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YACnC,QAAQ,CAAC,mBAAmB,CAAC,SAAS,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;QAC1D,CAAC;QAED,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;IACxB,CAAC;CACF;AA/DD,oCA+DC"}
|
package/styles.css
CHANGED
|
@@ -3096,6 +3096,9 @@
|
|
|
3096
3096
|
color: color-mix(in oklab, var(--smart-color-gray-600) 75%, transparent);
|
|
3097
3097
|
}
|
|
3098
3098
|
}
|
|
3099
|
+
.smart\:hover\:text-gray-800:hover {
|
|
3100
|
+
color: var(--smart-color-gray-800);
|
|
3101
|
+
}
|
|
3099
3102
|
.smart\:hover\:text-gray-900:hover {
|
|
3100
3103
|
color: var(--smart-color-gray-900);
|
|
3101
3104
|
}
|
|
@@ -5124,6 +5127,9 @@
|
|
|
5124
5127
|
.smart\:dark\:hover\:text-fuchsia-400:where(.dark, .dark *):hover {
|
|
5125
5128
|
color: var(--smart-color-fuchsia-400);
|
|
5126
5129
|
}
|
|
5130
|
+
.smart\:dark\:hover\:text-gray-200:where(.dark, .dark *):hover {
|
|
5131
|
+
color: var(--smart-color-gray-200);
|
|
5132
|
+
}
|
|
5127
5133
|
.smart\:dark\:hover\:text-gray-300:where(.dark, .dark *):hover {
|
|
5128
5134
|
color: var(--smart-color-gray-300);
|
|
5129
5135
|
}
|