@smartsoft001/react 2.203.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/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 +11 -4
- package/src/lib/components/overlays/overlays.js +47 -11
- package/src/lib/components/overlays/overlays.js.map +1 -1
- package/src/lib/models/interfaces.d.ts +1 -1
- package/src/lib/services/modal/modal.service.d.ts +5 -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 +27 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@smartsoft001/react",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.204.0",
|
|
4
4
|
"type": "commonjs",
|
|
5
5
|
"description": "A metadata-driven React UI library: Smart* components, the provider, services and hooks behind them, and the form factory that turns model metadata into a form.",
|
|
6
6
|
"publishConfig": {
|
|
@@ -15,9 +15,9 @@
|
|
|
15
15
|
"moment": "^2.31.0"
|
|
16
16
|
},
|
|
17
17
|
"peerDependencies": {
|
|
18
|
-
"@smartsoft001/domain-core": "2.
|
|
19
|
-
"@smartsoft001/models": "2.
|
|
20
|
-
"@smartsoft001/utils": "2.
|
|
18
|
+
"@smartsoft001/domain-core": "2.204.0",
|
|
19
|
+
"@smartsoft001/models": "2.204.0",
|
|
20
|
+
"@smartsoft001/utils": "2.204.0",
|
|
21
21
|
"react": "^19.0.0",
|
|
22
22
|
"react-dom": "^19.0.0",
|
|
23
23
|
"reflect-metadata": "^0.2.1"
|
|
@@ -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,C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C,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,EAAE;KAC3D;SACE,MAAM,CAAC,OAAO,CAAC;SACf,IAAI,CAAC,GAAG,CAAC,CAAC;AACf,CAAC;AAED,SAAgB,qBAAqB,CACnC,UAAmC,SAAS;IAE5C,OAAO,GAAG,WAAW,IAAI,iBAAiB,CAAC,OAAO,CAAC,EAAE,CAAC;AACxD,CAAC"}
|
|
@@ -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,4CAAwC;AAExC;;;;;GAKG;AACH,MAAM,oBAAoB,GAAG;IAC3B,aAAa;IACb,iBAAiB;IACjB,gBAAgB;IAChB,gBAAgB;IAChB,cAAc;IACd,WAAW;IACX,cAAc;IACd,kBAAkB;IAClB,qBAAqB;IACrB,uBAAuB;IACvB,kBAAkB;IAClB,oBAAoB;IACpB,uBAAuB;CACxB,CAAC;AAEF;;;;;GAKG;AACH,SAAgB,kBAAkB,CAAC,KAAsB;IACvD,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;IACtD,MAAM,WAAW,GAAG,OAAO,EAAE,OAAO,KAAK,cAAc,CAAC;IAExD,OAAO,CACL,oCACE,IAAI,EAAE,IAAI,EACV,SAAS,EACP,IAAA,gBAAE,EAAC,WAAW,IAAI,oBAAoB,EAAE,SAAS,CAAC,IAAI,SAAS,kBAEnD,OAAO,EAAE,OAAO,EAC9B,IAAI,EAAC,QAAQ,gBACF,MAAM,qBACA,KAAK,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,SAAS,gBAC5C,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,SAAS,IAAI,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,EAClE,OAAO,EAAE,KAAK,aAEb,OAAO,EAAE,WAAW,IAAI,CACvB,mCACE,IAAI,EAAC,QAAQ,EACb,SAAS,EAAC,qBAAqB,gBACpB,OAAO,EAClB,OAAO,EAAE,KAAK,uBAGP,CACV,EACA,KAAK,IAAI,+BAAI,EAAE,EAAC,mBAAmB,YAAE,KAAK,GAAM,EAChD,WAAW,IAAI,wCAAI,WAAW,GAAK,EACnC,QAAQ,EACR,OAAO,CAAC,MAAM,GAAG,CAAC,IAAI,CACrB,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,13 +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
12
|
* The components `ModalService.show` opened, each in a `<SmartModal>` with its
|
|
7
13
|
* close button, the last one on top. The component gets its `props` and a
|
|
8
|
-
* `dismiss(data)` prop that closes the modal with a result. `
|
|
9
|
-
*
|
|
10
|
-
* `
|
|
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.
|
|
11
18
|
*/
|
|
12
19
|
export declare function SmartModalHost(): import("react/jsx-runtime").JSX.Element | null;
|
|
13
20
|
/**
|
|
@@ -21,19 +21,47 @@ function BodyPortal({ children }) {
|
|
|
21
21
|
return null;
|
|
22
22
|
return (0, react_dom_1.createPortal)(children, document.body);
|
|
23
23
|
}
|
|
24
|
-
/**
|
|
24
|
+
/**
|
|
25
|
+
* The notification variant of a toast: `simple` without buttons (it renders no
|
|
26
|
+
* actions), `condensed` for a message with buttons, `with-actions-below` for a
|
|
27
|
+
* title, its message and buttons (`condensed` would drop the message).
|
|
28
|
+
*/
|
|
29
|
+
function getToastVariant(toast) {
|
|
30
|
+
if (!toast.buttons?.length)
|
|
31
|
+
return 'simple';
|
|
32
|
+
return toast.title ? 'with-actions-below' : 'condensed';
|
|
33
|
+
}
|
|
34
|
+
/** The buttons of a toast as notification actions, keyed by their index. */
|
|
35
|
+
function getToastActions(toast) {
|
|
36
|
+
return toast.buttons?.map((button, index) => ({
|
|
37
|
+
id: String(index),
|
|
38
|
+
label: button.text,
|
|
39
|
+
}));
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* The toasts of `ToastService`, rendered through `<SmartNotification>` in a
|
|
43
|
+
* stack fixed to the bottom of the viewport, above the modals. A toast shows
|
|
44
|
+
* its title with the message under it, or the message alone; its buttons are
|
|
45
|
+
* the notification's actions, each running its handler and closing the toast.
|
|
46
|
+
* Error toasts are announced assertively, info toasts politely.
|
|
47
|
+
*/
|
|
25
48
|
function SmartToastHost() {
|
|
26
49
|
const { toastService } = (0, smart_context_1.useSmart)();
|
|
27
50
|
const toasts = (0, store_1.useStore)(toastService.toasts);
|
|
28
51
|
if (!toasts.length)
|
|
29
52
|
return null;
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
53
|
+
const runAction = (toast, actionId) => {
|
|
54
|
+
try {
|
|
55
|
+
toast.buttons?.[Number(actionId)]?.handler();
|
|
56
|
+
}
|
|
57
|
+
finally {
|
|
58
|
+
toastService.dismiss(toast.id);
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
return ((0, jsx_runtime_1.jsx)(BodyPortal, { children: (0, jsx_runtime_1.jsx)("div", { className: "smart:pointer-events-none smart:fixed smart:inset-x-0 smart:bottom-0 smart:z-[100] smart:flex smart:flex-col smart:items-center smart:gap-2 smart:p-4 smart:sm:items-end", "data-role": "toasts", children: toasts.map((toast) => ((0, jsx_runtime_1.jsx)("div", { className: "smart:pointer-events-auto smart:w-full smart:max-w-sm", "data-type": toast.type, children: (0, jsx_runtime_1.jsx)(notification_1.SmartNotification, { title: toast.title || toast.message, description: toast.title ? toast.message : undefined, dismissible: true, actions: getToastActions(toast), options: {
|
|
62
|
+
variant: getToastVariant(toast),
|
|
35
63
|
ariaLive: toast.type === 'error' ? 'assertive' : 'polite',
|
|
36
|
-
}, onActionClick: ({ actionId }) => toast
|
|
64
|
+
}, onActionClick: ({ actionId }) => runAction(toast, actionId), onDismissed: () => toastService.dismiss(toast.id) }) }, toast.id))) }) }));
|
|
37
65
|
}
|
|
38
66
|
/** The dialogs `AlertService.show` opened, rendered through `<SmartAlert>`. */
|
|
39
67
|
function SmartAlertHost() {
|
|
@@ -45,6 +73,11 @@ function SmartAlertHost() {
|
|
|
45
73
|
}
|
|
46
74
|
/** The modals of `ModalService` show their close button. */
|
|
47
75
|
const MODAL_HOST_OPTIONS = { withDismiss: true };
|
|
76
|
+
/** `mode: 'bottom'`: the bottom sheet, with its close button. */
|
|
77
|
+
const MODAL_HOST_BOTTOM_SHEET_OPTIONS = {
|
|
78
|
+
withDismiss: true,
|
|
79
|
+
variant: 'bottom-sheet',
|
|
80
|
+
};
|
|
48
81
|
/**
|
|
49
82
|
* With `backdropDismiss: false`, stops a click that lands in the modal but
|
|
50
83
|
* outside its dialog (the backdrop) before the modal sees it.
|
|
@@ -59,9 +92,10 @@ function keepOpenOnBackdrop(request, event) {
|
|
|
59
92
|
/**
|
|
60
93
|
* The components `ModalService.show` opened, each in a `<SmartModal>` with its
|
|
61
94
|
* close button, the last one on top. The component gets its `props` and a
|
|
62
|
-
* `dismiss(data)` prop that closes the modal with a result. `
|
|
63
|
-
*
|
|
64
|
-
* `
|
|
95
|
+
* `dismiss(data)` prop that closes the modal with a result. `mode: 'bottom'`
|
|
96
|
+
* renders the `'bottom-sheet'` variant; `cssClass` (and `smart-modal-bottom`
|
|
97
|
+
* for `mode: 'bottom'`) goes on the modal; with `backdropDismiss: false` a
|
|
98
|
+
* click on the backdrop leaves it open.
|
|
65
99
|
*/
|
|
66
100
|
function SmartModalHost() {
|
|
67
101
|
const { modalService } = (0, smart_context_1.useSmart)();
|
|
@@ -71,7 +105,9 @@ function SmartModalHost() {
|
|
|
71
105
|
return ((0, jsx_runtime_1.jsx)(BodyPortal, { children: modals.map((request) => {
|
|
72
106
|
const { id, component: Component, props, dismiss, cssClass, mode, } = request;
|
|
73
107
|
return ((0, jsx_runtime_1.jsx)("div", { className: "smart:contents", "data-role": "modal", "data-mode": mode ?? 'default', onClickCapture: (event) => keepOpenOnBackdrop(request, event), children: (0, jsx_runtime_1.jsx)(modal_1.SmartModal, { open: true, className: (0, class_names_1.cn)(cssClass, mode === 'bottom' && 'smart-modal-bottom') ||
|
|
74
|
-
undefined, options:
|
|
108
|
+
undefined, options: mode === 'bottom'
|
|
109
|
+
? MODAL_HOST_BOTTOM_SHEET_OPTIONS
|
|
110
|
+
: MODAL_HOST_OPTIONS, onClosed: () => dismiss(), children: (0, jsx_runtime_1.jsx)(Component, { ...(props ?? {}), dismiss: dismiss }) }) }, id));
|
|
75
111
|
}) }));
|
|
76
112
|
}
|
|
77
113
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"overlays.js","sourceRoot":"","sources":["../../../../../../../../packages/shared/react/src/lib/components/overlays/overlays.tsx"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"overlays.js","sourceRoot":"","sources":["../../../../../../../../packages/shared/react/src/lib/components/overlays/overlays.tsx"],"names":[],"mappings":";;AAuDA,wCA2CC;AAGD,wCAiBC;AAkCD,wCA8CC;AAMD,sCAQC;;AApND,iCAA4C;AAE5C,yCAAyC;AAOzC,iEAAyD;AAGzD,6CAA6C;AAC7C,yDAA6C;AAC7C,0CAA4C;AAC5C,0CAA4C;AAC5C,+DAAiE;AAEjE,8EAA8E;AAC9E,SAAS,UAAU,CAAC,EAAE,QAAQ,EAA2B;IACvD,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,IAAA,gBAAQ,EAAC,KAAK,CAAC,CAAC;IAE9C,IAAA,iBAAS,EAAC,GAAG,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC;IAEtC,IAAI,CAAC,OAAO,IAAI,OAAO,QAAQ,KAAK,WAAW;QAAE,OAAO,IAAI,CAAC;IAE7D,OAAO,IAAA,wBAAY,EAAC,QAAQ,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC;AAC/C,CAAC;AAED;;;;GAIG;AACH,SAAS,eAAe,CAAC,KAAa;IACpC,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,MAAM;QAAE,OAAO,QAAQ,CAAC;IAE5C,OAAO,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC,WAAW,CAAC;AAC1D,CAAC;AAED,4EAA4E;AAC5E,SAAS,eAAe,CAAC,KAAa;IACpC,OAAO,KAAK,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC;QAC5C,EAAE,EAAE,MAAM,CAAC,KAAK,CAAC;QACjB,KAAK,EAAE,MAAM,CAAC,IAAI;KACnB,CAAC,CAAC,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G,IAAA,gBAAQ,EAAC,YAAY,CAAC,MAAM,CAAC,CAAC;IAE7C,IAAI,CAAC,MAAM,CAAC,MAAM;QAAE,OAAO,IAAI,CAAC;IAEhC,OAAO,CACL,uBAAC,UAAU,cACR,MAAM,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE;YACtB,MAAM,EACJ,EAAE,EACF,SAAS,EAAE,SAAS,EACpB,KAAK,EACL,OAAO,EACP,QAAQ,EACR,IAAI,GACL,GAAG,OAAO,CAAC;YAEZ,OAAO,CACL,gCAEE,SAAS,EAAC,gBAAgB,eAChB,OAAO,eACN,IAAI,IAAI,SAAS,EAC5B,cAAc,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,kBAAkB,CAAC,OAAO,EAAE,KAAK,CAAC,YAE7D,uBAAC,kBAAU,IACT,IAAI,QACJ,SAAS,EACP,IAAA,gBAAE,EAAC,QAAQ,EAAE,IAAI,KAAK,QAAQ,IAAI,oBAAoB,CAAC;wBACvD,SAAS,EAEX,OAAO,EACL,IAAI,KAAK,QAAQ;wBACf,CAAC,CAAC,+BAA+B;wBACjC,CAAC,CAAC,kBAAkB,EAExB,QAAQ,EAAE,GAAG,EAAE,CAAC,OAAO,EAAE,YAEzB,uBAAC,SAAS,OAAK,CAAC,KAAK,IAAI,EAAE,CAAC,EAAE,OAAO,EAAE,OAAO,GAAI,GACvC,IApBR,EAAE,CAqBH,CACP,CAAC;QACJ,CAAC,CAAC,GACS,CACd,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,SAAgB,aAAa;IAC3B,OAAO,CACL,6DACE,uBAAC,cAAc,KAAG,EAClB,uBAAC,cAAc,KAAG,EAClB,uBAAC,cAAc,KAAG,IACjB,CACJ,CAAC;AACJ,CAAC"}
|
|
@@ -338,7 +338,7 @@ export interface ICommandPaletteOptions {
|
|
|
338
338
|
emptyText?: string;
|
|
339
339
|
ariaLabel?: string;
|
|
340
340
|
}
|
|
341
|
-
export type SmartModalVariant = 'centered' | 'wide' | 'alert' | 'left-aligned-buttons';
|
|
341
|
+
export type SmartModalVariant = 'centered' | 'wide' | 'alert' | 'left-aligned-buttons' | 'bottom-sheet';
|
|
342
342
|
export type SmartModalActionVariant = 'primary' | 'secondary' | 'danger';
|
|
343
343
|
export type SmartModalFooterStyle = 'default' | 'gray';
|
|
344
344
|
export interface IModalAction {
|
|
@@ -4,7 +4,11 @@ export interface IModalServiceOptions {
|
|
|
4
4
|
/** Rendered in the modal with `props` and a `dismiss(data)` prop. */
|
|
5
5
|
component: ComponentType<any>;
|
|
6
6
|
props?: Record<string, unknown>;
|
|
7
|
-
/**
|
|
7
|
+
/**
|
|
8
|
+
* `'bottom'` opens the modal as a bottom sheet (the `'bottom-sheet'` modal
|
|
9
|
+
* variant: docked to the bottom of the viewport, full width up to a max
|
|
10
|
+
* width) and adds the `smart-modal-bottom` class to it.
|
|
11
|
+
*/
|
|
8
12
|
mode?: 'default' | 'bottom';
|
|
9
13
|
/** Classes added to the modal (`<SmartModal className>`). */
|
|
10
14
|
cssClass?: string[];
|
|
@@ -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;AA+BzC;;;;;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,GAA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oC;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"}
|
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
import { SmartStore } from '../../store';
|
|
2
2
|
export interface IToastButton {
|
|
3
3
|
text: string;
|
|
4
|
+
/** Kept for compatibility; the actions render in the order given. */
|
|
4
5
|
position: 'start' | 'end';
|
|
6
|
+
/** Runs on a click on the button; the toast closes afterwards. */
|
|
5
7
|
handler: () => void;
|
|
6
8
|
}
|
|
7
9
|
export interface IToastOptions {
|
|
8
10
|
title?: string;
|
|
9
11
|
message: string;
|
|
10
|
-
/**
|
|
12
|
+
/**
|
|
13
|
+
* Milliseconds before the toast closes itself; 2000 when it is missing,
|
|
14
|
+
* zero or negative.
|
|
15
|
+
*/
|
|
11
16
|
duration?: number;
|
|
12
17
|
buttons?: Array<IToastButton>;
|
|
13
18
|
}
|
|
@@ -17,9 +22,11 @@ export interface IToast extends IToastOptions {
|
|
|
17
22
|
}
|
|
18
23
|
/**
|
|
19
24
|
* Short messages shown at the bottom of the screen. `SmartProvider` renders
|
|
20
|
-
* the queue; any code with the service can push to it.
|
|
21
|
-
*
|
|
22
|
-
*
|
|
25
|
+
* the queue; any code with the service can push to it. A toast closes itself
|
|
26
|
+
* after its `duration`, on its close button or after one of its buttons ran
|
|
27
|
+
* its handler. Error toasts are announced assertively, info toasts politely.
|
|
28
|
+
* While an error lock is held (`addLockError`), error toasts are swallowed,
|
|
29
|
+
* e.g. during a sign-out that makes every pending request fail.
|
|
23
30
|
*/
|
|
24
31
|
export declare class ToastService {
|
|
25
32
|
readonly toasts: SmartStore<IToast[]>;
|
|
@@ -27,6 +34,7 @@ export declare class ToastService {
|
|
|
27
34
|
private nextId;
|
|
28
35
|
private readonly timers;
|
|
29
36
|
addLockError(): void;
|
|
37
|
+
/** Releases one error lock; the count does not go below zero. */
|
|
30
38
|
removeLockError(): void;
|
|
31
39
|
error(config: IToastOptions): Promise<void>;
|
|
32
40
|
info(config: IToastOptions): Promise<void>;
|
|
@@ -2,11 +2,15 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ToastService = void 0;
|
|
4
4
|
const store_1 = require("../../store");
|
|
5
|
+
/** Milliseconds a toast stays without a positive `duration`. */
|
|
6
|
+
const DEFAULT_TOAST_DURATION = 2000;
|
|
5
7
|
/**
|
|
6
8
|
* Short messages shown at the bottom of the screen. `SmartProvider` renders
|
|
7
|
-
* the queue; any code with the service can push to it.
|
|
8
|
-
*
|
|
9
|
-
*
|
|
9
|
+
* the queue; any code with the service can push to it. A toast closes itself
|
|
10
|
+
* after its `duration`, on its close button or after one of its buttons ran
|
|
11
|
+
* its handler. Error toasts are announced assertively, info toasts politely.
|
|
12
|
+
* While an error lock is held (`addLockError`), error toasts are swallowed,
|
|
13
|
+
* e.g. during a sign-out that makes every pending request fail.
|
|
10
14
|
*/
|
|
11
15
|
class ToastService {
|
|
12
16
|
toasts = new store_1.SmartStore([]);
|
|
@@ -16,6 +20,7 @@ class ToastService {
|
|
|
16
20
|
addLockError() {
|
|
17
21
|
++this.lockError;
|
|
18
22
|
}
|
|
23
|
+
/** Releases one error lock; the count does not go below zero. */
|
|
19
24
|
removeLockError() {
|
|
20
25
|
this.lockError = Math.max(0, this.lockError - 1);
|
|
21
26
|
}
|
|
@@ -36,8 +41,11 @@ class ToastService {
|
|
|
36
41
|
}
|
|
37
42
|
push(type, config) {
|
|
38
43
|
const id = this.nextId++;
|
|
44
|
+
const duration = config.duration && config.duration > 0
|
|
45
|
+
? config.duration
|
|
46
|
+
: DEFAULT_TOAST_DURATION;
|
|
39
47
|
this.toasts.update((toasts) => [...toasts, { ...config, id, type }]);
|
|
40
|
-
this.timers.set(id, setTimeout(() => this.dismiss(id),
|
|
48
|
+
this.timers.set(id, setTimeout(() => this.dismiss(id), duration));
|
|
41
49
|
}
|
|
42
50
|
}
|
|
43
51
|
exports.ToastService = ToastService;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toast.service.js","sourceRoot":"","sources":["../../../../../../../../packages/shared/react/src/lib/services/toast/toast.service.ts"],"names":[],"mappings":";;;AAAA,uCAAyC;
|
|
1
|
+
{"version":3,"file":"toast.service.js","sourceRoot":"","sources":["../../../../../../../../packages/shared/react/src/lib/services/toast/toast.service.ts"],"names":[],"mappings":";;;AAAA,uCAAyC;AA0BzC,gEAAgE;AAChE,MAAM,sBAAsB,GAAG,IAAI,CAAC;AAEpC;;;;;;;GAOG;AACH,MAAa,YAAY;IACd,MAAM,GAAG,IAAI,kBAAU,CAAW,EAAE,CAAC,CAAC;IAEvC,SAAS,GAAG,CAAC,CAAC;IACd,MAAM,GAAG,CAAC,CAAC;IACF,MAAM,GAAG,IAAI,GAAG,EAAyC,CAAC;IAE3E,YAAY;QACV,EAAE,IAAI,CAAC,SAAS,CAAC;IACnB,CAAC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,CAAC,MAAM,CAAC,GAAG,CACb,EAAE,EACF,UAAU,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,EAAE,QAAQ,CAAC,CAC7C,CAAC;IACJ,CAAC;CACF;AAhDD,oCAgDC"}
|
package/styles.css
CHANGED
|
@@ -204,6 +204,7 @@
|
|
|
204
204
|
--smart-container-md: 28rem;
|
|
205
205
|
--smart-container-lg: 32rem;
|
|
206
206
|
--smart-container-xl: 36rem;
|
|
207
|
+
--smart-container-2xl: 42rem;
|
|
207
208
|
--smart-container-3xl: 48rem;
|
|
208
209
|
--smart-container-4xl: 56rem;
|
|
209
210
|
--smart-container-5xl: 64rem;
|
|
@@ -472,6 +473,9 @@
|
|
|
472
473
|
.smart\:top-16 {
|
|
473
474
|
top: calc(var(--smart-spacing) * 16);
|
|
474
475
|
}
|
|
476
|
+
.smart\:top-auto {
|
|
477
|
+
top: auto;
|
|
478
|
+
}
|
|
475
479
|
.smart\:top-full {
|
|
476
480
|
top: 100%;
|
|
477
481
|
}
|
|
@@ -529,6 +533,9 @@
|
|
|
529
533
|
.smart\:z-\[90\] {
|
|
530
534
|
z-index: 90;
|
|
531
535
|
}
|
|
536
|
+
.smart\:z-\[100\] {
|
|
537
|
+
z-index: 100;
|
|
538
|
+
}
|
|
532
539
|
.smart\:order-first {
|
|
533
540
|
order: -9999;
|
|
534
541
|
}
|
|
@@ -544,6 +551,9 @@
|
|
|
544
551
|
.smart\:-m-2 {
|
|
545
552
|
margin: calc(var(--smart-spacing) * -2);
|
|
546
553
|
}
|
|
554
|
+
.smart\:m-0 {
|
|
555
|
+
margin: 0px;
|
|
556
|
+
}
|
|
547
557
|
.smart\:m-2 {
|
|
548
558
|
margin: calc(var(--smart-spacing) * 2);
|
|
549
559
|
}
|
|
@@ -872,6 +882,9 @@
|
|
|
872
882
|
.smart\:max-h-96 {
|
|
873
883
|
max-height: calc(var(--smart-spacing) * 96);
|
|
874
884
|
}
|
|
885
|
+
.smart\:max-h-\[85dvh\] {
|
|
886
|
+
max-height: 85dvh;
|
|
887
|
+
}
|
|
875
888
|
.smart\:min-h-9\.5 {
|
|
876
889
|
min-height: calc(var(--smart-spacing) * 9.5);
|
|
877
890
|
}
|
|
@@ -1990,6 +2003,9 @@
|
|
|
1990
2003
|
.smart\:pb-8 {
|
|
1991
2004
|
padding-bottom: calc(var(--smart-spacing) * 8);
|
|
1992
2005
|
}
|
|
2006
|
+
.smart\:pb-\[env\(safe-area-inset-bottom\)\] {
|
|
2007
|
+
padding-bottom: env(safe-area-inset-bottom);
|
|
2008
|
+
}
|
|
1993
2009
|
.smart\:pb-px {
|
|
1994
2010
|
padding-bottom: 1px;
|
|
1995
2011
|
}
|
|
@@ -3706,6 +3722,9 @@
|
|
|
3706
3722
|
.smart\:sm\:w-full {
|
|
3707
3723
|
width: 100%;
|
|
3708
3724
|
}
|
|
3725
|
+
.smart\:sm\:max-w-2xl {
|
|
3726
|
+
max-width: var(--smart-container-2xl);
|
|
3727
|
+
}
|
|
3709
3728
|
.smart\:sm\:max-w-lg {
|
|
3710
3729
|
max-width: var(--smart-container-lg);
|
|
3711
3730
|
}
|
|
@@ -3768,6 +3787,14 @@
|
|
|
3768
3787
|
.smart\:sm\:rounded-xl {
|
|
3769
3788
|
border-radius: var(--smart-radius-xl);
|
|
3770
3789
|
}
|
|
3790
|
+
.smart\:sm\:rounded-t-xl {
|
|
3791
|
+
border-top-left-radius: var(--smart-radius-xl);
|
|
3792
|
+
border-top-right-radius: var(--smart-radius-xl);
|
|
3793
|
+
}
|
|
3794
|
+
.smart\:sm\:border-x {
|
|
3795
|
+
border-inline-style: var(--tw-border-style);
|
|
3796
|
+
border-inline-width: 1px;
|
|
3797
|
+
}
|
|
3771
3798
|
.smart\:sm\:p-5 {
|
|
3772
3799
|
padding: calc(var(--smart-spacing) * 5);
|
|
3773
3800
|
}
|