@tcn/ui 0.9.0 → 0.11.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/bar.css +1 -0
- package/dist/body.css +1 -1
- package/dist/body.module-BbFZ7KNP.js +5 -0
- package/dist/body.module-BbFZ7KNP.js.map +1 -0
- package/dist/divider.css +1 -1
- package/dist/footer.css +1 -1
- package/dist/form/field/h_field/h_field.d.ts.map +1 -1
- package/dist/form/field/h_field/h_field.js +33 -35
- package/dist/form/field/h_field/h_field.js.map +1 -1
- package/dist/form/field/v_field/v_field.d.ts.map +1 -1
- package/dist/form/field/v_field/v_field.js +34 -36
- package/dist/form/field/v_field/v_field.js.map +1 -1
- package/dist/frame.css +1 -1
- package/dist/inputs/color_input/color_input.d.ts.map +1 -1
- package/dist/inputs/color_input/color_input.js +47 -46
- package/dist/inputs/color_input/color_input.js.map +1 -1
- package/dist/inputs/combo_box/combo_box.d.ts.map +1 -1
- package/dist/inputs/combo_box/combo_box.js +61 -58
- package/dist/inputs/combo_box/combo_box.js.map +1 -1
- package/dist/inputs/index.d.ts +1 -0
- package/dist/inputs/index.d.ts.map +1 -1
- package/dist/inputs/index.js +34 -31
- package/dist/inputs/index.js.map +1 -1
- package/dist/inputs/input/input.js +9 -9
- package/dist/inputs/input/input.js.map +1 -1
- package/dist/inputs/input_group/input_group.d.ts +5 -0
- package/dist/inputs/input_group/input_group.d.ts.map +1 -0
- package/dist/inputs/input_group/input_group.js +20 -0
- package/dist/inputs/input_group/input_group.js.map +1 -0
- package/dist/inputs/phone_number_input/countries_phone_information.d.ts +2 -2
- package/dist/inputs/phone_number_input/countries_phone_information.d.ts.map +1 -1
- package/dist/inputs/phone_number_input/countries_phone_information.js +5 -353
- package/dist/inputs/phone_number_input/countries_phone_information.js.map +1 -1
- package/dist/inputs/phone_number_input/phone_number_context.d.ts +24 -0
- package/dist/inputs/phone_number_input/phone_number_context.d.ts.map +1 -0
- package/dist/inputs/phone_number_input/phone_number_context.js +23 -0
- package/dist/inputs/phone_number_input/phone_number_context.js.map +1 -0
- package/dist/inputs/phone_number_input/phone_number_country_select_adapter.d.ts +19 -0
- package/dist/inputs/phone_number_input/phone_number_country_select_adapter.d.ts.map +1 -0
- package/dist/inputs/phone_number_input/phone_number_country_select_adapter.js +77 -0
- package/dist/inputs/phone_number_input/phone_number_country_select_adapter.js.map +1 -0
- package/dist/inputs/phone_number_input/phone_number_input.d.ts +16 -14
- package/dist/inputs/phone_number_input/phone_number_input.d.ts.map +1 -1
- package/dist/inputs/phone_number_input/phone_number_input.js +104 -274
- package/dist/inputs/phone_number_input/phone_number_input.js.map +1 -1
- package/dist/inputs/phone_number_input/phone_number_input_adapter.d.ts +6 -0
- package/dist/inputs/phone_number_input/phone_number_input_adapter.d.ts.map +1 -0
- package/dist/inputs/phone_number_input/phone_number_input_adapter.js +95 -0
- package/dist/inputs/phone_number_input/phone_number_input_adapter.js.map +1 -0
- package/dist/inputs/phone_number_input/sip_input.d.ts +12 -0
- package/dist/inputs/phone_number_input/sip_input.d.ts.map +1 -0
- package/dist/inputs/phone_number_input/sip_input.js +111 -0
- package/dist/inputs/phone_number_input/sip_input.js.map +1 -0
- package/dist/inputs/select/select.d.ts.map +1 -1
- package/dist/inputs/select/select.js +3 -2
- package/dist/inputs/select/select.js.map +1 -1
- package/dist/inputs/suggestions/suggestion_list.d.ts +4 -1
- package/dist/inputs/suggestions/suggestion_list.d.ts.map +1 -1
- package/dist/inputs/suggestions/suggestion_list.js +120 -111
- package/dist/inputs/suggestions/suggestion_list.js.map +1 -1
- package/dist/inputs/textarea/textarea.js +8 -8
- package/dist/inputs/textarea/textarea.js.map +1 -1
- package/dist/inputs/unit_input/unit_input.d.ts.map +1 -1
- package/dist/inputs/unit_input/unit_input.js +39 -39
- package/dist/inputs/unit_input/unit_input.js.map +1 -1
- package/dist/layouts/bar/bar.d.ts +5 -0
- package/dist/layouts/bar/bar.d.ts.map +1 -0
- package/dist/layouts/bar/bar.js +20 -0
- package/dist/layouts/bar/bar.js.map +1 -0
- package/dist/layouts/body/body.d.ts +2 -2
- package/dist/layouts/body/body.d.ts.map +1 -1
- package/dist/layouts/body/body.js +12 -12
- package/dist/layouts/body/body.js.map +1 -1
- package/dist/layouts/body/h_body.d.ts.map +1 -1
- package/dist/layouts/body/h_body.js +18 -12
- package/dist/layouts/body/h_body.js.map +1 -1
- package/dist/layouts/body/v_body.d.ts.map +1 -1
- package/dist/layouts/body/v_body.js +16 -10
- package/dist/layouts/body/v_body.js.map +1 -1
- package/dist/layouts/footer/footer.d.ts +2 -3
- package/dist/layouts/footer/footer.d.ts.map +1 -1
- package/dist/layouts/footer/footer.js +7 -7
- package/dist/layouts/footer/footer.js.map +1 -1
- package/dist/layouts/header/header.d.ts +2 -2
- package/dist/layouts/header/header.d.ts.map +1 -1
- package/dist/layouts/header/header.js +13 -21
- package/dist/layouts/header/header.js.map +1 -1
- package/dist/layouts/index.d.ts +0 -1
- package/dist/layouts/index.d.ts.map +1 -1
- package/dist/layouts/index.js +17 -19
- package/dist/layouts/index.js.map +1 -1
- package/dist/layouts/rail/rail.js +41 -41
- package/dist/layouts/rail/rail.js.map +1 -1
- package/dist/layouts/rail/side/side.d.ts.map +1 -1
- package/dist/layouts/rail/side/side.js +1 -1
- package/dist/layouts/rail/side/side.js.map +1 -1
- package/dist/layouts/rail/utility_strip/utility_strip.d.ts.map +1 -1
- package/dist/layouts/rail/utility_strip/utility_strip.js +21 -17
- package/dist/layouts/rail/utility_strip/utility_strip.js.map +1 -1
- package/dist/layouts/scaffold/scaffold.js +32 -32
- package/dist/layouts/scaffold/scaffold.js.map +1 -1
- package/dist/layouts/utility_bar/utility_bar.d.ts +2 -2
- package/dist/layouts/utility_bar/utility_bar.d.ts.map +1 -1
- package/dist/layouts/utility_bar/utility_bar.js +17 -19
- package/dist/layouts/utility_bar/utility_bar.js.map +1 -1
- package/dist/overlay/frame/frame.d.ts +8 -4
- package/dist/overlay/frame/frame.d.ts.map +1 -1
- package/dist/overlay/frame/frame.js +87 -23
- package/dist/overlay/frame/frame.js.map +1 -1
- package/dist/overlay/popper/base/dismissal_decorator.js.map +1 -1
- package/dist/overlay/popper/legacy/popper.d.ts.map +1 -1
- package/dist/overlay/popper/legacy/popper.js +52 -50
- package/dist/overlay/popper/legacy/popper.js.map +1 -1
- package/dist/panel.css +1 -0
- package/dist/phone_number_input.css +1 -1
- package/dist/rail.css +1 -1
- package/dist/scaffold.css +1 -1
- package/dist/side.css +1 -1
- package/dist/stacks/box/bottom_resize_handle.d.ts +2 -2
- package/dist/stacks/box/bottom_resize_handle.d.ts.map +1 -1
- package/dist/stacks/box/bottom_resize_handle.js +12 -10
- package/dist/stacks/box/bottom_resize_handle.js.map +1 -1
- package/dist/stacks/box/box.d.ts +4 -4
- package/dist/stacks/box/box.d.ts.map +1 -1
- package/dist/stacks/box/box.js +26 -26
- package/dist/stacks/box/box.js.map +1 -1
- package/dist/stacks/box/end_resize_handle.d.ts +2 -2
- package/dist/stacks/box/end_resize_handle.d.ts.map +1 -1
- package/dist/stacks/box/end_resize_handle.js +6 -5
- package/dist/stacks/box/end_resize_handle.js.map +1 -1
- package/dist/stacks/box/left_resize_handle.d.ts +2 -2
- package/dist/stacks/box/left_resize_handle.d.ts.map +1 -1
- package/dist/stacks/box/left_resize_handle.js +10 -9
- package/dist/stacks/box/left_resize_handle.js.map +1 -1
- package/dist/stacks/box/resize_handlers.d.ts +2 -2
- package/dist/stacks/box/resize_handlers.d.ts.map +1 -1
- package/dist/stacks/box/resize_handlers.js +32 -32
- package/dist/stacks/box/resize_handlers.js.map +1 -1
- package/dist/stacks/box/right_resize_handle.d.ts +2 -2
- package/dist/stacks/box/right_resize_handle.d.ts.map +1 -1
- package/dist/stacks/box/right_resize_handle.js +6 -5
- package/dist/stacks/box/right_resize_handle.js.map +1 -1
- package/dist/stacks/box/start_resize_handle.d.ts +2 -2
- package/dist/stacks/box/start_resize_handle.d.ts.map +1 -1
- package/dist/stacks/box/start_resize_handle.js +6 -6
- package/dist/stacks/box/start_resize_handle.js.map +1 -1
- package/dist/stacks/box/top_resize_handle.d.ts +2 -2
- package/dist/stacks/box/top_resize_handle.d.ts.map +1 -1
- package/dist/stacks/box/top_resize_handle.js +6 -5
- package/dist/stacks/box/top_resize_handle.js.map +1 -1
- package/dist/stacks/h_collapsible_box.d.ts.map +1 -1
- package/dist/stacks/h_collapsible_box.js +25 -25
- package/dist/stacks/h_collapsible_box.js.map +1 -1
- package/dist/stacks/v_collapsible_box.js +25 -25
- package/dist/stacks/v_collapsible_box.js.map +1 -1
- package/dist/suggestion_list.css +1 -1
- package/dist/surfaces/index.d.ts +1 -2
- package/dist/surfaces/index.d.ts.map +1 -1
- package/dist/surfaces/index.js +18 -20
- package/dist/surfaces/index.js.map +1 -1
- package/dist/surfaces/panel/panel.d.ts +5 -0
- package/dist/surfaces/panel/panel.d.ts.map +1 -0
- package/dist/surfaces/panel/panel.js +19 -0
- package/dist/surfaces/panel/panel.js.map +1 -0
- package/dist/surfaces/pop_confirm/pop_confirm.js +2 -3
- package/dist/surfaces/pop_confirm/pop_confirm.js.map +1 -1
- package/dist/surfaces/window/window.d.ts +1 -1
- package/dist/surfaces/window/window.d.ts.map +1 -1
- package/dist/surfaces/window/window.js +20 -10
- package/dist/surfaces/window/window.js.map +1 -1
- package/dist/themes/stylesheets/reset.css +1 -1
- package/dist/themes/stylesheets/reset.js +8 -1
- package/dist/themes/stylesheets/reset.js.map +1 -1
- package/dist/themes/theme.d.ts +2 -1
- package/dist/themes/theme.d.ts.map +1 -1
- package/dist/themes/theme.js +16 -9
- package/dist/themes/theme.js.map +1 -1
- package/dist/themes/themes/ergo/ergo_theme.css +1 -1
- package/dist/themes/themes/ergo/ergo_theme.js +210 -18
- package/dist/themes/themes/ergo/ergo_theme.js.map +1 -1
- package/dist/typography/body_text/body_text.d.ts.map +1 -1
- package/dist/typography/body_text/body_text.js +12 -10
- package/dist/typography/body_text/body_text.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 +22 -19
- package/dist/utils/dnd/hooks/use_drag_container.js.map +1 -1
- package/package.json +4 -2
- package/src/form/field/h_field/h_field.tsx +0 -4
- package/src/form/field/v_field/v_field.stories.tsx +8 -0
- package/src/form/field/v_field/v_field.tsx +1 -4
- package/src/form/field_set/field_set.stories.tsx +2 -1
- package/src/inputs/__docs__/inputs.mdx +81 -0
- package/src/inputs/__docs__/inputs.stories.tsx +268 -0
- package/src/inputs/color_input/color_input.tsx +17 -17
- package/src/inputs/combo_box/combo_box.tsx +17 -13
- package/src/inputs/index.ts +2 -0
- package/src/inputs/input/input.tsx +1 -1
- package/src/inputs/input_group/input_group.tsx +26 -0
- package/src/inputs/phone_number_input/countries_phone_information.ts +6 -353
- package/src/inputs/phone_number_input/phone_number_context.tsx +32 -0
- package/src/inputs/phone_number_input/phone_number_country_select_adapter.tsx +126 -0
- package/src/inputs/phone_number_input/phone_number_input.module.css +5 -63
- package/src/inputs/phone_number_input/phone_number_input.stories.tsx +180 -150
- package/src/inputs/phone_number_input/phone_number_input.tsx +133 -400
- package/src/inputs/phone_number_input/phone_number_input_adapter.tsx +123 -0
- package/src/inputs/phone_number_input/sip_input.tsx +147 -0
- package/src/inputs/select/select.tsx +13 -14
- package/src/inputs/suggestions/suggestion_list.module.css +1 -0
- package/src/inputs/suggestions/suggestion_list.stories.tsx +12 -8
- package/src/inputs/suggestions/suggestion_list.tsx +24 -3
- package/src/inputs/textarea/textarea.tsx +1 -1
- package/src/inputs/unit_input/unit_input.tsx +17 -17
- package/src/layouts/__stories__/composed.stories.tsx +0 -55
- package/src/layouts/__stories__/rail.stories.tsx +78 -0
- package/src/layouts/__stories__/scaffold.stories.tsx +90 -0
- package/src/layouts/__stories__/utils/content.tsx +27 -0
- package/src/layouts/__stories__/utils/layout_theme.css +88 -0
- package/src/layouts/__stories__/utils/layout_theme_provider.tsx +11 -0
- package/src/layouts/__stories__/utils.tsx +6 -6
- package/src/layouts/{utility_bar/utility_bar.module.css → bar/bar.module.css} +2 -1
- package/src/layouts/bar/bar.tsx +23 -0
- package/src/layouts/body/body.module.css +9 -4
- package/src/layouts/body/body.tsx +7 -6
- package/src/layouts/body/h_body.module.css +1 -2
- package/src/layouts/body/h_body.tsx +9 -4
- package/src/layouts/body/v_body.tsx +9 -4
- package/src/layouts/divider/divider.module.css +1 -1
- package/src/layouts/footer/footer.module.css +0 -3
- package/src/layouts/footer/footer.tsx +5 -6
- package/src/layouts/header/header.tsx +6 -15
- package/src/layouts/index.ts +0 -1
- package/src/layouts/rail/rail.module.css +9 -5
- package/src/layouts/rail/rail.tsx +1 -1
- package/src/layouts/rail/side/side.module.css +0 -1
- package/src/layouts/rail/side/side.tsx +1 -2
- package/src/layouts/rail/utility_strip/utility_strip.module.css +5 -0
- package/src/layouts/rail/utility_strip/utility_strip.tsx +4 -1
- package/src/layouts/scaffold/scaffold.module.css +10 -7
- package/src/layouts/scaffold/scaffold.tsx +1 -1
- package/src/layouts/utility_bar/utility_bar.tsx +6 -9
- package/src/overlay/frame/frame.module.css +2 -4
- package/src/overlay/frame/frame.stories.tsx +13 -10
- package/src/overlay/frame/frame.tsx +124 -16
- package/src/overlay/popper/base/dismissal_decorator.tsx +1 -1
- package/src/overlay/popper/legacy/popper.tsx +5 -1
- package/src/stacks/box/bottom_resize_handle.tsx +12 -5
- package/src/stacks/box/box.tsx +18 -14
- package/src/stacks/box/end_resize_handle.tsx +11 -6
- package/src/stacks/box/left_resize_handle.tsx +9 -3
- package/src/stacks/box/resize_handlers.ts +27 -13
- package/src/stacks/box/right_resize_handle.tsx +9 -3
- package/src/stacks/box/start_resize_handle.tsx +9 -4
- package/src/stacks/box/top_resize_handle.tsx +10 -4
- package/src/stacks/collapsible_box.stories.tsx +11 -11
- package/src/stacks/h_collapsible_box.tsx +5 -5
- package/src/stacks/v_collapsible_box.tsx +4 -4
- package/src/surfaces/index.ts +1 -2
- package/src/surfaces/panel/__stories__/panel.stories.tsx +12 -12
- package/src/surfaces/panel/__stories__/panel_stories.module.css +3 -3
- package/src/surfaces/panel/panel.module.css +1 -6
- package/src/surfaces/panel/panel.tsx +22 -0
- package/src/surfaces/window/window.tsx +14 -4
- package/src/themes/stories/controls_fieldset.tsx +1 -1
- package/src/themes/stylesheets/reset.css +8 -1
- package/src/themes/theme.tsx +6 -2
- package/src/themes/themes/ergo/__stories__/material.stories.tsx +15 -16
- package/src/themes/themes/ergo/ergo_theme.css +210 -18
- package/src/typography/body_text/body_text.tsx +2 -0
- package/src/utils/dnd/__stories__/draggable.stories.tsx +14 -8
- package/src/utils/dnd/hooks/use_drag_container.ts +13 -3
- package/dist/h_body.css +0 -1
- package/dist/h_panel.css +0 -1
- package/dist/header.css +0 -1
- package/dist/layouts/rail/main/main.d.ts +0 -6
- package/dist/layouts/rail/main/main.d.ts.map +0 -1
- package/dist/layouts/rail/main/main.js +0 -21
- package/dist/layouts/rail/main/main.js.map +0 -1
- package/dist/main.css +0 -1
- package/dist/surfaces/panel/h_panel.d.ts +0 -9
- package/dist/surfaces/panel/h_panel.d.ts.map +0 -1
- package/dist/surfaces/panel/h_panel.js +0 -60
- package/dist/surfaces/panel/h_panel.js.map +0 -1
- package/dist/surfaces/panel/v_panel.d.ts +0 -5
- package/dist/surfaces/panel/v_panel.d.ts.map +0 -1
- package/dist/surfaces/panel/v_panel.js +0 -19
- package/dist/surfaces/panel/v_panel.js.map +0 -1
- package/dist/utility_bar.css +0 -1
- package/dist/v_body.css +0 -1
- package/src/inputs/phone_number_input/__tests__/utils.test.ts +0 -52
- package/src/layouts/header/header.module.css +0 -8
- package/src/layouts/rail/__stories__/rail.stories.tsx +0 -64
- package/src/layouts/rail/__stories__/rail_stories.module.css +0 -25
- package/src/layouts/rail/main/main.module.css +0 -7
- package/src/layouts/rail/main/main.tsx +0 -26
- package/src/layouts/scaffold/__stories__/scaffold.stories.tsx +0 -53
- package/src/layouts/scaffold/__stories__/scaffold_stories.module.css +0 -31
- package/src/surfaces/panel/h_panel.tsx +0 -65
- package/src/surfaces/panel/v_panel.tsx +0 -20
|
@@ -1,50 +1,158 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
1
|
+
import { clsx } from 'clsx';
|
|
2
|
+
import React, { useCallback } from 'react';
|
|
3
|
+
import { flushSync } from 'react-dom';
|
|
4
|
+
import { Box, ZStack, type BoxProps } from '../../stacks/index.js';
|
|
5
|
+
import { useDragContainer } from '../../utils/dnd/context.js';
|
|
4
6
|
import { Draggable } from '../../utils/dnd/draggable/draggable.js';
|
|
7
|
+
import { Portal } from '../portal/portal.js';
|
|
5
8
|
|
|
6
9
|
// Styles
|
|
7
10
|
import styles from './frame.module.css';
|
|
8
|
-
import { clsx } from 'clsx';
|
|
9
|
-
|
|
10
11
|
export interface FrameOwnProps {
|
|
11
12
|
isOpen?: boolean;
|
|
12
|
-
children?: React.ReactNode;
|
|
13
13
|
draggable?: boolean;
|
|
14
14
|
veil?: boolean;
|
|
15
|
+
resizable?: boolean;
|
|
15
16
|
}
|
|
16
17
|
|
|
17
|
-
export type FrameProps =
|
|
18
|
+
export type FrameProps = Omit<
|
|
19
|
+
BoxProps,
|
|
20
|
+
| 'enableResizeOnLeft'
|
|
21
|
+
| 'enableResizeOnRight'
|
|
22
|
+
| 'enableResizeOnTop'
|
|
23
|
+
| 'enableResizeOnBottom'
|
|
24
|
+
> &
|
|
25
|
+
FrameOwnProps;
|
|
18
26
|
|
|
19
|
-
export const Frame = React.forwardRef<
|
|
27
|
+
export const Frame = React.forwardRef<HTMLElement, FrameProps>(function Frame(
|
|
20
28
|
{
|
|
21
29
|
children,
|
|
22
30
|
isOpen = false,
|
|
23
31
|
draggable = true,
|
|
24
32
|
veil = false,
|
|
33
|
+
resizable = true,
|
|
25
34
|
className,
|
|
26
35
|
...rest
|
|
27
36
|
}: FrameProps,
|
|
28
37
|
ref
|
|
29
38
|
) {
|
|
30
|
-
if (!isOpen)
|
|
31
|
-
return null;
|
|
32
|
-
}
|
|
33
|
-
|
|
39
|
+
if (!isOpen) return null;
|
|
34
40
|
return (
|
|
35
41
|
<Portal>
|
|
36
42
|
<ZStack width="100%" height="100%" data-is-veil={veil} className="tcn-frame-veil">
|
|
37
43
|
<Draggable draggable={draggable}>
|
|
38
|
-
<
|
|
39
|
-
|
|
44
|
+
<FrameDialog
|
|
45
|
+
className={className}
|
|
40
46
|
ref={ref}
|
|
41
|
-
|
|
47
|
+
enableResizeOnLeft={resizable}
|
|
48
|
+
enableResizeOnRight={resizable}
|
|
49
|
+
enableResizeOnTop={resizable}
|
|
50
|
+
enableResizeOnBottom={resizable}
|
|
51
|
+
draggable={draggable}
|
|
42
52
|
{...rest}
|
|
43
53
|
>
|
|
44
54
|
{children}
|
|
45
|
-
</
|
|
55
|
+
</FrameDialog>
|
|
46
56
|
</Draggable>
|
|
47
57
|
</ZStack>
|
|
48
58
|
</Portal>
|
|
49
59
|
);
|
|
50
60
|
});
|
|
61
|
+
interface FrameDialogProps extends BoxProps {}
|
|
62
|
+
|
|
63
|
+
export const FrameDialog = React.forwardRef<HTMLElement, FrameDialogProps>(
|
|
64
|
+
function FrameDialog(
|
|
65
|
+
{
|
|
66
|
+
as = 'div',
|
|
67
|
+
role = 'dialog',
|
|
68
|
+
children,
|
|
69
|
+
className,
|
|
70
|
+
draggable,
|
|
71
|
+
onWidthResize,
|
|
72
|
+
onHeightResize,
|
|
73
|
+
...rest
|
|
74
|
+
}: FrameDialogProps,
|
|
75
|
+
ref: React.Ref<HTMLElement>
|
|
76
|
+
) {
|
|
77
|
+
const drag = useDragContainer();
|
|
78
|
+
|
|
79
|
+
const handleWidthResize = React.useCallback(
|
|
80
|
+
(
|
|
81
|
+
width: number,
|
|
82
|
+
origin: 'left' | 'right',
|
|
83
|
+
totalDelta: number,
|
|
84
|
+
currentDelta: number
|
|
85
|
+
) => {
|
|
86
|
+
if (!draggable) {
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
// TODO: add clamp logic
|
|
90
|
+
if (origin === 'right') {
|
|
91
|
+
flushSync(() => {
|
|
92
|
+
drag.setPosition(prev => ({
|
|
93
|
+
x: prev.x + currentDelta / 2,
|
|
94
|
+
y: prev.y,
|
|
95
|
+
}));
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
if (origin === 'left') {
|
|
99
|
+
flushSync(() => {
|
|
100
|
+
drag.setPosition(prev => ({
|
|
101
|
+
x: prev.x - currentDelta / 2,
|
|
102
|
+
y: prev.y,
|
|
103
|
+
}));
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
onWidthResize?.(width, origin, totalDelta, currentDelta);
|
|
108
|
+
},
|
|
109
|
+
[onWidthResize, drag, draggable]
|
|
110
|
+
);
|
|
111
|
+
|
|
112
|
+
const handleHeightResize = useCallback(
|
|
113
|
+
(
|
|
114
|
+
height: number,
|
|
115
|
+
origin: 'top' | 'bottom',
|
|
116
|
+
totalDelta: number,
|
|
117
|
+
currentDelta: number
|
|
118
|
+
) => {
|
|
119
|
+
if (!draggable) {
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
// TODO: add clamp logic
|
|
123
|
+
if (origin === 'bottom') {
|
|
124
|
+
flushSync(() => {
|
|
125
|
+
drag.setPosition(prev => ({
|
|
126
|
+
x: prev.x,
|
|
127
|
+
y: prev.y + currentDelta / 2,
|
|
128
|
+
}));
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
if (origin === 'top') {
|
|
132
|
+
flushSync(() => {
|
|
133
|
+
drag.setPosition(prev => ({
|
|
134
|
+
x: prev.x,
|
|
135
|
+
y: prev.y - currentDelta / 2,
|
|
136
|
+
}));
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
onHeightResize?.(height, origin, totalDelta, currentDelta);
|
|
140
|
+
},
|
|
141
|
+
[onHeightResize, drag, draggable]
|
|
142
|
+
);
|
|
143
|
+
|
|
144
|
+
return (
|
|
145
|
+
<Box
|
|
146
|
+
className={clsx(styles['frame-dialog'], 'tcn-frame-dialog', className)}
|
|
147
|
+
ref={ref}
|
|
148
|
+
onWidthResize={handleWidthResize}
|
|
149
|
+
onHeightResize={handleHeightResize}
|
|
150
|
+
as={as}
|
|
151
|
+
role={role}
|
|
152
|
+
{...rest}
|
|
153
|
+
>
|
|
154
|
+
{children}
|
|
155
|
+
</Box>
|
|
156
|
+
);
|
|
157
|
+
}
|
|
158
|
+
);
|
|
@@ -36,7 +36,7 @@ export const PopperDismissalDecorator = forwardRef<
|
|
|
36
36
|
|
|
37
37
|
function buildExceptionHandler(dismissal: PopperDismissal) {
|
|
38
38
|
if (dismissal in dismissals) {
|
|
39
|
-
return target => isException?.(dismissal, target) ?? false;
|
|
39
|
+
return (target: HTMLElement) => isException?.(dismissal, target) ?? false;
|
|
40
40
|
}
|
|
41
41
|
return () => false;
|
|
42
42
|
}
|
|
@@ -152,13 +152,17 @@ export function Popper({
|
|
|
152
152
|
};
|
|
153
153
|
|
|
154
154
|
useLayoutEffect(() => {
|
|
155
|
-
updatePosition();
|
|
156
155
|
window.addEventListener('resize', updatePosition);
|
|
157
156
|
return () => {
|
|
158
157
|
window.removeEventListener('resize', updatePosition);
|
|
159
158
|
};
|
|
160
159
|
});
|
|
161
160
|
|
|
161
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: updatePosition depends on open and anchorElement
|
|
162
|
+
useLayoutEffect(() => {
|
|
163
|
+
updatePosition();
|
|
164
|
+
}, [open, anchorElement]);
|
|
165
|
+
|
|
162
166
|
useLayoutEffect(() => {
|
|
163
167
|
if (open) {
|
|
164
168
|
activeElementRef.current = window.document.activeElement as HTMLElement;
|
|
@@ -1,14 +1,19 @@
|
|
|
1
|
+
import { clsx } from 'clsx';
|
|
1
2
|
import React from 'react';
|
|
2
3
|
import styles from './bottom_resize_handle.module.css';
|
|
3
|
-
import { createVerticalResizeHandler } from './resize_handlers.js';
|
|
4
|
-
import { clsx } from 'clsx';
|
|
5
4
|
import type { HandleProps } from './handle_props.js';
|
|
5
|
+
import { createVerticalResizeHandler } from './resize_handlers.js';
|
|
6
6
|
|
|
7
7
|
export interface BottomResizeHandleProps {
|
|
8
8
|
targetRef: React.MutableRefObject<HTMLElement | null>;
|
|
9
9
|
handleProps?: HandleProps;
|
|
10
|
-
onHeightResize?: (
|
|
11
|
-
|
|
10
|
+
onHeightResize?: (
|
|
11
|
+
height: number,
|
|
12
|
+
origin: 'top' | 'bottom',
|
|
13
|
+
totalDelta: number,
|
|
14
|
+
currentDelta: number
|
|
15
|
+
) => void;
|
|
16
|
+
onHeightResizeEnd?: (height: number, origin: 'top' | 'bottom') => void;
|
|
12
17
|
}
|
|
13
18
|
|
|
14
19
|
export function BottomResizeHandle({
|
|
@@ -20,7 +25,9 @@ export function BottomResizeHandle({
|
|
|
20
25
|
const resizeHandler = createVerticalResizeHandler(
|
|
21
26
|
targetRef,
|
|
22
27
|
onHeightResize,
|
|
23
|
-
onHeightResizeEnd
|
|
28
|
+
onHeightResizeEnd,
|
|
29
|
+
false,
|
|
30
|
+
'bottom'
|
|
24
31
|
);
|
|
25
32
|
const offset = handleProps?.offset ? handleProps.offset : -8;
|
|
26
33
|
|
package/src/stacks/box/box.tsx
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { clsx } from 'clsx';
|
|
2
2
|
import React, { CSSProperties, HTMLAttributes, useRef } from 'react';
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
3
|
+
import { useForkRef } from '../../utils/index.js';
|
|
4
|
+
import styles from '../stack.module.css';
|
|
5
|
+
import { isCustomSizeProp } from '../utils/isCustomSizeProp.js';
|
|
6
|
+
import { removeUndefinedProperties } from '../utils/remove_undefined_properties.js';
|
|
5
7
|
import { BottomResizeHandle } from './bottom_resize_handle.js';
|
|
6
8
|
import { EndResizeHandle } from './end_resize_handle.js';
|
|
9
|
+
import { HandleProps } from './handle_props.js';
|
|
10
|
+
import { LeftResizeHandle } from './left_resize_handle.js';
|
|
11
|
+
import { RightResizeHandle } from './right_resize_handle.js';
|
|
7
12
|
import { StartResizeHandle } from './start_resize_handle.js';
|
|
8
13
|
import { TopResizeHandle } from './top_resize_handle.js';
|
|
9
|
-
import { clsx } from 'clsx';
|
|
10
|
-
import { isCustomSizeProp } from '../utils/isCustomSizeProp.js';
|
|
11
|
-
import { removeUndefinedProperties } from '../utils/remove_undefined_properties.js';
|
|
12
|
-
import styles from '../stack.module.css';
|
|
13
|
-
import { HandleProps } from './handle_props.js';
|
|
14
14
|
|
|
15
15
|
export interface BoxProps<T extends HTMLElement = HTMLElement> extends HTMLAttributes<T> {
|
|
16
16
|
as?: string;
|
|
@@ -46,15 +46,19 @@ export interface BoxProps<T extends HTMLElement = HTMLElement> extends HTMLAttri
|
|
|
46
46
|
horizontalHandleProps?: HandleProps;
|
|
47
47
|
verticalHandleProps?: HandleProps;
|
|
48
48
|
onWidthResize?: (
|
|
49
|
-
width: number
|
|
50
|
-
|
|
49
|
+
width: number,
|
|
50
|
+
origin: 'left' | 'right',
|
|
51
|
+
totalDelta: number,
|
|
52
|
+
currentDelta: number
|
|
51
53
|
) => void;
|
|
52
54
|
onHeightResize?: (
|
|
53
|
-
height: number
|
|
54
|
-
|
|
55
|
+
height: number,
|
|
56
|
+
origin: 'top' | 'bottom',
|
|
57
|
+
totalDelta: number,
|
|
58
|
+
currentDelta: number
|
|
55
59
|
) => void;
|
|
56
|
-
onWidthResizeEnd?: (width: number) => void;
|
|
57
|
-
onHeightResizeEnd?: (
|
|
60
|
+
onWidthResizeEnd?: (width: number, origin: 'left' | 'right') => void;
|
|
61
|
+
onHeightResizeEnd?: (height: number, origin: 'top' | 'bottom') => void;
|
|
58
62
|
}
|
|
59
63
|
|
|
60
64
|
export const Box = React.forwardRef<HTMLElement, BoxProps>(function Box(
|
|
@@ -1,16 +1,20 @@
|
|
|
1
|
+
import { clsx } from 'clsx';
|
|
1
2
|
import React from 'react';
|
|
2
3
|
import styles from './end_resize_handle.module.css';
|
|
4
|
+
import { HandleProps } from './handle_props.js';
|
|
3
5
|
import { createHorizontalResizeHandler } from './resize_handlers.js';
|
|
4
|
-
import { clsx } from 'clsx';
|
|
5
|
-
import type { HandleProps } from './handle_props.js';
|
|
6
6
|
|
|
7
7
|
export interface EndResizeHandleProps {
|
|
8
8
|
targetRef: React.MutableRefObject<HTMLElement | null>;
|
|
9
9
|
handleProps?: HandleProps;
|
|
10
|
-
onWidthResize?: (
|
|
11
|
-
|
|
10
|
+
onWidthResize?: (
|
|
11
|
+
width: number,
|
|
12
|
+
origin: 'left' | 'right',
|
|
13
|
+
totalDelta: number,
|
|
14
|
+
currentDelta: number
|
|
15
|
+
) => void;
|
|
16
|
+
onWidthResizeEnd?: (width: number, origin: 'left' | 'right') => void;
|
|
12
17
|
}
|
|
13
|
-
|
|
14
18
|
export function EndResizeHandle({
|
|
15
19
|
targetRef,
|
|
16
20
|
handleProps,
|
|
@@ -20,7 +24,8 @@ export function EndResizeHandle({
|
|
|
20
24
|
const resizeHandler = createHorizontalResizeHandler(
|
|
21
25
|
targetRef,
|
|
22
26
|
onWidthResize,
|
|
23
|
-
onWidthResizeEnd
|
|
27
|
+
onWidthResizeEnd,
|
|
28
|
+
'right'
|
|
24
29
|
);
|
|
25
30
|
const offset = handleProps?.offset ? handleProps.offset : -8;
|
|
26
31
|
|
|
@@ -1,14 +1,19 @@
|
|
|
1
|
+
import { clsx } from 'clsx';
|
|
1
2
|
import React from 'react';
|
|
2
3
|
import { HandleProps } from './handle_props.js';
|
|
3
4
|
import styles from './left_resize_handle.module.css';
|
|
4
5
|
import { createHorizontalResizeHandler } from './resize_handlers.js';
|
|
5
|
-
import { clsx } from 'clsx';
|
|
6
6
|
|
|
7
7
|
export interface LeftResizeHandleProps {
|
|
8
8
|
targetRef: React.MutableRefObject<HTMLElement | null>;
|
|
9
9
|
handleProps?: HandleProps;
|
|
10
|
-
onWidthResize?: (
|
|
11
|
-
|
|
10
|
+
onWidthResize?: (
|
|
11
|
+
width: number,
|
|
12
|
+
origin: 'left' | 'right',
|
|
13
|
+
totalDelta: number,
|
|
14
|
+
currentDelta: number
|
|
15
|
+
) => void;
|
|
16
|
+
onWidthResizeEnd?: (width: number, origin: 'left' | 'right') => void;
|
|
12
17
|
}
|
|
13
18
|
export function LeftResizeHandle({
|
|
14
19
|
targetRef,
|
|
@@ -20,6 +25,7 @@ export function LeftResizeHandle({
|
|
|
20
25
|
targetRef,
|
|
21
26
|
onWidthResize,
|
|
22
27
|
onWidthResizeEnd,
|
|
28
|
+
'left',
|
|
23
29
|
true,
|
|
24
30
|
true
|
|
25
31
|
);
|
|
@@ -9,8 +9,14 @@ function createVeil() {
|
|
|
9
9
|
|
|
10
10
|
export function createHorizontalResizeHandler(
|
|
11
11
|
targetRef: React.MutableRefObject<HTMLElement | null>,
|
|
12
|
-
onWidthResize?: (
|
|
13
|
-
|
|
12
|
+
onWidthResize?: (
|
|
13
|
+
width: number,
|
|
14
|
+
origin: 'left' | 'right',
|
|
15
|
+
totalDelta: number,
|
|
16
|
+
currentDelta: number
|
|
17
|
+
) => void,
|
|
18
|
+
onWidthResizeEnd?: (width: number, origin: 'left' | 'right') => void,
|
|
19
|
+
origin: 'left' | 'right' = 'right',
|
|
14
20
|
invert = false,
|
|
15
21
|
disableDirection = false
|
|
16
22
|
) {
|
|
@@ -34,13 +40,14 @@ export function createHorizontalResizeHandler(
|
|
|
34
40
|
let width = startRect.width;
|
|
35
41
|
|
|
36
42
|
const drag = (event: MouseEvent) => {
|
|
37
|
-
const
|
|
38
|
-
const newWidth = startRect.width +
|
|
43
|
+
const totalDelta = direction * (event.clientX - startX);
|
|
44
|
+
const newWidth = startRect.width + totalDelta;
|
|
45
|
+
const currentDelta = newWidth - width;
|
|
39
46
|
|
|
40
47
|
width = newWidth;
|
|
41
48
|
|
|
42
49
|
box.style.width = `${newWidth}px`;
|
|
43
|
-
onWidthResize
|
|
50
|
+
onWidthResize?.(newWidth, origin, totalDelta, currentDelta);
|
|
44
51
|
event.stopPropagation();
|
|
45
52
|
event.preventDefault();
|
|
46
53
|
};
|
|
@@ -60,7 +67,7 @@ export function createHorizontalResizeHandler(
|
|
|
60
67
|
event.stopPropagation();
|
|
61
68
|
event.preventDefault();
|
|
62
69
|
|
|
63
|
-
onWidthResizeEnd
|
|
70
|
+
onWidthResizeEnd?.(width, origin);
|
|
64
71
|
};
|
|
65
72
|
|
|
66
73
|
document.body.addEventListener('mousemove', drag);
|
|
@@ -73,9 +80,15 @@ export function createHorizontalResizeHandler(
|
|
|
73
80
|
|
|
74
81
|
export function createVerticalResizeHandler(
|
|
75
82
|
targetRef: React.MutableRefObject<HTMLElement | null>,
|
|
76
|
-
onHeightResize?: (
|
|
77
|
-
|
|
78
|
-
|
|
83
|
+
onHeightResize?: (
|
|
84
|
+
height: number,
|
|
85
|
+
origin: 'top' | 'bottom',
|
|
86
|
+
totalDelta: number,
|
|
87
|
+
currentDelta: number
|
|
88
|
+
) => void,
|
|
89
|
+
onHeightResizeEnd?: (height: number, origin: 'top' | 'bottom') => void,
|
|
90
|
+
invert = false,
|
|
91
|
+
origin: 'top' | 'bottom' = 'bottom'
|
|
79
92
|
) {
|
|
80
93
|
const direction = invert ? -1 : 1;
|
|
81
94
|
return function startVerticalResize(event: React.MouseEvent) {
|
|
@@ -93,11 +106,12 @@ export function createVerticalResizeHandler(
|
|
|
93
106
|
let height = startRect.height;
|
|
94
107
|
|
|
95
108
|
const drag = (event: MouseEvent) => {
|
|
96
|
-
const
|
|
97
|
-
const newHeight = startRect.height +
|
|
109
|
+
const totalDelta = direction * (event.clientY - startY);
|
|
110
|
+
const newHeight = startRect.height + totalDelta;
|
|
111
|
+
const currentDelta = newHeight - height;
|
|
98
112
|
height = newHeight;
|
|
99
113
|
box.style.height = `${newHeight}px`;
|
|
100
|
-
onHeightResize
|
|
114
|
+
onHeightResize?.(newHeight, origin, totalDelta, currentDelta);
|
|
101
115
|
event.stopPropagation();
|
|
102
116
|
event.preventDefault();
|
|
103
117
|
};
|
|
@@ -117,7 +131,7 @@ export function createVerticalResizeHandler(
|
|
|
117
131
|
event.stopPropagation();
|
|
118
132
|
event.preventDefault();
|
|
119
133
|
|
|
120
|
-
onHeightResizeEnd
|
|
134
|
+
onHeightResizeEnd?.(height, origin);
|
|
121
135
|
};
|
|
122
136
|
|
|
123
137
|
document.body.addEventListener('mousemove', drag);
|
|
@@ -1,14 +1,19 @@
|
|
|
1
|
+
import { clsx } from 'clsx';
|
|
1
2
|
import React from 'react';
|
|
2
3
|
import { HandleProps } from './handle_props.js';
|
|
3
4
|
import { createHorizontalResizeHandler } from './resize_handlers.js';
|
|
4
5
|
import styles from './right_resize_handle.module.css';
|
|
5
|
-
import { clsx } from 'clsx';
|
|
6
6
|
|
|
7
7
|
export interface RightResizeHandleProps {
|
|
8
8
|
targetRef: React.MutableRefObject<HTMLElement | null>;
|
|
9
9
|
handleProps?: HandleProps;
|
|
10
|
-
onWidthResize?: (
|
|
11
|
-
|
|
10
|
+
onWidthResize?: (
|
|
11
|
+
width: number,
|
|
12
|
+
origin: 'left' | 'right',
|
|
13
|
+
totalDelta: number,
|
|
14
|
+
currentDelta: number
|
|
15
|
+
) => void;
|
|
16
|
+
onWidthResizeEnd?: (width: number, origin: 'left' | 'right') => void;
|
|
12
17
|
}
|
|
13
18
|
export function RightResizeHandle({
|
|
14
19
|
targetRef,
|
|
@@ -20,6 +25,7 @@ export function RightResizeHandle({
|
|
|
20
25
|
targetRef,
|
|
21
26
|
onWidthResize,
|
|
22
27
|
onWidthResizeEnd,
|
|
28
|
+
'right',
|
|
23
29
|
false,
|
|
24
30
|
true
|
|
25
31
|
);
|
|
@@ -1,14 +1,19 @@
|
|
|
1
|
+
import { clsx } from 'clsx';
|
|
1
2
|
import React from 'react';
|
|
2
3
|
import { HandleProps } from './handle_props.js';
|
|
3
4
|
import { createHorizontalResizeHandler } from './resize_handlers.js';
|
|
4
5
|
import styles from './start_resize_handle.module.css';
|
|
5
|
-
import { clsx } from 'clsx';
|
|
6
6
|
|
|
7
7
|
export interface StartResizeHandleProps {
|
|
8
8
|
targetRef: React.MutableRefObject<HTMLElement | null>;
|
|
9
9
|
handleProps?: HandleProps;
|
|
10
|
-
onWidthResize?: (
|
|
11
|
-
|
|
10
|
+
onWidthResize?: (
|
|
11
|
+
width: number,
|
|
12
|
+
origin: 'left' | 'right',
|
|
13
|
+
totalDelta: number,
|
|
14
|
+
currentDelta: number
|
|
15
|
+
) => void;
|
|
16
|
+
onWidthResizeEnd?: (width: number, origin: 'left' | 'right') => void;
|
|
12
17
|
}
|
|
13
18
|
export function StartResizeHandle({
|
|
14
19
|
targetRef,
|
|
@@ -20,7 +25,7 @@ export function StartResizeHandle({
|
|
|
20
25
|
targetRef,
|
|
21
26
|
onWidthResize,
|
|
22
27
|
onWidthResizeEnd,
|
|
23
|
-
|
|
28
|
+
'left'
|
|
24
29
|
);
|
|
25
30
|
const offset = handleProps?.offset ? handleProps.offset : -8;
|
|
26
31
|
|
|
@@ -1,14 +1,19 @@
|
|
|
1
|
+
import { clsx } from 'clsx';
|
|
1
2
|
import React from 'react';
|
|
2
3
|
import { HandleProps } from './handle_props.js';
|
|
3
4
|
import { createVerticalResizeHandler } from './resize_handlers.js';
|
|
4
5
|
import styles from './top_resize_handle.module.css';
|
|
5
|
-
import { clsx } from 'clsx';
|
|
6
6
|
|
|
7
7
|
export interface TopResizeHandleProps {
|
|
8
8
|
targetRef: React.MutableRefObject<HTMLElement | null>;
|
|
9
9
|
handleProps?: HandleProps;
|
|
10
|
-
onHeightResize?: (
|
|
11
|
-
|
|
10
|
+
onHeightResize?: (
|
|
11
|
+
height: number,
|
|
12
|
+
origin: 'top' | 'bottom',
|
|
13
|
+
totalDelta: number,
|
|
14
|
+
currentDelta: number
|
|
15
|
+
) => void;
|
|
16
|
+
onHeightResizeEnd?: (height: number, origin: 'top' | 'bottom') => void;
|
|
12
17
|
}
|
|
13
18
|
export function TopResizeHandle({
|
|
14
19
|
targetRef,
|
|
@@ -20,7 +25,8 @@ export function TopResizeHandle({
|
|
|
20
25
|
targetRef,
|
|
21
26
|
onHeightResize,
|
|
22
27
|
onHeightResizeEnd,
|
|
23
|
-
true
|
|
28
|
+
true,
|
|
29
|
+
'top'
|
|
24
30
|
);
|
|
25
31
|
const offset = handleProps?.offset ? handleProps.offset : -8;
|
|
26
32
|
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
+
import { ChevronLeftIcon as ChevronLeft } from '@tcn/icons/chevron_left_icon.js';
|
|
2
|
+
import { PlusIcon as Plus } from '@tcn/icons/plus_icon.js';
|
|
1
3
|
import React from 'react';
|
|
2
4
|
import { Button, SlimButton } from '../actions/index.js';
|
|
3
|
-
import { HCollapsibleBox as HComponent } from './h_collapsible_box.js';
|
|
4
|
-
import { VCollapsibleBox as VComponent } from './v_collapsible_box.js';
|
|
5
5
|
import { Title } from '../typography/index.js';
|
|
6
|
-
import {
|
|
6
|
+
import { HCollapsibleBox } from './h_collapsible_box.js';
|
|
7
7
|
import { HStack } from './h_stack.js';
|
|
8
|
+
import { Spacer } from './spacer.js';
|
|
9
|
+
import { VCollapsibleBox } from './v_collapsible_box.js';
|
|
8
10
|
import { VStack } from './v_stack.js';
|
|
9
|
-
import { ChevronLeftIcon as ChevronLeft } from '@tcn/icons/chevron_left_icon.js';
|
|
10
|
-
import { PlusIcon as Plus } from '@tcn/icons/plus_icon.js';
|
|
11
11
|
|
|
12
12
|
export default {
|
|
13
13
|
title: 'Stacks/Collapsible Box',
|
|
@@ -49,13 +49,13 @@ export function CollapsibleBox() {
|
|
|
49
49
|
<Button onClick={() => setVHopen(c => !c)}>toggle vertical collapse</Button>
|
|
50
50
|
<Button onClick={() => setHOpen(c => !c)}>toggle horizontal collapse</Button>
|
|
51
51
|
</VStack>
|
|
52
|
-
<
|
|
52
|
+
<VCollapsibleBox open={vOpen} enableResizeOnTop>
|
|
53
53
|
<MyPanel />
|
|
54
|
-
</
|
|
54
|
+
</VCollapsibleBox>
|
|
55
55
|
</VStack>
|
|
56
|
-
<
|
|
56
|
+
<HCollapsibleBox open={hOpen} enableResizeOnStart>
|
|
57
57
|
<MyPanel />
|
|
58
|
-
</
|
|
58
|
+
</HCollapsibleBox>
|
|
59
59
|
</HStack>
|
|
60
60
|
);
|
|
61
61
|
}
|
|
@@ -67,9 +67,9 @@ export function VerticalCollapsibleBox() {
|
|
|
67
67
|
<HStack height="flex" hAlign="end" gap="16px">
|
|
68
68
|
<Button onClick={() => setOpen(c => !c)}>toggle collapse</Button>
|
|
69
69
|
</HStack>
|
|
70
|
-
<
|
|
70
|
+
<VCollapsibleBox open={open} enableResizeOnTop defaultHeight="300px">
|
|
71
71
|
<MyPanel />
|
|
72
|
-
</
|
|
72
|
+
</VCollapsibleBox>
|
|
73
73
|
</VStack>
|
|
74
74
|
);
|
|
75
75
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { clsx } from 'clsx';
|
|
1
2
|
import React, { useLayoutEffect } from 'react';
|
|
2
3
|
import { useForkRef } from '../utils/index.js';
|
|
3
|
-
import { clsx } from 'clsx';
|
|
4
4
|
import { Box, BoxProps } from './box/box.js';
|
|
5
5
|
import styles from './collapsible_box.module.css';
|
|
6
6
|
import { useIsCollapsed } from './utils/use_is_collapsed.js';
|
|
@@ -32,13 +32,13 @@ export const HCollapsibleBox = React.forwardRef(function CollapsibleBox(
|
|
|
32
32
|
data-is-collapsed={!open}
|
|
33
33
|
data-collapse-orientation="horizontal"
|
|
34
34
|
data-is-resizing={resizing}
|
|
35
|
-
onWidthResize={width => {
|
|
35
|
+
onWidthResize={(width, origin, totalDelta, currentDelta) => {
|
|
36
36
|
setIsResizing(true);
|
|
37
|
-
props.onWidthResize?.(width);
|
|
37
|
+
props.onWidthResize?.(width, origin, totalDelta, currentDelta);
|
|
38
38
|
}}
|
|
39
|
-
onWidthResizeEnd={width => {
|
|
39
|
+
onWidthResizeEnd={(width, origin) => {
|
|
40
40
|
setIsResizing(false);
|
|
41
|
-
props.onWidthResizeEnd?.(width);
|
|
41
|
+
props.onWidthResizeEnd?.(width, origin);
|
|
42
42
|
collapsibleRef.current?.style.setProperty('--collapsible-size', `${width}px`);
|
|
43
43
|
}}
|
|
44
44
|
className={clsx(
|
|
@@ -32,14 +32,14 @@ export const VCollapsibleBox = React.forwardRef(function CollapsibleBox(
|
|
|
32
32
|
data-is-collapsed={!open}
|
|
33
33
|
data-collapse-orientation="vertical"
|
|
34
34
|
data-is-resizing={resizing}
|
|
35
|
-
onHeightResize={height => {
|
|
35
|
+
onHeightResize={(height, origin, totalDelta, currentDelta) => {
|
|
36
36
|
setIsResizing(true);
|
|
37
|
-
props.onHeightResize?.(height);
|
|
37
|
+
props.onHeightResize?.(height, origin, totalDelta, currentDelta);
|
|
38
38
|
}}
|
|
39
|
-
onHeightResizeEnd={height => {
|
|
39
|
+
onHeightResizeEnd={(height, origin) => {
|
|
40
40
|
setIsResizing(false);
|
|
41
41
|
collapsibleRef.current?.style.setProperty('--collapsible-size', `${height}px`);
|
|
42
|
-
props.onHeightResizeEnd?.(height);
|
|
42
|
+
props.onHeightResizeEnd?.(height, origin);
|
|
43
43
|
}}
|
|
44
44
|
className={clsx(
|
|
45
45
|
props.className,
|
package/src/surfaces/index.ts
CHANGED
|
@@ -3,8 +3,7 @@ export * from './card/card.js';
|
|
|
3
3
|
export * from './confirm/confirm.js';
|
|
4
4
|
export * from './page/h_page.js';
|
|
5
5
|
export * from './page/v_page.js';
|
|
6
|
-
export * from './panel/
|
|
7
|
-
export * from './panel/v_panel.js';
|
|
6
|
+
export * from './panel/panel.js';
|
|
8
7
|
export * from './popover/popover.js';
|
|
9
8
|
export * from './drawers/drawer_bottom/drawer_bottom.js';
|
|
10
9
|
export * from './drawers/drawer_top/drawer_top.js';
|