@negative-space/modal 1.0.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Matheus Bastani
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,15 @@
1
+ # @negative-space/modal
2
+
3
+ A lightweight Modal component from Negative Space, enabling fully custom interactive UI experiences.
4
+
5
+ ## Installation
6
+
7
+ # Using Yarn
8
+ yarn add @negative-space/modal
9
+
10
+ # Using npm
11
+ npm install @negative-space/modal
12
+
13
+ ## Contributing
14
+
15
+ Feel free to fork, tweak, and send a pull request!
@@ -0,0 +1,35 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { IconButtonProps } from '@negative-space/button/src/IconButton';
3
+ import { PopoverHandle, FixedPosition, PopoverProps } from '@negative-space/popover';
4
+ import React from 'react';
5
+
6
+ interface UseModalOptions {
7
+ defaultOpen?: boolean;
8
+ open?: boolean;
9
+ onOpenChange?: (open: boolean) => void;
10
+ dismissOnClickOutside?: boolean;
11
+ dismissOnEscape?: boolean;
12
+ trapFocus?: boolean;
13
+ usePortal?: boolean;
14
+ zIndex?: number;
15
+ position?: FixedPosition;
16
+ }
17
+ type ModalHandle = PopoverHandle;
18
+ declare function useModal(options?: UseModalOptions): ModalHandle;
19
+
20
+ interface ModalProps extends Omit<PopoverProps, 'popover' | 'classNames' | 'styles'> {
21
+ classNames?: Omit<NonNullable<PopoverProps['classNames']>, 'arrow'> & {
22
+ closeButton?: string;
23
+ closeIcon?: string;
24
+ };
25
+ styles?: Omit<NonNullable<PopoverProps['styles']>, 'arrow'> & {
26
+ closeButton?: React.CSSProperties;
27
+ closeIcon?: React.CSSProperties;
28
+ };
29
+ hideCloseButton?: boolean;
30
+ buttonProps?: Omit<IconButtonProps, 'onClick' | 'aria-label' | 'className' | 'style'>;
31
+ modal: ModalHandle;
32
+ }
33
+ declare const Modal: ({ modal, hideCloseButton, classNames, styles, children, ...popoverProps }: ModalProps) => react_jsx_runtime.JSX.Element;
34
+
35
+ export { Modal, type ModalHandle, type ModalProps, type UseModalOptions, useModal };
@@ -0,0 +1,35 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { IconButtonProps } from '@negative-space/button/src/IconButton';
3
+ import { PopoverHandle, FixedPosition, PopoverProps } from '@negative-space/popover';
4
+ import React from 'react';
5
+
6
+ interface UseModalOptions {
7
+ defaultOpen?: boolean;
8
+ open?: boolean;
9
+ onOpenChange?: (open: boolean) => void;
10
+ dismissOnClickOutside?: boolean;
11
+ dismissOnEscape?: boolean;
12
+ trapFocus?: boolean;
13
+ usePortal?: boolean;
14
+ zIndex?: number;
15
+ position?: FixedPosition;
16
+ }
17
+ type ModalHandle = PopoverHandle;
18
+ declare function useModal(options?: UseModalOptions): ModalHandle;
19
+
20
+ interface ModalProps extends Omit<PopoverProps, 'popover' | 'classNames' | 'styles'> {
21
+ classNames?: Omit<NonNullable<PopoverProps['classNames']>, 'arrow'> & {
22
+ closeButton?: string;
23
+ closeIcon?: string;
24
+ };
25
+ styles?: Omit<NonNullable<PopoverProps['styles']>, 'arrow'> & {
26
+ closeButton?: React.CSSProperties;
27
+ closeIcon?: React.CSSProperties;
28
+ };
29
+ hideCloseButton?: boolean;
30
+ buttonProps?: Omit<IconButtonProps, 'onClick' | 'aria-label' | 'className' | 'style'>;
31
+ modal: ModalHandle;
32
+ }
33
+ declare const Modal: ({ modal, hideCloseButton, classNames, styles, children, ...popoverProps }: ModalProps) => react_jsx_runtime.JSX.Element;
34
+
35
+ export { Modal, type ModalHandle, type ModalProps, type UseModalOptions, useModal };
package/dist/index.js ADDED
@@ -0,0 +1,74 @@
1
+ 'use strict';
2
+
3
+ var IconButton = require('@negative-space/button/src/IconButton');
4
+ var popover = require('@negative-space/popover');
5
+ var system = require('@negative-space/system');
6
+ var jsxRuntime = require('react/jsx-runtime');
7
+
8
+ // src/Modal.tsx
9
+ var Modal = ({
10
+ modal,
11
+ hideCloseButton,
12
+ classNames,
13
+ styles,
14
+ children,
15
+ ...popoverProps
16
+ }) => {
17
+ const { global } = system.useNSUI();
18
+ return /* @__PURE__ */ jsxRuntime.jsxs(
19
+ popover.Popover,
20
+ {
21
+ ...popoverProps,
22
+ popover: modal,
23
+ role: "dialog",
24
+ classNames: {
25
+ root: system.cn(`${global.prefixCls}-modal`, classNames?.root),
26
+ content: system.cn(`${global.prefixCls}-modal-content`, classNames?.content),
27
+ overlay: system.cn(`${global.prefixCls}-modal-overlay`, classNames?.overlay)
28
+ },
29
+ styles: {
30
+ root: { ...styles?.root },
31
+ content: { ...styles?.content },
32
+ overlay: { ...styles?.overlay }
33
+ },
34
+ children: [
35
+ !hideCloseButton && /* @__PURE__ */ jsxRuntime.jsx(
36
+ IconButton.IconButton,
37
+ {
38
+ ...modal.triggerProps,
39
+ "aria-label": "close",
40
+ onClick: modal.close,
41
+ className: system.cn(`${global.prefixCls}-modal-close-button`, classNames?.closeButton),
42
+ style: styles?.closeButton,
43
+ children: /* @__PURE__ */ jsxRuntime.jsx(
44
+ system.X,
45
+ {
46
+ className: system.cn(`${global.prefixCls}-modal-close`, classNames?.closeIcon),
47
+ style: { position: "absolute", right: "0.5rem", top: "0.5rem", ...styles?.closeIcon }
48
+ }
49
+ )
50
+ }
51
+ ),
52
+ children
53
+ ]
54
+ }
55
+ );
56
+ };
57
+ function useModal(options = {}) {
58
+ const { position = "center", ...rest } = options;
59
+ return popover.usePopover({
60
+ ...rest,
61
+ overlay: true,
62
+ showArrow: false,
63
+ trigger: "click",
64
+ trapFocus: true,
65
+ usePortal: true,
66
+ zIndex: 9999,
67
+ fixedPosition: position
68
+ });
69
+ }
70
+
71
+ exports.Modal = Modal;
72
+ exports.useModal = useModal;
73
+ //# sourceMappingURL=index.js.map
74
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/Modal.tsx","../src/useModal.ts"],"names":["useNSUI","jsxs","Popover","cn","jsx","IconButton","X","usePopover"],"mappings":";;;;;;;;AAqBO,IAAM,QAAQ,CAAC;AAAA,EACpB,KAAA;AAAA,EACA,eAAA;AAAA,EACA,UAAA;AAAA,EACA,MAAA;AAAA,EACA,QAAA;AAAA,EACA,GAAG;AACL,CAAA,KAAkB;AAChB,EAAA,MAAM,EAAE,MAAA,EAAO,GAAIA,cAAA,EAAQ;AAE3B,EAAA,uBACEC,eAAA;AAAA,IAACC,eAAA;AAAA,IAAA;AAAA,MACE,GAAG,YAAA;AAAA,MACJ,OAAA,EAAS,KAAA;AAAA,MACT,IAAA,EAAK,QAAA;AAAA,MACL,UAAA,EAAY;AAAA,QACV,MAAMC,SAAA,CAAG,CAAA,EAAG,OAAO,SAAS,CAAA,MAAA,CAAA,EAAU,YAAY,IAAI,CAAA;AAAA,QACtD,SAASA,SAAA,CAAG,CAAA,EAAG,OAAO,SAAS,CAA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H,OAAA,EAAS,IAAA;AAAA,IACT,SAAA,EAAW,KAAA;AAAA,IACX,OAAA,EAAS,OAAA;AAAA,IACT,SAAA,EAAW,IAAA;AAAA,IACX,SAAA,EAAW,IAAA;AAAA,IACX,MAAA,EAAQ,IAAA;AAAA,IACR,aAAA,EAAe;AAAA,GACY,CAAA;AAC/B","file":"index.js","sourcesContent":["import { IconButton, type IconButtonProps } from '@negative-space/button/src/IconButton'\nimport { Popover, type PopoverProps } from '@negative-space/popover'\nimport { cn, useNSUI, X } from '@negative-space/system'\nimport React from 'react'\n\nimport { type ModalHandle } from './useModal'\n\nexport interface ModalProps extends Omit<PopoverProps, 'popover' | 'classNames' | 'styles'> {\n classNames?: Omit<NonNullable<PopoverProps['classNames']>, 'arrow'> & {\n closeButton?: string\n closeIcon?: string\n }\n styles?: Omit<NonNullable<PopoverProps['styles']>, 'arrow'> & {\n closeButton?: React.CSSProperties\n closeIcon?: React.CSSProperties\n }\n hideCloseButton?: boolean\n buttonProps?: Omit<IconButtonProps, 'onClick' | 'aria-label' | 'className' | 'style'>\n modal: ModalHandle\n}\n\nexport const Modal = ({\n modal,\n hideCloseButton,\n classNames,\n styles,\n children,\n ...popoverProps\n}: ModalProps) => {\n const { global } = useNSUI()\n\n return (\n <Popover\n {...popoverProps}\n popover={modal}\n role=\"dialog\"\n classNames={{\n root: cn(`${global.prefixCls}-modal`, classNames?.root),\n content: cn(`${global.prefixCls}-modal-content`, classNames?.content),\n overlay: cn(`${global.prefixCls}-modal-overlay`, classNames?.overlay)\n }}\n styles={{\n root: { ...styles?.root },\n content: { ...styles?.content },\n overlay: { ...styles?.overlay }\n }}\n >\n {!hideCloseButton && (\n <IconButton\n {...modal.triggerProps}\n aria-label=\"close\"\n onClick={modal.close}\n className={cn(`${global.prefixCls}-modal-close-button`, classNames?.closeButton)}\n style={styles?.closeButton}\n >\n <X\n className={cn(`${global.prefixCls}-modal-close`, classNames?.closeIcon)}\n style={{ position: 'absolute', right: '0.5rem', top: '0.5rem', ...styles?.closeIcon }}\n />\n </IconButton>\n )}\n {children}\n </Popover>\n )\n}\n","import {\n type FixedPosition,\n type PopoverHandle,\n usePopover,\n type UsePopoverOptions\n} from '@negative-space/popover'\n\nexport type { FixedPosition as ModalPosition }\n\nexport interface UseModalOptions {\n defaultOpen?: boolean\n open?: boolean\n onOpenChange?: (open: boolean) => void\n dismissOnClickOutside?: boolean\n dismissOnEscape?: boolean\n trapFocus?: boolean\n usePortal?: boolean\n zIndex?: number\n position?: FixedPosition\n}\n\nexport type ModalHandle = PopoverHandle\n\nexport function useModal(options: UseModalOptions = {}): ModalHandle {\n const { position = 'center', ...rest } = options\n\n return usePopover({\n ...rest,\n overlay: true,\n showArrow: false,\n trigger: 'click',\n trapFocus: true,\n usePortal: true,\n zIndex: 9999,\n fixedPosition: position\n } satisfies UsePopoverOptions)\n}\n"]}
package/dist/index.mjs ADDED
@@ -0,0 +1,71 @@
1
+ import { IconButton } from '@negative-space/button/src/IconButton';
2
+ import { Popover, usePopover } from '@negative-space/popover';
3
+ import { useNSUI, cn, X } from '@negative-space/system';
4
+ import { jsxs, jsx } from 'react/jsx-runtime';
5
+
6
+ // src/Modal.tsx
7
+ var Modal = ({
8
+ modal,
9
+ hideCloseButton,
10
+ classNames,
11
+ styles,
12
+ children,
13
+ ...popoverProps
14
+ }) => {
15
+ const { global } = useNSUI();
16
+ return /* @__PURE__ */ jsxs(
17
+ Popover,
18
+ {
19
+ ...popoverProps,
20
+ popover: modal,
21
+ role: "dialog",
22
+ classNames: {
23
+ root: cn(`${global.prefixCls}-modal`, classNames?.root),
24
+ content: cn(`${global.prefixCls}-modal-content`, classNames?.content),
25
+ overlay: cn(`${global.prefixCls}-modal-overlay`, classNames?.overlay)
26
+ },
27
+ styles: {
28
+ root: { ...styles?.root },
29
+ content: { ...styles?.content },
30
+ overlay: { ...styles?.overlay }
31
+ },
32
+ children: [
33
+ !hideCloseButton && /* @__PURE__ */ jsx(
34
+ IconButton,
35
+ {
36
+ ...modal.triggerProps,
37
+ "aria-label": "close",
38
+ onClick: modal.close,
39
+ className: cn(`${global.prefixCls}-modal-close-button`, classNames?.closeButton),
40
+ style: styles?.closeButton,
41
+ children: /* @__PURE__ */ jsx(
42
+ X,
43
+ {
44
+ className: cn(`${global.prefixCls}-modal-close`, classNames?.closeIcon),
45
+ style: { position: "absolute", right: "0.5rem", top: "0.5rem", ...styles?.closeIcon }
46
+ }
47
+ )
48
+ }
49
+ ),
50
+ children
51
+ ]
52
+ }
53
+ );
54
+ };
55
+ function useModal(options = {}) {
56
+ const { position = "center", ...rest } = options;
57
+ return usePopover({
58
+ ...rest,
59
+ overlay: true,
60
+ showArrow: false,
61
+ trigger: "click",
62
+ trapFocus: true,
63
+ usePortal: true,
64
+ zIndex: 9999,
65
+ fixedPosition: position
66
+ });
67
+ }
68
+
69
+ export { Modal, useModal };
70
+ //# sourceMappingURL=index.mjs.map
71
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/Modal.tsx","../src/useModal.ts"],"names":[],"mappings":";;;;;;AAqBO,IAAM,QAAQ,CAAC;AAAA,EACpB,KAAA;AAAA,EACA,eAAA;AAAA,EACA,UAAA;AAAA,EACA,MAAA;AAAA,EACA,QAAA;AAAA,EACA,GAAG;AACL,CAAA,KAAkB;AAChB,EAAA,MAAM,EAAE,MAAA,EAAO,GAAI,OAAA,EAAQ;AAE3B,EAAA,uBACE,IAAA;AAAA,IAAC,OAAA;AAAA,IAAA;AAAA,MACE,GAAG,YAAA;AAAA,MACJ,OAAA,EAAS,KAAA;AAAA,MACT,IAAA,EAAK,QAAA;AAAA,MACL,UAAA,EAAY;AAAA,QACV,MAAM,EAAA,CAAG,CAAA,EAAG,OAAO,SAAS,CAAA,MAAA,CAAA,EAAU,YAAY,IAAI,CAAA;AAAA,QACtD,SAAS,EAAA,CAAG,CAAA,EAAG,OAAO,SAAS,CAAA,cAAA,CAAA,EAAkB,YAAY,OAAO,CAAA;AAAA,QACpE,S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AAA,EAAS,OAAA;AAAA,IACT,SAAA,EAAW,IAAA;AAAA,IACX,SAAA,EAAW,IAAA;AAAA,IACX,MAAA,EAAQ,IAAA;AAAA,IACR,aAAA,EAAe;AAAA,GACY,CAAA;AAC/B","file":"index.mjs","sourcesContent":["import { IconButton, type IconButtonProps } from '@negative-space/button/src/IconButton'\nimport { Popover, type PopoverProps } from '@negative-space/popover'\nimport { cn, useNSUI, X } from '@negative-space/system'\nimport React from 'react'\n\nimport { type ModalHandle } from './useModal'\n\nexport interface ModalProps extends Omit<PopoverProps, 'popover' | 'classNames' | 'styles'> {\n classNames?: Omit<NonNullable<PopoverProps['classNames']>, 'arrow'> & {\n closeButton?: string\n closeIcon?: string\n }\n styles?: Omit<NonNullable<PopoverProps['styles']>, 'arrow'> & {\n closeButton?: React.CSSProperties\n closeIcon?: React.CSSProperties\n }\n hideCloseButton?: boolean\n buttonProps?: Omit<IconButtonProps, 'onClick' | 'aria-label' | 'className' | 'style'>\n modal: ModalHandle\n}\n\nexport const Modal = ({\n modal,\n hideCloseButton,\n classNames,\n styles,\n children,\n ...popoverProps\n}: ModalProps) => {\n const { global } = useNSUI()\n\n return (\n <Popover\n {...popoverProps}\n popover={modal}\n role=\"dialog\"\n classNames={{\n root: cn(`${global.prefixCls}-modal`, classNames?.root),\n content: cn(`${global.prefixCls}-modal-content`, classNames?.content),\n overlay: cn(`${global.prefixCls}-modal-overlay`, classNames?.overlay)\n }}\n styles={{\n root: { ...styles?.root },\n content: { ...styles?.content },\n overlay: { ...styles?.overlay }\n }}\n >\n {!hideCloseButton && (\n <IconButton\n {...modal.triggerProps}\n aria-label=\"close\"\n onClick={modal.close}\n className={cn(`${global.prefixCls}-modal-close-button`, classNames?.closeButton)}\n style={styles?.closeButton}\n >\n <X\n className={cn(`${global.prefixCls}-modal-close`, classNames?.closeIcon)}\n style={{ position: 'absolute', right: '0.5rem', top: '0.5rem', ...styles?.closeIcon }}\n />\n </IconButton>\n )}\n {children}\n </Popover>\n )\n}\n","import {\n type FixedPosition,\n type PopoverHandle,\n usePopover,\n type UsePopoverOptions\n} from '@negative-space/popover'\n\nexport type { FixedPosition as ModalPosition }\n\nexport interface UseModalOptions {\n defaultOpen?: boolean\n open?: boolean\n onOpenChange?: (open: boolean) => void\n dismissOnClickOutside?: boolean\n dismissOnEscape?: boolean\n trapFocus?: boolean\n usePortal?: boolean\n zIndex?: number\n position?: FixedPosition\n}\n\nexport type ModalHandle = PopoverHandle\n\nexport function useModal(options: UseModalOptions = {}): ModalHandle {\n const { position = 'center', ...rest } = options\n\n return usePopover({\n ...rest,\n overlay: true,\n showArrow: false,\n trigger: 'click',\n trapFocus: true,\n usePortal: true,\n zIndex: 9999,\n fixedPosition: position\n } satisfies UsePopoverOptions)\n}\n"]}
package/package.json ADDED
@@ -0,0 +1,56 @@
1
+ {
2
+ "name": "@negative-space/modal",
3
+ "version": "1.0.0",
4
+ "publishConfig": {
5
+ "access": "public"
6
+ },
7
+ "description": "A lightweight Modal component from Negative Space, enabling fully custom interactive UI experiences",
8
+ "keywords": [
9
+ "components",
10
+ "feedback",
11
+ "modal",
12
+ "negative-space",
13
+ "nsui",
14
+ "react",
15
+ "ui"
16
+ ],
17
+ "license": "MIT",
18
+ "main": "dist/index.js",
19
+ "module": "dist/index.mjs",
20
+ "types": "dist/index.d.ts",
21
+ "files": [
22
+ "dist"
23
+ ],
24
+ "repository": {
25
+ "type": "git",
26
+ "url": "git+https://github.com/negative-space-ui/nsui",
27
+ "directory": "packages/ui/modal"
28
+ },
29
+ "bugs": {
30
+ "url": "https://github.com/negative-space-ui/nsui/issues"
31
+ },
32
+ "dependencies": {
33
+ "@negative-space/button": "2.5.0",
34
+ "@negative-space/popover": "1.0.0",
35
+ "@negative-space/system": "1.3.0"
36
+ },
37
+ "peerDependencies": {
38
+ "react": "^19.2.3"
39
+ },
40
+ "clean-package": "../../../../clean-package.config.json",
41
+ "exports": {
42
+ ".": {
43
+ "types": "./dist/index.d.ts",
44
+ "import": "./dist/index.mjs",
45
+ "require": "./dist/index.js"
46
+ },
47
+ "./package.json": "./package.json"
48
+ },
49
+ "scripts": {
50
+ "build": "tsup",
51
+ "clean": "rimraf dist .turbo",
52
+ "dev": "pnpm build:fast --watch",
53
+ "lint": "eslint . --ext ts,tsx",
54
+ "typecheck": "tsc --noEmit"
55
+ }
56
+ }