@tcn/ui 0.8.1 → 0.9.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/dist/feedback/progress/progress_bar.js +13 -13
- package/dist/form/field/common/field_description.js +7 -8
- package/dist/form/field/common/field_description.js.map +1 -1
- package/dist/form/field/common/field_error.js +6 -6
- package/dist/form/field/common/field_label.js +7 -8
- package/dist/form/field/common/field_label.js.map +1 -1
- package/dist/form/field_set/field_set.js +7 -7
- package/dist/inputs/date_picker/date_picker_date.js +6 -6
- package/dist/inputs/date_picker/date_picker_day.js +6 -6
- package/dist/inputs/date_picker/date_picker_time_selector.js +5 -5
- package/dist/inputs/date_picker/date_picker_year_selector.js +5 -5
- package/dist/inputs/suggestions/suggestion_list.js +6 -6
- package/dist/layouts/index.d.ts +2 -0
- package/dist/layouts/index.d.ts.map +1 -1
- package/dist/layouts/index.js +46 -42
- package/dist/layouts/index.js.map +1 -1
- package/dist/layouts/responsive/breakpoint.d.ts +11 -0
- package/dist/layouts/responsive/breakpoint.d.ts.map +1 -0
- package/dist/layouts/responsive/breakpoint.js +15 -0
- package/dist/layouts/responsive/breakpoint.js.map +1 -0
- package/dist/layouts/responsive/responsive.d.ts +7 -0
- package/dist/layouts/responsive/responsive.d.ts.map +1 -0
- package/dist/layouts/responsive/responsive.js +11 -0
- package/dist/layouts/responsive/responsive.js.map +1 -0
- package/dist/layouts/responsive/responsive_container.d.ts +7 -0
- package/dist/layouts/responsive/responsive_container.d.ts.map +1 -0
- package/dist/layouts/responsive/responsive_container.js +30 -0
- package/dist/layouts/responsive/responsive_container.js.map +1 -0
- package/dist/layouts/responsive/responsive_viewport.d.ts +7 -0
- package/dist/layouts/responsive/responsive_viewport.d.ts.map +1 -0
- package/dist/layouts/responsive/responsive_viewport.js +12 -0
- package/dist/layouts/responsive/responsive_viewport.js.map +1 -0
- package/dist/surfaces/confirm/confirm.js +5 -5
- package/dist/surfaces/pop_confirm/pop_confirm.js +3 -2
- package/dist/surfaces/pop_confirm/pop_confirm.js.map +1 -1
- package/dist/typography/body_text/body_text.d.ts +2 -1
- package/dist/typography/body_text/body_text.d.ts.map +1 -1
- package/dist/typography/body_text/body_text.js +24 -23
- package/dist/typography/body_text/body_text.js.map +1 -1
- package/dist/typography/callout/callout.d.ts +2 -1
- package/dist/typography/callout/callout.d.ts.map +1 -1
- package/dist/typography/callout/callout.js +28 -27
- package/dist/typography/callout/callout.js.map +1 -1
- package/dist/typography/caption/caption.d.ts +2 -1
- package/dist/typography/caption/caption.d.ts.map +1 -1
- package/dist/typography/caption/caption.js +18 -17
- package/dist/typography/caption/caption.js.map +1 -1
- package/dist/typography/footnote/footnote.d.ts +2 -1
- package/dist/typography/footnote/footnote.d.ts.map +1 -1
- package/dist/typography/footnote/footnote.js +25 -24
- package/dist/typography/footnote/footnote.js.map +1 -1
- package/dist/typography/headline/headline.d.ts +2 -1
- package/dist/typography/headline/headline.d.ts.map +1 -1
- package/dist/typography/headline/headline.js +36 -33
- package/dist/typography/headline/headline.js.map +1 -1
- package/dist/typography/subheadline/subheadline.d.ts +2 -1
- package/dist/typography/subheadline/subheadline.d.ts.map +1 -1
- package/dist/typography/subheadline/subheadline.js +35 -32
- package/dist/typography/subheadline/subheadline.js.map +1 -1
- package/dist/utils/dnd/context.d.ts.map +1 -1
- package/dist/utils/dnd/context.js +9 -7
- package/dist/utils/dnd/context.js.map +1 -1
- package/dist/utils/dnd/hooks/use_drag_container.d.ts.map +1 -1
- package/dist/utils/dnd/hooks/use_drag_container.js +29 -15
- package/dist/utils/dnd/hooks/use_drag_container.js.map +1 -1
- package/dist/utils/dnd/types.d.ts +3 -4
- package/dist/utils/dnd/types.d.ts.map +1 -1
- package/dist/utils/hooks/use_media_query.d.ts +5 -8
- package/dist/utils/hooks/use_media_query.d.ts.map +1 -1
- package/dist/utils/hooks/use_media_query.js +10 -11
- package/dist/utils/hooks/use_media_query.js.map +1 -1
- package/dist/utils/index.d.ts +1 -2
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +19 -21
- package/dist/utils/index.js.map +1 -1
- package/package.json +1 -1
- package/src/layouts/index.ts +2 -0
- package/src/layouts/responsive/breakpoint.tsx +29 -0
- package/src/layouts/responsive/responsive.stories.tsx +37 -0
- package/src/layouts/responsive/responsive.tsx +18 -0
- package/src/layouts/responsive/responsive_container.tsx +51 -0
- package/src/layouts/responsive/responsive_viewport.tsx +17 -0
- package/src/typography/body_text/body_text.tsx +21 -17
- package/src/typography/callout/callout.tsx +20 -16
- package/src/typography/caption/caption.tsx +20 -16
- package/src/typography/footnote/footnote.tsx +20 -16
- package/src/typography/headline/headline.tsx +60 -54
- package/src/typography/subheadline/subheadline.tsx +60 -54
- package/src/utils/dnd/__stories__/draggable.stories.tsx +34 -0
- package/src/utils/dnd/context.ts +1 -0
- package/src/utils/dnd/hooks/use_drag_container.ts +18 -1
- package/src/utils/dnd/types.ts +4 -1
- package/src/utils/hooks/use_media_query.ts +16 -27
- package/src/utils/index.ts +1 -3
- package/dist/body_text.module-h4XQE2pC.js +0 -5
- package/dist/body_text.module-h4XQE2pC.js.map +0 -1
- package/dist/callout.module-D8ECmxpO.js +0 -5
- package/dist/callout.module-D8ECmxpO.js.map +0 -1
- package/dist/caption.module-DDq0H4xZ.js +0 -5
- package/dist/caption.module-DDq0H4xZ.js.map +0 -1
- package/dist/footnote.module-DEyFuqOr.js +0 -5
- package/dist/footnote.module-DEyFuqOr.js.map +0 -1
- package/dist/headline.module-BiwHBtGf.js +0 -5
- package/dist/headline.module-BiwHBtGf.js.map +0 -1
- package/dist/subheadline.module-C-v7zMkQ.js +0 -5
- package/dist/subheadline.module-C-v7zMkQ.js.map +0 -1
- package/dist/utils/responsive/responsive_renderer.d.ts +0 -21
- package/dist/utils/responsive/responsive_renderer.d.ts.map +0 -1
- package/dist/utils/responsive/responsive_renderer.js +0 -12
- package/dist/utils/responsive/responsive_renderer.js.map +0 -1
- package/src/utils/responsive/responsive_renderer.stories.tsx +0 -77
- package/src/utils/responsive/responsive_renderer.tsx +0 -31
|
@@ -20,21 +20,24 @@ export interface CalloutOwnProps {
|
|
|
20
20
|
|
|
21
21
|
export type CalloutProps = WithDetailedHTMLProps<CalloutOwnProps, 'div'>;
|
|
22
22
|
|
|
23
|
-
export function Callout(
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
23
|
+
export const Callout = React.forwardRef<HTMLDivElement, CalloutProps>(function Callout(
|
|
24
|
+
{
|
|
25
|
+
size = 'md',
|
|
26
|
+
emphasis = 'normal',
|
|
27
|
+
hierarchy = 'primary',
|
|
28
|
+
color,
|
|
29
|
+
children,
|
|
30
|
+
className,
|
|
31
|
+
style = {},
|
|
32
|
+
padStart,
|
|
33
|
+
padEnd,
|
|
34
|
+
padBottom,
|
|
35
|
+
padTop,
|
|
36
|
+
pad,
|
|
37
|
+
selectable = true,
|
|
38
|
+
}: CalloutProps,
|
|
39
|
+
ref
|
|
40
|
+
) {
|
|
38
41
|
if (pad) {
|
|
39
42
|
style.padding = pad;
|
|
40
43
|
}
|
|
@@ -61,6 +64,7 @@ export function Callout({
|
|
|
61
64
|
|
|
62
65
|
return (
|
|
63
66
|
<div
|
|
67
|
+
ref={ref}
|
|
64
68
|
data-hierarchy={hierarchy}
|
|
65
69
|
data-emphasis={emphasis}
|
|
66
70
|
data-selectable={selectable}
|
|
@@ -71,4 +75,4 @@ export function Callout({
|
|
|
71
75
|
{children}
|
|
72
76
|
</div>
|
|
73
77
|
);
|
|
74
|
-
}
|
|
78
|
+
});
|
|
@@ -20,21 +20,24 @@ export interface CaptionOwnProps {
|
|
|
20
20
|
|
|
21
21
|
export type CaptionProps = WithDetailedHTMLProps<CaptionOwnProps, 'div'>;
|
|
22
22
|
|
|
23
|
-
export function Caption(
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
23
|
+
export const Caption = React.forwardRef<HTMLDivElement, CaptionProps>(function Caption(
|
|
24
|
+
{
|
|
25
|
+
size = 'md',
|
|
26
|
+
emphasis = 'normal',
|
|
27
|
+
hierarchy = 'primary',
|
|
28
|
+
color,
|
|
29
|
+
children,
|
|
30
|
+
className,
|
|
31
|
+
style = {},
|
|
32
|
+
padStart,
|
|
33
|
+
padEnd,
|
|
34
|
+
padBottom,
|
|
35
|
+
padTop,
|
|
36
|
+
pad,
|
|
37
|
+
selectable = true,
|
|
38
|
+
}: CaptionProps,
|
|
39
|
+
ref
|
|
40
|
+
) {
|
|
38
41
|
if (pad) {
|
|
39
42
|
style.padding = pad;
|
|
40
43
|
}
|
|
@@ -61,6 +64,7 @@ export function Caption({
|
|
|
61
64
|
|
|
62
65
|
return (
|
|
63
66
|
<div
|
|
67
|
+
ref={ref}
|
|
64
68
|
data-hierarchy={hierarchy}
|
|
65
69
|
data-emphasis={emphasis}
|
|
66
70
|
data-selectable={selectable}
|
|
@@ -71,4 +75,4 @@ export function Caption({
|
|
|
71
75
|
{children}
|
|
72
76
|
</div>
|
|
73
77
|
);
|
|
74
|
-
}
|
|
78
|
+
});
|
|
@@ -20,21 +20,24 @@ export interface FootnoteOwnProps {
|
|
|
20
20
|
|
|
21
21
|
export type FootnoteProps = WithDetailedHTMLProps<FootnoteOwnProps, 'div'>;
|
|
22
22
|
|
|
23
|
-
export function Footnote(
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
23
|
+
export const Footnote = React.forwardRef<HTMLDivElement, FootnoteProps>(function Footnote(
|
|
24
|
+
{
|
|
25
|
+
size = 'md',
|
|
26
|
+
emphasis = 'normal',
|
|
27
|
+
hierarchy = 'primary',
|
|
28
|
+
color,
|
|
29
|
+
children,
|
|
30
|
+
className,
|
|
31
|
+
style = {},
|
|
32
|
+
padStart,
|
|
33
|
+
padEnd,
|
|
34
|
+
padBottom,
|
|
35
|
+
padTop,
|
|
36
|
+
pad,
|
|
37
|
+
selectable = true,
|
|
38
|
+
}: FootnoteProps,
|
|
39
|
+
ref
|
|
40
|
+
) {
|
|
38
41
|
if (pad) {
|
|
39
42
|
style.padding = pad;
|
|
40
43
|
}
|
|
@@ -61,6 +64,7 @@ export function Footnote({
|
|
|
61
64
|
|
|
62
65
|
return (
|
|
63
66
|
<div
|
|
67
|
+
ref={ref}
|
|
64
68
|
data-hierarchy={hierarchy}
|
|
65
69
|
data-emphasis={emphasis}
|
|
66
70
|
data-selectable={selectable}
|
|
@@ -71,4 +75,4 @@ export function Footnote({
|
|
|
71
75
|
{children}
|
|
72
76
|
</div>
|
|
73
77
|
);
|
|
74
|
-
}
|
|
78
|
+
});
|
|
@@ -20,65 +20,71 @@ export interface HeadlineOwnProps {
|
|
|
20
20
|
|
|
21
21
|
export type HeadlineProps = WithDetailedHTMLProps<HeadlineOwnProps, 'h1' | 'h2' | 'h3'>;
|
|
22
22
|
|
|
23
|
-
export
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
23
|
+
export const Headline = React.forwardRef<HTMLHeadingElement, HeadlineProps>(
|
|
24
|
+
function Headline(
|
|
25
|
+
{
|
|
26
|
+
size = 'md',
|
|
27
|
+
emphasis = 'normal',
|
|
28
|
+
hierarchy = 'primary',
|
|
29
|
+
color,
|
|
30
|
+
children,
|
|
31
|
+
className,
|
|
32
|
+
style = {},
|
|
33
|
+
padStart,
|
|
34
|
+
padEnd,
|
|
35
|
+
padBottom,
|
|
36
|
+
padTop,
|
|
37
|
+
pad,
|
|
38
|
+
selectable = true,
|
|
39
|
+
}: HeadlineProps,
|
|
40
|
+
ref
|
|
41
|
+
) {
|
|
42
|
+
let As: React.ElementType;
|
|
39
43
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
44
|
+
if (size === 'lg') {
|
|
45
|
+
As = 'h1';
|
|
46
|
+
} else if (size === 'md') {
|
|
47
|
+
As = 'h2';
|
|
48
|
+
} else {
|
|
49
|
+
As = 'h3';
|
|
50
|
+
}
|
|
47
51
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
52
|
+
if (pad) {
|
|
53
|
+
style.padding = pad;
|
|
54
|
+
}
|
|
51
55
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
56
|
+
if (padStart) {
|
|
57
|
+
style.paddingInlineStart = padStart;
|
|
58
|
+
}
|
|
55
59
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
60
|
+
if (padEnd) {
|
|
61
|
+
style.paddingInlineEnd = padEnd;
|
|
62
|
+
}
|
|
59
63
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
64
|
+
if (padTop) {
|
|
65
|
+
style.paddingTop = padTop;
|
|
66
|
+
}
|
|
63
67
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
68
|
+
if (padBottom) {
|
|
69
|
+
style.paddingBottom = padBottom;
|
|
70
|
+
}
|
|
67
71
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
72
|
+
if (color) {
|
|
73
|
+
style.color = color;
|
|
74
|
+
}
|
|
71
75
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
76
|
+
return (
|
|
77
|
+
<As
|
|
78
|
+
ref={ref}
|
|
79
|
+
data-hierarchy={hierarchy}
|
|
80
|
+
data-emphasis={emphasis}
|
|
81
|
+
data-selectable={selectable}
|
|
82
|
+
className={clsx(styles['headline'], className, 'tcn-headline')}
|
|
83
|
+
style={style}
|
|
84
|
+
data-size={size}
|
|
85
|
+
>
|
|
86
|
+
{children}
|
|
87
|
+
</As>
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
);
|
|
@@ -23,65 +23,71 @@ export type SubheadlineProps = WithDetailedHTMLProps<
|
|
|
23
23
|
'h3' | 'h4' | 'h5'
|
|
24
24
|
>;
|
|
25
25
|
|
|
26
|
-
export
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
26
|
+
export const Subheadline = React.forwardRef<HTMLHeadingElement, SubheadlineProps>(
|
|
27
|
+
function Subheadline(
|
|
28
|
+
{
|
|
29
|
+
size = 'md',
|
|
30
|
+
emphasis = 'normal',
|
|
31
|
+
hierarchy = 'primary',
|
|
32
|
+
color,
|
|
33
|
+
children,
|
|
34
|
+
className,
|
|
35
|
+
style = {},
|
|
36
|
+
padStart,
|
|
37
|
+
padEnd,
|
|
38
|
+
padBottom,
|
|
39
|
+
padTop,
|
|
40
|
+
pad,
|
|
41
|
+
selectable = true,
|
|
42
|
+
}: SubheadlineProps,
|
|
43
|
+
ref
|
|
44
|
+
) {
|
|
45
|
+
let As: React.ElementType;
|
|
42
46
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
47
|
+
if (size === 'lg') {
|
|
48
|
+
As = 'h3';
|
|
49
|
+
} else if (size === 'md') {
|
|
50
|
+
As = 'h4';
|
|
51
|
+
} else {
|
|
52
|
+
As = 'h5';
|
|
53
|
+
}
|
|
50
54
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
55
|
+
if (pad) {
|
|
56
|
+
style.padding = pad;
|
|
57
|
+
}
|
|
54
58
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
59
|
+
if (padStart) {
|
|
60
|
+
style.paddingInlineStart = padStart;
|
|
61
|
+
}
|
|
58
62
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
63
|
+
if (padEnd) {
|
|
64
|
+
style.paddingInlineEnd = padEnd;
|
|
65
|
+
}
|
|
62
66
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
67
|
+
if (padTop) {
|
|
68
|
+
style.paddingTop = padTop;
|
|
69
|
+
}
|
|
66
70
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
71
|
+
if (padBottom) {
|
|
72
|
+
style.paddingBottom = padBottom;
|
|
73
|
+
}
|
|
70
74
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
75
|
+
if (color) {
|
|
76
|
+
style.color = color;
|
|
77
|
+
}
|
|
74
78
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
79
|
+
return (
|
|
80
|
+
<As
|
|
81
|
+
ref={ref}
|
|
82
|
+
data-hierarchy={hierarchy}
|
|
83
|
+
data-emphasis={emphasis}
|
|
84
|
+
data-selectable={selectable}
|
|
85
|
+
className={clsx(styles['subheadline'], className, 'tcn-subheadline')}
|
|
86
|
+
style={style}
|
|
87
|
+
data-size={size}
|
|
88
|
+
>
|
|
89
|
+
{children}
|
|
90
|
+
</As>
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
);
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { Draggable } from '../draggable/draggable.js';
|
|
2
|
+
import { useDragContainer } from '../context.js';
|
|
2
3
|
import { VStack } from '../../../stacks/v_stack.js';
|
|
3
4
|
import { DragHandle } from '../handle.js';
|
|
4
5
|
import { Box } from '../../../stacks/box/box.js';
|
|
5
6
|
import { BodyText } from '../../../typography/index.js';
|
|
7
|
+
import { Button } from '../../../actions/button/button/button.js';
|
|
6
8
|
import styles from './draggable_stories.module.css';
|
|
7
9
|
|
|
8
10
|
export default {
|
|
@@ -46,3 +48,35 @@ export const DraggableStory = () => {
|
|
|
46
48
|
</VStack>
|
|
47
49
|
);
|
|
48
50
|
};
|
|
51
|
+
|
|
52
|
+
function ResetPositionButton() {
|
|
53
|
+
const { setPosition } = useDragContainer();
|
|
54
|
+
return (
|
|
55
|
+
<Button onClick={() => setPosition({ x: 0, y: 0 })} hierarchy="secondary">
|
|
56
|
+
Reset position
|
|
57
|
+
</Button>
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export const WithSetPosition = () => {
|
|
62
|
+
return (
|
|
63
|
+
<VStack minHeight="600px" height="100%" width="100%" gap="8px">
|
|
64
|
+
<BodyText>
|
|
65
|
+
Drag the box, then click "Reset position" to move it back to (0, 0).
|
|
66
|
+
Dragging again should start from the new position.
|
|
67
|
+
</BodyText>
|
|
68
|
+
<Draggable>
|
|
69
|
+
<Box width="400px" height="300px" className={styles['handle-container']}>
|
|
70
|
+
<VStack gap="8px" padding="8px">
|
|
71
|
+
<DragHandle>
|
|
72
|
+
<Box className={styles.handle} width="120px" padding="8px">
|
|
73
|
+
<BodyText>Drag Handle</BodyText>
|
|
74
|
+
</Box>
|
|
75
|
+
</DragHandle>
|
|
76
|
+
<ResetPositionButton />
|
|
77
|
+
</VStack>
|
|
78
|
+
</Box>
|
|
79
|
+
</Draggable>
|
|
80
|
+
</VStack>
|
|
81
|
+
);
|
|
82
|
+
};
|
package/src/utils/dnd/context.ts
CHANGED
|
@@ -30,6 +30,17 @@ export function useMakeDragContainer(options: UseDragContainerOptions): DragCont
|
|
|
30
30
|
},
|
|
31
31
|
});
|
|
32
32
|
|
|
33
|
+
const setPositionState = useCallback(
|
|
34
|
+
(value: Position | ((prev: Position) => Position)) => {
|
|
35
|
+
setPosition(prev => {
|
|
36
|
+
const next = typeof value === 'function' ? value(prev) : value;
|
|
37
|
+
positionRef.current = next;
|
|
38
|
+
return next;
|
|
39
|
+
});
|
|
40
|
+
},
|
|
41
|
+
[]
|
|
42
|
+
);
|
|
43
|
+
|
|
33
44
|
const registerHandle = useCallback((handle: React.RefObject<HTMLElement>) => {
|
|
34
45
|
setHandles(prev => [...prev, handle]);
|
|
35
46
|
}, []);
|
|
@@ -38,5 +49,11 @@ export function useMakeDragContainer(options: UseDragContainerOptions): DragCont
|
|
|
38
49
|
setHandles(prev => prev.filter(h => h !== handle));
|
|
39
50
|
}, []);
|
|
40
51
|
|
|
41
|
-
return {
|
|
52
|
+
return {
|
|
53
|
+
registerHandle,
|
|
54
|
+
unregisterHandle,
|
|
55
|
+
position,
|
|
56
|
+
isDragging,
|
|
57
|
+
setPosition: setPositionState,
|
|
58
|
+
};
|
|
42
59
|
}
|
package/src/utils/dnd/types.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
import type { Position } from '../types/dimensions.js';
|
|
2
|
+
|
|
1
3
|
export interface DragContainer {
|
|
2
4
|
registerHandle: (handle: React.RefObject<HTMLElement>) => void;
|
|
3
5
|
unregisterHandle: (handle: React.RefObject<HTMLElement>) => void;
|
|
4
6
|
isDragging: boolean;
|
|
5
|
-
position:
|
|
7
|
+
position: Position;
|
|
8
|
+
setPosition: (value: Position | ((prev: Position) => Position)) => void;
|
|
6
9
|
}
|
|
@@ -1,32 +1,21 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { useLayoutEffect, useState } from 'react';
|
|
2
|
+
import { useResizeObserver } from './use_resize_observer.js';
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
* @param query - The media query to match against (e.g. "(min-width: 768px)")
|
|
8
|
-
* @returns boolean indicating if the media query matches
|
|
9
|
-
*/
|
|
10
|
-
export function useMediaQuery(query: string): boolean {
|
|
11
|
-
const [matches, setMatches] = React.useState(false);
|
|
12
|
-
|
|
13
|
-
React.useEffect(() => {
|
|
14
|
-
const mediaQuery = window.matchMedia(query);
|
|
15
|
-
|
|
16
|
-
// Set initial value
|
|
17
|
-
setMatches(mediaQuery.matches);
|
|
18
|
-
|
|
19
|
-
// Create event listener
|
|
20
|
-
const handler = (event: MediaQueryListEvent) => {
|
|
21
|
-
setMatches(event.matches);
|
|
22
|
-
};
|
|
4
|
+
export interface ViewportSize {
|
|
5
|
+
width: number;
|
|
6
|
+
height: number;
|
|
7
|
+
}
|
|
23
8
|
|
|
24
|
-
|
|
25
|
-
|
|
9
|
+
export function useMediaQuery(): ViewportSize {
|
|
10
|
+
const [size, setSize] = useState<ViewportSize>({ width: 0, height: 0 });
|
|
11
|
+
const resizeRef = useResizeObserver((width, height) => {
|
|
12
|
+
setSize({ width, height });
|
|
13
|
+
});
|
|
26
14
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
15
|
+
useLayoutEffect(() => {
|
|
16
|
+
const body = document.body;
|
|
17
|
+
resizeRef(body);
|
|
18
|
+
}, [resizeRef]);
|
|
30
19
|
|
|
31
|
-
return
|
|
20
|
+
return size;
|
|
32
21
|
}
|
package/src/utils/index.ts
CHANGED
|
@@ -5,8 +5,8 @@ export * from './scroll_away_listener.js';
|
|
|
5
5
|
export * from './dnd/hooks/use_draggable.js';
|
|
6
6
|
export * from './hooks/make_context_hook.js';
|
|
7
7
|
export * from './hooks/use_fork_ref.js';
|
|
8
|
-
export * from './hooks/use_media_query.js';
|
|
9
8
|
export * from './hooks/use_resize_observer.js';
|
|
9
|
+
export * from './hooks/use_media_query.js';
|
|
10
10
|
|
|
11
11
|
export * from './default_value.js';
|
|
12
12
|
|
|
@@ -19,7 +19,5 @@ export * from './calendar/month.js';
|
|
|
19
19
|
export * from './types/dimensions.js';
|
|
20
20
|
export * from './types/variations.js';
|
|
21
21
|
|
|
22
|
-
export * from './responsive/responsive_renderer.js';
|
|
23
|
-
|
|
24
22
|
export * from './dnd/draggable/draggable.js';
|
|
25
23
|
export * from './dnd/handle.js';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"body_text.module-h4XQE2pC.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"callout.module-D8ECmxpO.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"caption.module-DDq0H4xZ.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"footnote.module-DEyFuqOr.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"headline.module-BiwHBtGf.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"subheadline.module-C-v7zMkQ.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { default as React } from 'react';
|
|
2
|
-
export interface ResponsiveRendererProps {
|
|
3
|
-
/**
|
|
4
|
-
* Component to render on mobile devices (width < 768px)
|
|
5
|
-
*/
|
|
6
|
-
mobile: React.ReactNode;
|
|
7
|
-
/**
|
|
8
|
-
* Component to render on desktop devices (width >= 768px)
|
|
9
|
-
*/
|
|
10
|
-
desktop: React.ReactNode;
|
|
11
|
-
/**
|
|
12
|
-
* Optional breakpoint in pixels. Defaults to 768px
|
|
13
|
-
*/
|
|
14
|
-
breakpoint?: number;
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* A component that renders different content based on screen size.
|
|
18
|
-
* Uses the useMediaQuery hook to detect screen size changes.
|
|
19
|
-
*/
|
|
20
|
-
export declare function ResponsiveRenderer({ mobile, desktop, breakpoint, }: ResponsiveRendererProps): React.ReactNode;
|
|
21
|
-
//# sourceMappingURL=responsive_renderer.d.ts.map
|