@tcn/ui 0.12.4 → 0.12.5
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/dist/overlay/frame/frame.d.ts.map +1 -1
- package/dist/overlay/frame/frame.js +57 -63
- package/dist/overlay/frame/frame.js.map +1 -1
- package/dist/stacks/box/box.d.ts +5 -4
- package/dist/stacks/box/box.d.ts.map +1 -1
- package/dist/stacks/box/box.js.map +1 -1
- package/dist/stacks/box/detect_resize_bounds.d.ts +15 -0
- package/dist/stacks/box/detect_resize_bounds.d.ts.map +1 -0
- package/dist/stacks/box/detect_resize_bounds.js +49 -0
- package/dist/stacks/box/detect_resize_bounds.js.map +1 -0
- package/dist/stacks/box/resize_handlers.d.ts.map +1 -1
- package/dist/stacks/box/resize_handlers.js +51 -44
- package/dist/stacks/box/resize_handlers.js.map +1 -1
- package/dist/stacks/box/start_resize_handle.d.ts.map +1 -1
- package/dist/stacks/box/start_resize_handle.js +2 -1
- package/dist/stacks/box/start_resize_handle.js.map +1 -1
- package/dist/stacks/box/types.d.ts +17 -4
- package/dist/stacks/box/types.d.ts.map +1 -1
- package/dist/surfaces/modal/modal.d.ts.map +1 -1
- package/dist/surfaces/modal/modal.js +22 -13
- package/dist/surfaces/modal/modal.js.map +1 -1
- package/dist/surfaces/window/window.d.ts.map +1 -1
- package/dist/surfaces/window/window.js +21 -24
- package/dist/surfaces/window/window.js.map +1 -1
- package/package.json +2 -2
- package/src/overlay/frame/frame.tsx +34 -51
- package/src/stacks/box/box.tsx +10 -16
- package/src/stacks/box/detect_resize_bounds.ts +84 -0
- package/src/stacks/box/resize_handlers.ts +27 -15
- package/src/stacks/box/start_resize_handle.tsx +6 -3
- package/src/stacks/box/types.ts +23 -25
- package/src/surfaces/modal/__stories__/modal.stories.tsx +70 -3
- package/src/surfaces/modal/modal.tsx +11 -2
- package/src/surfaces/window/window.stories.tsx +64 -8
- package/src/surfaces/window/window.tsx +6 -9
|
@@ -3,7 +3,7 @@ import { Button } from '../../../actions/index.js';
|
|
|
3
3
|
import { Footer, Header, UtilityBar, VBody } from '../../../layouts/index.js';
|
|
4
4
|
import { ZStack } from '../../../stacks/z_stack.js';
|
|
5
5
|
import { BodyText, Title } from '../../../typography/index.js';
|
|
6
|
-
import { Modal } from '../modal.js';
|
|
6
|
+
import { Modal, type ModalProps } from '../modal.js';
|
|
7
7
|
import { Spacer } from '../../../stacks/index.js';
|
|
8
8
|
import { CrossIcon } from '@tcn/icons/cross_icon.js';
|
|
9
9
|
import { BugIcon } from '@tcn/icons/bug_icon.js';
|
|
@@ -12,9 +12,61 @@ export default {
|
|
|
12
12
|
title: 'Surfaces/Modal',
|
|
13
13
|
component: Modal,
|
|
14
14
|
tags: ['autodocs'],
|
|
15
|
+
argTypes: {
|
|
16
|
+
draggable: {
|
|
17
|
+
control: 'boolean',
|
|
18
|
+
},
|
|
19
|
+
veil: {
|
|
20
|
+
control: 'boolean',
|
|
21
|
+
},
|
|
22
|
+
resizable: {
|
|
23
|
+
control: 'boolean',
|
|
24
|
+
},
|
|
25
|
+
width: {
|
|
26
|
+
control: 'text',
|
|
27
|
+
},
|
|
28
|
+
height: {
|
|
29
|
+
control: 'text',
|
|
30
|
+
},
|
|
31
|
+
minWidth: {
|
|
32
|
+
control: 'text',
|
|
33
|
+
},
|
|
34
|
+
minHeight: {
|
|
35
|
+
control: 'text',
|
|
36
|
+
},
|
|
37
|
+
maxWidth: {
|
|
38
|
+
control: 'text',
|
|
39
|
+
},
|
|
40
|
+
maxHeight: {
|
|
41
|
+
control: 'text',
|
|
42
|
+
},
|
|
43
|
+
},
|
|
15
44
|
};
|
|
16
45
|
|
|
17
|
-
|
|
46
|
+
type ModalStoryProps = Pick<
|
|
47
|
+
ModalProps,
|
|
48
|
+
| 'resizable'
|
|
49
|
+
| 'draggable'
|
|
50
|
+
| 'veil'
|
|
51
|
+
| 'width'
|
|
52
|
+
| 'height'
|
|
53
|
+
| 'minWidth'
|
|
54
|
+
| 'minHeight'
|
|
55
|
+
| 'maxWidth'
|
|
56
|
+
| 'maxHeight'
|
|
57
|
+
>;
|
|
58
|
+
|
|
59
|
+
export const Baseline = ({
|
|
60
|
+
resizable,
|
|
61
|
+
draggable,
|
|
62
|
+
veil,
|
|
63
|
+
width = '400px',
|
|
64
|
+
height = '500px',
|
|
65
|
+
minWidth,
|
|
66
|
+
minHeight,
|
|
67
|
+
maxWidth,
|
|
68
|
+
maxHeight,
|
|
69
|
+
}: ModalStoryProps) => {
|
|
18
70
|
const [isOpen, setIsOpen] = useState(false);
|
|
19
71
|
|
|
20
72
|
function toggle() {
|
|
@@ -27,7 +79,20 @@ export const ModalStory = () => {
|
|
|
27
79
|
{isOpen ? 'Close' : 'Open'}
|
|
28
80
|
</Button>
|
|
29
81
|
|
|
30
|
-
<Modal
|
|
82
|
+
<Modal
|
|
83
|
+
isOpen={isOpen}
|
|
84
|
+
width={width}
|
|
85
|
+
height={height}
|
|
86
|
+
draggable={draggable}
|
|
87
|
+
veil={veil}
|
|
88
|
+
resizable={resizable}
|
|
89
|
+
minWidth={minWidth}
|
|
90
|
+
minHeight={minHeight}
|
|
91
|
+
maxWidth={maxWidth}
|
|
92
|
+
maxHeight={maxHeight}
|
|
93
|
+
>
|
|
94
|
+
{/* Add a drag handle around the areas of the modal you want to be draggable (usually the header) */}
|
|
95
|
+
{/* <DragHandle> */}
|
|
31
96
|
<Header>
|
|
32
97
|
<Title>Modal Title</Title>
|
|
33
98
|
<Spacer />
|
|
@@ -41,6 +106,8 @@ export const ModalStory = () => {
|
|
|
41
106
|
<CrossIcon />
|
|
42
107
|
</Button>
|
|
43
108
|
</Header>
|
|
109
|
+
{/* </DragHandle> */}
|
|
110
|
+
|
|
44
111
|
<UtilityBar>
|
|
45
112
|
<Title>Utility Bar</Title>
|
|
46
113
|
<Spacer />
|
|
@@ -9,15 +9,24 @@ import styles from './modal.module.css';
|
|
|
9
9
|
export type ModalProps = FrameProps;
|
|
10
10
|
|
|
11
11
|
export const Modal = React.forwardRef<HTMLElement, ModalProps>(function Modal(
|
|
12
|
-
{
|
|
12
|
+
{
|
|
13
|
+
children,
|
|
14
|
+
className,
|
|
15
|
+
isOpen,
|
|
16
|
+
veil = true,
|
|
17
|
+
resizable = false,
|
|
18
|
+
draggable = false,
|
|
19
|
+
...props
|
|
20
|
+
}: ModalProps,
|
|
13
21
|
ref
|
|
14
22
|
) {
|
|
15
23
|
return (
|
|
16
24
|
<Frame
|
|
17
25
|
ref={ref}
|
|
18
26
|
isOpen={isOpen}
|
|
19
|
-
draggable={draggable}
|
|
20
27
|
veil={veil}
|
|
28
|
+
draggable={draggable}
|
|
29
|
+
resizable={resizable}
|
|
21
30
|
className={clsx(styles['modal'], 'tcn-surface', 'tcn-modal', className)}
|
|
22
31
|
{...props}
|
|
23
32
|
>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useState } from 'react';
|
|
2
|
-
import { Window } from './window.js';
|
|
2
|
+
import { Window, type WindowProps } from './window.js';
|
|
3
3
|
import { Footer, Header, UtilityBar, VBody } from '../../layouts/index.js';
|
|
4
4
|
import { BodyText, Title } from '../../typography/index.js';
|
|
5
5
|
import { Spacer } from '../../stacks/spacer.js';
|
|
@@ -13,9 +13,61 @@ export default {
|
|
|
13
13
|
title: 'Surfaces/Window',
|
|
14
14
|
component: Window,
|
|
15
15
|
tags: ['autodocs'],
|
|
16
|
+
argTypes: {
|
|
17
|
+
draggable: {
|
|
18
|
+
control: 'boolean',
|
|
19
|
+
},
|
|
20
|
+
veil: {
|
|
21
|
+
control: 'boolean',
|
|
22
|
+
},
|
|
23
|
+
resizable: {
|
|
24
|
+
control: 'boolean',
|
|
25
|
+
},
|
|
26
|
+
width: {
|
|
27
|
+
control: 'text',
|
|
28
|
+
},
|
|
29
|
+
height: {
|
|
30
|
+
control: 'text',
|
|
31
|
+
},
|
|
32
|
+
minWidth: {
|
|
33
|
+
control: 'text',
|
|
34
|
+
},
|
|
35
|
+
minHeight: {
|
|
36
|
+
control: 'text',
|
|
37
|
+
},
|
|
38
|
+
maxWidth: {
|
|
39
|
+
control: 'text',
|
|
40
|
+
},
|
|
41
|
+
maxHeight: {
|
|
42
|
+
control: 'text',
|
|
43
|
+
},
|
|
44
|
+
},
|
|
16
45
|
};
|
|
17
46
|
|
|
18
|
-
|
|
47
|
+
type WindowStoryProps = Pick<
|
|
48
|
+
WindowProps,
|
|
49
|
+
| 'resizable'
|
|
50
|
+
| 'draggable'
|
|
51
|
+
| 'veil'
|
|
52
|
+
| 'width'
|
|
53
|
+
| 'height'
|
|
54
|
+
| 'minWidth'
|
|
55
|
+
| 'minHeight'
|
|
56
|
+
| 'maxWidth'
|
|
57
|
+
| 'maxHeight'
|
|
58
|
+
>;
|
|
59
|
+
|
|
60
|
+
export const Baseline = ({
|
|
61
|
+
resizable,
|
|
62
|
+
draggable,
|
|
63
|
+
veil,
|
|
64
|
+
width = '400px',
|
|
65
|
+
height = '400px',
|
|
66
|
+
minWidth = 'min-content',
|
|
67
|
+
minHeight = '30%',
|
|
68
|
+
maxWidth = 500,
|
|
69
|
+
maxHeight = '500px',
|
|
70
|
+
}: WindowStoryProps) => {
|
|
19
71
|
const [isOpen, setIsOpen] = useState(false);
|
|
20
72
|
|
|
21
73
|
function toggle() {
|
|
@@ -27,13 +79,17 @@ export const WindowStory = () => {
|
|
|
27
79
|
<Button onClick={toggle}>{isOpen ? 'Close' : 'Open'}</Button>
|
|
28
80
|
<Window
|
|
29
81
|
isOpen={isOpen}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
82
|
+
draggable={draggable}
|
|
83
|
+
veil={veil}
|
|
84
|
+
resizable={resizable}
|
|
85
|
+
width={width}
|
|
86
|
+
height={height}
|
|
87
|
+
minWidth={minWidth}
|
|
88
|
+
minHeight={minHeight}
|
|
89
|
+
maxWidth={maxWidth}
|
|
90
|
+
maxHeight={maxHeight}
|
|
36
91
|
>
|
|
92
|
+
{/* Place the drag handle around the areas of the window you want to be draggable (usually the header) */}
|
|
37
93
|
<DragHandle>
|
|
38
94
|
<Header>
|
|
39
95
|
<Title>Window Title</Title>
|
|
@@ -13,27 +13,24 @@ export const Window = React.forwardRef<HTMLElement, WindowProps>(function Window
|
|
|
13
13
|
children,
|
|
14
14
|
className,
|
|
15
15
|
isOpen,
|
|
16
|
-
draggable = true,
|
|
17
|
-
resizable = true,
|
|
18
16
|
veil = false,
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
draggable = true,
|
|
18
|
+
resizable = false,
|
|
21
19
|
...props
|
|
22
20
|
}: WindowProps,
|
|
23
21
|
ref
|
|
24
22
|
) {
|
|
25
23
|
return (
|
|
26
24
|
<Frame
|
|
25
|
+
ref={ref}
|
|
27
26
|
isOpen={isOpen}
|
|
28
|
-
draggable={draggable}
|
|
29
27
|
veil={veil}
|
|
28
|
+
draggable={draggable}
|
|
29
|
+
resizable={resizable}
|
|
30
30
|
className={clsx(styles['window'], 'tcn-surface', 'tcn-window', className)}
|
|
31
|
-
width={width}
|
|
32
|
-
height={height}
|
|
33
|
-
ref={ref}
|
|
34
31
|
{...props}
|
|
35
32
|
>
|
|
36
|
-
<Scaffold width="100%" height="100%"
|
|
33
|
+
<Scaffold className={'tcn-window-scaffold'} width="100%" height="100%">
|
|
37
34
|
{children}
|
|
38
35
|
</Scaffold>
|
|
39
36
|
</Frame>
|