@uxf/ui 11.48.4 → 11.49.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/components.d.ts +4 -4
- package/components.js +4 -4
- package/css/dialog.css +24 -1
- package/dialog/dialog-panel.d.ts +12 -0
- package/dialog/dialog-panel.js +13 -0
- package/dialog/dialog.d.ts +3 -3
- package/dialog/dialog.js +4 -4
- package/dialog/index.d.ts +3 -1
- package/dialog/index.js +3 -1
- package/dialog/theme.d.ts +1 -3
- package/modal/README.md +42 -4
- package/modal/index.d.ts +2 -2
- package/modal/index.js +3 -1
- package/modal/modal-provider.d.ts +3 -0
- package/modal/modal-provider.js +57 -0
- package/modal/modal-service.d.ts +2 -2
- package/modal/modal.d.ts +3 -16
- package/modal/modal.js +23 -53
- package/modal/modal.stories.d.ts +1 -0
- package/modal/modal.stories.js +101 -54
- package/modal/theme.d.ts +0 -9
- package/modal/types.d.ts +23 -0
- package/modal/types.js +2 -0
- package/package.json +1 -1
- package/readmes.d.ts +1 -1
- package/readmes.js +1 -1
- package/css/modal.css +0 -21
package/components.d.ts
CHANGED
|
@@ -30,7 +30,7 @@ import * as formComponentStories from "./form-component/form-component.stories";
|
|
|
30
30
|
import * as iconStories from "./icon/icon.stories";
|
|
31
31
|
import * as iconButtonStories from "./icon-button/icon-button.stories";
|
|
32
32
|
import * as imageGalleryStories from "./image-gallery/image-gallery.stories";
|
|
33
|
-
import * as
|
|
33
|
+
import * as infoBoxStories from "./info-box/info-box.stories";
|
|
34
34
|
import * as inputStories from "./input/input.stories";
|
|
35
35
|
import * as labelStories from "./label/label.stories";
|
|
36
36
|
import * as layoutStories from "./layout/layout.stories";
|
|
@@ -187,9 +187,9 @@ export declare const components: {
|
|
|
187
187
|
readonly title: "ImageGallery";
|
|
188
188
|
readonly stories: typeof imageGalleryStories;
|
|
189
189
|
};
|
|
190
|
-
readonly
|
|
191
|
-
readonly title: "
|
|
192
|
-
readonly stories: typeof
|
|
190
|
+
readonly "info-box": {
|
|
191
|
+
readonly title: "InfoBox";
|
|
192
|
+
readonly stories: typeof infoBoxStories;
|
|
193
193
|
};
|
|
194
194
|
readonly input: {
|
|
195
195
|
readonly title: "Input";
|
package/components.js
CHANGED
|
@@ -57,7 +57,7 @@ const formComponentStories = __importStar(require("./form-component/form-compone
|
|
|
57
57
|
const iconStories = __importStar(require("./icon/icon.stories"));
|
|
58
58
|
const iconButtonStories = __importStar(require("./icon-button/icon-button.stories"));
|
|
59
59
|
const imageGalleryStories = __importStar(require("./image-gallery/image-gallery.stories"));
|
|
60
|
-
const
|
|
60
|
+
const infoBoxStories = __importStar(require("./info-box/info-box.stories"));
|
|
61
61
|
const inputStories = __importStar(require("./input/input.stories"));
|
|
62
62
|
const labelStories = __importStar(require("./label/label.stories"));
|
|
63
63
|
const layoutStories = __importStar(require("./layout/layout.stories"));
|
|
@@ -214,9 +214,9 @@ exports.components = {
|
|
|
214
214
|
title: "ImageGallery",
|
|
215
215
|
stories: imageGalleryStories
|
|
216
216
|
},
|
|
217
|
-
"
|
|
218
|
-
title: "
|
|
219
|
-
stories:
|
|
217
|
+
"info-box": {
|
|
218
|
+
title: "InfoBox",
|
|
219
|
+
stories: infoBoxStories
|
|
220
220
|
},
|
|
221
221
|
"input": {
|
|
222
222
|
title: "Input",
|
package/css/dialog.css
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
.uxf-dialog {
|
|
2
|
-
--panel-max-w: unset;
|
|
3
2
|
--panel-border-radius: theme("borderRadius.2xl");
|
|
4
3
|
|
|
5
4
|
position: relative;
|
|
@@ -30,6 +29,10 @@
|
|
|
30
29
|
}
|
|
31
30
|
}
|
|
32
31
|
|
|
32
|
+
&__panel-wrapper {
|
|
33
|
+
display: contents;
|
|
34
|
+
}
|
|
35
|
+
|
|
33
36
|
&__panel {
|
|
34
37
|
background-color: theme("colors.white");
|
|
35
38
|
border-top-left-radius: var(--panel-border-radius);
|
|
@@ -48,6 +51,26 @@
|
|
|
48
51
|
@screen sm {
|
|
49
52
|
border-radius: var(--panel-border-radius);
|
|
50
53
|
}
|
|
54
|
+
|
|
55
|
+
&--width-xs {
|
|
56
|
+
--panel-max-w: theme("maxWidth.xs");
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
&--width-sm {
|
|
60
|
+
--panel-max-w: theme("maxWidth.sm");
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
&--width-default {
|
|
64
|
+
--panel-max-w: theme("maxWidth.lg");
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
&--width-lg {
|
|
68
|
+
--panel-max-w: theme("maxWidth.3xl");
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
&--width-xl {
|
|
72
|
+
--panel-max-w: theme("maxWidth.5xl");
|
|
73
|
+
}
|
|
51
74
|
}
|
|
52
75
|
|
|
53
76
|
&--variant-drawer-right {
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { DialogPanelWidths } from "@uxf/ui/dialog/theme";
|
|
2
|
+
import React, { ReactNode } from "react";
|
|
3
|
+
export type DialogPanelWidth = keyof DialogPanelWidths;
|
|
4
|
+
export interface DialogPanelProps {
|
|
5
|
+
children?: ReactNode;
|
|
6
|
+
className?: string;
|
|
7
|
+
width?: DialogPanelWidth;
|
|
8
|
+
}
|
|
9
|
+
export declare function DialogPanel(props: DialogPanelProps): React.JSX.Element;
|
|
10
|
+
export declare namespace DialogPanel {
|
|
11
|
+
var displayName: string;
|
|
12
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
+
};
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.DialogPanel = DialogPanel;
|
|
8
|
+
const react_1 = __importDefault(require("react"));
|
|
9
|
+
function DialogPanel(props) {
|
|
10
|
+
var _a, _b;
|
|
11
|
+
return (react_1.default.createElement("div", { className: `uxf-dialog__panel uxf-dialog__panel--width-${(_a = props.width) !== null && _a !== void 0 ? _a : "default"} ${(_b = props.className) !== null && _b !== void 0 ? _b : ""}` }, props.children));
|
|
12
|
+
}
|
|
13
|
+
DialogPanel.displayName = "UxfUiDialogPanel";
|
package/dialog/dialog.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { UseFloatingReturn } from "@floating-ui/react";
|
|
2
|
-
import {
|
|
2
|
+
import { DialogVariants } from "@uxf/ui/dialog/theme";
|
|
3
3
|
import React, { FC, HTMLProps, ReactNode, Ref } from "react";
|
|
4
4
|
type GetFloatingElementProps = (userProps?: HTMLProps<HTMLElement>) => Record<string, unknown>;
|
|
5
|
+
export type DialogVariant = keyof DialogVariants;
|
|
5
6
|
export interface DialogProps {
|
|
6
7
|
children?: ReactNode;
|
|
7
8
|
className?: string;
|
|
@@ -11,9 +12,8 @@ export interface DialogProps {
|
|
|
11
12
|
getFloatingProps: GetFloatingElementProps;
|
|
12
13
|
isOpen: boolean;
|
|
13
14
|
variant?: DialogVariant;
|
|
14
|
-
width?: DialogWidth;
|
|
15
15
|
}
|
|
16
|
-
type DialogProviderProps = Pick<DialogProps, "variant" | "
|
|
16
|
+
type DialogProviderProps = Pick<DialogProps, "variant" | "className" | "children">;
|
|
17
17
|
export declare const Dialog: React.NamedExoticComponent<DialogProps>;
|
|
18
18
|
type DialogCloseHandler = () => void;
|
|
19
19
|
export declare function useDialog(dialogConfig?: {
|
package/dialog/dialog.js
CHANGED
|
@@ -32,14 +32,14 @@ const use_latest_1 = require("@uxf/core-react/hooks/use-latest");
|
|
|
32
32
|
const is_not_nil_1 = require("@uxf/core/utils/is-not-nil");
|
|
33
33
|
const react_2 = __importStar(require("react"));
|
|
34
34
|
exports.Dialog = (0, react_2.memo)((props) => {
|
|
35
|
-
var _a, _b
|
|
35
|
+
var _a, _b;
|
|
36
36
|
return (react_2.default.createElement(react_1.FloatingPortal, null,
|
|
37
37
|
react_2.default.createElement(show_1.Show, { when: props.isOpen },
|
|
38
|
-
react_2.default.createElement(react_1.FloatingOverlay, { className: `uxf-dialog uxf-dialog__backdrop uxf-dialog--variant-${(_a = props.variant) !== null && _a !== void 0 ? _a : "default"} ${(_b = props.className) !== null && _b !== void 0 ? _b : ""}
|
|
38
|
+
react_2.default.createElement(react_1.FloatingOverlay, { className: `uxf-dialog uxf-dialog__backdrop uxf-dialog--variant-${(_a = props.variant) !== null && _a !== void 0 ? _a : "default"} ${(_b = props.className) !== null && _b !== void 0 ? _b : ""}`, lockScroll: true },
|
|
39
39
|
react_2.default.createElement(react_1.FloatingFocusManager, { context: props.context, guards: true, initialFocus: 0, modal: true },
|
|
40
40
|
react_2.default.createElement("div", { className: "uxf-dialog__wrapper" },
|
|
41
41
|
react_2.default.createElement("div", { className: "uxf-dialog__body" },
|
|
42
|
-
react_2.default.createElement("div", { className: "uxf-dialog__panel", ref: props.forwardedRef, ...props.getFloatingProps() }, props.children))))))));
|
|
42
|
+
react_2.default.createElement("div", { className: "uxf-dialog__panel-wrapper", ref: props.forwardedRef, ...props.getFloatingProps() }, props.children))))))));
|
|
43
43
|
});
|
|
44
44
|
exports.Dialog.displayName = "UxfUiDialog";
|
|
45
45
|
function useDialog(dialogConfig) {
|
|
@@ -64,7 +64,7 @@ function useDialog(dialogConfig) {
|
|
|
64
64
|
const { getReferenceProps, getFloatingProps } = (0, react_1.useInteractions)([click, role, dismiss]);
|
|
65
65
|
const latestContext = (0, use_latest_1.useLatest)(context);
|
|
66
66
|
const DialogProvider = (0, react_2.useCallback)((config) => {
|
|
67
|
-
return (react_2.default.createElement(exports.Dialog, { className: config === null || config === void 0 ? void 0 : config.className, context: latestContext.current, forwardedRef: refs.setFloating, getFloatingProps: getFloatingProps, isOpen: Boolean(content), variant: config === null || config === void 0 ? void 0 : config.variant
|
|
67
|
+
return (react_2.default.createElement(exports.Dialog, { className: config === null || config === void 0 ? void 0 : config.className, context: latestContext.current, forwardedRef: refs.setFloating, getFloatingProps: getFloatingProps, isOpen: Boolean(content), variant: config === null || config === void 0 ? void 0 : config.variant }, content));
|
|
68
68
|
}, [latestContext, refs.setFloating, getFloatingProps, content]);
|
|
69
69
|
return {
|
|
70
70
|
openDialog: setContent,
|
package/dialog/index.d.ts
CHANGED
package/dialog/index.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Dialog = void 0;
|
|
3
|
+
exports.DialogPanel = exports.Dialog = void 0;
|
|
4
4
|
var dialog_1 = require("./dialog");
|
|
5
5
|
Object.defineProperty(exports, "Dialog", { enumerable: true, get: function () { return dialog_1.Dialog; } });
|
|
6
|
+
var dialog_panel_1 = require("./dialog-panel");
|
|
7
|
+
Object.defineProperty(exports, "DialogPanel", { enumerable: true, get: function () { return dialog_panel_1.DialogPanel; } });
|
package/dialog/theme.d.ts
CHANGED
|
@@ -2,12 +2,10 @@ export interface DialogVariants {
|
|
|
2
2
|
default: true;
|
|
3
3
|
"drawer-right": true;
|
|
4
4
|
}
|
|
5
|
-
export
|
|
6
|
-
export interface DialogWidths {
|
|
5
|
+
export interface DialogPanelWidths {
|
|
7
6
|
xs: true;
|
|
8
7
|
sm: true;
|
|
9
8
|
default: true;
|
|
10
9
|
lg: true;
|
|
11
10
|
xl: true;
|
|
12
11
|
}
|
|
13
|
-
export type DialogWidth = keyof DialogWidths;
|
package/modal/README.md
CHANGED
|
@@ -4,21 +4,59 @@
|
|
|
4
4
|
|
|
5
5
|
```css
|
|
6
6
|
@import url("@uxf/ui/dialog/dialog.css");
|
|
7
|
-
@import url("@uxf/ui/modal/modal.css");
|
|
8
7
|
```
|
|
9
8
|
|
|
10
|
-
## Implementation
|
|
9
|
+
## Implementation ModalProvider
|
|
11
10
|
|
|
12
11
|
```tsx
|
|
13
12
|
import {AppProps} from "next/app";
|
|
14
|
-
import {getModalRef,
|
|
13
|
+
import {getModalRef, ModalProvider} from "@uxf/ui/modal";
|
|
15
14
|
|
|
16
15
|
function App(props: AppProps) {
|
|
17
16
|
return (
|
|
18
17
|
<UiContextProvider value={...}>
|
|
19
18
|
{props.children}
|
|
20
|
-
<
|
|
19
|
+
<ModalProvider ref={getModalRef()}/>
|
|
21
20
|
</UiContextProvider>
|
|
22
21
|
);
|
|
23
22
|
}
|
|
23
|
+
|
|
24
|
+
function Component(props: AppProps) {
|
|
25
|
+
return (
|
|
26
|
+
<div>
|
|
27
|
+
<Button
|
|
28
|
+
onClick={() =>
|
|
29
|
+
openModal({
|
|
30
|
+
children: (
|
|
31
|
+
<DialogPanel width="xs">Whatever content inside Modal</DialogPanel>
|
|
32
|
+
),
|
|
33
|
+
onClose: () => console.log("modal closed"),
|
|
34
|
+
})
|
|
35
|
+
}
|
|
36
|
+
>
|
|
37
|
+
Click to open modal - default
|
|
38
|
+
</Button>
|
|
39
|
+
</div>
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Implementation Modal
|
|
48
|
+
|
|
49
|
+
```tsx
|
|
50
|
+
function Component(props: AppProps) {
|
|
51
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
52
|
+
|
|
53
|
+
return (
|
|
54
|
+
<div>
|
|
55
|
+
<Button onClick={() => setIsOpen(true)}>Click to open modal</Button>
|
|
56
|
+
<Modal close={() => setIsOpen(false)} isOpen={isOpen}>
|
|
57
|
+
<DialogPanel width="xs">Whatever content inside Modal</DialogPanel>
|
|
58
|
+
</Modal>
|
|
59
|
+
</div>
|
|
60
|
+
);
|
|
61
|
+
}
|
|
24
62
|
```
|
package/modal/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { Modal } from "./modal";
|
|
2
|
-
export
|
|
2
|
+
export { ModalProvider } from "./modal-provider";
|
|
3
3
|
export { closeModal, getModalRef, openModal } from "./modal-service";
|
|
4
|
-
export type {
|
|
4
|
+
export type { ModalProps, ModalProviderProps, ModalRef, ModalVariant } from "./types";
|
package/modal/index.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.openModal = exports.getModalRef = exports.closeModal = exports.Modal = void 0;
|
|
3
|
+
exports.openModal = exports.getModalRef = exports.closeModal = exports.ModalProvider = exports.Modal = void 0;
|
|
4
4
|
var modal_1 = require("./modal");
|
|
5
5
|
Object.defineProperty(exports, "Modal", { enumerable: true, get: function () { return modal_1.Modal; } });
|
|
6
|
+
var modal_provider_1 = require("./modal-provider");
|
|
7
|
+
Object.defineProperty(exports, "ModalProvider", { enumerable: true, get: function () { return modal_provider_1.ModalProvider; } });
|
|
6
8
|
var modal_service_1 = require("./modal-service");
|
|
7
9
|
Object.defineProperty(exports, "closeModal", { enumerable: true, get: function () { return modal_service_1.closeModal; } });
|
|
8
10
|
Object.defineProperty(exports, "getModalRef", { enumerable: true, get: function () { return modal_service_1.getModalRef; } });
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
+
}) : function(o, v) {
|
|
17
|
+
o["default"] = v;
|
|
18
|
+
});
|
|
19
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
20
|
+
if (mod && mod.__esModule) return mod;
|
|
21
|
+
var result = {};
|
|
22
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
23
|
+
__setModuleDefault(result, mod);
|
|
24
|
+
return result;
|
|
25
|
+
};
|
|
26
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
+
exports.ModalProvider = void 0;
|
|
28
|
+
const react_1 = __importStar(require("react"));
|
|
29
|
+
const dialog_1 = require("../dialog/dialog");
|
|
30
|
+
exports.ModalProvider = (0, react_1.forwardRef)((props, ref) => {
|
|
31
|
+
var _a, _b;
|
|
32
|
+
const [content, setContent] = (0, react_1.useState)();
|
|
33
|
+
const { openDialog, DialogProvider, closeDialog } = (0, dialog_1.useDialog)({
|
|
34
|
+
onDialogClose: content === null || content === void 0 ? void 0 : content.onClose,
|
|
35
|
+
isBackdropCloseDisabled: content === null || content === void 0 ? void 0 : content.isBackdropCloseDisabled,
|
|
36
|
+
});
|
|
37
|
+
const openModalHandler = (modal) => {
|
|
38
|
+
openDialog(modal.children);
|
|
39
|
+
setContent(modal);
|
|
40
|
+
};
|
|
41
|
+
const closeModalHandler = () => {
|
|
42
|
+
if (content === null || content === void 0 ? void 0 : content.onClose) {
|
|
43
|
+
content.onClose();
|
|
44
|
+
}
|
|
45
|
+
closeDialog();
|
|
46
|
+
};
|
|
47
|
+
const innerRef = (0, react_1.useRef)({
|
|
48
|
+
close: closeModalHandler,
|
|
49
|
+
open: openModalHandler,
|
|
50
|
+
});
|
|
51
|
+
(0, react_1.useImperativeHandle)(ref, () => ({
|
|
52
|
+
close: innerRef.current.close,
|
|
53
|
+
open: innerRef.current.open,
|
|
54
|
+
}), []);
|
|
55
|
+
return (react_1.default.createElement(DialogProvider, { className: `uxf-modal uxf-modal--variant-${(_a = content === null || content === void 0 ? void 0 : content.variant) !== null && _a !== void 0 ? _a : "default"} ${(_b = content === null || content === void 0 ? void 0 : content.className) !== null && _b !== void 0 ? _b : ""}`, variant: content === null || content === void 0 ? void 0 : content.variant }));
|
|
56
|
+
});
|
|
57
|
+
exports.ModalProvider.displayName = "UxfUiModalProvider";
|
package/modal/modal-service.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ModalProviderProps, ModalRef } from "./types";
|
|
2
2
|
export declare function getModalRef(): import("react").RefObject<ModalRef>;
|
|
3
|
-
export declare function openModal(modal:
|
|
3
|
+
export declare function openModal(modal: ModalProviderProps): void;
|
|
4
4
|
export declare function closeModal(): void;
|
package/modal/modal.d.ts
CHANGED
|
@@ -1,16 +1,3 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
export interface ModalProps {
|
|
5
|
-
children: ReactNode;
|
|
6
|
-
className?: DialogProps["className"];
|
|
7
|
-
isBackdropCloseDisabled?: DialogProps["isBackdropCloseDisabled"];
|
|
8
|
-
onClose?: () => void;
|
|
9
|
-
variant?: ModalVariant;
|
|
10
|
-
width?: ModalWidth;
|
|
11
|
-
}
|
|
12
|
-
export interface ModalRef {
|
|
13
|
-
close: () => void;
|
|
14
|
-
open: (modal: ModalProps) => void;
|
|
15
|
-
}
|
|
16
|
-
export declare const Modal: React.ForwardRefExoticComponent<React.RefAttributes<ModalRef>>;
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { ModalProps } from "./types";
|
|
3
|
+
export declare function Modal(props: ModalProps): React.JSX.Element;
|
package/modal/modal.js
CHANGED
|
@@ -1,57 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
if (k2 === undefined) k2 = k;
|
|
5
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
-
}
|
|
9
|
-
Object.defineProperty(o, k2, desc);
|
|
10
|
-
}) : (function(o, m, k, k2) {
|
|
11
|
-
if (k2 === undefined) k2 = k;
|
|
12
|
-
o[k2] = m[k];
|
|
13
|
-
}));
|
|
14
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
-
}) : function(o, v) {
|
|
17
|
-
o["default"] = v;
|
|
18
|
-
});
|
|
19
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
20
|
-
if (mod && mod.__esModule) return mod;
|
|
21
|
-
var result = {};
|
|
22
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
23
|
-
__setModuleDefault(result, mod);
|
|
24
|
-
return result;
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
25
4
|
};
|
|
26
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
-
exports.Modal =
|
|
28
|
-
const react_1 =
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
6
|
+
exports.Modal = Modal;
|
|
7
|
+
const react_1 = require("@floating-ui/react");
|
|
8
|
+
const use_latest_1 = require("@uxf/core-react/hooks/use-latest");
|
|
9
|
+
const dialog_1 = require("@uxf/ui/dialog");
|
|
10
|
+
const react_2 = __importDefault(require("react"));
|
|
11
|
+
function Modal(props) {
|
|
12
|
+
var _a, _b;
|
|
13
|
+
const { refs, context } = (0, react_1.useFloating)({
|
|
14
|
+
open: props.isOpen,
|
|
15
|
+
onOpenChange(nextOpen, event, reason) {
|
|
16
|
+
if (!props.isBackdropCloseDisabled && (reason === "escape-key" || reason === "outside-press")) {
|
|
17
|
+
props.close();
|
|
18
|
+
}
|
|
19
|
+
},
|
|
36
20
|
});
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
};
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
45
|
-
closeDialog();
|
|
46
|
-
};
|
|
47
|
-
const innerRef = (0, react_1.useRef)({
|
|
48
|
-
close: closeModalHandler,
|
|
49
|
-
open: openModalHandler,
|
|
50
|
-
});
|
|
51
|
-
(0, react_1.useImperativeHandle)(ref, () => ({
|
|
52
|
-
close: innerRef.current.close,
|
|
53
|
-
open: innerRef.current.open,
|
|
54
|
-
}), []);
|
|
55
|
-
return (react_1.default.createElement(DialogProvider, { className: `uxf-modal uxf-modal--variant-${(_a = content === null || content === void 0 ? void 0 : content.variant) !== null && _a !== void 0 ? _a : "default"} uxf-modal--width-${(_b = content === null || content === void 0 ? void 0 : content.width) !== null && _b !== void 0 ? _b : "default"} ${(_c = content === null || content === void 0 ? void 0 : content.className) !== null && _c !== void 0 ? _c : ""}`, variant: content === null || content === void 0 ? void 0 : content.variant, width: content === null || content === void 0 ? void 0 : content.width }));
|
|
56
|
-
});
|
|
57
|
-
exports.Modal.displayName = "UxfUiModal";
|
|
21
|
+
const click = (0, react_1.useClick)(context);
|
|
22
|
+
const role = (0, react_1.useRole)(context);
|
|
23
|
+
const dismiss = (0, react_1.useDismiss)(context, { outsidePressEvent: "mousedown", escapeKey: true });
|
|
24
|
+
const { getFloatingProps } = (0, react_1.useInteractions)([click, role, dismiss]);
|
|
25
|
+
const latestContext = (0, use_latest_1.useLatest)(context);
|
|
26
|
+
return (react_2.default.createElement(dialog_1.Dialog, { className: `uxf-modal uxf-modal--variant-${(_a = props.variant) !== null && _a !== void 0 ? _a : "default"} ${(_b = props.className) !== null && _b !== void 0 ? _b : ""}`, context: latestContext.current, forwardedRef: refs.setFloating, getFloatingProps: getFloatingProps, isOpen: props.isOpen, variant: props.variant }, props.children));
|
|
27
|
+
}
|
package/modal/modal.stories.d.ts
CHANGED
package/modal/modal.stories.js
CHANGED
|
@@ -1,62 +1,109 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
4
24
|
};
|
|
5
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
26
|
exports.Default = Default;
|
|
27
|
+
exports.ModalProvider = ModalProvider;
|
|
7
28
|
const button_1 = require("@uxf/ui/button");
|
|
8
|
-
const
|
|
29
|
+
const dialog_1 = require("@uxf/ui/dialog");
|
|
30
|
+
const react_1 = __importStar(require("react"));
|
|
31
|
+
const modal_1 = require("./modal");
|
|
9
32
|
const modal_service_1 = require("./modal-service");
|
|
10
33
|
function Default() {
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
react_1.default.createElement(
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
34
|
+
const [isOpenXs, setIsOpenXs] = (0, react_1.useState)(false);
|
|
35
|
+
const [isOpenRightDrawer, setIsOpenRightDrawer] = (0, react_1.useState)(false);
|
|
36
|
+
const [isOpenDisableBackdrop, setIsOpenDisableBackdrop] = (0, react_1.useState)(false);
|
|
37
|
+
return (react_1.default.createElement("div", { className: "space-y-2 p-20 lg:w-1/2" },
|
|
38
|
+
react_1.default.createElement("div", null,
|
|
39
|
+
react_1.default.createElement(button_1.Button, { onClick: () => setIsOpenXs(true) }, "Click to open modal xs"),
|
|
40
|
+
react_1.default.createElement(modal_1.Modal, { close: () => setIsOpenXs(false), isOpen: isOpenXs },
|
|
41
|
+
react_1.default.createElement(dialog_1.DialogPanel, { width: "xs" }, "Whatever content inside Modal xs"))),
|
|
42
|
+
react_1.default.createElement("div", null,
|
|
43
|
+
react_1.default.createElement(button_1.Button, { onClick: () => setIsOpenRightDrawer(true) }, "Click to open modal drawer-right"),
|
|
44
|
+
react_1.default.createElement(modal_1.Modal, { close: () => setIsOpenRightDrawer(false), isOpen: isOpenRightDrawer, variant: "drawer-right" },
|
|
45
|
+
react_1.default.createElement(dialog_1.DialogPanel, null, "Whatever content inside Modal drawer-right"))),
|
|
46
|
+
react_1.default.createElement("div", null,
|
|
47
|
+
react_1.default.createElement(button_1.Button, { onClick: () => setIsOpenDisableBackdrop(true) }, "Click to open modal DisableBackdrop"),
|
|
48
|
+
react_1.default.createElement(modal_1.Modal, { close: () => setIsOpenDisableBackdrop(false), isBackdropCloseDisabled: true, isOpen: isOpenDisableBackdrop },
|
|
49
|
+
react_1.default.createElement(dialog_1.DialogPanel, null,
|
|
50
|
+
react_1.default.createElement("div", { className: "p-4" },
|
|
51
|
+
react_1.default.createElement("p", null, "Whatever content inside DisableBackdrop:"),
|
|
52
|
+
react_1.default.createElement(button_1.Button, { className: "mt-2", onClick: () => setIsOpenDisableBackdrop(false) }, "Close")))))));
|
|
53
|
+
}
|
|
54
|
+
function ModalProvider() {
|
|
55
|
+
return (react_1.default.createElement("div", { className: "space-y-2 p-20 lg:w-1/2" },
|
|
56
|
+
react_1.default.createElement("div", { className: "light inline-flex flex-col space-y-4" },
|
|
57
|
+
react_1.default.createElement(button_1.Button, { onClick: () => (0, modal_service_1.openModal)({
|
|
58
|
+
children: (react_1.default.createElement(dialog_1.DialogPanel, null,
|
|
59
|
+
react_1.default.createElement("div", { className: "p-4" },
|
|
60
|
+
react_1.default.createElement("p", { className: "mb-3 text-lg font-bold" }, "Modal - default size"),
|
|
61
|
+
react_1.default.createElement(button_1.Button, { isFullWidth: true, onClick: modal_service_1.closeModal }, "Close modal")))),
|
|
62
|
+
onClose: () => console.log("modal closed"),
|
|
63
|
+
}) }, "Click to open modal - default"),
|
|
64
|
+
react_1.default.createElement(button_1.Button, { onClick: () => (0, modal_service_1.openModal)({
|
|
65
|
+
children: (react_1.default.createElement(dialog_1.DialogPanel, { width: "xs" },
|
|
66
|
+
react_1.default.createElement("div", { className: "p-4" },
|
|
67
|
+
react_1.default.createElement("p", { className: "mb-3 text-lg font-bold" }, "Modal - xs size"),
|
|
68
|
+
react_1.default.createElement(button_1.Button, { isFullWidth: true, onClick: modal_service_1.closeModal }, "Close modal")))),
|
|
69
|
+
}) }, "Click to open modal - xs"),
|
|
70
|
+
react_1.default.createElement(button_1.Button, { onClick: () => (0, modal_service_1.openModal)({
|
|
71
|
+
children: (react_1.default.createElement(dialog_1.DialogPanel, { width: "sm" },
|
|
72
|
+
react_1.default.createElement("div", { className: "p-4" },
|
|
73
|
+
react_1.default.createElement("p", { className: "mb-3 text-lg font-bold" }, "Modal - sm size"),
|
|
74
|
+
react_1.default.createElement(button_1.Button, { isFullWidth: true, onClick: modal_service_1.closeModal }, "Close modal")))),
|
|
75
|
+
}) }, "Click to open modal - sm"),
|
|
76
|
+
react_1.default.createElement(button_1.Button, { onClick: () => (0, modal_service_1.openModal)({
|
|
77
|
+
children: (react_1.default.createElement(dialog_1.DialogPanel, { width: "lg" },
|
|
78
|
+
react_1.default.createElement("div", { className: "p-4" },
|
|
79
|
+
react_1.default.createElement("p", { className: "mb-3 text-lg font-bold" }, "Modal - lg size"),
|
|
80
|
+
react_1.default.createElement(button_1.Button, { isFullWidth: true, onClick: modal_service_1.closeModal }, "Close modal")))),
|
|
81
|
+
}) }, "Click to open modal - lg"),
|
|
82
|
+
react_1.default.createElement(button_1.Button, { onClick: () => (0, modal_service_1.openModal)({
|
|
83
|
+
children: (react_1.default.createElement(dialog_1.DialogPanel, { width: "xl" },
|
|
84
|
+
react_1.default.createElement("div", { className: "p-4" },
|
|
85
|
+
react_1.default.createElement("p", { className: "mb-3 text-lg font-bold" }, "Modal - xl size"),
|
|
86
|
+
react_1.default.createElement(button_1.Button, { isFullWidth: true, onClick: modal_service_1.closeModal }, "Close modal")))),
|
|
87
|
+
}) }, "Click to open modal - xl"),
|
|
88
|
+
react_1.default.createElement(button_1.Button, { onClick: () => (0, modal_service_1.openModal)({
|
|
89
|
+
children: (react_1.default.createElement(dialog_1.DialogPanel, null,
|
|
90
|
+
react_1.default.createElement("div", { className: "p-4" },
|
|
91
|
+
react_1.default.createElement("p", { className: "mb-3 text-lg font-bold" }, "Modal - dark"),
|
|
92
|
+
react_1.default.createElement(button_1.Button, { isFullWidth: true, onClick: modal_service_1.closeModal }, "Close modal")))),
|
|
93
|
+
className: "dark",
|
|
94
|
+
}) }, "Click to open modal - dark"),
|
|
95
|
+
react_1.default.createElement(button_1.Button, { onClick: () => (0, modal_service_1.openModal)({
|
|
96
|
+
children: (react_1.default.createElement(dialog_1.DialogPanel, null,
|
|
97
|
+
react_1.default.createElement("div", { className: "p-4" },
|
|
98
|
+
react_1.default.createElement("p", { className: "mb-3 text-lg font-bold" }, "Modal - disable backdrop close"),
|
|
99
|
+
react_1.default.createElement(button_1.Button, { isFullWidth: true, onClick: modal_service_1.closeModal }, "Close modal")))),
|
|
100
|
+
isBackdropCloseDisabled: true,
|
|
101
|
+
}) }, "Click to open modal - disable backdrop close"),
|
|
102
|
+
react_1.default.createElement(button_1.Button, { onClick: () => (0, modal_service_1.openModal)({
|
|
103
|
+
children: (react_1.default.createElement(dialog_1.DialogPanel, null,
|
|
104
|
+
react_1.default.createElement("div", { className: "p-4" },
|
|
105
|
+
react_1.default.createElement("p", { className: "mb-3 text-lg font-bold" }, "Modal - variant right drawer"),
|
|
106
|
+
react_1.default.createElement(button_1.Button, { isFullWidth: true, onClick: modal_service_1.closeModal }, "Close modal")))),
|
|
107
|
+
variant: "drawer-right",
|
|
108
|
+
}) }, "Click to open modal - variant right drawer"))));
|
|
62
109
|
}
|
package/modal/theme.d.ts
CHANGED
|
@@ -1,13 +1,4 @@
|
|
|
1
|
-
export interface ModalWidths {
|
|
2
|
-
xs: true;
|
|
3
|
-
sm: true;
|
|
4
|
-
default: true;
|
|
5
|
-
lg: true;
|
|
6
|
-
xl: true;
|
|
7
|
-
}
|
|
8
|
-
export type ModalWidth = keyof ModalWidths;
|
|
9
1
|
export interface ModalVariants {
|
|
10
2
|
default: true;
|
|
11
3
|
"drawer-right": true;
|
|
12
4
|
}
|
|
13
|
-
export type ModalVariant = keyof ModalVariants;
|
package/modal/types.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
import type { DialogProps } from "../dialog";
|
|
3
|
+
import { ModalVariants } from "./theme";
|
|
4
|
+
export type ModalVariant = keyof ModalVariants;
|
|
5
|
+
export interface ModalProviderProps {
|
|
6
|
+
children: ReactNode;
|
|
7
|
+
className?: DialogProps["className"];
|
|
8
|
+
isBackdropCloseDisabled?: DialogProps["isBackdropCloseDisabled"];
|
|
9
|
+
onClose?: () => void;
|
|
10
|
+
variant?: ModalVariant;
|
|
11
|
+
}
|
|
12
|
+
export interface ModalRef {
|
|
13
|
+
close: () => void;
|
|
14
|
+
open: (modal: ModalProviderProps) => void;
|
|
15
|
+
}
|
|
16
|
+
export interface ModalProps {
|
|
17
|
+
children: ReactNode;
|
|
18
|
+
className?: DialogProps["className"];
|
|
19
|
+
close: () => void;
|
|
20
|
+
isBackdropCloseDisabled?: boolean;
|
|
21
|
+
isOpen: boolean;
|
|
22
|
+
variant?: ModalVariant;
|
|
23
|
+
}
|
package/modal/types.js
ADDED
package/package.json
CHANGED
package/readmes.d.ts
CHANGED
|
@@ -32,7 +32,7 @@ export declare const readmes: {
|
|
|
32
32
|
readonly icon: typeof alertBubbleReadme;
|
|
33
33
|
readonly "icon-button": typeof alertBubbleReadme;
|
|
34
34
|
readonly "image-gallery": typeof alertBubbleReadme;
|
|
35
|
-
readonly
|
|
35
|
+
readonly "info-box": typeof alertBubbleReadme;
|
|
36
36
|
readonly input: typeof alertBubbleReadme;
|
|
37
37
|
readonly label: typeof alertBubbleReadme;
|
|
38
38
|
readonly layout: typeof alertBubbleReadme;
|
package/readmes.js
CHANGED
|
@@ -98,7 +98,7 @@ exports.readmes = {
|
|
|
98
98
|
"icon": README_md_30.default,
|
|
99
99
|
"icon-button": README_md_31.default,
|
|
100
100
|
"image-gallery": README_md_32.default,
|
|
101
|
-
"
|
|
101
|
+
"info-box": README_md_33.default,
|
|
102
102
|
"input": README_md_34.default,
|
|
103
103
|
"label": README_md_35.default,
|
|
104
104
|
"layout": README_md_36.default,
|
package/css/modal.css
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
.uxf-modal {
|
|
2
|
-
&--width-xs {
|
|
3
|
-
--panel-max-w: theme("maxWidth.xs");
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
&--width-sm {
|
|
7
|
-
--panel-max-w: theme("maxWidth.sm");
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
&--width-default {
|
|
11
|
-
--panel-max-w: theme("maxWidth.lg");
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
&--width-lg {
|
|
15
|
-
--panel-max-w: theme("maxWidth.3xl");
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
&--width-xl {
|
|
19
|
-
--panel-max-w: theme("maxWidth.5xl");
|
|
20
|
-
}
|
|
21
|
-
}
|