@hortiview/shared-components 2.3.0 → 2.4.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/CHANGELOG.md +17 -0
- package/README.md +11 -0
- package/dist/OfflineView-BW19N4Cu.js +48 -0
- package/dist/assets/ContextMenu.css +1 -1
- package/dist/assets/OfflineView.css +1 -0
- package/dist/components/BaseView/BaseView.d.ts +10 -1
- package/dist/components/BaseView/BaseView.js +42 -39
- package/dist/components/BaseView/BaseView.test.js +51 -34
- package/dist/components/ContextMenu/ContextMenu.d.ts +12 -1
- package/dist/components/ContextMenu/ContextMenu.js +40 -36
- package/dist/components/ContextMenu/ContextMenu.test.js +42 -19
- package/dist/components/DeleteModal/DeleteModal.d.ts +13 -1
- package/dist/components/DeleteModal/DeleteModal.js +52 -48
- package/dist/components/DeleteModal/DeleteModal.test.js +35 -11
- package/dist/components/GenericTable/GenericTable.d.ts +3 -1
- package/dist/components/GenericTable/GenericTable.js +1225 -1216
- package/dist/components/GenericTable/GenericTable.test.js +36 -6
- package/dist/components/Modal/Modal.d.ts +6 -1
- package/dist/components/Modal/Modal.js +94 -89
- package/dist/components/OfflineView/OfflineView.d.ts +68 -0
- package/dist/components/OfflineView/OfflineView.js +9 -0
- package/dist/components/OfflineView/OfflineView.test.d.ts +1 -0
- package/dist/components/OfflineView/OfflineView.test.js +24 -0
- package/dist/main.d.ts +1 -0
- package/dist/main.js +65 -63
- package/dist/types/GenericTable.d.ts +9 -0
- package/package.json +1 -1
|
@@ -55,18 +55,18 @@ h("GenericTable Test", () => {
|
|
|
55
55
|
] })), t(e.getByText("primText")).toBeInTheDocument(), e.getByText("primText").click(), t(d).toHaveBeenCalledWith(1);
|
|
56
56
|
}), i("render GenericTable with custom order", () => {
|
|
57
57
|
o(/* @__PURE__ */ a(s, { data: [{ id: 1, name: "test", age: 20 }], order: ["name", "age"] }));
|
|
58
|
-
const d = e.getByText("id"),
|
|
59
|
-
t(
|
|
58
|
+
const d = e.getByText("id"), l = e.getByText("name"), c = e.getByText("age");
|
|
59
|
+
t(l).toBeInTheDocument(), t(c).toBeInTheDocument(), t(d).toBeInTheDocument(), t(l.compareDocumentPosition(c)).toBe(4), t(c.compareDocumentPosition(d)).toBe(4);
|
|
60
60
|
}), i("render GenericTable with custom columnWidth in pixel", () => {
|
|
61
61
|
o(
|
|
62
62
|
/* @__PURE__ */ a(s, { data: [{ id: 1, name: "test", age: 20 }], customColumnWidth: { id: 200, name: 200, age: 200 } })
|
|
63
63
|
);
|
|
64
|
-
const
|
|
65
|
-
t(
|
|
64
|
+
const l = e.getAllByRole("cell")[0].getAttribute("width");
|
|
65
|
+
t(l).toBe("200");
|
|
66
66
|
}), i("render GenericTable with custom columnWidth in percent", () => {
|
|
67
67
|
o(/* @__PURE__ */ a(s, { data: [{ id: 1, name: "test" }], customColumnWidth: { id: "50%", name: "50%" } }));
|
|
68
|
-
const
|
|
69
|
-
t(
|
|
68
|
+
const l = e.getAllByRole("cell")[0].getAttribute("width");
|
|
69
|
+
t(l).toBe("50%");
|
|
70
70
|
}), i("render GenericTable with title", () => {
|
|
71
71
|
o(/* @__PURE__ */ a(s, { data: [{ id: 1, name: "test" }], title: "test-title" })), t(e.getByText("test-title")).toBeInTheDocument();
|
|
72
72
|
}), i("render GenericTable with title and table actions", () => {
|
|
@@ -81,5 +81,35 @@ h("GenericTable Test", () => {
|
|
|
81
81
|
isTablet: !1,
|
|
82
82
|
isDesktopNavbar: !1
|
|
83
83
|
}), o(/* @__PURE__ */ a(s, { data: [{ id: 1, name: "test", age: 20 }], title: "test-title", cardTitleColumn: "name" })), t(e.getAllByTestId("card-title")).toHaveLength(1), t(e.getAllByTestId("card-body")).toHaveLength(1), t(e.getAllByTestId("row")).toHaveLength(2);
|
|
84
|
+
}), i("render GenericTable with OfflineView", () => {
|
|
85
|
+
o(
|
|
86
|
+
/* @__PURE__ */ a(
|
|
87
|
+
s,
|
|
88
|
+
{
|
|
89
|
+
data: [{ id: 1, name: "test" }],
|
|
90
|
+
noContentText: "noContent",
|
|
91
|
+
isOnline: !1,
|
|
92
|
+
offlineViewProps: { "data-testid": "offline-test" }
|
|
93
|
+
}
|
|
94
|
+
)
|
|
95
|
+
), t(e.getByTestId("offline-test")).toBeInTheDocument();
|
|
96
|
+
}), i("shows OfflineView on mobile when offline", () => {
|
|
97
|
+
r.spyOn(m, "useBreakpoints").mockReturnValue({
|
|
98
|
+
isDesktop: !1,
|
|
99
|
+
isMobile: !0,
|
|
100
|
+
isTablet: !1,
|
|
101
|
+
isDesktopNavbar: !1
|
|
102
|
+
}), o(
|
|
103
|
+
/* @__PURE__ */ a(
|
|
104
|
+
s,
|
|
105
|
+
{
|
|
106
|
+
data: [{ id: 1, name: "test", age: 20 }],
|
|
107
|
+
title: "test-title",
|
|
108
|
+
cardTitleColumn: "name",
|
|
109
|
+
isOnline: !1,
|
|
110
|
+
offlineViewProps: { "data-testid": "offline-test" }
|
|
111
|
+
}
|
|
112
|
+
)
|
|
113
|
+
), t(e.getByTestId("offline-test")).toBeInTheDocument();
|
|
84
114
|
});
|
|
85
115
|
});
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { ModalProps as ElementModalProps } from '@element-public/react-modal';
|
|
2
2
|
import { AvailableCustomIcons } from '../../enums/AvailableCustomIcons';
|
|
3
|
+
import { OfflineViewProps } from '../OfflineView/OfflineView';
|
|
3
4
|
|
|
4
5
|
type ModalProps = ElementModalProps & React.HTMLProps<HTMLElement> & React.DOMAttributes<HTMLElement> & {
|
|
5
6
|
leadingIcon?: keyof typeof AvailableCustomIcons | string;
|
|
7
|
+
isOnline?: boolean;
|
|
8
|
+
offlineViewProps?: Partial<OfflineViewProps>;
|
|
6
9
|
};
|
|
7
10
|
/**
|
|
8
11
|
* A custom modal providing a custom header and close button.
|
|
@@ -13,7 +16,9 @@ type ModalProps = ElementModalProps & React.HTMLProps<HTMLElement> & React.DOMAt
|
|
|
13
16
|
* @param hideCloseIcon - If true, the close icon will be hidden. @default true.
|
|
14
17
|
* @param leadingIcon - Iconify icon string (material icons and custom icons)
|
|
15
18
|
* @param - Other element props to pass to the modal.
|
|
19
|
+
* @param isOnline - Whether the user is online; shows OfflineView when false.
|
|
20
|
+
* @param offlineViewProps - Props forwarded to OfflineView when offline.
|
|
16
21
|
* @returns
|
|
17
22
|
*/
|
|
18
|
-
export declare const Modal: ({ onClose, title, headerActions, hideCloseIcon, leadingIcon, ...props }: ModalProps) => import("react/jsx-runtime").JSX.Element;
|
|
23
|
+
export declare const Modal: ({ onClose, title, headerActions, hideCloseIcon, leadingIcon, isOnline, offlineViewProps, children, ...props }: ModalProps) => import("react/jsx-runtime").JSX.Element;
|
|
19
24
|
export {};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { jsxs as ft, jsx as
|
|
1
|
+
import { jsxs as ft, jsx as C, Fragment as pt } from "react/jsx-runtime";
|
|
2
2
|
import { G as z } from "../../index.es-DntoATwO.js";
|
|
3
3
|
import { I as it } from "../../index.es-0lQcz8m1.js";
|
|
4
4
|
import { _ as ht, c as B, P as s } from "../../identity-DLWZln-X.js";
|
|
5
|
-
import d, { forwardRef as gt, useRef as et, useImperativeHandle as _t, useState as nt, useEffect as
|
|
6
|
-
import { i as Et, c as
|
|
5
|
+
import d, { forwardRef as gt, useRef as et, useImperativeHandle as _t, useState as nt, useEffect as _, useCallback as j, useMemo as Y } from "react";
|
|
6
|
+
import { i as Et, c as b, a as Ct } from "../../index.es-da0cf7oE.js";
|
|
7
7
|
import { b as at, c as ot, d as St } from "../../tslib.es6-BDCynO9F.js";
|
|
8
8
|
import { M as vt, a as yt } from "../../component-neHBNHRu.js";
|
|
9
9
|
import { M as Ot, c as Tt, m as At } from "../../component-DsB0poTj.js";
|
|
@@ -11,6 +11,7 @@ import { A as bt } from "../../animationframe-EMBh6XeO.js";
|
|
|
11
11
|
import { P as Dt } from "../../index.es-D-CKRzIB.js";
|
|
12
12
|
import { b as It } from "../../index.es-D54RuMc_.js";
|
|
13
13
|
import { Iconify as Nt } from "../Iconify/Iconify.js";
|
|
14
|
+
import { O as Lt } from "../../OfflineView-BW19N4Cu.js";
|
|
14
15
|
import '../../assets/Modal.css';/**
|
|
15
16
|
* @license
|
|
16
17
|
* Copyright 2016 Google Inc.
|
|
@@ -33,19 +34,19 @@ import '../../assets/Modal.css';/**
|
|
|
33
34
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
34
35
|
* THE SOFTWARE.
|
|
35
36
|
*/
|
|
36
|
-
function
|
|
37
|
+
function Ft(i, e, t) {
|
|
37
38
|
return e(i, { initialFocusEl: t });
|
|
38
39
|
}
|
|
39
|
-
function
|
|
40
|
+
function Rt(i) {
|
|
40
41
|
return i ? i.scrollHeight > i.offsetHeight : !1;
|
|
41
42
|
}
|
|
42
|
-
function
|
|
43
|
+
function Bt(i) {
|
|
43
44
|
return i ? i.scrollTop === 0 : !1;
|
|
44
45
|
}
|
|
45
|
-
function
|
|
46
|
+
function wt(i) {
|
|
46
47
|
return i ? Math.ceil(i.scrollHeight - i.scrollTop) === i.clientHeight : !1;
|
|
47
48
|
}
|
|
48
|
-
function
|
|
49
|
+
function Mt(i) {
|
|
49
50
|
var e = /* @__PURE__ */ new Set();
|
|
50
51
|
return [].forEach.call(i, function(t) {
|
|
51
52
|
return e.add(t.offsetTop);
|
|
@@ -73,7 +74,7 @@ function wt(i) {
|
|
|
73
74
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
74
75
|
* THE SOFTWARE.
|
|
75
76
|
*/
|
|
76
|
-
var q = "mdc-dom-focus-sentinel",
|
|
77
|
+
var q = "mdc-dom-focus-sentinel", kt = (
|
|
77
78
|
/** @class */
|
|
78
79
|
function() {
|
|
79
80
|
function i(e, t) {
|
|
@@ -171,7 +172,7 @@ var r = {
|
|
|
171
172
|
// to prevent interactions with the content behind this scrim, and to capture
|
|
172
173
|
// scrim clicks.
|
|
173
174
|
SCRIM_HIDDEN: "mdc-dialog__scrim--hidden"
|
|
174
|
-
},
|
|
175
|
+
}, v = {
|
|
175
176
|
ACTION_ATTRIBUTE: "data-mdc-dialog-action",
|
|
176
177
|
BUTTON_DEFAULT_ATTRIBUTE: "data-mdc-dialog-button-default",
|
|
177
178
|
BUTTON_SELECTOR: ".mdc-dialog__button",
|
|
@@ -227,7 +228,7 @@ var rt = (
|
|
|
227
228
|
at(e, i);
|
|
228
229
|
function e(t) {
|
|
229
230
|
var n = i.call(this, ot(ot({}, e.defaultAdapter), t)) || this;
|
|
230
|
-
return n.dialogOpen = !1, n.isFullscreen = !1, n.animationFrame = 0, n.animationTimer = 0, n.escapeKeyAction =
|
|
231
|
+
return n.dialogOpen = !1, n.isFullscreen = !1, n.animationFrame = 0, n.animationTimer = 0, n.escapeKeyAction = v.CLOSE_ACTION, n.scrimClickAction = v.CLOSE_ACTION, n.autoStackButtons = !0, n.areButtonsStacked = !1, n.suppressDefaultPressSelector = v.SUPPRESS_DEFAULT_PRESS_SELECTOR, n.animFrame = new bt(), n.contentScrollHandler = function() {
|
|
231
232
|
n.handleScrollEvent();
|
|
232
233
|
}, n.windowResizeHandler = function() {
|
|
233
234
|
n.layout();
|
|
@@ -243,7 +244,7 @@ var rt = (
|
|
|
243
244
|
configurable: !0
|
|
244
245
|
}), Object.defineProperty(e, "strings", {
|
|
245
246
|
get: function() {
|
|
246
|
-
return
|
|
247
|
+
return v;
|
|
247
248
|
},
|
|
248
249
|
enumerable: !1,
|
|
249
250
|
configurable: !0
|
|
@@ -319,7 +320,7 @@ var rt = (
|
|
|
319
320
|
}), e.prototype.init = function() {
|
|
320
321
|
this.adapter.hasClass(r.STACKED) && this.setAutoStackButtons(!1), this.isFullscreen = this.adapter.hasClass(r.FULLSCREEN);
|
|
321
322
|
}, e.prototype.destroy = function() {
|
|
322
|
-
this.dialogOpen && this.close(
|
|
323
|
+
this.dialogOpen && this.close(v.DESTROY_ACTION), this.animationTimer && (clearTimeout(this.animationTimer), this.handleAnimationTimerEnd()), this.isFullscreen && this.adapter.deregisterContentEventHandler("scroll", this.contentScrollHandler), this.animFrame.cancelAll(), this.adapter.deregisterWindowEventHandler("resize", this.windowResizeHandler), this.adapter.deregisterWindowEventHandler("orientationchange", this.windowOrientationChangeHandler);
|
|
323
324
|
}, e.prototype.open = function(t) {
|
|
324
325
|
var n = this;
|
|
325
326
|
this.dialogOpen = !0, this.adapter.notifyOpening(), this.adapter.addClass(r.OPENING), this.isFullscreen && this.adapter.registerContentEventHandler("scroll", this.contentScrollHandler), t && t.isAboveFullscreenDialog && this.adapter.addClass(r.SCRIM_HIDDEN), this.adapter.registerWindowEventHandler("resize", this.windowResizeHandler), this.adapter.registerWindowEventHandler("orientationchange", this.windowOrientationChangeHandler), this.runNextAnimationFrame(function() {
|
|
@@ -365,7 +366,7 @@ var rt = (
|
|
|
365
366
|
t.layoutInternal();
|
|
366
367
|
});
|
|
367
368
|
}, e.prototype.handleClick = function(t) {
|
|
368
|
-
var n = this.adapter.eventTargetMatches(t.target,
|
|
369
|
+
var n = this.adapter.eventTargetMatches(t.target, v.SCRIM_SELECTOR);
|
|
369
370
|
if (n && this.scrimClickAction !== "")
|
|
370
371
|
this.close(this.scrimClickAction);
|
|
371
372
|
else {
|
|
@@ -433,7 +434,7 @@ var rt = (
|
|
|
433
434
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
434
435
|
* THE SOFTWARE.
|
|
435
436
|
*/
|
|
436
|
-
var u = rt.strings,
|
|
437
|
+
var u = rt.strings, Ht = (
|
|
437
438
|
/** @class */
|
|
438
439
|
function(i) {
|
|
439
440
|
at(e, i);
|
|
@@ -477,8 +478,8 @@ var u = rt.strings, kt = (
|
|
|
477
478
|
return new e(t);
|
|
478
479
|
}, e.prototype.initialize = function(t) {
|
|
479
480
|
var n, o;
|
|
480
|
-
t === void 0 && (t = function(
|
|
481
|
-
return new
|
|
481
|
+
t === void 0 && (t = function(h, E) {
|
|
482
|
+
return new kt(h, E);
|
|
482
483
|
});
|
|
483
484
|
var a = this.root.querySelector(u.CONTAINER_SELECTOR);
|
|
484
485
|
if (!a)
|
|
@@ -486,11 +487,11 @@ var u = rt.strings, kt = (
|
|
|
486
487
|
this.container = a, this.content = this.root.querySelector(u.CONTENT_SELECTOR), this.buttons = [].slice.call(this.root.querySelectorAll(u.BUTTON_SELECTOR)), this.defaultButton = this.root.querySelector("[" + u.BUTTON_DEFAULT_ATTRIBUTE + "]"), this.focusTrapFactory = t, this.buttonRipples = [];
|
|
487
488
|
try {
|
|
488
489
|
for (var f = St(this.buttons), p = f.next(); !p.done; p = f.next()) {
|
|
489
|
-
var
|
|
490
|
-
this.buttonRipples.push(new Ot(
|
|
490
|
+
var S = p.value;
|
|
491
|
+
this.buttonRipples.push(new Ot(S));
|
|
491
492
|
}
|
|
492
|
-
} catch (
|
|
493
|
-
n = { error:
|
|
493
|
+
} catch (h) {
|
|
494
|
+
n = { error: h };
|
|
494
495
|
} finally {
|
|
495
496
|
try {
|
|
496
497
|
p && !p.done && (o = f.return) && o.call(f);
|
|
@@ -500,7 +501,7 @@ var u = rt.strings, kt = (
|
|
|
500
501
|
}
|
|
501
502
|
}, e.prototype.initialSyncWithDOM = function() {
|
|
502
503
|
var t = this;
|
|
503
|
-
this.focusTrap =
|
|
504
|
+
this.focusTrap = Ft(this.container, this.focusTrapFactory, this.getInitialFocusEl() || void 0), this.handleClick = this.foundation.handleClick.bind(this.foundation), this.handleKeydown = this.foundation.handleKeydown.bind(this.foundation), this.handleDocumentKeydown = this.foundation.handleDocumentKeydown.bind(this.foundation), this.handleOpening = function() {
|
|
504
505
|
document.addEventListener("keydown", t.handleDocumentKeydown);
|
|
505
506
|
}, this.handleClosing = function() {
|
|
506
507
|
document.removeEventListener("keydown", t.handleDocumentKeydown);
|
|
@@ -524,7 +525,7 @@ var u = rt.strings, kt = (
|
|
|
524
525
|
return t.root.classList.add(o);
|
|
525
526
|
},
|
|
526
527
|
areButtonsStacked: function() {
|
|
527
|
-
return
|
|
528
|
+
return Mt(t.buttons);
|
|
528
529
|
},
|
|
529
530
|
clickDefaultButton: function() {
|
|
530
531
|
t.defaultButton && t.defaultButton.click();
|
|
@@ -545,7 +546,7 @@ var u = rt.strings, kt = (
|
|
|
545
546
|
return t.root.classList.contains(o);
|
|
546
547
|
},
|
|
547
548
|
isContentScrollable: function() {
|
|
548
|
-
return
|
|
549
|
+
return Rt(t.content);
|
|
549
550
|
},
|
|
550
551
|
notifyClosed: function(o) {
|
|
551
552
|
return t.emit(u.CLOSED_EVENT, o ? { action: o } : {});
|
|
@@ -583,10 +584,10 @@ var u = rt.strings, kt = (
|
|
|
583
584
|
t.content instanceof HTMLElement && t.content.removeEventListener(o, a);
|
|
584
585
|
},
|
|
585
586
|
isScrollableContentAtTop: function() {
|
|
586
|
-
return
|
|
587
|
+
return Bt(t.content);
|
|
587
588
|
},
|
|
588
589
|
isScrollableContentAtBottom: function() {
|
|
589
|
-
return
|
|
590
|
+
return wt(t.content);
|
|
590
591
|
},
|
|
591
592
|
registerWindowEventHandler: function(o, a) {
|
|
592
593
|
window.addEventListener(o, a);
|
|
@@ -601,7 +602,7 @@ var u = rt.strings, kt = (
|
|
|
601
602
|
}, e;
|
|
602
603
|
}(yt)
|
|
603
604
|
);
|
|
604
|
-
const
|
|
605
|
+
const Pt = {
|
|
605
606
|
/**
|
|
606
607
|
* An action button that will not automatically trigger a dismiss or accept. It is meant to be used only in certain circumstances where more control of the modal is required such as validating forms. If primaryButton is sent with actionButton, actionButton will be ignored.
|
|
607
608
|
*
|
|
@@ -764,7 +765,7 @@ const Ht = {
|
|
|
764
765
|
* Defaults to **null**.
|
|
765
766
|
*/
|
|
766
767
|
title: s.string
|
|
767
|
-
},
|
|
768
|
+
}, Ut = {
|
|
768
769
|
actionButton: null,
|
|
769
770
|
backButton: null,
|
|
770
771
|
badge: void 0,
|
|
@@ -796,18 +797,18 @@ const Ht = {
|
|
|
796
797
|
backButton: a,
|
|
797
798
|
children: f,
|
|
798
799
|
className: p,
|
|
799
|
-
content:
|
|
800
|
-
defaultButton:
|
|
801
|
-
dismissiveButton:
|
|
802
|
-
footerSupplemental:
|
|
800
|
+
content: S,
|
|
801
|
+
defaultButton: h,
|
|
802
|
+
dismissiveButton: E,
|
|
803
|
+
footerSupplemental: y,
|
|
803
804
|
headerActions: J,
|
|
804
805
|
hideCloseIcon: H,
|
|
805
806
|
indicator: st,
|
|
806
|
-
initialFocus:
|
|
807
|
+
initialFocus: O,
|
|
807
808
|
mobileStackedButtons: P,
|
|
808
|
-
modalSize:
|
|
809
|
-
nextButton:
|
|
810
|
-
noActions:
|
|
809
|
+
modalSize: g,
|
|
810
|
+
nextButton: T,
|
|
811
|
+
noActions: A,
|
|
811
812
|
onClose: U,
|
|
812
813
|
onClosed: x,
|
|
813
814
|
onOpen: D,
|
|
@@ -822,23 +823,23 @@ const Ht = {
|
|
|
822
823
|
...lt
|
|
823
824
|
} = i, N = et(), l = et();
|
|
824
825
|
_t(e, () => N.current, []);
|
|
825
|
-
const [W, ct] = nt(), [V, dt] = nt(() =>
|
|
826
|
-
|
|
827
|
-
dt(
|
|
828
|
-
}, [
|
|
826
|
+
const [W, ct] = nt(), [V, dt] = nt(() => T || a);
|
|
827
|
+
_(() => {
|
|
828
|
+
dt(T || a);
|
|
829
|
+
}, [T, a]);
|
|
829
830
|
const L = j(() => {
|
|
830
831
|
ct(window.innerWidth <= 600);
|
|
831
832
|
}, []);
|
|
832
|
-
|
|
833
|
+
_(() => (L(), window.addEventListener("resize", L), () => {
|
|
833
834
|
window.removeEventListener("resize", L);
|
|
834
|
-
}), [L]),
|
|
835
|
+
}), [L]), _(() => (l.current = Ht.attachTo(N.current), () => {
|
|
835
836
|
l.current.destroy();
|
|
836
|
-
}), [l, N]),
|
|
837
|
+
}), [l, N]), _(() => {
|
|
837
838
|
l.current.foundation.setAutoStackButtons(P);
|
|
838
|
-
}, [P]),
|
|
839
|
-
|
|
839
|
+
}, [P]), _(() => {
|
|
840
|
+
A && (l.current.foundation.adapter.trapFocus = () => {
|
|
840
841
|
});
|
|
841
|
-
}, [
|
|
842
|
+
}, [A]), _(() => {
|
|
842
843
|
l.current.scrimClickAction = G ? "" : "close", l.current.escapeKeyAction = G ? "" : "close";
|
|
843
844
|
}, [G]);
|
|
844
845
|
const F = j((m) => {
|
|
@@ -846,15 +847,15 @@ const Ht = {
|
|
|
846
847
|
}, [U]), R = j((m) => {
|
|
847
848
|
K && Et(K), x && x(m);
|
|
848
849
|
}, [K, x]);
|
|
849
|
-
|
|
850
|
+
_(() => (l.current.unlisten("MDCDialog: opening", D), l.current.listen("MDCDialog: opening", D), () => {
|
|
850
851
|
l.current.unlisten("MDCDialog: opening", D);
|
|
851
|
-
}), [l, D]),
|
|
852
|
+
}), [l, D]), _(() => (l.current.unlisten("MDCDialog:opened", I), l.current.listen("MDCDialog:opened", I), () => {
|
|
852
853
|
l.current.unlisten("MDCDialog:opened", I);
|
|
853
|
-
}), [l, I]),
|
|
854
|
+
}), [l, I]), _(() => (l.current.unlisten("MDCDialog:closing", F), l.current.listen("MDCDialog:closing", F), () => {
|
|
854
855
|
l.current.unlisten("MDCDialog:closing", F);
|
|
855
|
-
}), [l, F]),
|
|
856
|
+
}), [l, F]), _(() => (l.current.unlisten("MDCDialog:closed", R), l.current.listen("MDCDialog:closed", R), () => {
|
|
856
857
|
l.current.unlisten("MDCDialog:closed", R);
|
|
857
|
-
}), [l, R]),
|
|
858
|
+
}), [l, R]), _(() => {
|
|
858
859
|
Q ? l.current.open() : l.current.close();
|
|
859
860
|
}, [l, Q]);
|
|
860
861
|
const ut = Y(() => () => {
|
|
@@ -863,27 +864,27 @@ const Ht = {
|
|
|
863
864
|
elevation: t?.props.elevation !== "default" ? t?.props.elevation : "flat",
|
|
864
865
|
variant: t?.props.variant || "filled"
|
|
865
866
|
};
|
|
866
|
-
return
|
|
867
|
-
}, [t?.props.elevation, t?.props.variant,
|
|
867
|
+
return h === "action" && (m["data-mdc-dialog-button-default"] = !0), O === "action" && (m["data-mdc-dialog-initial-focus"] = !0), m;
|
|
868
|
+
}, [t?.props.elevation, t?.props.variant, h, O]), mt = Y(() => () => {
|
|
868
869
|
const m = {
|
|
869
870
|
className: "lmnt-modal__button mdc-dialog__button",
|
|
870
871
|
"data-mdc-dialog-action": X ? "" : "accept",
|
|
871
872
|
elevation: c?.props.elevation !== "default" ? c?.props.elevation : "flat",
|
|
872
873
|
variant: c?.props.variant || "filled"
|
|
873
874
|
};
|
|
874
|
-
return
|
|
875
|
-
}, [X,
|
|
875
|
+
return h === "primary" && (m["data-mdc-dialog-button-default"] = !0), O === "primary" && (m["data-mdc-dialog-initial-focus"] = !0), m;
|
|
876
|
+
}, [X, h, O, c?.props.elevation, c?.props.variant]);
|
|
876
877
|
return /* @__PURE__ */ d.createElement("aside", ht({
|
|
877
878
|
ref: N,
|
|
878
879
|
className: B("lmnt", "lmnt-modal", "mdc-dialog", Z && "lmnt-modal--scrollable mdc-dialog--scrollable", p),
|
|
879
880
|
role: "alertdialog"
|
|
880
881
|
}, lt), /* @__PURE__ */ d.createElement("div", {
|
|
881
|
-
className: B("lmnt-modal__container", "mdc-dialog__container",
|
|
882
|
+
className: B("lmnt-modal__container", "mdc-dialog__container", g === "fullscreen" && "mdc-dialog--fullscreen", g === "max" && "lmnt-modal__max", g === "xlarge" && "lmnt-modal__xl", g === "large" && "lmnt-modal__lg", g === "medium" && "lmnt-modal__md", g === "small" && "lmnt-modal__sm", (g === "mobile" || W) && "lmnt-modal__mobile", g === "dialog" && "lmnt-modal__dialog", A && "lmnt-modal-no-actions")
|
|
882
883
|
}, /* @__PURE__ */ d.createElement("div", {
|
|
883
884
|
className: "lmnt-modal__surface mdc-dialog__surface"
|
|
884
885
|
}, /* @__PURE__ */ d.createElement("header", {
|
|
885
|
-
className: B("lmnt-modal__title", "mdc-dialog__title", (
|
|
886
|
-
}, !H &&
|
|
886
|
+
className: B("lmnt-modal__title", "mdc-dialog__title", (g === "dialog" || H) && "lmnt-modal_title-hide-close-icon", n && "lmnt-modal_title-actionsIcons", Z && "lmnt-modal__title-scrollable", (H || g === "dialog" || A) && "lmnt-modal--no-close-icon")
|
|
887
|
+
}, !H && g !== "dialog" && !A && /* @__PURE__ */ d.createElement(it, {
|
|
887
888
|
className: "mdc-icon-button material-icons mdc-dialog__close",
|
|
888
889
|
"data-mdc-dialog-action": "close",
|
|
889
890
|
icon: "clear"
|
|
@@ -894,24 +895,24 @@ const Ht = {
|
|
|
894
895
|
style: {
|
|
895
896
|
marginLeft: "0"
|
|
896
897
|
}
|
|
897
|
-
}, o)), (
|
|
898
|
+
}, o)), (S || f) && /* @__PURE__ */ d.createElement("section", {
|
|
898
899
|
className: "lmnt-modal__content mdc-dialog__content"
|
|
899
|
-
},
|
|
900
|
-
className: B("lmnt-modal__actions", "mdc-dialog__actions", W && "lmnt-dialog__actions__mobile",
|
|
901
|
-
}, !V &&
|
|
900
|
+
}, S || f), st, (t || a || E || T || c || y) && /* @__PURE__ */ d.createElement("footer", {
|
|
901
|
+
className: B("lmnt-modal__actions", "mdc-dialog__actions", W && "lmnt-dialog__actions__mobile", y && "lmnt-modal__actions--supplemental-btn", W && P && "lmnt-modal_actions-mobile-stacked")
|
|
902
|
+
}, !V && y && /* @__PURE__ */ d.createElement("div", {
|
|
902
903
|
className: "lmnt-dialog__actions__supplemental"
|
|
903
|
-
},
|
|
904
|
+
}, b(y, () => {
|
|
904
905
|
const m = {};
|
|
905
|
-
return
|
|
906
|
-
})), !V && (t ||
|
|
906
|
+
return h === "footerSupplemental" && (m["data-mdc-dialog-button-default"] = !0), O === "footerSupplemental" && (m["data-mdc-dialog-initial-focus"] = !0), m;
|
|
907
|
+
})), !V && (t || E || c) && /* @__PURE__ */ d.createElement("div", {
|
|
907
908
|
className: "lmnt-dialog__actions__right-align lmnt-modal_actions_button"
|
|
908
|
-
},
|
|
909
|
+
}, E && b(E, {
|
|
909
910
|
variant: "text",
|
|
910
911
|
className: "lmnt-modal__button mdc-dialog__button",
|
|
911
912
|
"data-mdc-dialog-action": "close"
|
|
912
|
-
}), t && !c &&
|
|
913
|
+
}), t && !c && b(t, ut), c && b(c, mt)), V && /* @__PURE__ */ d.createElement("div", {
|
|
913
914
|
className: "lmnt-modal_actions_button lmnt-dialog__actions__directional"
|
|
914
|
-
}, /* @__PURE__ */ d.createElement("div", null, Ct(a, "lmnt-modal__button")), /* @__PURE__ */ d.createElement("div", null,
|
|
915
|
+
}, /* @__PURE__ */ d.createElement("div", null, Ct(a, "lmnt-modal__button")), /* @__PURE__ */ d.createElement("div", null, b(T, {
|
|
915
916
|
className: "lmnt-modal__button",
|
|
916
917
|
"data-mdc-dialog-initial-focus": !0
|
|
917
918
|
})))))), /* @__PURE__ */ d.createElement("div", {
|
|
@@ -919,26 +920,29 @@ const Ht = {
|
|
|
919
920
|
}));
|
|
920
921
|
});
|
|
921
922
|
k.displayName = "Modal";
|
|
922
|
-
k.propTypes =
|
|
923
|
-
k.defaultProps =
|
|
924
|
-
const
|
|
925
|
-
modal:
|
|
926
|
-
title:
|
|
927
|
-
titleWithoutCloseIcon:
|
|
928
|
-
closeButton:
|
|
929
|
-
},
|
|
923
|
+
k.propTypes = Pt;
|
|
924
|
+
k.defaultProps = Ut;
|
|
925
|
+
const xt = "_modal_fr8bw_1", Gt = "_title_fr8bw_6", Kt = "_titleWithoutCloseIcon_fr8bw_18", Wt = "_closeButton_fr8bw_22", w = {
|
|
926
|
+
modal: xt,
|
|
927
|
+
title: Gt,
|
|
928
|
+
titleWithoutCloseIcon: Kt,
|
|
929
|
+
closeButton: Wt
|
|
930
|
+
}, ie = ({
|
|
930
931
|
onClose: i,
|
|
931
932
|
title: e,
|
|
932
933
|
headerActions: t,
|
|
933
934
|
hideCloseIcon: n,
|
|
934
935
|
leadingIcon: o,
|
|
935
|
-
|
|
936
|
+
isOnline: a = !0,
|
|
937
|
+
offlineViewProps: f,
|
|
938
|
+
children: p,
|
|
939
|
+
...S
|
|
936
940
|
}) => {
|
|
937
|
-
const
|
|
938
|
-
const
|
|
939
|
-
!n && /* @__PURE__ */
|
|
940
|
-
o ? /* @__PURE__ */
|
|
941
|
-
/* @__PURE__ */
|
|
941
|
+
const h = Y(() => {
|
|
942
|
+
const E = /* @__PURE__ */ ft(z, { primaryAlign: "center", secondaryAlign: "center", children: [
|
|
943
|
+
!n && /* @__PURE__ */ C(it, { icon: "close", onClick: () => i?.(), type: "button", className: w.closeButton }),
|
|
944
|
+
o ? /* @__PURE__ */ C(Dt, { customPadding: "0.25rem 0 0 0.75rem", children: /* @__PURE__ */ C(Nt, { icon: o }) }) : /* @__PURE__ */ C(pt, {}),
|
|
945
|
+
/* @__PURE__ */ C(
|
|
942
946
|
It,
|
|
943
947
|
{
|
|
944
948
|
level: 6,
|
|
@@ -947,20 +951,21 @@ const Ut = "_modal_fr8bw_1", xt = "_title_fr8bw_6", Gt = "_titleWithoutCloseIcon
|
|
|
947
951
|
}
|
|
948
952
|
)
|
|
949
953
|
] }, "base-group");
|
|
950
|
-
return t ? Array.isArray(t) ? [
|
|
954
|
+
return t ? Array.isArray(t) ? [E, /* @__PURE__ */ C(z, { children: t }, "action-group")] : [E, t] : E;
|
|
951
955
|
}, [t, n, o, i, e]);
|
|
952
|
-
return /* @__PURE__ */
|
|
956
|
+
return /* @__PURE__ */ C(
|
|
953
957
|
k,
|
|
954
958
|
{
|
|
955
|
-
...
|
|
959
|
+
...S,
|
|
956
960
|
"data-testid": "modal",
|
|
957
|
-
className: `${w.modal} ${w.title} ${
|
|
961
|
+
className: `${w.modal} ${w.title} ${S.className ?? ""}`,
|
|
958
962
|
hideCloseIcon: !0,
|
|
959
|
-
headerActions: /* @__PURE__ */
|
|
960
|
-
preventClose: !0
|
|
963
|
+
headerActions: /* @__PURE__ */ C(z, { primaryAlign: "space-between", secondaryAlign: "center", children: h }, "header-group"),
|
|
964
|
+
preventClose: !0,
|
|
965
|
+
children: a ? p : /* @__PURE__ */ C(Lt, { ...f })
|
|
961
966
|
}
|
|
962
967
|
);
|
|
963
968
|
};
|
|
964
969
|
export {
|
|
965
|
-
|
|
970
|
+
ie as Modal
|
|
966
971
|
};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
export type OfflineViewProps = {
|
|
2
|
+
/**
|
|
3
|
+
* The title of the offline view
|
|
4
|
+
*
|
|
5
|
+
* Defaults to **You’re currently offline**
|
|
6
|
+
*/
|
|
7
|
+
title?: string;
|
|
8
|
+
/**
|
|
9
|
+
* The subtitle of the offline view, optional
|
|
10
|
+
*/
|
|
11
|
+
subtitle?: string;
|
|
12
|
+
/**
|
|
13
|
+
* The Icon of the offline view
|
|
14
|
+
*
|
|
15
|
+
* Defaults to **cloud_off**.
|
|
16
|
+
*/
|
|
17
|
+
icon?: string;
|
|
18
|
+
/**
|
|
19
|
+
* The offline view size
|
|
20
|
+
*
|
|
21
|
+
* Defaults to **large**
|
|
22
|
+
*/
|
|
23
|
+
size?: 'large' | 'small';
|
|
24
|
+
/**
|
|
25
|
+
* Visual variant
|
|
26
|
+
*
|
|
27
|
+
* Defaults to **basic**
|
|
28
|
+
*/
|
|
29
|
+
variant?: 'basic' | 'filled';
|
|
30
|
+
/**
|
|
31
|
+
* The button label. If provided, a button will be shown.
|
|
32
|
+
*/
|
|
33
|
+
buttonLabel?: string;
|
|
34
|
+
/**
|
|
35
|
+
* Click handler for the button (used only if a button is rendered).
|
|
36
|
+
*/
|
|
37
|
+
onClick?: () => void;
|
|
38
|
+
/**
|
|
39
|
+
* Optional test id pass-through.
|
|
40
|
+
*/
|
|
41
|
+
'data-testid'?: string;
|
|
42
|
+
/**
|
|
43
|
+
* Optional CSS class for the root element
|
|
44
|
+
*/
|
|
45
|
+
className?: string;
|
|
46
|
+
/**
|
|
47
|
+
* Stretch to the container’s full width.
|
|
48
|
+
*
|
|
49
|
+
* Defaults to **false**.
|
|
50
|
+
*/
|
|
51
|
+
fullWidth?: boolean;
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* Offline placeholder/view shown when no network connection is available.
|
|
55
|
+
*
|
|
56
|
+
* @param {string} title - The title of the offline view
|
|
57
|
+
* @param {string} subtitle - Optional subtitle
|
|
58
|
+
* @param {string} icon - The Icon of the offline view, default is cloud_off
|
|
59
|
+
* @param {'large' | 'small'} size - The offline view size, default is large
|
|
60
|
+
* @param {'basic' | 'filled'} variant - Visual variant, default is basic
|
|
61
|
+
* @param {string} buttonLabel - The button label, if defined, the button will be displayed
|
|
62
|
+
* @param {() => void} onClick - Event handler for the button
|
|
63
|
+
* @param {string} 'data-testid' - Optional test id passthrough
|
|
64
|
+
* @param {string} className - Optional CSS class for the root element
|
|
65
|
+
* @param {boolean} fullWidth - Stretch to the container’s full width.
|
|
66
|
+
* @returns {JSX.Element}
|
|
67
|
+
*/
|
|
68
|
+
export declare const OfflineView: ({ title, subtitle, icon, size, variant, "data-testid": dataTestId, buttonLabel, fullWidth, className, onClick, }: OfflineViewProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import "react/jsx-runtime";
|
|
2
|
+
import "../../index.es-DntoATwO.js";
|
|
3
|
+
import "../Iconify/Iconify.js";
|
|
4
|
+
import "../../index.es-D54RuMc_.js";
|
|
5
|
+
import { O as f } from "../../OfflineView-BW19N4Cu.js";
|
|
6
|
+
import "../../index.es-CiqbARoC.js";
|
|
7
|
+
export {
|
|
8
|
+
f as OfflineView
|
|
9
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { jsx as o } from "react/jsx-runtime";
|
|
2
|
+
import { a as n, s as t, f as u } from "../../react.esm-CX1WJ2Pp.js";
|
|
3
|
+
import { s as r, O as i } from "../../OfflineView-BW19N4Cu.js";
|
|
4
|
+
import { d as B, t as l, g as e, a as c } from "../../vi.CjhMlMwf-CKxPQtd6.js";
|
|
5
|
+
B("OfflineView", () => {
|
|
6
|
+
l("should render OfflineView with title and subtitle", () => {
|
|
7
|
+
n(/* @__PURE__ */ o(i, { title: "test-title", subtitle: "test-subtitle" })), e(t.getByTestId("offline-view-container")).toBeInTheDocument(), e(t.getByText("test-title")).toBeInTheDocument(), e(t.getByText("test-subtitle")).toBeInTheDocument(), e(t.queryByText("cloud_off")).toBeInTheDocument();
|
|
8
|
+
}), l("should render without subtitle", () => {
|
|
9
|
+
n(/* @__PURE__ */ o(i, { title: "test-title" })), e(t.getByTestId("offline-view-container")).toBeInTheDocument(), e(t.getByText("test-title")).toBeInTheDocument(), e(t.queryByText("test-subtitle")).not.toBeInTheDocument();
|
|
10
|
+
}), l("should render custom icon", () => {
|
|
11
|
+
n(/* @__PURE__ */ o(i, { title: "test-title", icon: "add" })), e(t.getByTestId("offline-view-container")).toBeInTheDocument(), e(t.getByText("test-title")).toBeInTheDocument(), e(t.getByText("add")).toBeInTheDocument();
|
|
12
|
+
}), l("should render the small offline view", () => {
|
|
13
|
+
n(/* @__PURE__ */ o(i, { title: "test-title", size: "small" })), e(t.getByText("test-title")).toHaveClass("mdc-typography--subtitle1");
|
|
14
|
+
}), l("should render the filled offline view", () => {
|
|
15
|
+
n(/* @__PURE__ */ o(i, { title: "test-title", variant: "filled", "data-testid": "test" })), e(t.getByTestId("test")).toHaveClass(r.bgGrey);
|
|
16
|
+
}), l("should render OfflineView with button", () => {
|
|
17
|
+
n(/* @__PURE__ */ o(i, { title: "test-title", buttonLabel: "Button" })), e(t.getByText("Button")).toBeInTheDocument(), e(t.getByRole("button")).toBeInTheDocument();
|
|
18
|
+
}), l("calls onClick when button is clicked", () => {
|
|
19
|
+
const s = c.fn();
|
|
20
|
+
n(/* @__PURE__ */ o(i, { title: "test-title", buttonLabel: "Button", onClick: s })), u.click(t.getByText("Button")), e(s).toHaveBeenCalled();
|
|
21
|
+
}), l("should render OfflineView without button", () => {
|
|
22
|
+
n(/* @__PURE__ */ o(i, { title: "test-title" })), e(t.queryByText("Button")).not.toBeInTheDocument(), e(t.queryByRole("button")).not.toBeInTheDocument();
|
|
23
|
+
});
|
|
24
|
+
});
|
package/dist/main.d.ts
CHANGED
|
@@ -21,6 +21,7 @@ export { ListArea } from './components/ListArea/ListArea';
|
|
|
21
21
|
export { LoadingSpinner } from './components/LoadingSpinner/Default/LoadingSpinner';
|
|
22
22
|
export { Modal } from './components/Modal/Modal';
|
|
23
23
|
export { ModulePadding } from './components/ModulePadding/ModulePadding';
|
|
24
|
+
export { OfflineView } from './components/OfflineView/OfflineView';
|
|
24
25
|
export { OnboardingBanner } from './components/OnboardingBanner/OnboardingBanner';
|
|
25
26
|
export { OverflowTooltip } from './components/OverflowTooltip/OverflowTooltip';
|
|
26
27
|
export { ScrollbarX, ScrollbarY } from './components/Scrollbar/Scrollbar';
|