@pittorica/dialog-react 0.22.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 Davide Di Criscito
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,84 @@
1
+ # @pittorica/dialog-react
2
+
3
+ A window overlaid on either the primary window or another dialog window, rendering the content underneath inert.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @pittorica/dialog-react
9
+ ```
10
+
11
+ You will also need to install the core `pittorica` package which contains the CSS, and its dependencies.
12
+
13
+ ```bash
14
+ npm install pittorica @pittorica/box-react @pittorica/heading-react @pittorica/button-react
15
+ ```
16
+
17
+ ## Usage
18
+
19
+ ```jsx
20
+ import { useState } from 'react';
21
+ import {
22
+ Dialog,
23
+ DialogActions,
24
+ DialogDescription,
25
+ DialogTitle,
26
+ } from '@pittorica/dialog-react';
27
+ import { Button } from '@pittorica/button-react';
28
+ import 'pittorica/reset';
29
+ import 'pittorica/tokens';
30
+
31
+ function MyDialog() {
32
+ const [open, setOpen] = useState(false);
33
+
34
+ return (
35
+ <>
36
+ <Button variant="elevated" onClick={() => setOpen(true)}>
37
+ Open Dialog
38
+ </Button>
39
+
40
+ <Dialog open={open} onClose={() => setOpen(false)}>
41
+ <DialogTitle>Dialog Title</DialogTitle>
42
+ <DialogDescription>
43
+ This is a description of the dialog content. It provides context for
44
+ the user regarding the action they are about to take.
45
+ </DialogDescription>
46
+ <DialogActions>
47
+ <Button variant="text" color="slate" onClick={() => setOpen(false)}>
48
+ Cancel
49
+ </Button>
50
+ <Button variant="filled" onClick={() => setOpen(false)}>
51
+ Confirm
52
+ </Button>
53
+ </DialogActions>
54
+ </Dialog>
55
+ </>
56
+ );
57
+ }
58
+ ```
59
+
60
+ ## API Reference
61
+
62
+ ### Dialog
63
+
64
+ | Prop | Type | Description | Default |
65
+ | --------------------- | -------------------------------- | ------------------------------------------------ | ------- |
66
+ | `open` | `boolean` | If `true`, the dialog is open. | |
67
+ | `onClose` | `() => void` | Callback fired when the dialog is closed. | |
68
+ | `children` | `React.ReactNode` | The content of the dialog. | |
69
+ | `className` | `string` | Optional class name for the dialog. | |
70
+ | `appearance` | `'light' \| 'dark' \| 'inherit'` | The appearance of the dialog. | |
71
+ | `closeOnOverlayClick` | `boolean` | If `true`, the dialog closes on overlay click. | `true` |
72
+ | `closeOnEsc` | `boolean` | If `true`, the dialog closes on `Esc` key press. | `true` |
73
+
74
+ ### DialogTitle
75
+
76
+ The `DialogTitle` component accepts all props of the `Heading` component.
77
+
78
+ ### DialogDescription
79
+
80
+ The `DialogDescription` component accepts all props of the `Box` component.
81
+
82
+ ### DialogActions
83
+
84
+ The `DialogActions` component accepts all props of the `Box` component.
@@ -0,0 +1,34 @@
1
+ import React from 'react';
2
+ import { Box } from '@pittorica/box-react';
3
+ import { Heading } from '@pittorica/heading-react';
4
+ export interface DialogProps {
5
+ open: boolean;
6
+ onClose: () => void;
7
+ children: React.ReactNode;
8
+ className?: string;
9
+ appearance?: 'light' | 'dark' | 'inherit';
10
+ /** @default true */
11
+ closeOnOverlayClick?: boolean;
12
+ /** @default true */
13
+ closeOnEsc?: boolean;
14
+ }
15
+ /**
16
+ * Dialog component.
17
+ * Provides a modal window with focus trap and scroll lock.
18
+ */
19
+ export declare const Dialog: ({ open, onClose, children, className, appearance, closeOnOverlayClick, closeOnEsc, }: DialogProps) => React.ReactNode;
20
+ /**
21
+ * Accessible title for the Dialog.
22
+ */
23
+ export declare const DialogTitle: ({ children, id: _id, ...props }: React.ComponentProps<typeof Heading>) => import("react/jsx-runtime").JSX.Element;
24
+ /**
25
+ * Accessible description for the Dialog.
26
+ */
27
+ export declare const DialogDescription: ({ children, id: _id, ...props }: React.ComponentProps<typeof Box>) => import("react/jsx-runtime").JSX.Element;
28
+ /**
29
+ * Container for Dialog actions (usually buttons).
30
+ */
31
+ export declare const DialogActions: ({ children }: {
32
+ children: React.ReactNode;
33
+ }) => import("react/jsx-runtime").JSX.Element;
34
+ //# sourceMappingURL=Dialog.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Dialog.d.ts","sourceRoot":"","sources":["../src/Dialog.tsx"],"names":[],"mappings":"AACA,OAAO,KAQN,MAAM,OAAO,CAAC;AAOf,OAAO,EAAE,GAAG,EAAE,MAAM,sBAAsB,CAAC;AAC3C,OAAO,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AAEnD,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,OAAO,CAAC;IACd,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAAC;IAC1C,oBAAoB;IACpB,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,oBAAoB;IACpB,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAqBD;;;GAGG;AACH,eAAO,MAAM,MAAM,GAAI,sFAQpB,WAAW,KAAG,KAAK,CAAC,SA+EtB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,WAAW,GAAI,iCAIzB,KAAK,CAAC,cAAc,CAAC,OAAO,OAAO,CAAC,4CAOtC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,iBAAiB,GAAI,iCAI/B,KAAK,CAAC,cAAc,CAAC,OAAO,GAAG,CAAC,4CAelC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,aAAa,GAAI,cAAc;IAAE,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAAE,4CAWxE,CAAC"}
@@ -0,0 +1,8 @@
1
+ import type { Meta, StoryObj } from '@storybook/react';
2
+ import { Dialog } from './Dialog';
3
+ declare const meta: Meta<typeof Dialog>;
4
+ export default meta;
5
+ type Story = StoryObj<typeof Dialog>;
6
+ export declare const Basic: Story;
7
+ export declare const Dark: Story;
8
+ //# sourceMappingURL=Dialog.stories.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Dialog.stories.d.ts","sourceRoot":"","sources":["../src/Dialog.stories.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAEvD,OAAO,EACL,MAAM,EAIP,MAAM,UAAU,CAAC;AAElB,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,OAAO,MAAM,CAc7B,CAAC;AAEF,eAAe,IAAI,CAAC;AACpB,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,MAAM,CAAC,CAAC;AAErC,eAAO,MAAM,KAAK,EAAE,KAiCnB,CAAC;AAEF,eAAO,MAAM,IAAI,EAAE,KAsClB,CAAC"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * @vitest-environment jsdom
3
+ */
4
+ import '@testing-library/jest-dom';
5
+ //# sourceMappingURL=Dialog.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Dialog.test.d.ts","sourceRoot":"","sources":["../src/Dialog.test.tsx"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,2BAA2B,CAAC"}
@@ -0,0 +1,3 @@
1
+ export type { DialogProps } from './Dialog.js';
2
+ export { Dialog, DialogActions, DialogDescription, DialogTitle, } from './Dialog.js';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EACL,MAAM,EACN,aAAa,EACb,iBAAiB,EACjB,WAAW,GACZ,MAAM,aAAa,CAAC"}