@tcn/ui 0.12.2 → 0.12.4
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/actions/index.d.ts +0 -2
- package/dist/actions/index.d.ts.map +1 -1
- package/dist/actions/index.js +6 -10
- package/dist/actions/index.js.map +1 -1
- package/dist/group.css +1 -0
- package/dist/inputs/color_input/color_input.js +2 -4
- package/dist/inputs/color_input/color_input.js.map +1 -1
- package/dist/inputs/date_picker/date_picker_header.js +20 -22
- package/dist/inputs/date_picker/date_picker_header.js.map +1 -1
- package/dist/inputs/date_picker/date_picker_input.js +2 -4
- package/dist/inputs/date_picker/date_picker_input.js.map +1 -1
- package/dist/inputs/date_picker/date_picker_time_selector.js +9 -11
- package/dist/inputs/date_picker/date_picker_time_selector.js.map +1 -1
- package/dist/inputs/date_picker/date_picker_year_input.js +5 -7
- package/dist/inputs/date_picker/date_picker_year_input.js.map +1 -1
- package/dist/inputs/date_picker/date_picker_year_selector.js +2 -4
- package/dist/inputs/date_picker/date_picker_year_selector.js.map +1 -1
- package/dist/inputs/index.d.ts +2 -0
- package/dist/inputs/index.d.ts.map +1 -1
- package/dist/inputs/index.js +24 -20
- package/dist/inputs/index.js.map +1 -1
- package/dist/inputs/multiselect/multiselect_inline_values.js +7 -9
- package/dist/inputs/multiselect/multiselect_inline_values.js.map +1 -1
- package/dist/inputs/multiselect/multiselect_values.js +2 -4
- package/dist/inputs/multiselect/multiselect_values.js.map +1 -1
- package/dist/inputs/phone_number_input/phone_number_input_adapter.js +2 -4
- package/dist/inputs/phone_number_input/phone_number_input_adapter.js.map +1 -1
- package/dist/inputs/phone_number_input/sip_input.js +13 -15
- package/dist/inputs/phone_number_input/sip_input.js.map +1 -1
- package/dist/inputs/select/select.js +2 -4
- package/dist/inputs/select/select.js.map +1 -1
- package/dist/{actions/button → inputs}/select_group/select_group.d.ts +1 -1
- package/dist/inputs/select_group/select_group.d.ts.map +1 -0
- package/dist/{actions/button → inputs}/select_group/select_group.js +3 -3
- package/dist/inputs/select_group/select_group.js.map +1 -0
- package/dist/inputs/select_group/single_select_group.d.ts.map +1 -0
- package/dist/inputs/select_group/single_select_group.js.map +1 -0
- package/dist/inputs/suggestions/suggestion_list.js +2 -4
- package/dist/inputs/suggestions/suggestion_list.js.map +1 -1
- package/dist/layouts/group/group.d.ts +5 -0
- package/dist/layouts/group/group.d.ts.map +1 -0
- package/dist/layouts/group/group.js +26 -0
- package/dist/layouts/group/group.js.map +1 -0
- package/dist/layouts/index.d.ts +2 -0
- package/dist/layouts/index.d.ts.map +1 -1
- package/dist/layouts/index.js +36 -32
- package/dist/layouts/index.js.map +1 -1
- package/dist/overlay/popper/base/dismissal_decorator.js +6 -6
- package/dist/overlay/popper/base/dismissal_decorator.js.map +1 -1
- package/dist/overlay/popper/context_popper.d.ts.map +1 -1
- package/dist/overlay/popper/context_popper.js +34 -26
- package/dist/overlay/popper/context_popper.js.map +1 -1
- package/dist/overlay/popper/element_popper.d.ts.map +1 -1
- package/dist/overlay/popper/element_popper.js +43 -25
- package/dist/overlay/popper/element_popper.js.map +1 -1
- package/dist/overlay/tethered/hooks/use_ref_dimensions.d.ts +3 -0
- package/dist/overlay/tethered/hooks/use_ref_dimensions.d.ts.map +1 -0
- package/dist/overlay/tethered/hooks/use_ref_dimensions.js +26 -0
- package/dist/overlay/tethered/hooks/use_ref_dimensions.js.map +1 -0
- package/dist/overlay/tethered/hooks/{useTether.d.ts → use_tether.d.ts} +7 -4
- package/dist/overlay/tethered/hooks/use_tether.d.ts.map +1 -0
- package/dist/overlay/tethered/hooks/{useTether.js → use_tether.js} +19 -15
- package/dist/overlay/tethered/hooks/use_tether.js.map +1 -0
- package/dist/overlay/tethered/hooks/use_tether_origin.d.ts +10 -0
- package/dist/overlay/tethered/hooks/use_tether_origin.d.ts.map +1 -0
- package/dist/overlay/tethered/hooks/use_tether_origin.js +22 -0
- package/dist/overlay/tethered/hooks/use_tether_origin.js.map +1 -0
- package/dist/overlay/tethered/hooks/{calculate_origin.d.ts → utils/calculate_origin.d.ts} +4 -10
- package/dist/overlay/tethered/hooks/utils/calculate_origin.d.ts.map +1 -0
- package/dist/overlay/tethered/hooks/utils/calculate_origin.js +41 -0
- package/dist/overlay/tethered/hooks/utils/calculate_origin.js.map +1 -0
- package/dist/overlay/tethered/hooks/{calculate_position.d.ts → utils/calculate_position.d.ts} +2 -2
- package/dist/overlay/tethered/hooks/utils/calculate_position.d.ts.map +1 -0
- package/dist/overlay/tethered/hooks/utils/calculate_position.js.map +1 -0
- package/dist/overlay/tethered/tethered.d.ts.map +1 -1
- package/dist/overlay/tethered/tethered.js +63 -62
- package/dist/overlay/tethered/tethered.js.map +1 -1
- package/dist/select_group.css +1 -1
- package/dist/surfaces/alert/alert.d.ts +0 -2
- package/dist/surfaces/alert/alert.d.ts.map +1 -1
- package/dist/surfaces/alert/alert.js +5 -7
- package/dist/surfaces/alert/alert.js.map +1 -1
- package/dist/surfaces/confirm/confirm.d.ts +3 -3
- package/dist/surfaces/confirm/confirm.d.ts.map +1 -1
- package/dist/surfaces/confirm/confirm.js +46 -45
- package/dist/surfaces/confirm/confirm.js.map +1 -1
- package/dist/surfaces/pop_confirm/pop_confirm.js +11 -9
- package/dist/surfaces/pop_confirm/pop_confirm.js.map +1 -1
- package/dist/surfaces/tooltip/tooltip.d.ts.map +1 -1
- package/dist/surfaces/tooltip/tooltip.js +27 -28
- package/dist/surfaces/tooltip/tooltip.js.map +1 -1
- package/dist/themes/stories/button_showcase.d.ts.map +1 -1
- package/dist/themes/stylesheets/reset.css +1 -1
- package/dist/themes/stylesheets/reset.js +3 -3
- package/dist/themes/stylesheets/reset.js.map +1 -1
- package/dist/themes/themes/ergo/ergo_theme.css +1 -1
- package/dist/themes/themes/ergo/ergo_theme.js +128 -12
- package/dist/themes/themes/ergo/ergo_theme.js.map +1 -1
- package/package.json +3 -2
- package/src/actions/index.ts +0 -8
- package/src/inputs/index.ts +9 -0
- package/src/{actions/button/__stories__ → inputs/select_group}/select_group.stories.tsx +5 -26
- package/src/{actions/button → inputs}/select_group/select_group.tsx +3 -3
- package/src/layouts/bar/bar.stories.tsx +61 -0
- package/src/layouts/group/group.module.css +8 -0
- package/src/layouts/group/group.tsx +23 -0
- package/src/layouts/index.ts +2 -0
- package/src/overlay/popper/__stories__/element_popper.stories.tsx +1 -1
- package/src/overlay/popper/base/dismissal_decorator.tsx +1 -1
- package/src/overlay/popper/context_popper.tsx +7 -3
- package/src/overlay/popper/element_popper.tsx +14 -4
- package/src/overlay/tethered/__stories__/shared/base_story_config.ts +1 -1
- package/src/overlay/tethered/hooks/use_ref_dimensions.ts +32 -0
- package/src/overlay/tethered/hooks/{useTether.ts → use_tether.ts} +7 -2
- package/src/overlay/tethered/hooks/use_tether_origin.ts +46 -0
- package/src/overlay/tethered/hooks/{calculate_origin.ts → utils/calculate_origin.ts} +12 -12
- package/src/overlay/tethered/hooks/{calculate_position.ts → utils/calculate_position.ts} +3 -3
- package/src/overlay/tethered/tethered.tsx +22 -26
- package/src/surfaces/alert/alert.tsx +0 -2
- package/src/surfaces/confirm/confirm.tsx +24 -9
- package/src/surfaces/pop_confirm/pop_confirm.stories.tsx +206 -6
- package/src/surfaces/pop_confirm/pop_confirm.tsx +1 -1
- package/src/surfaces/tooltip/__stories__/tooltip.stories.tsx +136 -0
- package/src/surfaces/tooltip/__stories__/tooltip_stories.module.css +14 -0
- package/src/surfaces/tooltip/tooltip.tsx +6 -2
- package/src/themes/stories/button_showcase.tsx +19 -51
- package/src/themes/stylesheets/reset.css +3 -3
- package/src/themes/themes/ergo/ergo_theme.css +128 -12
- package/dist/actions/button/select_group/select_group.d.ts.map +0 -1
- package/dist/actions/button/select_group/select_group.js.map +0 -1
- package/dist/actions/button/select_group/single_select_group.d.ts.map +0 -1
- package/dist/actions/button/select_group/single_select_group.js.map +0 -1
- package/dist/overlay/tethered/hooks/calculate_origin.d.ts.map +0 -1
- package/dist/overlay/tethered/hooks/calculate_origin.js +0 -41
- package/dist/overlay/tethered/hooks/calculate_origin.js.map +0 -1
- package/dist/overlay/tethered/hooks/calculate_position.d.ts.map +0 -1
- package/dist/overlay/tethered/hooks/calculate_position.js.map +0 -1
- package/dist/overlay/tethered/hooks/useCaretRefDimensions.d.ts +0 -9
- package/dist/overlay/tethered/hooks/useCaretRefDimensions.d.ts.map +0 -1
- package/dist/overlay/tethered/hooks/useCaretRefDimensions.js +0 -14
- package/dist/overlay/tethered/hooks/useCaretRefDimensions.js.map +0 -1
- package/dist/overlay/tethered/hooks/useTether.d.ts.map +0 -1
- package/dist/overlay/tethered/hooks/useTether.js.map +0 -1
- package/dist/overlay/tethered/hooks/useTetherContentRect.d.ts +0 -3
- package/dist/overlay/tethered/hooks/useTetherContentRect.d.ts.map +0 -1
- package/dist/overlay/tethered/hooks/useTetherContentRect.js +0 -36
- package/dist/overlay/tethered/hooks/useTetherContentRect.js.map +0 -1
- package/dist/overlay/tethered/hooks/useTetherOrigin.d.ts +0 -14
- package/dist/overlay/tethered/hooks/useTetherOrigin.d.ts.map +0 -1
- package/dist/overlay/tethered/hooks/useTetherOrigin.js +0 -24
- package/dist/overlay/tethered/hooks/useTetherOrigin.js.map +0 -1
- package/dist/surfaces/popconfirm/pop_confirm.d.ts +0 -5
- package/dist/surfaces/popconfirm/pop_confirm.d.ts.map +0 -1
- package/dist/surfaces/popconfirm/pop_confirm.js +0 -13
- package/dist/surfaces/popconfirm/pop_confirm.js.map +0 -1
- package/src/overlay/tethered/hooks/useCaretRefDimensions.ts +0 -22
- package/src/overlay/tethered/hooks/useTetherContentRect.ts +0 -49
- package/src/overlay/tethered/hooks/useTetherOrigin.ts +0 -49
- package/src/surfaces/popconfirm/pop_confirm.tsx +0 -18
- package/src/surfaces/tooltip/tooltip.stories.tsx +0 -54
- /package/dist/{actions/button → inputs}/select_group/single_select_group.d.ts +0 -0
- /package/dist/{actions/button → inputs}/select_group/single_select_group.js +0 -0
- /package/dist/overlay/tethered/hooks/{calculate_position.js → utils/calculate_position.js} +0 -0
- /package/src/{actions/button → inputs}/select_group/select_group.module.css +0 -0
- /package/src/{actions/button → inputs}/select_group/single_select_group.tsx +0 -0
|
@@ -2,25 +2,35 @@ import { useRef, useState } from 'react';
|
|
|
2
2
|
import { Button } from '../../actions/index.js';
|
|
3
3
|
import { Footer, Header, Section, VBody } from '../../layouts/index.js';
|
|
4
4
|
import { HStack } from '../../stacks/h_stack.js';
|
|
5
|
-
import { PopConfirm
|
|
5
|
+
import { PopConfirm, type PopConfirmProps } from './pop_confirm.js';
|
|
6
6
|
import { BodyText, Title } from '../../typography/index.js';
|
|
7
7
|
import { VStack } from '../../stacks/v_stack.js';
|
|
8
8
|
import { Spacer } from '../../stacks/spacer.js';
|
|
9
|
+
import { PopperDismissal } from '../../overlay/popper/base/dismissal_decorator.js';
|
|
10
|
+
import {
|
|
11
|
+
tetheredArgs,
|
|
12
|
+
tetheredArgTypes,
|
|
13
|
+
} from '../../overlay/tethered/__stories__/shared/base_story_config.js';
|
|
9
14
|
|
|
10
15
|
export default {
|
|
11
16
|
title: 'Surfaces/Pop Confirm',
|
|
12
|
-
component:
|
|
17
|
+
component: PopConfirm,
|
|
13
18
|
tags: ['autodocs'],
|
|
14
19
|
parameters: {
|
|
15
20
|
docs: {
|
|
16
21
|
description: {
|
|
17
|
-
component:
|
|
22
|
+
component:
|
|
23
|
+
'A confirmation popover triggered by a button. Supports different dismissal behaviors: click away, mouse leave, and scroll away.',
|
|
18
24
|
},
|
|
19
25
|
},
|
|
20
26
|
},
|
|
27
|
+
args: tetheredArgs,
|
|
28
|
+
argTypes: tetheredArgTypes,
|
|
21
29
|
};
|
|
22
30
|
|
|
23
|
-
export const DefaultPopConfirm = (
|
|
31
|
+
export const DefaultPopConfirm = (
|
|
32
|
+
args: Omit<PopConfirmProps, 'anchorElement' | 'open' | 'onDismissal'>
|
|
33
|
+
) => {
|
|
24
34
|
const anchorRef = useRef<HTMLButtonElement>(null);
|
|
25
35
|
const [open, setOpen] = useState(false);
|
|
26
36
|
|
|
@@ -42,11 +52,14 @@ export const DefaultPopConfirm = () => {
|
|
|
42
52
|
<Button ref={anchorRef} onClick={prompt}>
|
|
43
53
|
Click to Confirm
|
|
44
54
|
</Button>
|
|
45
|
-
<
|
|
55
|
+
<PopConfirm
|
|
46
56
|
height={'200px'}
|
|
47
57
|
open={open}
|
|
48
58
|
onDismissal={cancel}
|
|
49
59
|
anchorElement={anchorRef}
|
|
60
|
+
// PopperDismissal.CLICK_AWAY is the default dismissal behavior but shown here for demonstration purposes
|
|
61
|
+
dismissals={[PopperDismissal.CLICK_AWAY]}
|
|
62
|
+
{...args}
|
|
50
63
|
>
|
|
51
64
|
<Header>
|
|
52
65
|
<Title>Confirmation Title</Title>
|
|
@@ -65,8 +78,195 @@ export const DefaultPopConfirm = () => {
|
|
|
65
78
|
Confirm
|
|
66
79
|
</Button>
|
|
67
80
|
</Footer>
|
|
68
|
-
</
|
|
81
|
+
</PopConfirm>
|
|
69
82
|
</HStack>
|
|
70
83
|
</VStack>
|
|
71
84
|
);
|
|
72
85
|
};
|
|
86
|
+
|
|
87
|
+
DefaultPopConfirm.parameters = {
|
|
88
|
+
docs: {
|
|
89
|
+
description: {
|
|
90
|
+
story:
|
|
91
|
+
'Closes only when clicking outside the popover. Clicking inside (title, body, or buttons) keeps it open.',
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
export const ManualCloseOnly = () => {
|
|
97
|
+
const anchorRef = useRef<HTMLButtonElement>(null);
|
|
98
|
+
const [open, setOpen] = useState(false);
|
|
99
|
+
|
|
100
|
+
return (
|
|
101
|
+
<VStack hAlign="center" vAlign="center" height="100%" width="100%">
|
|
102
|
+
<HStack hAlign="center" vAlign="center">
|
|
103
|
+
<Button ref={anchorRef} onClick={() => setOpen(true)}>
|
|
104
|
+
Open
|
|
105
|
+
</Button>
|
|
106
|
+
<PopConfirm
|
|
107
|
+
height={'200px'}
|
|
108
|
+
open={open}
|
|
109
|
+
onDismissal={() => setOpen(false)}
|
|
110
|
+
anchorElement={anchorRef}
|
|
111
|
+
dismissals={[]}
|
|
112
|
+
>
|
|
113
|
+
<Header>
|
|
114
|
+
<Title>Must confirm or cancel</Title>
|
|
115
|
+
</Header>
|
|
116
|
+
<VBody>
|
|
117
|
+
<Section>
|
|
118
|
+
<BodyText>
|
|
119
|
+
No automatic dismissal. The popover stays open until you click Cancel or
|
|
120
|
+
Confirm. Clicking or scrolling outside does nothing.
|
|
121
|
+
</BodyText>
|
|
122
|
+
</Section>
|
|
123
|
+
</VBody>
|
|
124
|
+
<Footer>
|
|
125
|
+
<Spacer />
|
|
126
|
+
<Button hierarchy="secondary" onClick={() => setOpen(false)}>
|
|
127
|
+
Cancel
|
|
128
|
+
</Button>
|
|
129
|
+
<Button hierarchy="primary" onClick={() => setOpen(false)}>
|
|
130
|
+
Confirm
|
|
131
|
+
</Button>
|
|
132
|
+
</Footer>
|
|
133
|
+
</PopConfirm>
|
|
134
|
+
</HStack>
|
|
135
|
+
</VStack>
|
|
136
|
+
);
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
ManualCloseOnly.parameters = {
|
|
140
|
+
docs: {
|
|
141
|
+
description: {
|
|
142
|
+
story:
|
|
143
|
+
'No dismissal behaviors. The popover only closes when the user clicks Cancel or Confirm—clicking outside, scrolling, or moving the pointer away has no effect.',
|
|
144
|
+
},
|
|
145
|
+
},
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
export const MouseLeaveOnly = () => {
|
|
149
|
+
const anchorRef = useRef<HTMLButtonElement>(null);
|
|
150
|
+
const [open, setOpen] = useState(false);
|
|
151
|
+
|
|
152
|
+
return (
|
|
153
|
+
<VStack hAlign="center" vAlign="center" height="100%" width="100%">
|
|
154
|
+
<HStack hAlign="center" vAlign="center">
|
|
155
|
+
<Button ref={anchorRef} onMouseEnter={() => setOpen(true)}>
|
|
156
|
+
Hover to confirm
|
|
157
|
+
</Button>
|
|
158
|
+
<PopConfirm
|
|
159
|
+
height={'200px'}
|
|
160
|
+
open={open}
|
|
161
|
+
onDismissal={() => setOpen(false)}
|
|
162
|
+
anchorElement={anchorRef}
|
|
163
|
+
dismissals={[PopperDismissal.MOUSE_LEAVE]}
|
|
164
|
+
>
|
|
165
|
+
<Header>
|
|
166
|
+
<Title>Confirm action</Title>
|
|
167
|
+
</Header>
|
|
168
|
+
<VBody>
|
|
169
|
+
<Section>
|
|
170
|
+
<BodyText>
|
|
171
|
+
Closes when the pointer leaves the popover and trigger area.
|
|
172
|
+
</BodyText>
|
|
173
|
+
</Section>
|
|
174
|
+
</VBody>
|
|
175
|
+
<Footer>
|
|
176
|
+
<Spacer />
|
|
177
|
+
<Button hierarchy="secondary" onClick={() => setOpen(false)}>
|
|
178
|
+
Cancel
|
|
179
|
+
</Button>
|
|
180
|
+
<Button hierarchy="primary" onClick={() => setOpen(false)}>
|
|
181
|
+
OK
|
|
182
|
+
</Button>
|
|
183
|
+
</Footer>
|
|
184
|
+
</PopConfirm>
|
|
185
|
+
</HStack>
|
|
186
|
+
</VStack>
|
|
187
|
+
);
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
MouseLeaveOnly.parameters = {
|
|
191
|
+
docs: {
|
|
192
|
+
description: {
|
|
193
|
+
story:
|
|
194
|
+
'Closes when the mouse leaves the region (popover + trigger). No click-away or scroll-away. Suited to hover-triggered flows.',
|
|
195
|
+
},
|
|
196
|
+
},
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
export const ClickAwayAndScrollAway = () => {
|
|
200
|
+
const anchorRef = useRef<HTMLButtonElement>(null);
|
|
201
|
+
const [open, setOpen] = useState(false);
|
|
202
|
+
|
|
203
|
+
return (
|
|
204
|
+
<div
|
|
205
|
+
style={{
|
|
206
|
+
height: '320px',
|
|
207
|
+
overflow: 'auto',
|
|
208
|
+
padding: '16px',
|
|
209
|
+
boxSizing: 'border-box',
|
|
210
|
+
}}
|
|
211
|
+
>
|
|
212
|
+
<VStack gap="24px" padding="16px" style={{ minHeight: '600px' }}>
|
|
213
|
+
<Section>
|
|
214
|
+
<BodyText>
|
|
215
|
+
Scroll down to find the button and open the popover. Then scroll this
|
|
216
|
+
container—the popover will close when you scroll away.
|
|
217
|
+
</BodyText>
|
|
218
|
+
</Section>
|
|
219
|
+
<Spacer />
|
|
220
|
+
<HStack hAlign="center" vAlign="center">
|
|
221
|
+
<Button ref={anchorRef} onClick={() => setOpen(true)}>
|
|
222
|
+
Open
|
|
223
|
+
</Button>
|
|
224
|
+
<PopConfirm
|
|
225
|
+
height={'200px'}
|
|
226
|
+
open={open}
|
|
227
|
+
onDismissal={() => setOpen(false)}
|
|
228
|
+
anchorElement={anchorRef}
|
|
229
|
+
dismissals={[PopperDismissal.CLICK_AWAY, PopperDismissal.SCROLL_AWAY]}
|
|
230
|
+
>
|
|
231
|
+
<Header>
|
|
232
|
+
<Title>Scroll or click away</Title>
|
|
233
|
+
</Header>
|
|
234
|
+
<VBody>
|
|
235
|
+
<Section>
|
|
236
|
+
<BodyText>
|
|
237
|
+
Closes when you click outside or when you scroll outside the popover.
|
|
238
|
+
Scroll the container above or below to see it close.
|
|
239
|
+
</BodyText>
|
|
240
|
+
</Section>
|
|
241
|
+
</VBody>
|
|
242
|
+
<Footer>
|
|
243
|
+
<Spacer />
|
|
244
|
+
<Button hierarchy="secondary" onClick={() => setOpen(false)}>
|
|
245
|
+
Cancel
|
|
246
|
+
</Button>
|
|
247
|
+
<Button hierarchy="primary" onClick={() => setOpen(false)}>
|
|
248
|
+
Confirm
|
|
249
|
+
</Button>
|
|
250
|
+
</Footer>
|
|
251
|
+
</PopConfirm>
|
|
252
|
+
</HStack>
|
|
253
|
+
<Spacer />
|
|
254
|
+
<Section>
|
|
255
|
+
<BodyText>
|
|
256
|
+
More content below. After opening the popover, scroll up or down within this
|
|
257
|
+
panel—the popover dismisses because the scroll happened outside of it.
|
|
258
|
+
</BodyText>
|
|
259
|
+
</Section>
|
|
260
|
+
</VStack>
|
|
261
|
+
</div>
|
|
262
|
+
);
|
|
263
|
+
};
|
|
264
|
+
|
|
265
|
+
ClickAwayAndScrollAway.parameters = {
|
|
266
|
+
docs: {
|
|
267
|
+
description: {
|
|
268
|
+
story:
|
|
269
|
+
'Closes on outside click or when scrolling outside the popover. This story uses a scrollable container—open the popover, then scroll the panel; the popover dismisses because the scroll happened outside it.',
|
|
270
|
+
},
|
|
271
|
+
},
|
|
272
|
+
};
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { StyleBox } from '../../../stacks/story_components/style_box.js';
|
|
2
|
+
import { ZStack } from '../../../stacks/z_stack.js';
|
|
3
|
+
import { Tooltip as TooltipComponent, type TooltipProps } from '../tooltip.js';
|
|
4
|
+
import {
|
|
5
|
+
tetheredArgs,
|
|
6
|
+
tetheredArgTypes,
|
|
7
|
+
} from '../../../overlay/tethered/__stories__/shared/base_story_config.js';
|
|
8
|
+
import { BodyText, Title } from '../../../typography/index.js';
|
|
9
|
+
import { VStack } from '../../../stacks/v_stack.js';
|
|
10
|
+
import styles from './tooltip_stories.module.css';
|
|
11
|
+
|
|
12
|
+
export default {
|
|
13
|
+
title: 'Surfaces/Tooltip',
|
|
14
|
+
component: TooltipComponent,
|
|
15
|
+
tags: ['autodocs'],
|
|
16
|
+
parameters: {
|
|
17
|
+
docs: {
|
|
18
|
+
description: {
|
|
19
|
+
component: 'A tooltip component that displays a tooltip when hovered.',
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
argTypes: tetheredArgTypes,
|
|
24
|
+
args: tetheredArgs,
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
type TooltipStoryProps = TooltipProps & {
|
|
28
|
+
label: string;
|
|
29
|
+
};
|
|
30
|
+
export const DefaultTooltip = ({
|
|
31
|
+
label = 'Tooltip content',
|
|
32
|
+
precision = 'high',
|
|
33
|
+
...args
|
|
34
|
+
}: TooltipStoryProps) => {
|
|
35
|
+
return (
|
|
36
|
+
<ZStack width="100%" minWidth="400px" minHeight="300px">
|
|
37
|
+
<TooltipComponent label={label} precision={precision} {...args}>
|
|
38
|
+
<StyleBox
|
|
39
|
+
backgroundColor="red"
|
|
40
|
+
padding="8px"
|
|
41
|
+
borderRadius={'8px'}
|
|
42
|
+
width="200px"
|
|
43
|
+
height="100px"
|
|
44
|
+
display="flex"
|
|
45
|
+
justifyContent="center"
|
|
46
|
+
alignItems="center"
|
|
47
|
+
>
|
|
48
|
+
Hover to open
|
|
49
|
+
</StyleBox>
|
|
50
|
+
</TooltipComponent>
|
|
51
|
+
</ZStack>
|
|
52
|
+
);
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
export const CustomTooltip = ({
|
|
56
|
+
label = 'Tooltip content',
|
|
57
|
+
precision = 'high',
|
|
58
|
+
...args
|
|
59
|
+
}: TooltipStoryProps) => {
|
|
60
|
+
return (
|
|
61
|
+
<ZStack width="100%" minWidth="400px" minHeight="400px">
|
|
62
|
+
<TooltipComponent
|
|
63
|
+
className={styles.tooltip}
|
|
64
|
+
label={
|
|
65
|
+
<VStack
|
|
66
|
+
className={styles.label}
|
|
67
|
+
vAlign="center"
|
|
68
|
+
hAlign="center"
|
|
69
|
+
width="200px"
|
|
70
|
+
height="100px"
|
|
71
|
+
>
|
|
72
|
+
<Title>{label}</Title>
|
|
73
|
+
<BodyText>Custom Tooltip Content</BodyText>
|
|
74
|
+
</VStack>
|
|
75
|
+
}
|
|
76
|
+
precision={precision}
|
|
77
|
+
{...args}
|
|
78
|
+
>
|
|
79
|
+
<StyleBox
|
|
80
|
+
backgroundColor="red"
|
|
81
|
+
padding="8px"
|
|
82
|
+
borderRadius={'8px'}
|
|
83
|
+
width="200px"
|
|
84
|
+
height="100px"
|
|
85
|
+
display="flex"
|
|
86
|
+
justifyContent="center"
|
|
87
|
+
alignItems="center"
|
|
88
|
+
>
|
|
89
|
+
Hover to open
|
|
90
|
+
</StyleBox>
|
|
91
|
+
</TooltipComponent>
|
|
92
|
+
</ZStack>
|
|
93
|
+
);
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
export const CustomTooltipLabel = ({
|
|
97
|
+
label = 'Tooltip content',
|
|
98
|
+
precision = 'high',
|
|
99
|
+
...args
|
|
100
|
+
}: TooltipStoryProps) => {
|
|
101
|
+
return (
|
|
102
|
+
<ZStack width="100%" minWidth="400px" minHeight="400px">
|
|
103
|
+
<TooltipComponent
|
|
104
|
+
label={
|
|
105
|
+
<VStack
|
|
106
|
+
className="tcn-tooltip-label"
|
|
107
|
+
vAlign="center"
|
|
108
|
+
hAlign="center"
|
|
109
|
+
width="200px"
|
|
110
|
+
height="100px"
|
|
111
|
+
>
|
|
112
|
+
<BodyText>✨ Can have custom children and styles</BodyText>
|
|
113
|
+
<BodyText>
|
|
114
|
+
✨ But still inherits the themes tooltip label container styles
|
|
115
|
+
</BodyText>
|
|
116
|
+
</VStack>
|
|
117
|
+
}
|
|
118
|
+
precision={precision}
|
|
119
|
+
{...args}
|
|
120
|
+
>
|
|
121
|
+
<StyleBox
|
|
122
|
+
backgroundColor="red"
|
|
123
|
+
padding="8px"
|
|
124
|
+
borderRadius={'8px'}
|
|
125
|
+
width="200px"
|
|
126
|
+
height="100px"
|
|
127
|
+
display="flex"
|
|
128
|
+
justifyContent="center"
|
|
129
|
+
alignItems="center"
|
|
130
|
+
>
|
|
131
|
+
Hover to open
|
|
132
|
+
</StyleBox>
|
|
133
|
+
</TooltipComponent>
|
|
134
|
+
</ZStack>
|
|
135
|
+
);
|
|
136
|
+
};
|
|
@@ -22,7 +22,7 @@ export const Tooltip = React.forwardRef<HTMLDivElement, TooltipProps>(function T
|
|
|
22
22
|
verticalOrigin = 'bottom',
|
|
23
23
|
horizontalAnchor = 'center',
|
|
24
24
|
horizontalOrigin = 'center',
|
|
25
|
-
precision = '
|
|
25
|
+
precision = 'high',
|
|
26
26
|
label,
|
|
27
27
|
...props
|
|
28
28
|
},
|
|
@@ -54,7 +54,11 @@ export const Tooltip = React.forwardRef<HTMLDivElement, TooltipProps>(function T
|
|
|
54
54
|
className={clsx(className, styles.tooltip, 'tcn-surface', 'tcn-tooltip')}
|
|
55
55
|
{...props}
|
|
56
56
|
>
|
|
57
|
-
{label
|
|
57
|
+
{typeof label === 'string' ? (
|
|
58
|
+
<span className="tcn-tooltip-label">{label}</span>
|
|
59
|
+
) : (
|
|
60
|
+
label
|
|
61
|
+
)}
|
|
58
62
|
</PreviewPopper>
|
|
59
63
|
</>
|
|
60
64
|
);
|
|
@@ -1,14 +1,7 @@
|
|
|
1
|
-
import { useState } from 'react';
|
|
2
1
|
import { CrossIcon } from '@tcn/icons/cross_icon.js';
|
|
3
2
|
import { PhoneIcon } from '@tcn/icons/phone_icon.js';
|
|
4
3
|
import { BluetoothIcon } from '@tcn/icons/bluetooth_icon.js';
|
|
5
|
-
import {
|
|
6
|
-
Button,
|
|
7
|
-
ButtonGroup,
|
|
8
|
-
SelectGroup,
|
|
9
|
-
SingleSelectGroup,
|
|
10
|
-
SlimButton,
|
|
11
|
-
} from '../../actions/index.js';
|
|
4
|
+
import { Button, ButtonGroup } from '../../actions/index.js';
|
|
12
5
|
import { HStack } from '../../stacks/h_stack.js';
|
|
13
6
|
import { VStack } from '../../stacks/v_stack.js';
|
|
14
7
|
import { Spacer } from '../../stacks/spacer.js';
|
|
@@ -17,12 +10,6 @@ import { FieldSet } from '../../form/field_set/field_set.js';
|
|
|
17
10
|
import { BodyText } from '../../typography/index.js';
|
|
18
11
|
|
|
19
12
|
export function ButtonShowcase() {
|
|
20
|
-
const [singleSelectedOptions, setSingleSelectedOptions] = useState<string>('option1');
|
|
21
|
-
const [multiselectOptions, setMultiselectOptions] = useState<string[]>([
|
|
22
|
-
'option1',
|
|
23
|
-
'option2',
|
|
24
|
-
]);
|
|
25
|
-
|
|
26
13
|
return (
|
|
27
14
|
<FieldSet legend="Button Showcase">
|
|
28
15
|
{/* Basic Buttons */}
|
|
@@ -57,60 +44,41 @@ export function ButtonShowcase() {
|
|
|
57
44
|
</VStack>
|
|
58
45
|
</Field>
|
|
59
46
|
|
|
60
|
-
{/* Select Groups */}
|
|
61
|
-
<Field label="Select Groups">
|
|
62
|
-
<VStack width="400px" gap="20px" hAlign="center">
|
|
63
|
-
<SingleSelectGroup
|
|
64
|
-
value={singleSelectedOptions}
|
|
65
|
-
onChange={setSingleSelectedOptions}
|
|
66
|
-
>
|
|
67
|
-
<option value="option1">Option 1</option>
|
|
68
|
-
<option value="option2">Option 2</option>
|
|
69
|
-
<option value="option3">Option 3</option>
|
|
70
|
-
</SingleSelectGroup>
|
|
71
|
-
<SelectGroup value={multiselectOptions} onChange={setMultiselectOptions}>
|
|
72
|
-
<option value="option1">Option 1</option>
|
|
73
|
-
<option value="option2">Option 2</option>
|
|
74
|
-
<option value="option3">Option 3</option>
|
|
75
|
-
</SelectGroup>
|
|
76
|
-
</VStack>
|
|
77
|
-
</Field>
|
|
78
|
-
|
|
79
47
|
{/* Slim Buttons */}
|
|
80
48
|
<Field label="Slim Buttons">
|
|
81
49
|
<VStack width="400px" gap="20px" hAlign="center">
|
|
82
50
|
<HStack gap="8px" hAlign="center">
|
|
83
|
-
<
|
|
51
|
+
<Button utility size="sm" hierarchy="primary">
|
|
84
52
|
<CrossIcon size="sm" />
|
|
85
|
-
</
|
|
86
|
-
<
|
|
53
|
+
</Button>
|
|
54
|
+
<Button utility size="md" hierarchy="primary">
|
|
87
55
|
<CrossIcon size="md" />
|
|
88
|
-
</
|
|
89
|
-
<
|
|
56
|
+
</Button>
|
|
57
|
+
<Button utility size="lg" hierarchy="primary">
|
|
90
58
|
<CrossIcon size="lg" />
|
|
91
|
-
</
|
|
59
|
+
</Button>
|
|
92
60
|
</HStack>
|
|
93
61
|
<HStack gap="8px" hAlign="center">
|
|
94
|
-
<
|
|
62
|
+
<Button utility size="sm" hierarchy="secondary">
|
|
95
63
|
<PhoneIcon size="sm" />
|
|
96
|
-
</
|
|
97
|
-
<
|
|
64
|
+
</Button>
|
|
65
|
+
<Button utility size="md" hierarchy="secondary">
|
|
98
66
|
<PhoneIcon size="md" />
|
|
99
|
-
</
|
|
100
|
-
<
|
|
67
|
+
</Button>
|
|
68
|
+
<Button utility size="lg" hierarchy="secondary">
|
|
101
69
|
<PhoneIcon size="lg" />
|
|
102
|
-
</
|
|
70
|
+
</Button>
|
|
103
71
|
</HStack>
|
|
104
72
|
<HStack gap="8px" hAlign="center">
|
|
105
|
-
<
|
|
73
|
+
<Button utility size="sm" hierarchy="tertiary">
|
|
106
74
|
<BluetoothIcon size="sm" />
|
|
107
|
-
</
|
|
108
|
-
<
|
|
75
|
+
</Button>
|
|
76
|
+
<Button utility size="md" hierarchy="tertiary">
|
|
109
77
|
<BluetoothIcon size="md" />
|
|
110
|
-
</
|
|
111
|
-
<
|
|
78
|
+
</Button>
|
|
79
|
+
<Button utility size="lg" hierarchy="tertiary">
|
|
112
80
|
<BluetoothIcon size="lg" />
|
|
113
|
-
</
|
|
81
|
+
</Button>
|
|
114
82
|
</HStack>
|
|
115
83
|
</VStack>
|
|
116
84
|
</Field>
|
|
@@ -91,17 +91,17 @@
|
|
|
91
91
|
vertical-align: baseline;
|
|
92
92
|
}
|
|
93
93
|
/* HTML5 display-role reset for older browsers */
|
|
94
|
+
/* FIXME: sometimes reset breaks stacks display value (flex) */
|
|
95
|
+
/* header, section */
|
|
94
96
|
article,
|
|
95
97
|
aside,
|
|
96
98
|
details,
|
|
97
99
|
figcaption,
|
|
98
100
|
figure,
|
|
99
101
|
footer,
|
|
100
|
-
header,
|
|
101
102
|
hgroup,
|
|
102
103
|
menu,
|
|
103
|
-
nav
|
|
104
|
-
section {
|
|
104
|
+
nav {
|
|
105
105
|
display: block;
|
|
106
106
|
}
|
|
107
107
|
body {
|