@smartsoft001/react 2.202.0 → 2.204.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/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/modal/preset/preset-classes.js +45 -7
- package/src/lib/components/modal/preset/preset-classes.js.map +1 -1
- package/src/lib/components/modal/standard/modal-standard.d.ts +2 -1
- package/src/lib/components/modal/standard/modal-standard.js +26 -2
- package/src/lib/components/modal/standard/modal-standard.js.map +1 -1
- package/src/lib/components/overlays/overlays.d.ts +13 -4
- package/src/lib/components/overlays/overlays.js +67 -11
- 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/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/models/interfaces.d.ts +21 -1
- 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 +22 -1
- package/src/lib/services/modal/modal.service.js +31 -1
- package/src/lib/services/modal/modal.service.js.map +1 -1
- package/src/lib/services/toast/toast.service.d.ts +12 -4
- package/src/lib/services/toast/toast.service.js +12 -4
- package/src/lib/services/toast/toast.service.js.map +1 -1
- package/styles.css +33 -0
|
@@ -30,6 +30,7 @@ export declare function useListMasonryGrid<T extends IEntity<string>>(props: Sma
|
|
|
30
30
|
itemHandler: ((id: string) => void) | null;
|
|
31
31
|
detailsComponent: import("react").ComponentType<any> | null;
|
|
32
32
|
detailsComponentProps: import("../../../models").IDetailsOptions<T> | null;
|
|
33
|
+
detailsHandler: ((item: T) => void) | null;
|
|
33
34
|
select: ((id: string) => void) | undefined;
|
|
34
35
|
unselect: (() => void) | undefined;
|
|
35
36
|
detailsButtonOptions: import("../../../models").IButtonOptions;
|
|
@@ -40,4 +41,10 @@ export declare function useListMasonryGrid<T extends IEntity<string>>(props: Sma
|
|
|
40
41
|
handlePageChange: (nextPage: number) => void;
|
|
41
42
|
infiniteScroll: boolean;
|
|
42
43
|
infiniteScrollRef: import("react").RefObject<HTMLDivElement | null>;
|
|
44
|
+
sortable: boolean;
|
|
45
|
+
activeSort: import("..").IListSortState | null;
|
|
46
|
+
isSortable: (key: string) => boolean;
|
|
47
|
+
sortBy: (key: string) => void;
|
|
48
|
+
getAriaSort: (key: string) => "ascending" | "descending" | null;
|
|
49
|
+
getSortIndicator: (key: string) => string;
|
|
43
50
|
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { IEntity } from '@smartsoft001/domain-core';
|
|
2
2
|
import { SmartListModeProps } from '../list.types';
|
|
3
3
|
/**
|
|
4
|
-
* The mobile list: a stacked list with one paragraph per cell and the
|
|
5
|
-
* item buttons, the `top` component factory above it and the paging below it
|
|
4
|
+
* The mobile list: a stacked list with one paragraph per cell and the details /
|
|
5
|
+
* remove / item buttons, the `top` component factory above it and the paging below it
|
|
6
6
|
* (`PaginationMode.singlePage`).
|
|
7
7
|
*/
|
|
8
8
|
export declare function SmartListMobile<T extends IEntity<string>>(props: SmartListModeProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -10,20 +10,20 @@ const model_1 = require("../../../utils/model");
|
|
|
10
10
|
const paging_1 = require("../../paging/paging");
|
|
11
11
|
const use_list_1 = require("../use-list");
|
|
12
12
|
/**
|
|
13
|
-
* The mobile list: a stacked list with one paragraph per cell and the
|
|
14
|
-
* item buttons, the `top` component factory above it and the paging below it
|
|
13
|
+
* The mobile list: a stacked list with one paragraph per cell and the details /
|
|
14
|
+
* remove / item buttons, the `top` component factory above it and the paging below it
|
|
15
15
|
* (`PaginationMode.singlePage`).
|
|
16
16
|
*/
|
|
17
17
|
function SmartListMobile(props) {
|
|
18
18
|
const { options, className } = props;
|
|
19
19
|
const t = (0, hooks_1.useTranslate)();
|
|
20
|
-
const { list, keys, cellPipe, type, checkRemoveHandler, removeHandler, itemHandler, page, totalPages, handlePageChange, infiniteScroll, infiniteScrollRef, } = (0, use_list_1.useList)(props);
|
|
20
|
+
const { list, keys, cellPipe, type, checkRemoveHandler, removeHandler, itemHandler, detailsHandler, page, totalPages, handlePageChange, infiniteScroll, infiniteScrollRef, } = (0, use_list_1.useList)(props);
|
|
21
21
|
const Top = options.componentFactories?.top;
|
|
22
22
|
const mobileItems = list ?? [];
|
|
23
23
|
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { children: Top ? (0, jsx_runtime_1.jsx)(Top, {}) : null }), (0, jsx_runtime_1.jsx)("ul", { role: "list", className: (0, class_names_1.cn)('smart:divide-y smart:divide-gray-100 smart:dark:divide-white/10', className), children: mobileItems.map((item) => ((0, jsx_runtime_1.jsxs)("li", { className: "smart:flex smart:justify-between smart:gap-x-6 smart:py-5", children: [(0, jsx_runtime_1.jsx)("div", { className: "smart:flex smart:min-w-0 smart:gap-x-4", children: (0, jsx_runtime_1.jsx)("div", { className: "smart:min-w-0 smart:flex-auto", children: keys.map((key) => {
|
|
24
24
|
const cell = (0, model_1.getListCell)(item, key, cellPipe, type, t);
|
|
25
25
|
return cell ? ((0, jsx_runtime_1.jsx)("p", { className: "smart:text-sm smart:text-gray-900 smart:dark:text-white", dangerouslySetInnerHTML: (0, html_1.toInnerHtml)(cell.value) }, key)) : null;
|
|
26
|
-
}) }) }), (0, jsx_runtime_1.jsxs)("div", { className: "smart:flex smart:shrink-0 smart:items-center smart:gap-x-4", children: [removeHandler &&
|
|
26
|
+
}) }) }), (0, jsx_runtime_1.jsxs)("div", { className: "smart:flex smart:shrink-0 smart:items-center smart:gap-x-4", children: [detailsHandler ? ((0, jsx_runtime_1.jsx)("button", { type: "button", "data-role": "details", className: "smart:text-indigo-600 smart:hover:text-indigo-900 smart:dark:text-indigo-400 smart:dark:hover:text-indigo-300 smart:text-sm", onClick: () => detailsHandler(item), children: t('show') })) : null, removeHandler &&
|
|
27
27
|
(!checkRemoveHandler || checkRemoveHandler(item)) ? ((0, jsx_runtime_1.jsx)("button", { type: "button", className: "smart:text-red-600 smart:hover:text-red-900 smart:dark:text-red-400 smart:dark:hover:text-red-300 smart:text-sm", onClick: () => removeHandler?.(item), children: t('remove') })) : null, itemHandler ? ((0, jsx_runtime_1.jsx)("button", { type: "button", className: "smart:text-indigo-600 smart:hover:text-indigo-900 smart:dark:text-indigo-400 smart:dark:hover:text-indigo-300 smart:text-sm", onClick: () => itemHandler?.(item.id), children: "\u2192" })) : null] })] }, item.id))) }), options.pagination?.mode === models_1.PaginationMode.singlePage ? ((0, jsx_runtime_1.jsx)(paging_1.SmartPaging, { currentPage: page ?? 1, totalPages: totalPages ?? 1, onPageChange: handlePageChange })) : null, infiniteScroll ? ((0, jsx_runtime_1.jsx)("div", { ref: infiniteScrollRef, "data-role": "infinite-scroll", "aria-hidden": "true" })) : null] }));
|
|
28
28
|
}
|
|
29
29
|
//# sourceMappingURL=list-mobile.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list-mobile.js","sourceRoot":"","sources":["../../../../../../../../../packages/shared/react/src/lib/components/list/mobile/list-mobile.tsx"],"names":[],"mappings":";;AAgBA,
|
|
1
|
+
{"version":3,"file":"list-mobile.js","sourceRoot":"","sources":["../../../../../../../../../packages/shared/react/src/lib/components/list/mobile/list-mobile.tsx"],"names":[],"mappings":";;AAgBA,0CAyGC;;AAvHD,4CAAiD;AACjD,oDAAwD;AACxD,4DAAgD;AAChD,8CAAkD;AAClD,gDAAmD;AACnD,gDAAkD;AAElD,0CAAsC;AAEtC;;;;GAIG;AACH,SAAgB,eAAe,CAC7B,KAA4B;IAE5B,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,KAAK,CAAC;IACrC,MAAM,CAAC,GAAG,IAAA,oBAAY,GAAE,CAAC;IACzB,MAAM,EACJ,IAAI,EACJ,IAAI,EACJ,QAAQ,EACR,IAAI,EACJ,kBAAkB,EAClB,aAAa,EACb,WAAW,EACX,cAAc,EACd,IAAI,EACJ,UAAU,EACV,gBAAgB,EAChB,cAAc,EACd,iBAAiB,GAClB,GAAG,IAAA,kBAAO,EAAC,KAAK,CAAC,CAAC;IACnB,MAAM,GAAG,GAAG,OAAO,CAAC,kBAAkB,EAAE,GAAG,CAAC;IAC5C,MAAM,WAAW,GAAG,IAAI,IAAI,EAAE,CAAC;IAE/B,OAAO,CACL,6DACE,0CAAM,GAAG,CAAC,CAAC,CAAC,uBAAC,GAAG,KAAG,CAAC,CAAC,CAAC,IAAI,GAAO,EAEjC,+BACE,IAAI,EAAC,MAAM,EACX,SAAS,EAAE,IAAA,gBAAE,EACX,iEAAiE,EACjE,SAAS,CACV,YAEA,WAAW,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CACzB,gCAEE,SAAS,EAAC,2DAA2D,aAErE,gCAAK,SAAS,EAAC,wCAAwC,YACrD,gCAAK,SAAS,EAAC,+BAA+B,YAC3C,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EA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WAAW,EAAE,IAAI,IAAI,CAAC,EACtB,UAAU,EAAE,UAAU,IAAI,CAAC,EAC3B,YAAY,EAAE,gBAAgB,GAC9B,CACH,CAAC,CAAC,CAAC,IAAI,EACP,cAAc,CAAC,CAAC,CAAC,CAChB,gCACE,GAAG,EAAE,iBAAiB,eACZ,iBAAiB,iBACf,MAAM,GACb,CACR,CAAC,CAAC,CAAC,IAAI,IACP,CACJ,CAAC;AACJ,CAAC"}
|
|
@@ -23,7 +23,7 @@ function SmartListMobilePreset(props) {
|
|
|
23
23
|
const { options, className } = props;
|
|
24
24
|
const t = (0, hooks_1.useTranslate)();
|
|
25
25
|
const fileUrl = (0, use_list_1.useListFileUrl)();
|
|
26
|
-
const { list, keys, cellPipe, type, checkRemoveHandler, removeHandler, itemHandler, page, totalPages, handlePageChange, infiniteScroll, infiniteScrollRef, } = (0, use_list_1.useList)(props);
|
|
26
|
+
const { list, keys, cellPipe, type, checkRemoveHandler, removeHandler, itemHandler, detailsHandler, page, totalPages, handlePageChange, infiniteScroll, infiniteScrollRef, } = (0, use_list_1.useList)(props);
|
|
27
27
|
const Top = options.componentFactories?.top;
|
|
28
28
|
const presetItems = list ?? [];
|
|
29
29
|
const cardContainerClasses = (0, preset_classes_1.getCardContainerClasses)();
|
|
@@ -37,7 +37,7 @@ function SmartListMobilePreset(props) {
|
|
|
37
37
|
if (!cell || cell.type === models_1.FieldType.image)
|
|
38
38
|
return null;
|
|
39
39
|
return key === titleKey ? ((0, jsx_runtime_1.jsx)("h3", { "data-role": "card-title", className: "smart:font-semibold smart:text-gray-900 smart:dark:text-white", dangerouslySetInnerHTML: (0, html_1.toInnerHtml)(cell.value) }, key)) : ((0, jsx_runtime_1.jsx)("p", { "data-role": "card-text", className: "smart:mt-1 smart:text-gray-500 smart:dark:text-gray-400", dangerouslySetInnerHTML: (0, html_1.toInnerHtml)(cell.value) }, key));
|
|
40
|
-
}), (0, jsx_runtime_1.jsxs)("div", { className: "smart:flex smart:items-center smart:gap-x-4", children: [itemHandler ? ((0, jsx_runtime_1.jsx)("button", { type: "button", "data-role": "item", className: "smart:mt-2 smart:py-2 smart:px-3 smart:inline-flex smart:justify-center smart:items-center smart:gap-x-2 smart:text-sm smart:font-medium smart:rounded-lg smart:bg-blue-600 smart:dark:bg-blue-500 smart:text-white smart:hover:bg-blue-700 smart:dark:hover:bg-blue-600 smart:focus:outline-hidden", onClick: () => itemHandler?.(item.id), children: t('details') })) : null, removeHandler &&
|
|
40
|
+
}), (0, jsx_runtime_1.jsxs)("div", { className: "smart:flex smart:items-center smart:gap-x-4", children: [itemHandler ? ((0, jsx_runtime_1.jsx)("button", { type: "button", "data-role": "item", className: "smart:mt-2 smart:py-2 smart:px-3 smart:inline-flex smart:justify-center smart:items-center smart:gap-x-2 smart:text-sm smart:font-medium smart:rounded-lg smart:bg-blue-600 smart:dark:bg-blue-500 smart:text-white smart:hover:bg-blue-700 smart:dark:hover:bg-blue-600 smart:focus:outline-hidden", onClick: () => itemHandler?.(item.id), children: t('details') })) : null, detailsHandler ? ((0, jsx_runtime_1.jsx)("button", { type: "button", "data-role": "details", className: "smart:mt-2 smart:text-blue-600 smart:hover:text-blue-700 smart:dark:text-blue-400 smart:dark:hover:text-blue-300 smart:text-sm", onClick: () => detailsHandler(item), children: t('show') })) : null, removeHandler &&
|
|
41
41
|
(!checkRemoveHandler || checkRemoveHandler(item)) ? ((0, jsx_runtime_1.jsx)("button", { type: "button", "data-role": "remove", className: "smart:mt-2 smart:text-red-600 smart:hover:text-red-900 smart:dark:text-red-400 smart:dark:hover:text-red-300 smart:text-sm", onClick: () => removeHandler?.(item), children: t('remove') })) : null] })] })] }, item.id));
|
|
42
42
|
}) }), options.pagination?.mode === models_2.PaginationMode.singlePage ? ((0, jsx_runtime_1.jsx)(paging_1.SmartPaging, { currentPage: page ?? 1, totalPages: totalPages ?? 1, onPageChange: handlePageChange })) : null, infiniteScroll ? ((0, jsx_runtime_1.jsx)("div", { ref: infiniteScrollRef, "data-role": "infinite-scroll", "aria-hidden": "true" })) : null] }));
|
|
43
43
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list-mobile-preset.js","sourceRoot":"","sources":["../../../../../../../../../../packages/shared/react/src/lib/components/list/mobile/preset/list-mobile-preset.tsx"],"names":[],"mappings":";;AAqBA,
|
|
1
|
+
{"version":3,"file":"list-mobile-preset.js","sourceRoot":"","sources":["../../../../../../../../../../packages/shared/react/src/lib/components/list/mobile/preset/list-mobile-preset.tsx"],"names":[],"mappings":";;AAqBA,sDAoIC;;AAxJD,iDAAiD;AAEjD,+CAAoD;AACpD,uDAA2D;AAC3D,+DAAmD;AACnD,iDAAqD;AACrD,mDAAsD;AACtD,wEAA8E;AAC9E,mDAAqD;AACrD,yDAAuD;AAEvD,6CAAyD;AAEzD;;;;;;GAMG;AACH,SAAgB,qBAAqB,CACnC,KAA4B;IAE5B,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,KAAK,CAAC;IACrC,MAAM,CAAC,GAAG,IAAA,oBAAY,GAAE,CAAC;IACzB,MAAM,OAAO,GAAG,IAAA,yBAAc,GAAE,CAAC;IACjC,MAAM,EACJ,IAAI,EACJ,IAAI,EACJ,QAAQ,EACR,IAAI,EACJ,kBAAkB,EAClB,aAAa,EACb,WAAW,EACX,cAAc,EACd,IAAI,EACJ,UAAU,EACV,gBAAgB,EAChB,cAAc,EACd,iBAAiB,GAClB,GAAG,IAAA,kBAAO,EAAC,KAAK,CAAC,CAAC;IACnB,MAAM,GAAG,GAAG,OAAO,CAAC,kBAAkB,EAAE,GAAG,CAAC;IAC5C,MAAM,WAAW,GAAG,IAAI,IAAI,EAAE,CAAC;IAC/B,MAAM,oBAAoB,GAAG,IAAA,wCAAuB,GAAE,CAAC;IACvD,MAAM,QAAQ,GAAG,IAAA,gCAAe,EAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAE7C,OAAO,CACL,6DACE,0CAAM,GAAG,CAAC,CAAC,CAAC,uBAAC,GAAG,KAAG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BAAgB,GAC9B,CACH,CAAC,CAAC,CAAC,IAAI,EACP,cAAc,CAAC,CAAC,CAAC,CAChB,gCACE,GAAG,EAAE,iBAAiB,eACZ,iBAAiB,iBACf,MAAM,GACb,CACR,CAAC,CAAC,CAAC,IAAI,IACP,CACJ,CAAC;AACJ,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { IEntity } from '@smartsoft001/domain-core';
|
|
2
2
|
import { IFieldOptions } from '@smartsoft001/models';
|
|
3
|
+
import { IListSortState } from './list-sort';
|
|
3
4
|
import { SmartListModeProps } from './list.types';
|
|
4
5
|
import { IButtonOptions, IDetailsOptions } from '../../models';
|
|
5
6
|
/**
|
|
@@ -22,6 +23,13 @@ export declare function useListFileUrl(): (file: {
|
|
|
22
23
|
* With `pagination.mode === PaginationMode.infiniteScroll` and a next page,
|
|
23
24
|
* `infiniteScroll` is `true`: render an element with `infiniteScrollRef`
|
|
24
25
|
* after the items, and the next page loads when it scrolls into view.
|
|
26
|
+
*
|
|
27
|
+
* With `sort`, `sortBy(key)` sorts by a column (ascending, or the other
|
|
28
|
+
* direction for the active one) through
|
|
29
|
+
* `provider.getData({ offset: 0, sortBy, sortDesc })`; `activeSort`,
|
|
30
|
+
* `getAriaSort(key)` and `getSortIndicator(key)` describe it for the headers.
|
|
31
|
+
* With `details`, `detailsHandler(item)` opens the details of an item in a
|
|
32
|
+
* modal (`SmartDetailsPage`, or `details.component`).
|
|
25
33
|
*/
|
|
26
34
|
export declare function useList<T extends IEntity<string>>({ options, }: SmartListModeProps<T>): {
|
|
27
35
|
fields: {
|
|
@@ -45,6 +53,7 @@ export declare function useList<T extends IEntity<string>>({ options, }: SmartLi
|
|
|
45
53
|
itemHandler: ((id: string) => void) | null;
|
|
46
54
|
detailsComponent: import("react").ComponentType<any> | null;
|
|
47
55
|
detailsComponentProps: IDetailsOptions<T> | null;
|
|
56
|
+
detailsHandler: ((item: T) => void) | null;
|
|
48
57
|
select: ((id: string) => void) | undefined;
|
|
49
58
|
unselect: (() => void) | undefined;
|
|
50
59
|
detailsButtonOptions: IButtonOptions;
|
|
@@ -55,4 +64,10 @@ export declare function useList<T extends IEntity<string>>({ options, }: SmartLi
|
|
|
55
64
|
handlePageChange: (nextPage: number) => void;
|
|
56
65
|
infiniteScroll: boolean;
|
|
57
66
|
infiniteScrollRef: import("react").RefObject<HTMLDivElement | null>;
|
|
67
|
+
sortable: boolean;
|
|
68
|
+
activeSort: IListSortState | null;
|
|
69
|
+
isSortable: (key: string) => boolean;
|
|
70
|
+
sortBy: (key: string) => void;
|
|
71
|
+
getAriaSort: (key: string) => "ascending" | "descending" | null;
|
|
72
|
+
getSortIndicator: (key: string) => string;
|
|
58
73
|
};
|
|
@@ -3,8 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.useListFileUrl = useListFileUrl;
|
|
4
4
|
exports.useList = useList;
|
|
5
5
|
const react_1 = require("react");
|
|
6
|
+
const list_details_modal_1 = require("./list-details-modal");
|
|
7
|
+
const list_sort_1 = require("./list-sort");
|
|
6
8
|
const models_1 = require("../../models");
|
|
9
|
+
const details_page_1 = require("../../pages/details/details-page");
|
|
7
10
|
const hooks_1 = require("../../providers/hooks");
|
|
11
|
+
const store_1 = require("../../store/store");
|
|
8
12
|
const NO_FIELDS = [];
|
|
9
13
|
/**
|
|
10
14
|
* The column keys of the list: the fields the user may see (list
|
|
@@ -60,12 +64,20 @@ function getItemUrl(routingPrefix, id) {
|
|
|
60
64
|
* With `pagination.mode === PaginationMode.infiniteScroll` and a next page,
|
|
61
65
|
* `infiniteScroll` is `true`: render an element with `infiniteScrollRef`
|
|
62
66
|
* after the items, and the next page loads when it scrolls into view.
|
|
67
|
+
*
|
|
68
|
+
* With `sort`, `sortBy(key)` sorts by a column (ascending, or the other
|
|
69
|
+
* direction for the active one) through
|
|
70
|
+
* `provider.getData({ offset: 0, sortBy, sortDesc })`; `activeSort`,
|
|
71
|
+
* `getAriaSort(key)` and `getSortIndicator(key)` describe it for the headers.
|
|
72
|
+
* With `details`, `detailsHandler(item)` opens the details of an item in a
|
|
73
|
+
* modal (`SmartDetailsPage`, or `details.component`).
|
|
63
74
|
*/
|
|
64
75
|
function useList({ options, }) {
|
|
65
76
|
const t = (0, hooks_1.useTranslate)();
|
|
66
77
|
const authService = (0, hooks_1.useAuthService)();
|
|
67
78
|
const alertService = (0, hooks_1.useAlertService)();
|
|
68
79
|
const navigation = (0, hooks_1.useNavigation)();
|
|
80
|
+
const modalService = (0, hooks_1.useModalService)();
|
|
69
81
|
const fields = options.fields ?? NO_FIELDS;
|
|
70
82
|
const provider = options.provider;
|
|
71
83
|
const sort = options.sort ?? {};
|
|
@@ -129,7 +141,7 @@ function useList({ options, }) {
|
|
|
129
141
|
const detailsProvider = options.details ? details?.provider : undefined;
|
|
130
142
|
const detailsComponent = (options.details && details?.component) || null;
|
|
131
143
|
const detailsComponentProps = (0, react_1.useMemo)(() => {
|
|
132
|
-
if (!
|
|
144
|
+
if (!detailsProvider)
|
|
133
145
|
return null;
|
|
134
146
|
return {
|
|
135
147
|
item: detailsProvider.item,
|
|
@@ -140,7 +152,6 @@ function useList({ options, }) {
|
|
|
140
152
|
componentFactories: details?.componentFactories,
|
|
141
153
|
};
|
|
142
154
|
}, [
|
|
143
|
-
detailsComponent,
|
|
144
155
|
detailsProvider,
|
|
145
156
|
type,
|
|
146
157
|
itemHandler,
|
|
@@ -149,6 +160,60 @@ function useList({ options, }) {
|
|
|
149
160
|
]);
|
|
150
161
|
const select = detailsProvider?.getData;
|
|
151
162
|
const unselect = detailsProvider?.clearData;
|
|
163
|
+
// The details modal reads the options from here, so it follows the item
|
|
164
|
+
// the provider loads after the modal opened.
|
|
165
|
+
const [detailsStore] = (0, react_1.useState)(() => new store_1.SmartStore(null));
|
|
166
|
+
(0, react_1.useEffect)(() => {
|
|
167
|
+
detailsStore.set(detailsComponentProps);
|
|
168
|
+
}, [detailsStore, detailsComponentProps]);
|
|
169
|
+
const detailsHandler = (0, react_1.useMemo)(() => {
|
|
170
|
+
if (!detailsProvider)
|
|
171
|
+
return null;
|
|
172
|
+
return (item) => {
|
|
173
|
+
unselect?.();
|
|
174
|
+
void modalService
|
|
175
|
+
.show({
|
|
176
|
+
component: list_details_modal_1.SmartListDetailsModal,
|
|
177
|
+
props: {
|
|
178
|
+
component: detailsComponent ?? details_page_1.SmartDetailsPage,
|
|
179
|
+
store: detailsStore,
|
|
180
|
+
},
|
|
181
|
+
mode: 'bottom',
|
|
182
|
+
})
|
|
183
|
+
.then(() => select?.(item.id));
|
|
184
|
+
};
|
|
185
|
+
}, [
|
|
186
|
+
detailsProvider,
|
|
187
|
+
detailsComponent,
|
|
188
|
+
detailsStore,
|
|
189
|
+
modalService,
|
|
190
|
+
select,
|
|
191
|
+
unselect,
|
|
192
|
+
]);
|
|
193
|
+
const sortOption = options.sort;
|
|
194
|
+
const sortable = !!sortOption;
|
|
195
|
+
const [sortState, setSortState] = (0, react_1.useState)(() => ({ source: sortOption, value: (0, list_sort_1.getListDefaultSort)(sortOption) }));
|
|
196
|
+
let activeSort = sortState.value;
|
|
197
|
+
// A new `sort` option starts over from its default.
|
|
198
|
+
if (sortState.source !== sortOption) {
|
|
199
|
+
activeSort = (0, list_sort_1.getListDefaultSort)(sortOption);
|
|
200
|
+
setSortState({ source: sortOption, value: activeSort });
|
|
201
|
+
}
|
|
202
|
+
const isSortable = (0, react_1.useCallback)((key) => sortable && (0, list_sort_1.isListSortableKey)(key), [sortable]);
|
|
203
|
+
const sortBy = (0, react_1.useCallback)((key) => {
|
|
204
|
+
if (!isSortable(key))
|
|
205
|
+
return;
|
|
206
|
+
const next = (0, list_sort_1.getNextListSort)(activeSort, key);
|
|
207
|
+
const filter = {
|
|
208
|
+
offset: 0,
|
|
209
|
+
sortBy: next.key,
|
|
210
|
+
sortDesc: next.desc,
|
|
211
|
+
};
|
|
212
|
+
setSortState({ source: sortOption, value: next });
|
|
213
|
+
provider?.getData(filter);
|
|
214
|
+
}, [isSortable, activeSort, sortOption, provider]);
|
|
215
|
+
const getAriaSort = (0, react_1.useCallback)((key) => isSortable(key) ? (0, list_sort_1.getListAriaSort)(activeSort, key) : null, [isSortable, activeSort]);
|
|
216
|
+
const getSortIndicator = (0, react_1.useCallback)((key) => (0, list_sort_1.getListSortIndicator)(activeSort, key), [activeSort]);
|
|
152
217
|
const detailsButtonOptions = (0, react_1.useMemo)(() => ({
|
|
153
218
|
loading,
|
|
154
219
|
click: () => {
|
|
@@ -231,6 +296,7 @@ function useList({ options, }) {
|
|
|
231
296
|
itemHandler,
|
|
232
297
|
detailsComponent,
|
|
233
298
|
detailsComponentProps,
|
|
299
|
+
detailsHandler,
|
|
234
300
|
select,
|
|
235
301
|
unselect,
|
|
236
302
|
detailsButtonOptions,
|
|
@@ -241,6 +307,12 @@ function useList({ options, }) {
|
|
|
241
307
|
handlePageChange,
|
|
242
308
|
infiniteScroll,
|
|
243
309
|
infiniteScrollRef,
|
|
310
|
+
sortable,
|
|
311
|
+
activeSort,
|
|
312
|
+
isSortable,
|
|
313
|
+
sortBy,
|
|
314
|
+
getAriaSort,
|
|
315
|
+
getSortIndicator,
|
|
244
316
|
};
|
|
245
317
|
}
|
|
246
318
|
//# sourceMappingURL=use-list.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-list.js","sourceRoot":"","sources":["../../../../../../../../packages/shared/react/src/lib/components/list/use-list.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"use-list.js","sourceRoot":"","sources":["../../../../../../../../packages/shared/react/src/lib/components/list/use-list.ts"],"names":[],"mappings":";;AAgGA,wCASC;AA8BD,0BAsUC;AA7cD,iCAA0E;AAK1E,6DAA6D;AAC7D,2CAQqB;AAErB,yCAOsB;AACtB,mEAAoE;AACpE,iDAO+B;AAC/B,6CAA+C;AAU/C,MAAM,SAAS,GAAgB,EAAE,CAAC;AAElC;;;;;GAKG;AACH,SAAS,WAAW,CAClB,MAAmB,EACnB,IAAsB,EACtB,iB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jB,QAAQ;QACR,UAAU;QACV,UAAU;QACV,MAAM;QACN,WAAW;QACX,gBAAgB;KACjB,CAAC;AACJ,CAAC"}
|
|
@@ -6,6 +6,12 @@ const react_1 = require("react");
|
|
|
6
6
|
const class_names_1 = require("../../../utils/class-names");
|
|
7
7
|
const use_modal_1 = require("../use-modal");
|
|
8
8
|
const preset_classes_1 = require("./preset-classes");
|
|
9
|
+
/**
|
|
10
|
+
* The preset modals that are open, in the order they opened. Every open preset
|
|
11
|
+
* listens to Escape on the whole document, so with modals stacked only the one
|
|
12
|
+
* on top closes on it.
|
|
13
|
+
*/
|
|
14
|
+
const openModalLayers = [];
|
|
9
15
|
/**
|
|
10
16
|
* Styled modal variation (preset). Register it as `components.modal` on
|
|
11
17
|
* `SmartProvider` to restyle every `<SmartModal>`, or render it directly.
|
|
@@ -21,12 +27,19 @@ function SmartModalPreset(props) {
|
|
|
21
27
|
(0, react_1.useEffect)(() => {
|
|
22
28
|
if (!open)
|
|
23
29
|
return undefined;
|
|
30
|
+
// Escape closes only the modal on top when modals are stacked.
|
|
31
|
+
const layer = {};
|
|
32
|
+
openModalLayers.push(layer);
|
|
24
33
|
const onKeyDown = (event) => {
|
|
25
|
-
|
|
34
|
+
const onTop = openModalLayers[openModalLayers.length - 1] === layer;
|
|
35
|
+
if (onTop && (event.key === 'Escape' || event.key === 'Esc'))
|
|
26
36
|
close();
|
|
27
37
|
};
|
|
28
38
|
document.addEventListener('keydown', onKeyDown);
|
|
29
|
-
return () =>
|
|
39
|
+
return () => {
|
|
40
|
+
document.removeEventListener('keydown', onKeyDown);
|
|
41
|
+
openModalLayers.splice(openModalLayers.indexOf(layer), 1);
|
|
42
|
+
};
|
|
30
43
|
}, [open, close]);
|
|
31
44
|
if (!open)
|
|
32
45
|
return null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modal-preset.js","sourceRoot":"","sources":["../../../../../../../../../packages/shared/react/src/lib/components/modal/preset/modal-preset.tsx"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"modal-preset.js","sourceRoot":"","sources":["../../../../../../../../../packages/shared/react/src/lib/components/modal/preset/modal-preset.tsx"],"names":[],"mappings":";;AAmCA,4CAwHC;;AA3JD,iCAAkC;AAGlC,4DAAgD;AAEhD,4CAAwC;AACxC,qDAW0B;AAE1B;;;;GAIG;AACH,MAAM,eAAe,GAAa,EAAE,CAAC;AAErC;;;;;;;;GAQG;AACH,SAAgB,gBAAgB,CAAC,KAAsB;IACrD,MAAM,EACJ,KAAK,EACL,WAAW,EACX,OAAO,GAAG,EAAE,EACZ,OAAO,EACP,SAAS,EACT,QAAQ,GACT,GAAG,KAAK,CAAC;IACV,MAAM,EAAE,IAAI,EAAE,YAAY,EAAE,KAAK,EAAE,GAAG,IAAA,oBAAQ,EAAC,KAAK,CAAC,CAAC;IAEtD,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,IAAI,CAAC,IAAI;YAAE,OAAO,SAAS,CAAC;QAE5B,+DAA+D;QAC/D,MAAM,KAAK,GAAG,EAAE,CAAC;QAEjB,eAAe,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAE5B,MAAM,SAAS,GAAG,CAAC,KAAoB,EAAE,EAAE;YACzC,MAAM,KAAK,GAAG,eAAe,CAAC,eAAe,CAAC,MAAM,GAAG,CAAC,CAAC,KAAK,KAAK,CAAC;YAEpE,IAAI,KAAK,IAAI,CAAC,KAAK,CAAC,GAAG,KAAK,QAAQ,IAAI,KAAK,CAAC,GAAG,KAAK,KAAK,CAAC;gBAAE,KAAK,EAAE,CAAC;QACxE,CAAC,CAAC;QAEF,QAAQ,CAAC,gBAAgB,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;QAEhD,OAAO,GAAG,EAAE;YACV,QAAQ,CAAC,mBAAmB,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;YACnD,eAAe,CAAC,MAAM,CAAC,eAAe,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAA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AO,EAClB,OAAO,EAAE,KAAK,aAEd,iCAAM,SAAS,EAAC,eAAe,sBAAa,EAC5C,iCACE,SAAS,EAAC,6BAA6B,EACvC,KAAK,EAAC,4BAA4B,EAClC,KAAK,EAAC,IAAI,EACV,MAAM,EAAC,IAAI,EACX,OAAO,EAAC,WAAW,EACnB,IAAI,EAAC,MAAM,EACX,MAAM,EAAC,cAAc,EACrB,WAAW,EAAC,GAAG,EACf,aAAa,EAAC,OAAO,EACrB,cAAc,EAAC,OAAO,iBACV,MAAM,aAElB,iCAAM,CAAC,EAAC,YAAY,GAAG,EACvB,iCAAM,CAAC,EAAC,YAAY,GAAG,IACnB,IACC,CACV,IACG,CACP,EAED,iCAAK,SAAS,EAAE,2BAAU,aACvB,WAAW,IAAI,8BAAG,SAAS,EAAE,kCAAiB,YAAG,WAAW,GAAK,EACjE,QAAQ,IACL,EAEL,OAAO,CAAC,MAAM,GAAG,CAAC,IAAI,CACrB,gCAAK,SAAS,EAAE,IAAA,sCAAqB,EAAC,OAAO,EAAE,WAAW,CAAC,YACxD,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CACvB,mCAEE,IAAI,EAAC,QAAQ,EACb,SAAS,EAAE,IAAA,sCAAqB,EAAC,MAAM,CAAC,OAAO,CAAC,EAChD,OAAO,EAAE,GAAG,EAAE,CAAC,YAAY,CAAC,MAAM,CAAC,EAAE,CAAC,YAErC,MAAM,CAAC,KAAK,IALR,MAAM,CAAC,EAAE,CAMP,CACV,CAAC,GACE,CACP,IACG,GACF,GACF,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -24,11 +24,20 @@ exports.MODAL_BACKDROP = [
|
|
|
24
24
|
'smart:dark:bg-gray-900/80',
|
|
25
25
|
].join(' ');
|
|
26
26
|
const WRAPPER_BASE = ['smart:m-3', 'smart:sm:mx-auto'].join(' ');
|
|
27
|
+
// The bottom sheet is docked to the bottom edge of the viewport: full width on
|
|
28
|
+
// small screens, centred under its max width from `sm`.
|
|
29
|
+
const WRAPPER_BOTTOM_SHEET = [
|
|
30
|
+
'smart:fixed',
|
|
31
|
+
'smart:inset-x-0',
|
|
32
|
+
'smart:bottom-0',
|
|
33
|
+
'smart:sm:mx-auto',
|
|
34
|
+
].join(' ');
|
|
27
35
|
const WRAPPER_WIDTH_BY_VARIANT = {
|
|
28
36
|
centered: 'smart:sm:max-w-lg smart:sm:w-full',
|
|
29
37
|
wide: 'smart:lg:max-w-4xl smart:lg:w-full',
|
|
30
38
|
alert: 'smart:sm:max-w-md smart:sm:w-full',
|
|
31
39
|
'left-aligned-buttons': 'smart:sm:max-w-lg smart:sm:w-full',
|
|
40
|
+
'bottom-sheet': 'smart:w-full smart:sm:max-w-2xl',
|
|
32
41
|
};
|
|
33
42
|
// Vertically-centered variants need the flex + min-height treatment.
|
|
34
43
|
const WRAPPER_CENTERED = [
|
|
@@ -48,6 +57,25 @@ const PANEL_BASE = [
|
|
|
48
57
|
'smart:rounded-xl',
|
|
49
58
|
'smart:pointer-events-auto',
|
|
50
59
|
].join(' ');
|
|
60
|
+
// The sheet's panel: flush with the bottom edge (a top border only on small
|
|
61
|
+
// screens, rounded top corners from `sm`), at most 85% of the viewport high so
|
|
62
|
+
// the body scrolls, and padded by the bottom safe area of notched phones.
|
|
63
|
+
const PANEL_BOTTOM_SHEET = [
|
|
64
|
+
'smart:flex',
|
|
65
|
+
'smart:flex-col',
|
|
66
|
+
'smart:w-full',
|
|
67
|
+
'smart:max-h-[85dvh]',
|
|
68
|
+
'smart:pb-[env(safe-area-inset-bottom)]',
|
|
69
|
+
'smart:bg-white',
|
|
70
|
+
'smart:dark:bg-gray-800',
|
|
71
|
+
'smart:border-t',
|
|
72
|
+
'smart:sm:border-x',
|
|
73
|
+
'smart:border-gray-200',
|
|
74
|
+
'smart:dark:border-gray-700',
|
|
75
|
+
'smart:shadow-lg',
|
|
76
|
+
'smart:sm:rounded-t-xl',
|
|
77
|
+
'smart:pointer-events-auto',
|
|
78
|
+
].join(' ');
|
|
51
79
|
exports.MODAL_HEADER = [
|
|
52
80
|
'smart:flex',
|
|
53
81
|
'smart:justify-between',
|
|
@@ -99,11 +127,10 @@ const FOOTER_BASE = [
|
|
|
99
127
|
'smart:border-gray-200',
|
|
100
128
|
'smart:dark:border-gray-700',
|
|
101
129
|
].join(' ');
|
|
102
|
-
const FOOTER_GRAY = [
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
].join(' ');
|
|
130
|
+
const FOOTER_GRAY = ['smart:bg-gray-50', 'smart:dark:bg-gray-800/50'].join(' ');
|
|
131
|
+
// The gray footer follows the rounded bottom corners of the card; the bottom
|
|
132
|
+
// sheet has none.
|
|
133
|
+
const FOOTER_GRAY_ROUNDED = 'smart:rounded-b-xl';
|
|
107
134
|
const ACTION_BASE = [
|
|
108
135
|
'smart:py-2',
|
|
109
136
|
'smart:px-3',
|
|
@@ -125,9 +152,12 @@ const ACTION_BY_VARIANT = {
|
|
|
125
152
|
function isCentered(variant) {
|
|
126
153
|
return variant === 'centered' || variant === 'alert';
|
|
127
154
|
}
|
|
155
|
+
function isBottomSheet(variant) {
|
|
156
|
+
return variant === 'bottom-sheet';
|
|
157
|
+
}
|
|
128
158
|
function getModalWrapperClasses(variant) {
|
|
129
159
|
return [
|
|
130
|
-
WRAPPER_BASE,
|
|
160
|
+
isBottomSheet(variant) ? WRAPPER_BOTTOM_SHEET : WRAPPER_BASE,
|
|
131
161
|
WRAPPER_WIDTH_BY_VARIANT[variant],
|
|
132
162
|
isCentered(variant) ? WRAPPER_CENTERED : '',
|
|
133
163
|
]
|
|
@@ -135,6 +165,8 @@ function getModalWrapperClasses(variant) {
|
|
|
135
165
|
.join(' ');
|
|
136
166
|
}
|
|
137
167
|
function getModalPanelClasses(variant) {
|
|
168
|
+
if (isBottomSheet(variant))
|
|
169
|
+
return PANEL_BOTTOM_SHEET;
|
|
138
170
|
// Centered wrappers stretch the panel to the wrapper width.
|
|
139
171
|
return [PANEL_BASE, isCentered(variant) ? 'smart:w-full' : '']
|
|
140
172
|
.filter(Boolean)
|
|
@@ -144,7 +176,13 @@ function getModalFooterClasses(variant, footerStyle) {
|
|
|
144
176
|
const alignment = variant === 'left-aligned-buttons'
|
|
145
177
|
? 'smart:justify-start'
|
|
146
178
|
: 'smart:justify-end';
|
|
147
|
-
|
|
179
|
+
const gray = footerStyle === 'gray';
|
|
180
|
+
return [
|
|
181
|
+
FOOTER_BASE,
|
|
182
|
+
alignment,
|
|
183
|
+
gray ? FOOTER_GRAY : '',
|
|
184
|
+
gray && !isBottomSheet(variant) ? FOOTER_GRAY_ROUNDED : '',
|
|
185
|
+
]
|
|
148
186
|
.filter(Boolean)
|
|
149
187
|
.join(' ');
|
|
150
188
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"preset-classes.js","sourceRoot":"","sources":["../../../../../../../../../packages/shared/react/src/lib/components/modal/preset/preset-classes.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"preset-classes.js","sourceRoot":"","sources":["../../../../../../../../../packages/shared/react/src/lib/components/modal/preset/preset-classes.ts"],"names":[],"mappings":";;;AAmLA,wDAQC;AAED,oDAOC;AAED,sDAkBC;AAED,sDAIC;AAxND;;;;;;;GAOG;AAEH,8DAA8D;AACjD,QAAA,cAAc,GAAG;IAC5B,aAAa;IACb,eAAe;IACf,cAAc;IACd,yBAAyB;IACzB,uBAAuB;IACvB,sBAAsB;IACtB,2BAA2B;CAC5B,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAEZ,MAAM,YAAY,GAAG,CAAC,WAAW,EAAE,kBAAkB,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAEjE,+EAA+E;AAC/E,wDAAwD;AACxD,MAAM,oBAAoB,GAAG;IAC3B,aAAa;IACb,iBAAiB;IACjB,gBAAgB;IAChB,kBAAkB;CACnB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAEZ,MAAM,wBAAwB,GAAsC;IAClE,QAAQ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2,6 +2,7 @@ import { SmartModalProps } from '../modal.types';
|
|
|
2
2
|
/**
|
|
3
3
|
* The default modal rendering: a native `<dialog>` always in the DOM, shown
|
|
4
4
|
* through its `open` attribute (not `showModal()`). Its native `close` event
|
|
5
|
-
* closes the modal as well.
|
|
5
|
+
* closes the modal as well. `options.variant` is exposed as `data-variant`;
|
|
6
|
+
* the `bottom-sheet` variant docks the dialog to the bottom of the viewport.
|
|
6
7
|
*/
|
|
7
8
|
export declare function SmartModalStandard(props: SmartModalProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -2,15 +2,39 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SmartModalStandard = SmartModalStandard;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const class_names_1 = require("../../../utils/class-names");
|
|
5
6
|
const use_modal_1 = require("../use-modal");
|
|
7
|
+
/**
|
|
8
|
+
* Minimal positioning of the `bottom-sheet` variant on the native dialog:
|
|
9
|
+
* docked to the bottom of the viewport, full width (centred under a max width
|
|
10
|
+
* from `sm`, with rounded top corners), at most 85% of the viewport high with
|
|
11
|
+
* its own scroll. The other variants keep the browser's dialog layout.
|
|
12
|
+
*/
|
|
13
|
+
const BOTTOM_SHEET_CLASSES = [
|
|
14
|
+
'smart:fixed',
|
|
15
|
+
'smart:inset-x-0',
|
|
16
|
+
'smart:top-auto',
|
|
17
|
+
'smart:bottom-0',
|
|
18
|
+
'smart:z-[80]',
|
|
19
|
+
'smart:m-0',
|
|
20
|
+
'smart:w-full',
|
|
21
|
+
'smart:max-w-none',
|
|
22
|
+
'smart:max-h-[85dvh]',
|
|
23
|
+
'smart:overflow-y-auto',
|
|
24
|
+
'smart:sm:mx-auto',
|
|
25
|
+
'smart:sm:max-w-2xl',
|
|
26
|
+
'smart:sm:rounded-t-xl',
|
|
27
|
+
];
|
|
6
28
|
/**
|
|
7
29
|
* The default modal rendering: a native `<dialog>` always in the DOM, shown
|
|
8
30
|
* through its `open` attribute (not `showModal()`). Its native `close` event
|
|
9
|
-
* closes the modal as well.
|
|
31
|
+
* closes the modal as well. `options.variant` is exposed as `data-variant`;
|
|
32
|
+
* the `bottom-sheet` variant docks the dialog to the bottom of the viewport.
|
|
10
33
|
*/
|
|
11
34
|
function SmartModalStandard(props) {
|
|
12
35
|
const { title, description, actions = [], options, className, children, } = props;
|
|
13
36
|
const { open, invokeAction, close } = (0, use_modal_1.useModal)(props);
|
|
14
|
-
|
|
37
|
+
const bottomSheet = options?.variant === 'bottom-sheet';
|
|
38
|
+
return ((0, jsx_runtime_1.jsxs)("dialog", { open: open, className: (0, class_names_1.cn)(bottomSheet && BOTTOM_SHEET_CLASSES, className) || undefined, "data-variant": options?.variant, role: "dialog", "aria-modal": "true", "aria-labelledby": title ? 'smart-modal-title' : undefined, "aria-label": !title ? (options?.ariaLabel ?? undefined) : undefined, onClose: close, children: [options?.withDismiss && ((0, jsx_runtime_1.jsx)("button", { type: "button", className: "smart-modal-dismiss", "aria-label": "Close", onClick: close, children: "\u00D7" })), title && (0, jsx_runtime_1.jsx)("h2", { id: "smart-modal-title", children: title }), description && (0, jsx_runtime_1.jsx)("p", { children: description }), children, actions.length > 0 && ((0, jsx_runtime_1.jsx)("footer", { children: actions.map((action) => ((0, jsx_runtime_1.jsx)("button", { type: "button", "data-variant": action.variant ?? 'primary', onClick: () => invokeAction(action.id), children: action.label }, action.id))) }))] }));
|
|
15
39
|
}
|
|
16
40
|
//# sourceMappingURL=modal-standard.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modal-standard.js","sourceRoot":"","sources":["../../../../../../../../../packages/shared/react/src/lib/components/modal/standard/modal-standard.tsx"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"modal-standard.js","sourceRoot":"","sources":["../../../../../../../../../packages/shared/react/src/lib/components/modal/standard/modal-standard.tsx"],"names":[],"mappings":";;AAgCA,gDAsDC;;AAtFD,4DAAgD;AAEhD,4C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ACrB,6CACG,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CACvB,mCAEE,IAAI,EAAC,QAAQ,kBACC,MAAM,CAAC,OAAO,IAAI,SAAS,EACzC,OAAO,EAAE,GAAG,EAAE,CAAC,YAAY,CAAC,MAAM,CAAC,EAAE,CAAC,YAErC,MAAM,CAAC,KAAK,IALR,MAAM,CAAC,EAAE,CAMP,CACV,CAAC,GACK,CACV,IACM,CACV,CAAC;AACJ,CAAC"}
|
|
@@ -1,11 +1,20 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/**
|
|
2
|
+
* The toasts of `ToastService`, rendered through `<SmartNotification>` in a
|
|
3
|
+
* stack fixed to the bottom of the viewport, above the modals. A toast shows
|
|
4
|
+
* its title with the message under it, or the message alone; its buttons are
|
|
5
|
+
* the notification's actions, each running its handler and closing the toast.
|
|
6
|
+
* Error toasts are announced assertively, info toasts politely.
|
|
7
|
+
*/
|
|
2
8
|
export declare function SmartToastHost(): import("react/jsx-runtime").JSX.Element | null;
|
|
3
9
|
/** The dialogs `AlertService.show` opened, rendered through `<SmartAlert>`. */
|
|
4
10
|
export declare function SmartAlertHost(): import("react/jsx-runtime").JSX.Element | null;
|
|
5
11
|
/**
|
|
6
|
-
* The components `ModalService.show` opened, each in a `<SmartModal
|
|
7
|
-
* component gets its `props` and a
|
|
8
|
-
* modal with a result.
|
|
12
|
+
* The components `ModalService.show` opened, each in a `<SmartModal>` with its
|
|
13
|
+
* close button, the last one on top. The component gets its `props` and a
|
|
14
|
+
* `dismiss(data)` prop that closes the modal with a result. `mode: 'bottom'`
|
|
15
|
+
* renders the `'bottom-sheet'` variant; `cssClass` (and `smart-modal-bottom`
|
|
16
|
+
* for `mode: 'bottom'`) goes on the modal; with `backdropDismiss: false` a
|
|
17
|
+
* click on the backdrop leaves it open.
|
|
9
18
|
*/
|
|
10
19
|
export declare function SmartModalHost(): import("react/jsx-runtime").JSX.Element | null;
|
|
11
20
|
/**
|