@tcn/ui 0.2.0 → 0.3.1
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/Color-ASIRERSW-B4GaVKuQ.js +990 -0
- package/dist/Color-ASIRERSW-B4GaVKuQ.js.map +1 -0
- package/dist/WithTooltip-IO6J4KBT-B1oq93K5.js +1485 -0
- package/dist/WithTooltip-IO6J4KBT-B1oq93K5.js.map +1 -0
- package/dist/actions/__docs__/components/gallery.d.ts +8 -0
- package/dist/actions/__docs__/components/gallery.d.ts.map +1 -0
- package/dist/actions/__docs__/components/gallery.js +20 -0
- package/dist/actions/__docs__/components/gallery.js.map +1 -0
- package/dist/actions/__docs__/components/showcase.d.ts +27 -0
- package/dist/actions/__docs__/components/showcase.d.ts.map +1 -0
- package/dist/actions/__docs__/components/showcase.js +15 -0
- package/dist/actions/__docs__/components/showcase.js.map +1 -0
- package/dist/actions/button/base_button/base_button.d.ts +2 -0
- package/dist/actions/button/base_button/base_button.d.ts.map +1 -1
- package/dist/actions/button/base_button/base_button.js +18 -16
- package/dist/actions/button/base_button/base_button.js.map +1 -1
- package/dist/actions/button/button/button.js +6 -6
- package/dist/actions/button/button_group/button_group.js +1 -1
- package/dist/actions/button/select_group/select_group.js +13 -13
- package/dist/actions/button/select_group/single_select_group.js +6 -6
- package/dist/actions/button/slim_button/slim_button.js +2 -2
- package/dist/actions/types.d.ts +2 -0
- package/dist/actions/types.d.ts.map +1 -0
- package/dist/actions/types.js +2 -0
- package/dist/actions/types.js.map +1 -0
- package/dist/divider.module-FptFV0PX.js +5 -0
- package/dist/divider.module-FptFV0PX.js.map +1 -0
- package/dist/feedback/loading/loading.js +12 -12
- package/dist/feedback/loading/loading.js.map +1 -1
- package/dist/feedback/progress/progress_bar.js +1 -1
- package/dist/form/field/common/field_control/field_control.js +8 -8
- package/dist/form/field/common/status_input/status_input.js +6 -6
- package/dist/form/field/field.js +6 -6
- package/dist/form/field/h_field/h_field.js +11 -11
- package/dist/form/field/v_field/v_field.js +10 -10
- package/dist/form/field_set/field_set.js +3 -3
- package/dist/formatter-QJ4M4OGQ-DaIl2Wi_.js +6 -0
- package/dist/formatter-QJ4M4OGQ-DaIl2Wi_.js.map +1 -0
- package/dist/frame.css +1 -0
- package/dist/gallery.css +1 -0
- package/dist/inputs/checkbox/checkbox.js +11 -11
- package/dist/inputs/color_input/color_input.js +1 -1
- package/dist/inputs/color_input/color_input.js.map +1 -1
- package/dist/inputs/color_input/color_picker.js +6 -6
- package/dist/inputs/combo_box/combo_box.js +17 -17
- package/dist/inputs/date_picker/date_picker.js +19 -19
- package/dist/inputs/date_picker/date_picker_body.js +2 -2
- package/dist/inputs/date_picker/date_picker_input.js +20 -20
- package/dist/inputs/date_picker/date_picker_input.js.map +1 -1
- package/dist/inputs/date_picker/date_picker_year_input.js +1 -1
- package/dist/inputs/date_picker/date_picker_year_input.js.map +1 -1
- package/dist/inputs/date_picker/date_picker_year_selector.js +1 -1
- package/dist/inputs/input/input.js +5 -5
- package/dist/inputs/mask_input/key_capture_input.js +8 -8
- package/dist/inputs/mask_input/mask_input.js +5 -5
- package/dist/inputs/multi_combo_box/multi_combo_box.js +17 -17
- package/dist/inputs/multiselect/multiselect.js +14 -14
- package/dist/inputs/multiselect/multiselect_row.js +8 -8
- package/dist/inputs/phone_number_input/phone_number_input.js +12 -12
- package/dist/inputs/radio/radio.js +10 -10
- package/dist/inputs/radio/radio_row.js +3 -3
- package/dist/inputs/select/select.js +15 -15
- package/dist/inputs/slider/slider.js +11 -11
- package/dist/inputs/suggestions/suggestion_list.js +2 -2
- package/dist/inputs/suggestions/suggestion_list.js.map +1 -1
- package/dist/inputs/switch/switch.js +5 -5
- package/dist/inputs/textarea/textarea.js +7 -7
- package/dist/inputs/unit_input/unit_input.js +5 -5
- package/dist/layouts/body/h_body.js +7 -7
- package/dist/layouts/body/v_body.js +6 -6
- package/dist/layouts/column/column.js +17 -17
- package/dist/layouts/divider/divider.js +24 -23
- package/dist/layouts/divider/divider.js.map +1 -1
- package/dist/layouts/footer/footer.js +7 -7
- package/dist/layouts/grid/grid.js +24 -24
- package/dist/layouts/header/header.js +2 -2
- package/dist/layouts/index.d.ts +6 -5
- package/dist/layouts/index.d.ts.map +1 -1
- package/dist/layouts/index.js +28 -26
- package/dist/layouts/index.js.map +1 -1
- package/dist/layouts/list/item.js +2 -2
- package/dist/layouts/list/list.js +7 -7
- package/dist/layouts/list/section_header.js +6 -6
- package/dist/layouts/scaffold/scaffold.d.ts +9 -0
- package/dist/layouts/scaffold/scaffold.d.ts.map +1 -0
- package/dist/layouts/scaffold/scaffold.js +55 -0
- package/dist/layouts/scaffold/scaffold.js.map +1 -0
- package/dist/layouts/sidebar_end/sidebar_end.js +14 -14
- package/dist/layouts/sidebar_start/sidebar_start.js +10 -10
- package/dist/layouts/utility_bar/utility_bar.js +10 -10
- package/dist/modal.css +1 -1
- package/dist/overlay/frame/frame.d.ts.map +1 -1
- package/dist/overlay/frame/frame.js +22 -5
- package/dist/overlay/frame/frame.js.map +1 -1
- package/dist/overlay/index.d.ts +9 -2
- package/dist/overlay/index.d.ts.map +1 -1
- package/dist/overlay/index.js +22 -10
- package/dist/overlay/index.js.map +1 -1
- package/dist/overlay/menu/menu.d.ts +1 -1
- package/dist/overlay/menu/menu.d.ts.map +1 -1
- package/dist/overlay/menu/menu.js +36 -36
- package/dist/overlay/menu/menu.js.map +1 -1
- package/dist/overlay/popper/base/base_popper.d.ts +11 -0
- package/dist/overlay/popper/base/base_popper.d.ts.map +1 -0
- package/dist/overlay/popper/base/base_popper.js +27 -0
- package/dist/overlay/popper/base/base_popper.js.map +1 -0
- package/dist/overlay/popper/base/dismissal_decorator.d.ts +16 -0
- package/dist/overlay/popper/base/dismissal_decorator.d.ts.map +1 -0
- package/dist/overlay/popper/base/dismissal_decorator.js +69 -0
- package/dist/overlay/popper/base/dismissal_decorator.js.map +1 -0
- package/dist/overlay/popper/context_popper.d.ts +11 -0
- package/dist/overlay/popper/context_popper.d.ts.map +1 -0
- package/dist/overlay/popper/context_popper.js +33 -0
- package/dist/overlay/popper/context_popper.js.map +1 -0
- package/dist/overlay/popper/element_popper.d.ts +7 -0
- package/dist/overlay/popper/element_popper.d.ts.map +1 -0
- package/dist/overlay/popper/element_popper.js +33 -0
- package/dist/overlay/popper/element_popper.js.map +1 -0
- package/dist/overlay/popper/hooks/use_context_trigger.d.ts +7 -0
- package/dist/overlay/popper/hooks/use_context_trigger.d.ts.map +1 -0
- package/dist/overlay/popper/hooks/use_context_trigger.js +31 -0
- package/dist/overlay/popper/hooks/use_context_trigger.js.map +1 -0
- package/dist/overlay/popper/hooks/use_hover_trigger.d.ts +6 -0
- package/dist/overlay/popper/hooks/use_hover_trigger.d.ts.map +1 -0
- package/dist/overlay/popper/hooks/use_hover_trigger.js +17 -0
- package/dist/overlay/popper/hooks/use_hover_trigger.js.map +1 -0
- package/dist/overlay/popper/hooks/use_restore_focus.d.ts +2 -0
- package/dist/overlay/popper/hooks/use_restore_focus.d.ts.map +1 -0
- package/dist/overlay/popper/hooks/use_restore_focus.js +18 -0
- package/dist/overlay/popper/hooks/use_restore_focus.js.map +1 -0
- package/dist/overlay/popper/legacy/popper.d.ts.map +1 -0
- package/dist/overlay/popper/{popper.js → legacy/popper.js} +6 -6
- package/dist/overlay/popper/legacy/popper.js.map +1 -0
- package/dist/overlay/popper/preview_popper.d.ts +7 -0
- package/dist/overlay/popper/preview_popper.d.ts.map +1 -0
- package/dist/overlay/popper/preview_popper.js +46 -0
- package/dist/overlay/popper/preview_popper.js.map +1 -0
- package/dist/overlay/portal/portal_platform_context.js +4 -4
- package/dist/overlay/tethered/element_tethered.d.ts +8 -0
- package/dist/overlay/tethered/element_tethered.d.ts.map +1 -0
- package/dist/overlay/tethered/element_tethered.js +33 -0
- package/dist/overlay/tethered/element_tethered.js.map +1 -0
- package/dist/overlay/tethered/hooks/calculate_position.d.ts +19 -0
- package/dist/overlay/tethered/hooks/calculate_position.d.ts.map +1 -0
- package/dist/overlay/tethered/hooks/calculate_position.js +43 -0
- package/dist/overlay/tethered/hooks/calculate_position.js.map +1 -0
- package/dist/overlay/tethered/hooks/useTether.d.ts +19 -0
- package/dist/overlay/tethered/hooks/useTether.d.ts.map +1 -0
- package/dist/overlay/tethered/hooks/useTether.js +61 -0
- package/dist/overlay/tethered/hooks/useTether.js.map +1 -0
- package/dist/overlay/tethered/tethered.d.ts +20 -0
- package/dist/overlay/tethered/tethered.d.ts.map +1 -0
- package/dist/overlay/tethered/tethered.js +59 -0
- package/dist/overlay/tethered/tethered.js.map +1 -0
- package/dist/overlay/tethered/types.d.ts +3 -0
- package/dist/overlay/tethered/types.d.ts.map +1 -0
- package/dist/overlay/tethered/types.js +2 -0
- package/dist/overlay/tethered/types.js.map +1 -0
- package/dist/popper.css +1 -1
- package/dist/scaffold.css +1 -0
- package/dist/showcase-WfP6kBEb.js +58401 -0
- package/dist/showcase-WfP6kBEb.js.map +1 -0
- package/dist/showcase.css +1 -0
- package/dist/stacks/box/box.js +24 -24
- package/dist/stacks/h_collapsible_box.js +3 -3
- package/dist/stacks/h_stack.js +41 -41
- package/dist/stacks/spacer.js +11 -11
- package/dist/stacks/story_components/circle.js +10 -10
- package/dist/stacks/story_components/picture_placeholder.js +9 -9
- package/dist/stacks/story_components/rect.js +7 -7
- package/dist/stacks/story_components/style_box.js +4 -4
- package/dist/stacks/utils/use_is_collapsed.js +6 -6
- package/dist/stacks/v_collapsible_box.js +3 -3
- package/dist/stacks/v_stack.js +42 -42
- package/dist/stacks/z_stack.js +39 -39
- package/dist/surfaces/alert/alert.js +4 -4
- package/dist/surfaces/card/card.d.ts +2 -2
- package/dist/surfaces/card/card.d.ts.map +1 -1
- package/dist/surfaces/card/card.js +7 -7
- package/dist/surfaces/card/card.js.map +1 -1
- package/dist/surfaces/confirm/confirm.js +9 -9
- package/dist/surfaces/drawers/drawer_start/drawer_start.js +2 -2
- package/dist/surfaces/drawers/drawer_top/drawer_top.js +2 -2
- package/dist/surfaces/index.d.ts +2 -0
- package/dist/surfaces/index.d.ts.map +1 -1
- package/dist/surfaces/index.js +22 -18
- package/dist/surfaces/index.js.map +1 -1
- package/dist/surfaces/modal/modal.d.ts +3 -3
- package/dist/surfaces/modal/modal.d.ts.map +1 -1
- package/dist/surfaces/modal/modal.js +14 -14
- package/dist/surfaces/modal/modal.js.map +1 -1
- package/dist/surfaces/page/h_page.js +7 -7
- package/dist/surfaces/page/v_page.js +5 -5
- package/dist/surfaces/panel/h_panel.js +29 -30
- package/dist/surfaces/panel/h_panel.js.map +1 -1
- package/dist/surfaces/panel/v_panel.d.ts +3 -7
- package/dist/surfaces/panel/v_panel.d.ts.map +1 -1
- package/dist/surfaces/panel/v_panel.js +12 -54
- package/dist/surfaces/panel/v_panel.js.map +1 -1
- package/dist/surfaces/pop_confirm/pop_confirm.d.ts +5 -0
- package/dist/surfaces/pop_confirm/pop_confirm.d.ts.map +1 -0
- package/dist/surfaces/pop_confirm/pop_confirm.js +37 -0
- package/dist/surfaces/pop_confirm/pop_confirm.js.map +1 -0
- package/dist/surfaces/popconfirm/pop_confirm.d.ts +5 -0
- package/dist/surfaces/popconfirm/pop_confirm.d.ts.map +1 -0
- package/dist/surfaces/popconfirm/pop_confirm.js +13 -0
- package/dist/surfaces/popconfirm/pop_confirm.js.map +1 -0
- package/dist/surfaces/popover/popover.d.ts +1 -1
- package/dist/surfaces/popover/popover.d.ts.map +1 -1
- package/dist/surfaces/popover/popover.js +1 -1
- package/dist/surfaces/popover/popover.js.map +1 -1
- package/dist/surfaces/tooltip/tooltip.d.ts +10 -0
- package/dist/surfaces/tooltip/tooltip.d.ts.map +1 -0
- package/dist/surfaces/tooltip/tooltip.js +38 -0
- package/dist/surfaces/tooltip/tooltip.js.map +1 -0
- package/dist/surfaces/window/window.d.ts +3 -3
- package/dist/surfaces/window/window.d.ts.map +1 -1
- package/dist/surfaces/window/window.js +15 -13
- package/dist/surfaces/window/window.js.map +1 -1
- package/dist/syntaxhighlighter-IQDEPFLK-BX_eF8__.js +3777 -0
- package/dist/syntaxhighlighter-IQDEPFLK-BX_eF8__.js.map +1 -0
- package/dist/tethered.css +1 -0
- package/dist/themes/themes/ergo/ergo_theme.js +177 -206
- package/dist/themes/themes/ergo/ergo_theme.js.map +1 -1
- package/dist/tokens/badge/badge.js +9 -9
- package/dist/tokens/bubble/bubble.js +8 -8
- package/dist/tokens/chip/chip.js +3 -3
- package/dist/tooltip.css +1 -1
- package/dist/utility_bar.css +1 -1
- package/dist/utils/click_away_listener.d.ts +1 -0
- package/dist/utils/click_away_listener.d.ts.map +1 -1
- package/dist/utils/click_away_listener.js +12 -11
- package/dist/utils/click_away_listener.js.map +1 -1
- package/dist/utils/dnd/draggable/draggable.js +4 -4
- package/dist/utils/dnd/handle.js +8 -8
- package/dist/utils/focus_redirect.js +5 -5
- package/dist/utils/hooks/make_context_hook.js +4 -4
- package/dist/utils/hooks/use_media_query.js +2 -2
- package/dist/utils/hooks/use_media_query.js.map +1 -1
- package/dist/utils/index.d.ts +6 -5
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +26 -23
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/mouse_leave_region.d.ts +8 -0
- package/dist/utils/mouse_leave_region.d.ts.map +1 -0
- package/dist/utils/mouse_leave_region.js +26 -0
- package/dist/utils/mouse_leave_region.js.map +1 -0
- package/dist/utils/types/dimensions.d.ts +11 -1
- package/dist/utils/types/dimensions.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/actions/__docs__/actions.mdx +131 -0
- package/src/actions/__docs__/actions.stories.tsx +309 -0
- package/src/actions/__docs__/components/gallery.module.css +6 -0
- package/src/actions/__docs__/components/gallery.tsx +28 -0
- package/src/actions/__docs__/components/showcase.module.css +55 -0
- package/src/actions/__docs__/components/showcase.tsx +121 -0
- package/src/actions/button/base_button/base_button.tsx +5 -1
- package/src/actions/types.ts +6 -0
- package/src/inputs/color_input/color_input.tsx +1 -1
- package/src/inputs/date_picker/date_picker_input.tsx +1 -1
- package/src/inputs/date_picker/date_picker_year_input.tsx +1 -1
- package/src/inputs/suggestions/suggestion_list.tsx +1 -1
- package/src/layouts/index.ts +7 -5
- package/src/layouts/scaffold/scaffold.module.css +5 -0
- package/src/layouts/scaffold/scaffold.tsx +60 -0
- package/src/layouts/utility_bar/utility_bar.module.css +0 -3
- package/src/overlay/frame/frame.module.css +5 -0
- package/src/overlay/frame/frame.stories.tsx +1 -1
- package/src/overlay/frame/frame.tsx +19 -3
- package/src/overlay/index.ts +29 -2
- package/src/overlay/menu/menu.tsx +1 -1
- package/src/overlay/popper/__stories__/base_args.ts +75 -0
- package/src/overlay/popper/__stories__/context_popper.stories.tsx +77 -0
- package/src/overlay/popper/__stories__/element_popper.stories.tsx +80 -0
- package/src/overlay/popper/__stories__/preview_popper.stories.tsx +73 -0
- package/src/overlay/popper/base/base_popper.tsx +55 -0
- package/src/overlay/popper/base/dismissal_decorator.tsx +80 -0
- package/src/overlay/popper/context_popper.tsx +43 -0
- package/src/overlay/popper/element_popper.tsx +42 -0
- package/src/overlay/popper/hooks/use_context_trigger.ts +50 -0
- package/src/overlay/popper/hooks/use_hover_trigger.ts +24 -0
- package/src/overlay/popper/hooks/use_restore_focus.ts +16 -0
- package/src/overlay/popper/{popper.stories.tsx → legacy/popper.stories.tsx} +11 -5
- package/src/overlay/popper/{popper.tsx → legacy/popper.tsx} +3 -2
- package/src/overlay/popper/preview_popper.tsx +54 -0
- package/src/overlay/tethered/__stories__/element/element_tethered.stories.tsx +57 -0
- package/src/overlay/tethered/__stories__/element/element_tethered_stories.module.css +14 -0
- package/src/overlay/tethered/__stories__/shared/base_story_config.ts +52 -0
- package/src/overlay/tethered/__stories__/shared/components/sb_point.module.css +20 -0
- package/src/overlay/tethered/__stories__/shared/components/sb_point.tsx +34 -0
- package/src/overlay/tethered/__stories__/shared/components/sb_reference_points.tsx +54 -0
- package/src/overlay/tethered/__stories__/tethered/tethered.stories.tsx +90 -0
- package/src/overlay/tethered/__stories__/tethered/tethered_stories.module.css +25 -0
- package/src/overlay/tethered/element_tethered.tsx +62 -0
- package/src/overlay/tethered/hooks/calculate_position.ts +110 -0
- package/src/overlay/tethered/hooks/useTether.ts +85 -0
- package/src/overlay/tethered/tethered.module.css +8 -0
- package/src/overlay/tethered/tethered.tsx +72 -0
- package/src/overlay/tethered/types.ts +2 -0
- package/src/stacks/h_stack.stories.tsx +2 -2
- package/src/stacks/v_stack.stories.tsx +2 -2
- package/src/surfaces/card/card.stories.tsx +64 -0
- package/src/surfaces/card/card.tsx +4 -4
- package/src/surfaces/card/card_stories.module.css +13 -0
- package/src/surfaces/index.ts +2 -0
- package/src/surfaces/modal/__stories__/modal.stories.tsx +12 -1
- package/src/surfaces/modal/modal.module.css +2 -2
- package/src/surfaces/modal/modal.tsx +14 -12
- package/src/surfaces/panel/__stories__/panel.stories.tsx +1 -1
- package/src/surfaces/panel/v_panel.tsx +8 -53
- package/src/surfaces/pop_confirm/pop_confirm.stories.tsx +70 -0
- package/src/surfaces/pop_confirm/pop_confirm.tsx +30 -0
- package/src/surfaces/popconfirm/pop_confirm.tsx +18 -0
- package/src/surfaces/popover/popover.tsx +1 -1
- package/src/surfaces/tooltip/tooltip.stories.tsx +54 -0
- package/src/surfaces/tooltip/tooltip.tsx +59 -0
- package/src/surfaces/window/window.stories.tsx +15 -1
- package/src/surfaces/window/window.tsx +16 -12
- package/src/themes/themes/ergo/__stories__/components/tone_picker/sb_tone_picker.tsx +7 -9
- package/src/themes/themes/ergo/__stories__/material.stories.tsx +2 -6
- package/src/themes/themes/ergo/__stories__/sb_materials.module.css +29 -21
- package/src/themes/themes/ergo/ergo_theme.css +177 -206
- package/src/utils/click_away_listener.tsx +1 -1
- package/src/utils/index.ts +7 -5
- package/src/utils/mouse_leave_region.tsx +38 -0
- package/src/utils/types/dimensions.ts +13 -1
- package/tsconfig.json +3 -0
- package/dist/overlay/popper/popper.d.ts.map +0 -1
- package/dist/overlay/popper/popper.js.map +0 -1
- package/dist/overlay/tooltip/tooltip.d.ts +0 -7
- package/dist/overlay/tooltip/tooltip.d.ts.map +0 -1
- package/dist/overlay/tooltip/tooltip.js +0 -20
- package/dist/overlay/tooltip/tooltip.js.map +0 -1
- package/dist/panel.module-DwGKncon.js +0 -5
- package/dist/panel.module-DwGKncon.js.map +0 -1
- package/src/overlay/tooltip/tooltip.stories.tsx +0 -22
- package/src/overlay/tooltip/tooltip.tsx +0 -24
- /package/dist/{panel.css → h_panel.css} +0 -0
- /package/dist/overlay/popper/{popper.d.ts → legacy/popper.d.ts} +0 -0
- /package/src/overlay/popper/{popper.module.css → legacy/popper.module.css} +0 -0
- /package/src/{overlay → surfaces}/tooltip/tooltip.module.css +0 -0
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import type { HorizontalTether, VerticalTether } from '../types.js';
|
|
2
|
+
import type { Rectangle } from '../../../utils/index.js';
|
|
3
|
+
import type { Dimensions } from '../../../utils/index.js';
|
|
4
|
+
|
|
5
|
+
export interface CalculateTetheredPositionParams {
|
|
6
|
+
anchor: Rectangle;
|
|
7
|
+
tether: Rectangle;
|
|
8
|
+
direction: 'ltr' | 'rtl';
|
|
9
|
+
verticalAnchor: VerticalTether;
|
|
10
|
+
verticalOrigin: VerticalTether;
|
|
11
|
+
horizontalAnchor: HorizontalTether;
|
|
12
|
+
horizontalOrigin: HorizontalTether;
|
|
13
|
+
verticalOffset: number;
|
|
14
|
+
horizontalOffset: number;
|
|
15
|
+
viewport: Dimensions;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export const calculateTetheredPosition = ({
|
|
19
|
+
anchor,
|
|
20
|
+
tether,
|
|
21
|
+
direction,
|
|
22
|
+
verticalAnchor,
|
|
23
|
+
verticalOrigin,
|
|
24
|
+
horizontalAnchor,
|
|
25
|
+
horizontalOrigin,
|
|
26
|
+
verticalOffset,
|
|
27
|
+
horizontalOffset,
|
|
28
|
+
viewport,
|
|
29
|
+
}: CalculateTetheredPositionParams) => {
|
|
30
|
+
const isRtl = direction === 'rtl';
|
|
31
|
+
|
|
32
|
+
let top = anchor.position.y;
|
|
33
|
+
let left = anchor.position.x;
|
|
34
|
+
|
|
35
|
+
// Calculate vertical position
|
|
36
|
+
switch (verticalAnchor) {
|
|
37
|
+
case 'top':
|
|
38
|
+
top += verticalOffset;
|
|
39
|
+
break;
|
|
40
|
+
case 'center':
|
|
41
|
+
top += anchor.dimensions.height / 2;
|
|
42
|
+
break;
|
|
43
|
+
case 'bottom':
|
|
44
|
+
top += anchor.dimensions.height - verticalOffset;
|
|
45
|
+
break;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
switch (verticalOrigin) {
|
|
49
|
+
case 'top':
|
|
50
|
+
break;
|
|
51
|
+
case 'center':
|
|
52
|
+
top -= tether.dimensions.height / 2;
|
|
53
|
+
break;
|
|
54
|
+
case 'bottom':
|
|
55
|
+
top -= tether.dimensions.height;
|
|
56
|
+
break;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// Calculate horizontal position with direction sensitivity
|
|
60
|
+
if (horizontalAnchor === 'start') {
|
|
61
|
+
left += isRtl ? anchor.dimensions.width + horizontalOffset : horizontalOffset;
|
|
62
|
+
} else if (horizontalAnchor === 'center') {
|
|
63
|
+
left += anchor.dimensions.width / 2;
|
|
64
|
+
} else if (horizontalAnchor === 'end') {
|
|
65
|
+
left += isRtl ? -horizontalOffset : anchor.dimensions.width + horizontalOffset;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// Adjust the origin based on RTL direction
|
|
69
|
+
let adjustedHorizontalOrigin = horizontalOrigin;
|
|
70
|
+
if (isRtl) {
|
|
71
|
+
if (horizontalOrigin === 'start') {
|
|
72
|
+
adjustedHorizontalOrigin = 'end';
|
|
73
|
+
} else if (horizontalOrigin === 'end') {
|
|
74
|
+
adjustedHorizontalOrigin = 'start';
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// Apply adjusted origin to the position calculation
|
|
79
|
+
if (adjustedHorizontalOrigin === 'start') {
|
|
80
|
+
// No adjustment needed
|
|
81
|
+
} else if (adjustedHorizontalOrigin === 'center') {
|
|
82
|
+
left -= tether.dimensions.width / 2;
|
|
83
|
+
} else if (adjustedHorizontalOrigin === 'end') {
|
|
84
|
+
left -= tether.dimensions.width;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// Ensure the popover stays within the viewport
|
|
88
|
+
// Prevent overflow to the right
|
|
89
|
+
if (left + tether.dimensions.width > viewport.width) {
|
|
90
|
+
left = viewport.width - tether.dimensions.width;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// Prevent overflow to the left
|
|
94
|
+
if (left < 0) {
|
|
95
|
+
left = 0;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// Prevent overflow to the bottom
|
|
99
|
+
// FIXME: doesn't account for padding.
|
|
100
|
+
if (top + tether.dimensions.height > viewport.height) {
|
|
101
|
+
top = viewport.height - tether.dimensions.height;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// Prevent overflow to the top
|
|
105
|
+
if (top < 0) {
|
|
106
|
+
top = 0;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
return { top, left };
|
|
110
|
+
};
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { useCallback, useLayoutEffect, useRef, useState } from 'react';
|
|
2
|
+
import type { HorizontalTether, VerticalTether } from '../types.js';
|
|
3
|
+
import { type Rectangle } from '../../../utils/index.js';
|
|
4
|
+
import { calculateTetheredPosition } from './calculate_position.js';
|
|
5
|
+
|
|
6
|
+
export interface UseTetherParams {
|
|
7
|
+
anchor: Rectangle | null;
|
|
8
|
+
verticalAnchor?: VerticalTether;
|
|
9
|
+
verticalOrigin?: VerticalTether;
|
|
10
|
+
horizontalOrigin?: HorizontalTether;
|
|
11
|
+
horizontalAnchor?: HorizontalTether;
|
|
12
|
+
verticalOffset?: number;
|
|
13
|
+
horizontalOffset?: number;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function useTether({
|
|
17
|
+
anchor,
|
|
18
|
+
verticalAnchor = 'bottom',
|
|
19
|
+
verticalOrigin = 'top',
|
|
20
|
+
horizontalAnchor = 'start',
|
|
21
|
+
horizontalOrigin = 'start',
|
|
22
|
+
verticalOffset = 0,
|
|
23
|
+
horizontalOffset = 0,
|
|
24
|
+
}: UseTetherParams) {
|
|
25
|
+
const [position, setPosition] = useState({ top: 0, left: 0 });
|
|
26
|
+
const tetherRef = useRef<HTMLDivElement>(null);
|
|
27
|
+
|
|
28
|
+
const getPosition = useCallback(() => {
|
|
29
|
+
if (!anchor || !tetherRef.current) return;
|
|
30
|
+
|
|
31
|
+
const tether = tetherRef.current.getBoundingClientRect();
|
|
32
|
+
const computedStyle = getComputedStyle(tetherRef.current);
|
|
33
|
+
|
|
34
|
+
return calculateTetheredPosition({
|
|
35
|
+
anchor: anchor,
|
|
36
|
+
tether: {
|
|
37
|
+
dimensions: {
|
|
38
|
+
width: tether.width,
|
|
39
|
+
height: tether.height,
|
|
40
|
+
},
|
|
41
|
+
position: {
|
|
42
|
+
x: tether.left,
|
|
43
|
+
y: tether.top,
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
direction: computedStyle.direction as 'ltr' | 'rtl',
|
|
47
|
+
verticalAnchor: verticalAnchor,
|
|
48
|
+
verticalOrigin: verticalOrigin,
|
|
49
|
+
horizontalAnchor: horizontalAnchor,
|
|
50
|
+
horizontalOrigin: horizontalOrigin,
|
|
51
|
+
verticalOffset: verticalOffset,
|
|
52
|
+
horizontalOffset: horizontalOffset,
|
|
53
|
+
viewport: {
|
|
54
|
+
width: window.innerWidth,
|
|
55
|
+
height: window.innerHeight,
|
|
56
|
+
},
|
|
57
|
+
});
|
|
58
|
+
}, [
|
|
59
|
+
anchor,
|
|
60
|
+
verticalAnchor,
|
|
61
|
+
verticalOrigin,
|
|
62
|
+
horizontalAnchor,
|
|
63
|
+
horizontalOrigin,
|
|
64
|
+
verticalOffset,
|
|
65
|
+
horizontalOffset,
|
|
66
|
+
]);
|
|
67
|
+
|
|
68
|
+
// Update the position when the window is resized
|
|
69
|
+
useLayoutEffect(() => {
|
|
70
|
+
const update = () => {
|
|
71
|
+
const newPosition = getPosition();
|
|
72
|
+
if (!newPosition) return;
|
|
73
|
+
if (position.top !== newPosition.top || position.left !== newPosition.left) {
|
|
74
|
+
setPosition(newPosition);
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
update();
|
|
78
|
+
window.addEventListener('resize', update);
|
|
79
|
+
return () => {
|
|
80
|
+
window.removeEventListener('resize', update);
|
|
81
|
+
};
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
return { position, tetherRef };
|
|
85
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { forwardRef, type PropsWithChildren } from 'react';
|
|
2
|
+
import type { HorizontalTether, VerticalTether } from './types.js';
|
|
3
|
+
import { ZStack, type ZStackProps } from '../../stacks/index.js';
|
|
4
|
+
import { useForkRef, type Rectangle } from '../../utils/index.js';
|
|
5
|
+
import { useTether } from './hooks/useTether.js';
|
|
6
|
+
import { clsx } from 'clsx';
|
|
7
|
+
import { Portal } from '../portal/portal.js';
|
|
8
|
+
|
|
9
|
+
// Styles
|
|
10
|
+
import styles from './tethered.module.css';
|
|
11
|
+
|
|
12
|
+
export interface BaseTetheredOwnProps {
|
|
13
|
+
verticalAnchor?: VerticalTether;
|
|
14
|
+
verticalOrigin?: VerticalTether;
|
|
15
|
+
horizontalOrigin?: HorizontalTether;
|
|
16
|
+
horizontalAnchor?: HorizontalTether;
|
|
17
|
+
verticalOffset?: number;
|
|
18
|
+
horizontalOffset?: number;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface TetheredOwnProp extends BaseTetheredOwnProps {
|
|
22
|
+
anchor: Rectangle | null;
|
|
23
|
+
}
|
|
24
|
+
export interface TetheredProps extends TetheredOwnProp, ZStackProps {}
|
|
25
|
+
|
|
26
|
+
export const Tethered = forwardRef<HTMLElement, PropsWithChildren<TetheredProps>>(
|
|
27
|
+
function Tethered(
|
|
28
|
+
{
|
|
29
|
+
anchor,
|
|
30
|
+
verticalAnchor = 'bottom',
|
|
31
|
+
verticalOrigin = 'top',
|
|
32
|
+
horizontalAnchor = 'start',
|
|
33
|
+
horizontalOrigin = 'start',
|
|
34
|
+
verticalOffset = 0,
|
|
35
|
+
horizontalOffset = 0,
|
|
36
|
+
children,
|
|
37
|
+
style,
|
|
38
|
+
className,
|
|
39
|
+
...rest
|
|
40
|
+
},
|
|
41
|
+
ref
|
|
42
|
+
) {
|
|
43
|
+
const { position, tetherRef } = useTether({
|
|
44
|
+
anchor,
|
|
45
|
+
verticalAnchor,
|
|
46
|
+
verticalOrigin,
|
|
47
|
+
horizontalAnchor,
|
|
48
|
+
horizontalOrigin,
|
|
49
|
+
verticalOffset,
|
|
50
|
+
horizontalOffset,
|
|
51
|
+
});
|
|
52
|
+
const forkedRef = useForkRef(ref, tetherRef);
|
|
53
|
+
|
|
54
|
+
const cssVariables = {
|
|
55
|
+
'--tethered-top': `${position.top}px`,
|
|
56
|
+
'--tethered-left': `${position.left}px`,
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
return (
|
|
60
|
+
<Portal>
|
|
61
|
+
<ZStack
|
|
62
|
+
ref={forkedRef}
|
|
63
|
+
className={clsx(styles.tethered, className)}
|
|
64
|
+
style={{ position: 'absolute', ...cssVariables, ...style }}
|
|
65
|
+
{...rest}
|
|
66
|
+
>
|
|
67
|
+
{children}
|
|
68
|
+
</ZStack>
|
|
69
|
+
</Portal>
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
);
|
|
@@ -80,7 +80,7 @@ const meta: Meta<HStackProps> = {
|
|
|
80
80
|
|
|
81
81
|
export default meta;
|
|
82
82
|
|
|
83
|
-
export function
|
|
83
|
+
export function SB_HStack(props: HStackProps) {
|
|
84
84
|
return (
|
|
85
85
|
<StyleBox border="1px dashed #ccc" backgroundColor="white">
|
|
86
86
|
<HStackComponent {...props}>
|
|
@@ -99,7 +99,7 @@ export function HStack(props: HStackProps) {
|
|
|
99
99
|
);
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
-
|
|
102
|
+
SB_HStack.storyName = 'HStack';
|
|
103
103
|
|
|
104
104
|
export function ManyChildren(props: HStackProps) {
|
|
105
105
|
return (
|
|
@@ -80,7 +80,7 @@ const meta: Meta<VStackProps> = {
|
|
|
80
80
|
|
|
81
81
|
export default meta;
|
|
82
82
|
|
|
83
|
-
export function
|
|
83
|
+
export function SBVStack(props: VStackProps) {
|
|
84
84
|
return (
|
|
85
85
|
<StyleBox
|
|
86
86
|
borderLeft="1px dashed #ccc"
|
|
@@ -102,7 +102,7 @@ export function VStack(props: VStackProps) {
|
|
|
102
102
|
);
|
|
103
103
|
}
|
|
104
104
|
|
|
105
|
-
|
|
105
|
+
SBVStack.storyName = 'VStack';
|
|
106
106
|
|
|
107
107
|
export function Padding() {
|
|
108
108
|
return (
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { BugIcon } from '@tcn/icons/bug_icon.js';
|
|
2
|
+
import { GridOneIcon } from '@tcn/icons/grid_one_icon.js';
|
|
3
|
+
import { Header } from '../../layouts/header/header.js';
|
|
4
|
+
import { VBody } from '../../layouts/body/v_body.js';
|
|
5
|
+
import { UtilityBar } from '../../layouts/utility_bar/utility_bar.js';
|
|
6
|
+
import { Box, Spacer } from '../../stacks/index.js';
|
|
7
|
+
import { Title } from '../../typography/title/title.js';
|
|
8
|
+
import { SlimButton } from '../../actions/index.js';
|
|
9
|
+
import { Card } from './card.js';
|
|
10
|
+
|
|
11
|
+
// Styles
|
|
12
|
+
import styles from './card_stories.module.css';
|
|
13
|
+
|
|
14
|
+
export default {
|
|
15
|
+
title: 'Surfaces/Card',
|
|
16
|
+
component: Card,
|
|
17
|
+
tags: ['autodocs'],
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export const Default = () => {
|
|
21
|
+
return (
|
|
22
|
+
<div className={styles['stories-container']}>
|
|
23
|
+
<Card maxHeight="400px">
|
|
24
|
+
<Header>
|
|
25
|
+
<Title>Card Header</Title>
|
|
26
|
+
<Spacer />
|
|
27
|
+
<SlimButton hierarchy="tertiary">
|
|
28
|
+
<GridOneIcon />
|
|
29
|
+
</SlimButton>
|
|
30
|
+
<SlimButton hierarchy="tertiary">
|
|
31
|
+
<GridOneIcon />
|
|
32
|
+
</SlimButton>
|
|
33
|
+
</Header>
|
|
34
|
+
<UtilityBar>
|
|
35
|
+
<Title>Utility Bar</Title>
|
|
36
|
+
<Spacer />
|
|
37
|
+
<SlimButton hierarchy="tertiary">
|
|
38
|
+
<BugIcon />
|
|
39
|
+
</SlimButton>
|
|
40
|
+
<SlimButton hierarchy="tertiary">
|
|
41
|
+
<BugIcon />
|
|
42
|
+
</SlimButton>
|
|
43
|
+
<SlimButton size="md" hierarchy="tertiary">
|
|
44
|
+
<BugIcon />
|
|
45
|
+
</SlimButton>
|
|
46
|
+
<SlimButton hierarchy="tertiary">
|
|
47
|
+
<BugIcon />
|
|
48
|
+
</SlimButton>
|
|
49
|
+
</UtilityBar>
|
|
50
|
+
|
|
51
|
+
<VBody>
|
|
52
|
+
<Box className={styles['content-box']} />
|
|
53
|
+
</VBody>
|
|
54
|
+
{/* Cards typically do not have a footer */}
|
|
55
|
+
{/* <Footer>
|
|
56
|
+
<Title>Footer</Title>
|
|
57
|
+
<Spacer />
|
|
58
|
+
<Button hierarchy="secondary">Secondary</Button>
|
|
59
|
+
<Button hierarchy="primary">Primary</Button>
|
|
60
|
+
</Footer> */}
|
|
61
|
+
</Card>
|
|
62
|
+
</div>
|
|
63
|
+
);
|
|
64
|
+
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { VStack, type VStackProps } from '../../stacks/v_stack.js';
|
|
2
1
|
import { clsx } from 'clsx';
|
|
3
2
|
import React from 'react';
|
|
3
|
+
import { Scaffold, type ScaffoldProps } from '../../layouts/scaffold/scaffold.js';
|
|
4
4
|
|
|
5
|
-
export interface CardProps extends Omit<
|
|
5
|
+
export interface CardProps extends Omit<ScaffoldProps, 'as' | 'children'> {
|
|
6
6
|
children?: React.ReactNode;
|
|
7
7
|
}
|
|
8
8
|
|
|
@@ -11,8 +11,8 @@ export const Card = React.forwardRef<HTMLElement, CardProps>(function Card(
|
|
|
11
11
|
ref
|
|
12
12
|
) {
|
|
13
13
|
return (
|
|
14
|
-
<
|
|
14
|
+
<Scaffold ref={ref} className={clsx(className, 'tcn-surface', 'tcn-card')} {...props}>
|
|
15
15
|
{children}
|
|
16
|
-
</
|
|
16
|
+
</Scaffold>
|
|
17
17
|
);
|
|
18
18
|
});
|
package/src/surfaces/index.ts
CHANGED
|
@@ -12,3 +12,5 @@ export * from './drawers/drawer_start/drawer_start.js';
|
|
|
12
12
|
export * from './drawers/drawer_end/drawer_end.js';
|
|
13
13
|
export { Window, type WindowProps } from './window/window.js';
|
|
14
14
|
export { Modal, type ModalProps } from './modal/modal.js';
|
|
15
|
+
export { Tooltip, type TooltipProps } from './tooltip/tooltip.js';
|
|
16
|
+
export { PopConfirm, type PopConfirmProps } from './pop_confirm/pop_confirm.js';
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { useState } from 'react';
|
|
2
2
|
import { Button, SlimButton } from '../../../actions/index.js';
|
|
3
|
-
import { Footer, Header, VBody } from '../../../layouts/index.js';
|
|
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
6
|
import { Modal } from '../modal.js';
|
|
7
7
|
import { Spacer } from '../../../stacks/index.js';
|
|
8
8
|
import { CrossIcon } from '@tcn/icons/cross_icon.js';
|
|
9
|
+
import { BugIcon } from '@tcn/icons/bug_icon.js';
|
|
9
10
|
|
|
10
11
|
export default {
|
|
11
12
|
title: 'Surfaces/Modal',
|
|
@@ -32,6 +33,16 @@ export const ModalStory = () => {
|
|
|
32
33
|
<CrossIcon />
|
|
33
34
|
</SlimButton>
|
|
34
35
|
</Header>
|
|
36
|
+
<UtilityBar>
|
|
37
|
+
<Title>Utility Bar</Title>
|
|
38
|
+
<Spacer />
|
|
39
|
+
<SlimButton hierarchy="tertiary">
|
|
40
|
+
<BugIcon />
|
|
41
|
+
</SlimButton>
|
|
42
|
+
<SlimButton hierarchy="tertiary">
|
|
43
|
+
<BugIcon />
|
|
44
|
+
</SlimButton>
|
|
45
|
+
</UtilityBar>
|
|
35
46
|
<VBody>
|
|
36
47
|
<BodyText>This is a modal</BodyText>
|
|
37
48
|
</VBody>
|
|
@@ -1,25 +1,27 @@
|
|
|
1
|
-
import { VStack, type VStackProps } from '../../stacks/v_stack.js';
|
|
2
1
|
import { clsx } from 'clsx';
|
|
3
2
|
import React from 'react';
|
|
4
|
-
import styles from './modal.module.css';
|
|
5
3
|
import { Frame, type FrameOwnProps } from '../../overlay/frame/frame.js';
|
|
4
|
+
import { Scaffold, type ScaffoldProps } from '../../layouts/scaffold/scaffold.js';
|
|
5
|
+
|
|
6
|
+
// Styles
|
|
7
|
+
import styles from './modal.module.css';
|
|
6
8
|
|
|
7
|
-
export type ModalProps = FrameOwnProps &
|
|
9
|
+
export type ModalProps = FrameOwnProps & ScaffoldProps;
|
|
8
10
|
|
|
9
|
-
export const Modal = React.forwardRef<
|
|
11
|
+
export const Modal = React.forwardRef<HTMLElement, ModalProps>(function Modal(
|
|
10
12
|
{ children, className, isOpen, draggable = false, veil = true, ...props }: ModalProps,
|
|
11
13
|
ref
|
|
12
14
|
) {
|
|
13
15
|
return (
|
|
14
|
-
<Frame
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
>
|
|
16
|
+
<Frame
|
|
17
|
+
isOpen={isOpen}
|
|
18
|
+
draggable={draggable}
|
|
19
|
+
veil={veil}
|
|
20
|
+
className={clsx(styles['modal'], 'tcn-surface', 'tcn-modal', className)}
|
|
21
|
+
>
|
|
22
|
+
<Scaffold ref={ref} {...props}>
|
|
21
23
|
{children}
|
|
22
|
-
</
|
|
24
|
+
</Scaffold>
|
|
23
25
|
</Frame>
|
|
24
26
|
);
|
|
25
27
|
});
|
|
@@ -24,7 +24,7 @@ export const Default = () => {
|
|
|
24
24
|
<div className={styles['stories-container']}>
|
|
25
25
|
<VPanel maxHeight="600px">
|
|
26
26
|
<Header>
|
|
27
|
-
<Title>Panel Primary Header</Title>
|
|
27
|
+
<Title emphasis="strong">Panel Primary Header</Title>
|
|
28
28
|
<Spacer />
|
|
29
29
|
<SlimButton hierarchy="tertiary">
|
|
30
30
|
<GridOneIcon />
|
|
@@ -1,65 +1,20 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import type { Alignment } from '../../stacks/types/alignment.js';
|
|
5
|
-
import { VStack } from '../../stacks/v_stack.js';
|
|
6
|
-
// Styles
|
|
7
|
-
import styles from './panel.module.css';
|
|
2
|
+
import { Scaffold, type ScaffoldProps } from '../../layouts/scaffold/scaffold.js';
|
|
3
|
+
import clsx from 'clsx';
|
|
8
4
|
|
|
9
|
-
export
|
|
10
|
-
vAlign?: Alignment;
|
|
11
|
-
hAlign?: Alignment;
|
|
12
|
-
}
|
|
5
|
+
export type VPanelProps = ScaffoldProps;
|
|
13
6
|
|
|
14
7
|
export const VPanel = React.forwardRef<HTMLElement, VPanelProps>(function VPanel(
|
|
15
|
-
{
|
|
16
|
-
children,
|
|
17
|
-
width,
|
|
18
|
-
height = '100%',
|
|
19
|
-
minWidth,
|
|
20
|
-
maxWidth,
|
|
21
|
-
minHeight,
|
|
22
|
-
maxHeight,
|
|
23
|
-
hAlign,
|
|
24
|
-
vAlign = 'start',
|
|
25
|
-
className,
|
|
26
|
-
...props
|
|
27
|
-
}: VPanelProps,
|
|
8
|
+
{ children, className, ...props }: VPanelProps,
|
|
28
9
|
ref
|
|
29
10
|
) {
|
|
30
11
|
return (
|
|
31
|
-
<
|
|
12
|
+
<Scaffold
|
|
32
13
|
ref={ref}
|
|
33
|
-
|
|
34
|
-
height={height}
|
|
35
|
-
minWidth={minWidth}
|
|
36
|
-
maxWidth={maxWidth}
|
|
37
|
-
minHeight={minHeight}
|
|
38
|
-
maxHeight={maxHeight}
|
|
39
|
-
data-h-alignment={hAlign}
|
|
40
|
-
data-v-alignment={vAlign}
|
|
41
|
-
className={clsx(className, 'panel', 'tcn-panel', 'tcn-v-panel')}
|
|
14
|
+
className={clsx('tcn-surface', 'tcn-panel', 'tcn-v-panel', className)}
|
|
42
15
|
{...props}
|
|
43
16
|
>
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
minWidth={minWidth}
|
|
47
|
-
maxWidth={maxWidth}
|
|
48
|
-
minHeight={minHeight}
|
|
49
|
-
maxHeight={maxHeight}
|
|
50
|
-
hAlign={hAlign}
|
|
51
|
-
vAlign={vAlign}
|
|
52
|
-
ref={ref}
|
|
53
|
-
className={clsx(
|
|
54
|
-
styles['panel-stack'],
|
|
55
|
-
className,
|
|
56
|
-
'panel-stack',
|
|
57
|
-
'tcn-panel-stack'
|
|
58
|
-
)}
|
|
59
|
-
zIndex={0}
|
|
60
|
-
>
|
|
61
|
-
{children}
|
|
62
|
-
</VStack>
|
|
63
|
-
</Box>
|
|
17
|
+
{children}
|
|
18
|
+
</Scaffold>
|
|
64
19
|
);
|
|
65
20
|
});
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { useRef, useState } from 'react';
|
|
2
|
+
import { Button } from '../../actions/index.js';
|
|
3
|
+
import { Footer, Header, VBody } from '../../layouts/index.js';
|
|
4
|
+
import { HStack } from '../../stacks/h_stack.js';
|
|
5
|
+
import { PopConfirm as PopConfirmComponent } from './pop_confirm.js';
|
|
6
|
+
import { BodyText, Title } from '../../typography/index.js';
|
|
7
|
+
import { VStack } from '../../stacks/v_stack.js';
|
|
8
|
+
import { Spacer } from '../../stacks/spacer.js';
|
|
9
|
+
|
|
10
|
+
export default {
|
|
11
|
+
title: 'Surfaces/Pop Confirm',
|
|
12
|
+
component: PopConfirmComponent,
|
|
13
|
+
tags: ['autodocs'],
|
|
14
|
+
parameters: {
|
|
15
|
+
docs: {
|
|
16
|
+
description: {
|
|
17
|
+
component: 'A tooltip component that displays a tooltip when hovered.',
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export const DefaultPopConfirm = () => {
|
|
24
|
+
const anchorRef = useRef<HTMLButtonElement>(null);
|
|
25
|
+
const [open, setOpen] = useState(false);
|
|
26
|
+
|
|
27
|
+
const cancel = () => {
|
|
28
|
+
setOpen(false);
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const confirm = () => {
|
|
32
|
+
setOpen(false);
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
const prompt = () => {
|
|
36
|
+
setOpen(true);
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
return (
|
|
40
|
+
<VStack hAlign="center" vAlign="center" height="100%" width="100%">
|
|
41
|
+
<HStack hAlign="center" vAlign="center">
|
|
42
|
+
<Button ref={anchorRef} onClick={prompt}>
|
|
43
|
+
Click to Confirm
|
|
44
|
+
</Button>
|
|
45
|
+
<PopConfirmComponent
|
|
46
|
+
height={'200px'}
|
|
47
|
+
open={open}
|
|
48
|
+
onDismissal={cancel}
|
|
49
|
+
anchorElement={anchorRef}
|
|
50
|
+
>
|
|
51
|
+
<Header>
|
|
52
|
+
<Title>Confirmation Title</Title>
|
|
53
|
+
</Header>
|
|
54
|
+
<VBody>
|
|
55
|
+
<BodyText>Are you sure you want to confirm this action?</BodyText>
|
|
56
|
+
</VBody>
|
|
57
|
+
<Footer>
|
|
58
|
+
<Spacer />
|
|
59
|
+
<Button hierarchy="secondary" onClick={cancel}>
|
|
60
|
+
Cancel
|
|
61
|
+
</Button>
|
|
62
|
+
<Button hierarchy="primary" onClick={confirm}>
|
|
63
|
+
Confirm
|
|
64
|
+
</Button>
|
|
65
|
+
</Footer>
|
|
66
|
+
</PopConfirmComponent>
|
|
67
|
+
</HStack>
|
|
68
|
+
</VStack>
|
|
69
|
+
);
|
|
70
|
+
};
|