@tcn/ui 0.12.5 → 0.13.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/aside.css +1 -0
- package/dist/body.css +1 -1
- package/dist/inputs/color_input/color_input.js +18 -18
- package/dist/inputs/color_input/color_input.js.map +1 -1
- package/dist/inputs/control/control.d.ts +10 -0
- package/dist/inputs/control/control.d.ts.map +1 -0
- package/dist/inputs/control/control.js +17 -0
- package/dist/inputs/control/control.js.map +1 -0
- package/dist/inputs/control_set/control_set.d.ts +5 -0
- package/dist/inputs/control_set/control_set.d.ts.map +1 -0
- package/dist/inputs/control_set/control_set.js +20 -0
- package/dist/inputs/{input_group/input_group.js.map → control_set/control_set.js.map} +1 -1
- 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/index.d.ts +2 -1
- package/dist/inputs/index.d.ts.map +1 -1
- package/dist/inputs/index.js +27 -24
- package/dist/inputs/index.js.map +1 -1
- package/dist/inputs/input/input.js +6 -6
- package/dist/inputs/input/input.js.map +1 -1
- package/dist/inputs/phone_number_input/phone_number_country_select_adapter.js +15 -15
- package/dist/inputs/phone_number_input/phone_number_country_select_adapter.js.map +1 -1
- package/dist/inputs/phone_number_input/phone_number_input.d.ts +2 -1
- package/dist/inputs/phone_number_input/phone_number_input.d.ts.map +1 -1
- package/dist/inputs/phone_number_input/phone_number_input.js +45 -43
- package/dist/inputs/phone_number_input/phone_number_input.js.map +1 -1
- package/dist/inputs/phone_number_input/phone_number_input_adapter.js +21 -21
- package/dist/inputs/phone_number_input/phone_number_input_adapter.js.map +1 -1
- package/dist/inputs/phone_number_input/sip_input.d.ts +2 -1
- package/dist/inputs/phone_number_input/sip_input.d.ts.map +1 -1
- package/dist/inputs/phone_number_input/sip_input.js +51 -49
- package/dist/inputs/phone_number_input/sip_input.js.map +1 -1
- package/dist/inputs/select/select.js +6 -6
- package/dist/inputs/select/select.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.js +20 -20
- package/dist/inputs/unit_input/unit_input.js.map +1 -1
- package/dist/layouts/body/body.d.ts +17 -0
- package/dist/layouts/body/body.d.ts.map +1 -1
- package/dist/layouts/body/body.js +11 -12
- package/dist/layouts/body/body.js.map +1 -1
- package/dist/layouts/index.d.ts +1 -2
- package/dist/layouts/index.d.ts.map +1 -1
- package/dist/layouts/index.js +38 -40
- package/dist/layouts/index.js.map +1 -1
- package/dist/layouts/scaffold/scaffold.js +1 -1
- package/dist/layouts/scaffold/scaffold.js.map +1 -1
- package/dist/layouts/section/section.d.ts.map +1 -1
- package/dist/layouts/section/section.js +14 -13
- package/dist/layouts/section/section.js.map +1 -1
- package/dist/overlay/frame/frame.d.ts +2 -2
- package/dist/overlay/frame/frame.d.ts.map +1 -1
- package/dist/overlay/frame/frame.js +67 -59
- package/dist/overlay/frame/frame.js.map +1 -1
- package/dist/overlay/slide/slide.d.ts +9 -0
- package/dist/overlay/slide/slide.d.ts.map +1 -0
- package/dist/overlay/slide/slide.js +29 -0
- package/dist/overlay/slide/slide.js.map +1 -0
- package/dist/page.css +1 -1
- package/dist/slide.css +1 -0
- package/dist/surfaces/aside/aside.d.ts +5 -0
- package/dist/surfaces/aside/aside.d.ts.map +1 -0
- package/dist/surfaces/aside/aside.js +19 -0
- package/dist/surfaces/aside/aside.js.map +1 -0
- package/dist/surfaces/drawers/drawer.d.ts +5 -0
- package/dist/surfaces/drawers/drawer.d.ts.map +1 -0
- package/dist/surfaces/drawers/drawer.js +31 -0
- package/dist/surfaces/drawers/drawer.js.map +1 -0
- package/dist/surfaces/index.d.ts +3 -6
- package/dist/surfaces/index.d.ts.map +1 -1
- package/dist/surfaces/index.js +20 -26
- package/dist/surfaces/index.js.map +1 -1
- package/dist/surfaces/modal/modal.d.ts +1 -1
- package/dist/surfaces/modal/modal.d.ts.map +1 -1
- package/dist/surfaces/modal/modal.js +22 -14
- package/dist/surfaces/modal/modal.js.map +1 -1
- package/dist/surfaces/page/page.d.ts +5 -0
- package/dist/surfaces/page/page.d.ts.map +1 -0
- package/dist/surfaces/page/page.js +19 -0
- package/dist/surfaces/page/page.js.map +1 -0
- package/dist/surfaces/pop_confirm/pop_confirm.d.ts.map +1 -1
- package/dist/surfaces/pop_confirm/pop_confirm.js +23 -16
- 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 +27 -19
- package/dist/surfaces/window/window.js.map +1 -1
- package/dist/themes/stylesheets/reset.css +1 -1
- package/dist/themes/stylesheets/reset.js +2 -2
- 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 +134 -44
- package/dist/themes/themes/ergo/ergo_theme.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.map +1 -1
- package/package.json +2 -2
- package/src/inputs/color_input/color_input.tsx +3 -3
- package/src/inputs/control/control.stories.tsx +158 -0
- package/src/inputs/control/control.tsx +32 -0
- package/src/inputs/control/control_stories.module.css +7 -0
- package/src/inputs/control_set/control_set.stories.tsx +46 -0
- package/src/inputs/{input_group/input_group.tsx → control_set/control_set.tsx} +5 -5
- package/src/inputs/date_picker/date_picker_input.stories.tsx +1 -1
- package/src/inputs/date_picker/date_picker_input.tsx +1 -1
- package/src/inputs/index.ts +2 -1
- package/src/inputs/input/input.tsx +1 -1
- package/src/inputs/phone_number_input/phone_number_country_select_adapter.tsx +1 -1
- package/src/inputs/phone_number_input/phone_number_input.tsx +4 -1
- package/src/inputs/phone_number_input/phone_number_input_adapter.tsx +2 -2
- package/src/inputs/phone_number_input/sip_input.tsx +7 -4
- package/src/inputs/select/select.tsx +1 -1
- package/src/inputs/textarea/textarea.stories.tsx +1 -1
- package/src/inputs/textarea/textarea.tsx +1 -1
- package/src/inputs/unit_input/unit_input.tsx +3 -3
- package/src/layouts/__stories__/composed_stories.module.css +1 -7
- package/src/layouts/__stories__/rail.stories.tsx +20 -13
- package/src/layouts/__stories__/scaffold.stories.tsx +34 -22
- package/src/layouts/__stories__/utils.tsx +10 -7
- package/src/layouts/body/body.module.css +0 -8
- package/src/layouts/body/body.tsx +19 -3
- package/src/layouts/index.ts +1 -2
- package/src/layouts/scaffold/scaffold.tsx +1 -1
- package/src/layouts/section/section.tsx +2 -1
- package/src/overlay/frame/frame.tsx +13 -16
- package/src/overlay/slide/slide.module.css +30 -0
- package/src/overlay/slide/slide.stories.tsx +61 -0
- package/src/overlay/slide/slide.tsx +51 -0
- package/src/surfaces/aside/aside.module.css +5 -0
- package/src/surfaces/aside/aside.stories.tsx +75 -0
- package/src/surfaces/aside/aside.tsx +22 -0
- package/src/surfaces/card/card.stories.tsx +8 -5
- package/src/surfaces/card/card_stories.module.css +4 -2
- package/src/surfaces/drawers/drawer.stories.tsx +144 -0
- package/src/surfaces/drawers/drawer.tsx +30 -0
- package/src/surfaces/index.ts +3 -6
- package/src/surfaces/modal/__stories__/modal.stories.tsx +21 -4
- package/src/surfaces/modal/modal.tsx +5 -1
- package/src/surfaces/page/page.module.css +0 -6
- package/src/surfaces/page/page.stories.tsx +71 -0
- package/src/surfaces/page/page.tsx +22 -0
- package/src/surfaces/panel/__stories__/panel.stories.tsx +66 -60
- package/src/surfaces/pop_confirm/pop_confirm.stories.tsx +43 -31
- package/src/surfaces/pop_confirm/pop_confirm.tsx +5 -1
- package/src/surfaces/tooltip/__stories__/tooltip.stories.tsx +31 -0
- package/src/surfaces/window/window.stories.tsx +15 -4
- package/src/surfaces/window/window.tsx +5 -1
- package/src/themes/stylesheets/reset.css +2 -2
- package/src/themes/themes/ergo/__stories__/components/tone_picker/sb_tone_card.tsx +16 -15
- package/src/themes/themes/ergo/__stories__/material.stories.tsx +6 -4
- package/src/themes/themes/ergo/ergo_theme.css +134 -44
- package/src/utils/dnd/hooks/use_drag_container.ts +0 -7
- package/dist/body.module-BbFZ7KNP.js +0 -5
- package/dist/body.module-BbFZ7KNP.js.map +0 -1
- package/dist/drawer_bottom.css +0 -1
- package/dist/drawer_end.css +0 -1
- package/dist/drawer_start.css +0 -1
- package/dist/drawer_top.css +0 -1
- package/dist/inputs/input_group/input_group.d.ts +0 -5
- package/dist/inputs/input_group/input_group.d.ts.map +0 -1
- package/dist/inputs/input_group/input_group.js +0 -20
- package/dist/layouts/body/h_body.d.ts +0 -6
- package/dist/layouts/body/h_body.d.ts.map +0 -1
- package/dist/layouts/body/h_body.js +0 -27
- package/dist/layouts/body/h_body.js.map +0 -1
- package/dist/layouts/body/v_body.d.ts +0 -6
- package/dist/layouts/body/v_body.d.ts.map +0 -1
- package/dist/layouts/body/v_body.js +0 -27
- package/dist/layouts/body/v_body.js.map +0 -1
- package/dist/page.module-DXhph-u6.js +0 -5
- package/dist/page.module-DXhph-u6.js.map +0 -1
- package/dist/surfaces/drawers/drawer_bottom/drawer_bottom.d.ts +0 -7
- package/dist/surfaces/drawers/drawer_bottom/drawer_bottom.d.ts.map +0 -1
- package/dist/surfaces/drawers/drawer_bottom/drawer_bottom.js +0 -22
- package/dist/surfaces/drawers/drawer_bottom/drawer_bottom.js.map +0 -1
- package/dist/surfaces/drawers/drawer_end/drawer_end.d.ts +0 -7
- package/dist/surfaces/drawers/drawer_end/drawer_end.d.ts.map +0 -1
- package/dist/surfaces/drawers/drawer_end/drawer_end.js +0 -20
- package/dist/surfaces/drawers/drawer_end/drawer_end.js.map +0 -1
- package/dist/surfaces/drawers/drawer_start/drawer_start.d.ts +0 -7
- package/dist/surfaces/drawers/drawer_start/drawer_start.d.ts.map +0 -1
- package/dist/surfaces/drawers/drawer_start/drawer_start.js +0 -22
- package/dist/surfaces/drawers/drawer_start/drawer_start.js.map +0 -1
- package/dist/surfaces/drawers/drawer_top/drawer_top.d.ts +0 -7
- package/dist/surfaces/drawers/drawer_top/drawer_top.d.ts.map +0 -1
- package/dist/surfaces/drawers/drawer_top/drawer_top.js +0 -20
- package/dist/surfaces/drawers/drawer_top/drawer_top.js.map +0 -1
- package/dist/surfaces/page/h_page.d.ts +0 -6
- package/dist/surfaces/page/h_page.d.ts.map +0 -1
- package/dist/surfaces/page/h_page.js +0 -22
- package/dist/surfaces/page/h_page.js.map +0 -1
- package/dist/surfaces/page/v_page.d.ts +0 -6
- package/dist/surfaces/page/v_page.d.ts.map +0 -1
- package/dist/surfaces/page/v_page.js +0 -21
- package/dist/surfaces/page/v_page.js.map +0 -1
- package/src/layouts/body/h_body.module.css +0 -7
- package/src/layouts/body/h_body.tsx +0 -28
- package/src/layouts/body/v_body.module.css +0 -7
- package/src/layouts/body/v_body.tsx +0 -28
- package/src/surfaces/drawers/__stories__/drawers.stories.tsx +0 -26
- package/src/surfaces/drawers/drawer_bottom/drawer_bottom.module.css +0 -5
- package/src/surfaces/drawers/drawer_bottom/drawer_bottom.tsx +0 -23
- package/src/surfaces/drawers/drawer_end/drawer_end.module.css +0 -5
- package/src/surfaces/drawers/drawer_end/drawer_end.tsx +0 -24
- package/src/surfaces/drawers/drawer_start/drawer_start.module.css +0 -5
- package/src/surfaces/drawers/drawer_start/drawer_start.tsx +0 -23
- package/src/surfaces/drawers/drawer_top/drawer_top.module.css +0 -5
- package/src/surfaces/drawers/drawer_top/drawer_top.tsx +0 -24
- package/src/surfaces/page/h_page.tsx +0 -23
- package/src/surfaces/page/v_page.tsx +0 -22
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Control, ControlRow } from './control.js';
|
|
3
|
+
import { Input } from '../input/input.js';
|
|
4
|
+
import { Button } from '../../actions/button/button/button.js';
|
|
5
|
+
import { SearchIcon } from '@tcn/icons/search_icon.js';
|
|
6
|
+
import { CrossIcon } from '@tcn/icons/cross_icon.js';
|
|
7
|
+
import { Textarea } from '../textarea/textarea.js';
|
|
8
|
+
import { BugIcon } from '@tcn/icons/bug_icon.js';
|
|
9
|
+
import { BodyText } from '../../typography/index.js';
|
|
10
|
+
import { Spacer } from '../../stacks/spacer.js';
|
|
11
|
+
import { CopyIcon } from '@tcn/icons/copy_icon.js';
|
|
12
|
+
import { SendOneIcon } from '@tcn/icons/send_one_icon.js';
|
|
13
|
+
import { FilterOneIcon } from '@tcn/icons/filter_one_icon.js';
|
|
14
|
+
import { PlusIcon } from '@tcn/icons/plus_icon.js';
|
|
15
|
+
import styles from './control_stories.module.css';
|
|
16
|
+
import { RefreshCcwAlertIcon } from '@tcn/icons/refresh_ccw_alert_icon.js';
|
|
17
|
+
import { PlayIcon } from '@tcn/icons/play_icon.js';
|
|
18
|
+
import { DatePickerInput } from '../date_picker/date_picker_input.js';
|
|
19
|
+
import { Divider } from '../../layouts/index.js';
|
|
20
|
+
import { CalendarDatesIcon } from '@tcn/icons/calendar_dates_icon.js';
|
|
21
|
+
|
|
22
|
+
export default {
|
|
23
|
+
title: 'Inputs/Control',
|
|
24
|
+
parameters: {
|
|
25
|
+
docs: {
|
|
26
|
+
description: {
|
|
27
|
+
component:
|
|
28
|
+
'Control and ControlRow layout components for grouping inputs with optional leading/trailing slots (icons, actions).',
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
tags: ['autodocs'],
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
function BaseInput(props: React.ComponentProps<typeof Input>) {
|
|
36
|
+
const [value, setValue] = React.useState(props.value ?? '');
|
|
37
|
+
return <Input {...props} value={value} onChange={setValue} />;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export function Baseline() {
|
|
41
|
+
return (
|
|
42
|
+
<Control maxWidth={400}>
|
|
43
|
+
<ControlRow>
|
|
44
|
+
<BaseInput placeholder="Enter text..." />
|
|
45
|
+
</ControlRow>
|
|
46
|
+
</Control>
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export function Icons() {
|
|
51
|
+
return (
|
|
52
|
+
<Control maxWidth={400}>
|
|
53
|
+
<ControlRow>
|
|
54
|
+
<BugIcon />
|
|
55
|
+
<BaseInput placeholder="Search..." />
|
|
56
|
+
<FilterOneIcon />
|
|
57
|
+
<SearchIcon />
|
|
58
|
+
</ControlRow>
|
|
59
|
+
</Control>
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export function Actions() {
|
|
64
|
+
return (
|
|
65
|
+
<Control maxWidth={400}>
|
|
66
|
+
<ControlRow>
|
|
67
|
+
<Button utility onClick={() => {}} hierarchy="tertiary">
|
|
68
|
+
<PlusIcon />
|
|
69
|
+
</Button>
|
|
70
|
+
<BaseInput placeholder="Type to clear..." value="Hello" />
|
|
71
|
+
<Button utility onClick={() => {}} hierarchy="tertiary">
|
|
72
|
+
<CrossIcon />
|
|
73
|
+
</Button>
|
|
74
|
+
</ControlRow>
|
|
75
|
+
</Control>
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export function DatePickerControl() {
|
|
80
|
+
const [value, setValue] = React.useState<Date | null>(null);
|
|
81
|
+
return (
|
|
82
|
+
<Control maxWidth={400}>
|
|
83
|
+
<ControlRow>
|
|
84
|
+
<DatePickerInput value={value} onChange={setValue} width="fill" />
|
|
85
|
+
<Button utility onClick={() => {}} hierarchy="tertiary">
|
|
86
|
+
<CrossIcon />
|
|
87
|
+
</Button>
|
|
88
|
+
<Divider vertical length="sm" />
|
|
89
|
+
<CalendarDatesIcon />
|
|
90
|
+
</ControlRow>
|
|
91
|
+
</Control>
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export function StartRow() {
|
|
96
|
+
return (
|
|
97
|
+
<Control maxWidth={400}>
|
|
98
|
+
<ControlRow>
|
|
99
|
+
<BugIcon />
|
|
100
|
+
<BodyText>script.js</BodyText>
|
|
101
|
+
<Spacer />
|
|
102
|
+
<Button utility onClick={() => {}} hierarchy="tertiary">
|
|
103
|
+
<CopyIcon />
|
|
104
|
+
</Button>
|
|
105
|
+
</ControlRow>
|
|
106
|
+
<ControlRow growWeight={1}>
|
|
107
|
+
<Textarea placeholder="console.log('Hello, world!');" />
|
|
108
|
+
</ControlRow>
|
|
109
|
+
</Control>
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export function EndRow() {
|
|
114
|
+
return (
|
|
115
|
+
<Control maxWidth={400}>
|
|
116
|
+
<ControlRow growWeight={1}>
|
|
117
|
+
<Textarea rows={6} placeholder="What's on your mind?" />
|
|
118
|
+
</ControlRow>
|
|
119
|
+
<Spacer />
|
|
120
|
+
<ControlRow growWeight={1}>
|
|
121
|
+
<BodyText>{`<n> characters remaining`}</BodyText>
|
|
122
|
+
<Spacer />
|
|
123
|
+
<Button onClick={() => {}} hierarchy="tertiary">
|
|
124
|
+
Post <SendOneIcon />
|
|
125
|
+
</Button>
|
|
126
|
+
</ControlRow>
|
|
127
|
+
</Control>
|
|
128
|
+
);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export function CustomStyles() {
|
|
132
|
+
return (
|
|
133
|
+
<Control className={styles.customStyles} maxWidth={400}>
|
|
134
|
+
<ControlRow growWeight={1}>
|
|
135
|
+
<BugIcon />
|
|
136
|
+
<BodyText>script.js</BodyText>
|
|
137
|
+
<Spacer />
|
|
138
|
+
<Button utility onClick={() => {}} hierarchy="tertiary">
|
|
139
|
+
<RefreshCcwAlertIcon />
|
|
140
|
+
</Button>
|
|
141
|
+
<Button utility onClick={() => {}} hierarchy="tertiary">
|
|
142
|
+
<CopyIcon />
|
|
143
|
+
</Button>
|
|
144
|
+
</ControlRow>
|
|
145
|
+
<ControlRow growWeight={1}>
|
|
146
|
+
<Textarea rows={6} placeholder="Enter your code..." />
|
|
147
|
+
</ControlRow>
|
|
148
|
+
<Spacer />
|
|
149
|
+
<ControlRow growWeight={1}>
|
|
150
|
+
<BodyText>{`Line <i> Column <j>`}</BodyText>
|
|
151
|
+
<Spacer />
|
|
152
|
+
<Button onClick={() => {}} hierarchy="tertiary">
|
|
153
|
+
Run <PlayIcon />
|
|
154
|
+
</Button>
|
|
155
|
+
</ControlRow>
|
|
156
|
+
</Control>
|
|
157
|
+
);
|
|
158
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { clsx } from 'clsx';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { VStack, type VStackProps } from '../../stacks/v_stack.js';
|
|
4
|
+
import { HStack, type HStackProps } from '../../stacks/h_stack.js';
|
|
5
|
+
|
|
6
|
+
export interface ControlProps extends VStackProps {}
|
|
7
|
+
|
|
8
|
+
export const Control = React.forwardRef<HTMLDivElement, ControlProps>(function Control(
|
|
9
|
+
{ as = 'div', className, children, ...props }: ControlProps,
|
|
10
|
+
ref: React.Ref<HTMLDivElement>
|
|
11
|
+
) {
|
|
12
|
+
return (
|
|
13
|
+
<VStack ref={ref} as={as} className={clsx(className, 'tcn-control')} {...props}>
|
|
14
|
+
{children}
|
|
15
|
+
</VStack>
|
|
16
|
+
);
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
export interface ControlRowProps extends HStackProps {}
|
|
20
|
+
|
|
21
|
+
export const ControlRow = React.forwardRef<HTMLDivElement, ControlRowProps>(
|
|
22
|
+
function ControlRow(
|
|
23
|
+
{ as = 'div', className, children, ...props }: ControlRowProps,
|
|
24
|
+
ref: React.Ref<HTMLDivElement>
|
|
25
|
+
) {
|
|
26
|
+
return (
|
|
27
|
+
<HStack ref={ref} as={as} className={clsx(className, 'tcn-control-row')} {...props}>
|
|
28
|
+
{children}
|
|
29
|
+
</HStack>
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
);
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
import { ControlSet } from './control_set.js';
|
|
3
|
+
import { Input } from '../input/input.js';
|
|
4
|
+
import { Select } from '../select/select.js';
|
|
5
|
+
import { Option } from '../options/option.js';
|
|
6
|
+
|
|
7
|
+
export default {
|
|
8
|
+
title: 'Inputs/Control Set',
|
|
9
|
+
parameters: {
|
|
10
|
+
docs: {
|
|
11
|
+
description: {
|
|
12
|
+
component:
|
|
13
|
+
'Control Sets are used to group controls and/or inputs that manage multiple values that are closely related and must be entered together. Usually a tuple like (value, unit) or (start, end). For example a value + unit input/selection.',
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
tags: ['autodocs'],
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export function Baseline() {
|
|
21
|
+
const [value, setValue] = useState('42');
|
|
22
|
+
const [unit, setUnit] = useState('kg');
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
<ControlSet maxWidth="200px">
|
|
26
|
+
<Input type="number" value={value} onChange={setValue} placeholder="Value" />
|
|
27
|
+
<Select
|
|
28
|
+
width="auto"
|
|
29
|
+
minWidth="24px"
|
|
30
|
+
value={unit}
|
|
31
|
+
onChange={setUnit}
|
|
32
|
+
placeholder="Unit"
|
|
33
|
+
>
|
|
34
|
+
<Option value="kg" label="kg">
|
|
35
|
+
kg
|
|
36
|
+
</Option>
|
|
37
|
+
<Option value="lb" label="lb">
|
|
38
|
+
lb
|
|
39
|
+
</Option>
|
|
40
|
+
<Option value="g" label="g">
|
|
41
|
+
g
|
|
42
|
+
</Option>
|
|
43
|
+
</Select>
|
|
44
|
+
</ControlSet>
|
|
45
|
+
);
|
|
46
|
+
}
|
|
@@ -2,23 +2,23 @@ import React from 'react';
|
|
|
2
2
|
import { clsx } from 'clsx';
|
|
3
3
|
import { HStack, type HStackProps } from '../../stacks/h_stack.js';
|
|
4
4
|
|
|
5
|
-
export type
|
|
5
|
+
export type ControlSetProps = HStackProps;
|
|
6
6
|
|
|
7
|
-
export const
|
|
7
|
+
export const ControlSet = React.forwardRef<HTMLElement, ControlSetProps>(
|
|
8
8
|
function InputGroup(
|
|
9
|
-
{ children, as = 'div', className, ...props }:
|
|
9
|
+
{ children, as = 'div', className, ...props }: ControlSetProps,
|
|
10
10
|
ref
|
|
11
11
|
) {
|
|
12
12
|
const clonedChildren = React.Children.map(children, child =>
|
|
13
13
|
React.isValidElement(child)
|
|
14
14
|
? React.cloneElement(child, {
|
|
15
15
|
...child.props,
|
|
16
|
-
className: clsx(child.props.className, 'tcn-
|
|
16
|
+
className: clsx(child.props.className, 'tcn-control-set-item'),
|
|
17
17
|
})
|
|
18
18
|
: child
|
|
19
19
|
);
|
|
20
20
|
return (
|
|
21
|
-
<HStack ref={ref} as={as} className={clsx(className, 'tcn-
|
|
21
|
+
<HStack ref={ref} as={as} className={clsx(className, 'tcn-control-set')} {...props}>
|
|
22
22
|
{clonedChildren}
|
|
23
23
|
</HStack>
|
|
24
24
|
);
|
|
@@ -61,7 +61,7 @@ function DatePickerActions({ presenter }: { presenter: DatePickerPresenter }) {
|
|
|
61
61
|
);
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
-
export function
|
|
64
|
+
export function Baseline() {
|
|
65
65
|
const [value, setValue] = useState<Date | null>(null);
|
|
66
66
|
|
|
67
67
|
return <DatePickerInputComponent value={value} onChange={setValue} width="300px" />;
|
|
@@ -125,7 +125,7 @@ export const DatePickerInput = React.forwardRef<HTMLButtonElement, DatePickerInp
|
|
|
125
125
|
<>
|
|
126
126
|
<Button
|
|
127
127
|
ref={ref}
|
|
128
|
-
className={clsx(styles.button, 'tcn-
|
|
128
|
+
className={clsx(styles.button, 'tcn-entry', 'tcn-date-picker-input')}
|
|
129
129
|
hAlign="start"
|
|
130
130
|
disabled={disabled}
|
|
131
131
|
hierarchy={hierarchy}
|
package/src/inputs/index.ts
CHANGED
|
@@ -55,7 +55,8 @@ export * from './textarea/textarea.js';
|
|
|
55
55
|
|
|
56
56
|
export * from './unit_input/unit_input.js';
|
|
57
57
|
|
|
58
|
-
export * from './
|
|
58
|
+
export * from './control_set/control_set.js';
|
|
59
|
+
export * from './control/control.js';
|
|
59
60
|
|
|
60
61
|
export {
|
|
61
62
|
SelectGroup,
|
|
@@ -22,7 +22,7 @@ export const Input = React.forwardRef(function Input(
|
|
|
22
22
|
) {
|
|
23
23
|
return (
|
|
24
24
|
<input
|
|
25
|
-
className={clsx(styles.input, className, 'tcn-input', 'tcn-
|
|
25
|
+
className={clsx(styles.input, className, 'tcn-input', 'tcn-entry')}
|
|
26
26
|
type={type}
|
|
27
27
|
ref={ref}
|
|
28
28
|
data-is-disabled={props.disabled || false}
|
|
@@ -117,7 +117,7 @@ export function PhoneNumberCountrySelectAdapter({
|
|
|
117
117
|
onChange={handleChange}
|
|
118
118
|
disabled={disabled}
|
|
119
119
|
aria-label={ariaLabel ?? 'Country'}
|
|
120
|
-
className={clsx(className, 'tcn-
|
|
120
|
+
className={clsx(className, 'tcn-control-set-item')}
|
|
121
121
|
width="auto"
|
|
122
122
|
>
|
|
123
123
|
{items}
|
|
@@ -16,6 +16,7 @@ export interface PhoneNumberInputProps
|
|
|
16
16
|
extends Omit<HStackProps, 'onChange' | 'children'> {
|
|
17
17
|
value?: string;
|
|
18
18
|
allowSip?: boolean;
|
|
19
|
+
sipAutoComplete?: string;
|
|
19
20
|
onChange: (value?: string) => void;
|
|
20
21
|
defaultCountry?: string;
|
|
21
22
|
allowedCountryCodes?: string[];
|
|
@@ -48,6 +49,7 @@ export function PhoneNumberInput({
|
|
|
48
49
|
limitMaxLength,
|
|
49
50
|
ariaSelectLabel,
|
|
50
51
|
ariaPhoneBookButtonLabel,
|
|
52
|
+
sipAutoComplete,
|
|
51
53
|
children,
|
|
52
54
|
...props
|
|
53
55
|
}: PhoneNumberInputProps) {
|
|
@@ -124,6 +126,7 @@ export function PhoneNumberInput({
|
|
|
124
126
|
autoFocus={autoFocus}
|
|
125
127
|
placeholder={placeholder}
|
|
126
128
|
countries={countries as CountryCode[]}
|
|
129
|
+
sipAutoComplete={sipAutoComplete}
|
|
127
130
|
/>
|
|
128
131
|
</PhoneBookProvider>
|
|
129
132
|
);
|
|
@@ -150,7 +153,7 @@ export function PhoneNumberInput({
|
|
|
150
153
|
className={clsx(
|
|
151
154
|
styles['phone-number-input'],
|
|
152
155
|
'tcn-phone-number-input',
|
|
153
|
-
'tcn-
|
|
156
|
+
'tcn-control-set'
|
|
154
157
|
)}
|
|
155
158
|
displayInitialValueAsLocalNumber
|
|
156
159
|
addInternationalOption={false}
|
|
@@ -95,13 +95,13 @@ export const PhoneNumberInputAdapter = forwardRef<
|
|
|
95
95
|
ref={forkedRef}
|
|
96
96
|
value={value}
|
|
97
97
|
{...(rest as any)}
|
|
98
|
-
className={clsx(className, 'tcn-
|
|
98
|
+
className={clsx(className, 'tcn-control-set-item')}
|
|
99
99
|
onChange={handleChange}
|
|
100
100
|
/>
|
|
101
101
|
{showPhoneBook && (
|
|
102
102
|
<Button
|
|
103
103
|
disabled={disabled}
|
|
104
|
-
className={clsx('tcn-
|
|
104
|
+
className={clsx('tcn-control-set-item', 'tcn-phone-number-phone-book')}
|
|
105
105
|
aria-label={ariaPhoneBookButtonLabel}
|
|
106
106
|
onClick={togglePhoneBook}
|
|
107
107
|
size="md"
|
|
@@ -2,7 +2,7 @@ import React, { useLayoutEffect } from 'react';
|
|
|
2
2
|
import { NotebookIcon } from '@tcn/icons/notebook_icon.js';
|
|
3
3
|
import { Input } from '../input/input.js';
|
|
4
4
|
import { Button } from '../../actions/index.js';
|
|
5
|
-
import {
|
|
5
|
+
import { ControlSet } from '../control_set/control_set.js';
|
|
6
6
|
import clsx from 'clsx';
|
|
7
7
|
import { usePhoneContext } from './phone_number_context.js';
|
|
8
8
|
import type { CountryCode } from 'libphonenumber-js';
|
|
@@ -14,6 +14,7 @@ import { SuggestionList } from '../suggestions/suggestion_list.js';
|
|
|
14
14
|
|
|
15
15
|
export interface SipInputProps {
|
|
16
16
|
onChange: (value: string) => void;
|
|
17
|
+
sipAutoComplete?: string;
|
|
17
18
|
countries?: CountryCode[];
|
|
18
19
|
disabled?: boolean;
|
|
19
20
|
name?: string;
|
|
@@ -29,6 +30,7 @@ export function SipInput({
|
|
|
29
30
|
'aria-label': ariaLabel,
|
|
30
31
|
autoFocus,
|
|
31
32
|
placeholder,
|
|
33
|
+
sipAutoComplete = 'on',
|
|
32
34
|
}: SipInputProps) {
|
|
33
35
|
const inputRef = React.useRef<HTMLInputElement>(null);
|
|
34
36
|
const [phoneBookElement, setPhoneBookElement] =
|
|
@@ -104,7 +106,7 @@ export function SipInput({
|
|
|
104
106
|
|
|
105
107
|
return (
|
|
106
108
|
<>
|
|
107
|
-
<
|
|
109
|
+
<ControlSet>
|
|
108
110
|
<PhoneNumberCountrySelectAdapter
|
|
109
111
|
value="SIP"
|
|
110
112
|
onChange={selectCountry}
|
|
@@ -120,11 +122,12 @@ export function SipInput({
|
|
|
120
122
|
aria-label={ariaLabel}
|
|
121
123
|
autoFocus={autoFocus}
|
|
122
124
|
placeholder={placeholder}
|
|
125
|
+
autoComplete={sipAutoComplete}
|
|
123
126
|
/>
|
|
124
127
|
{showPhoneBook && (
|
|
125
128
|
<Button
|
|
126
129
|
disabled={disabled}
|
|
127
|
-
className={clsx('tcn-
|
|
130
|
+
className={clsx('tcn-control-set-item', 'tcn-phone-number-phone-book')}
|
|
128
131
|
aria-label={ariaPhoneBookButtonLabel}
|
|
129
132
|
onClick={togglePhoneBook}
|
|
130
133
|
size="md"
|
|
@@ -132,7 +135,7 @@ export function SipInput({
|
|
|
132
135
|
<NotebookIcon size="md" />
|
|
133
136
|
</Button>
|
|
134
137
|
)}
|
|
135
|
-
</
|
|
138
|
+
</ControlSet>
|
|
136
139
|
<SuggestionList
|
|
137
140
|
open={isPhoneBookOpen}
|
|
138
141
|
anchorElement={phoneBookElement}
|
|
@@ -130,7 +130,7 @@ export const Select = React.forwardRef(function Select(
|
|
|
130
130
|
<>
|
|
131
131
|
<Button
|
|
132
132
|
ref={forkedRef}
|
|
133
|
-
className={clsx(className, 'tcn-select', 'tcn-
|
|
133
|
+
className={clsx(className, 'tcn-select', 'tcn-entry', styles.select)}
|
|
134
134
|
width="100%"
|
|
135
135
|
{...props}
|
|
136
136
|
hAlign="start"
|
|
@@ -20,7 +20,7 @@ export const Textarea = React.forwardRef(function Textarea(
|
|
|
20
20
|
return (
|
|
21
21
|
<textarea
|
|
22
22
|
style={{ width, height, ...style }}
|
|
23
|
-
className={clsx(className, styles.textarea, 'tcn-textarea', 'tcn-
|
|
23
|
+
className={clsx(className, styles.textarea, 'tcn-textarea', 'tcn-entry')}
|
|
24
24
|
data-is-disabled={props.disabled || false}
|
|
25
25
|
ref={ref}
|
|
26
26
|
onChange={e => {
|
|
@@ -7,7 +7,7 @@ import { Select } from '../select/select.js';
|
|
|
7
7
|
import { OptionProps } from '../options/option.js';
|
|
8
8
|
import styles from './unit_input.module.css';
|
|
9
9
|
|
|
10
|
-
import {
|
|
10
|
+
import { ControlSet } from '../control_set/control_set.js';
|
|
11
11
|
|
|
12
12
|
function getDisplayValue(value: string) {
|
|
13
13
|
return value
|
|
@@ -80,7 +80,7 @@ export const UnitInput = React.forwardRef(function UnitInput(
|
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
return (
|
|
83
|
-
<
|
|
83
|
+
<ControlSet
|
|
84
84
|
ref={ref}
|
|
85
85
|
className={clsx(styles['unit-input'], 'tcn-unit-input')}
|
|
86
86
|
height="auto"
|
|
@@ -110,6 +110,6 @@ export const UnitInput = React.forwardRef(function UnitInput(
|
|
|
110
110
|
>
|
|
111
111
|
{children}
|
|
112
112
|
</Select>
|
|
113
|
-
</
|
|
113
|
+
</ControlSet>
|
|
114
114
|
);
|
|
115
115
|
});
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
.secondary {
|
|
28
|
-
padding: 8px
|
|
28
|
+
padding: 8px;
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
.primary {
|
|
@@ -76,7 +76,6 @@
|
|
|
76
76
|
|
|
77
77
|
.body {
|
|
78
78
|
background: var(--bg-4);
|
|
79
|
-
gap: 8px;
|
|
80
79
|
}
|
|
81
80
|
|
|
82
81
|
/* Horizontal Layouts */
|
|
@@ -89,11 +88,6 @@
|
|
|
89
88
|
background: var(--bg-2);
|
|
90
89
|
}
|
|
91
90
|
|
|
92
|
-
.main {
|
|
93
|
-
background: var(--bg-3);
|
|
94
|
-
gap: 8px;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
91
|
.content {
|
|
98
92
|
background: rgba(0, 0, 0, 0.25);
|
|
99
93
|
display: flex;
|
|
@@ -5,10 +5,10 @@ import { SBLayoutContent } from './utils/content.js';
|
|
|
5
5
|
import { Rail } from '../rail/rail.js';
|
|
6
6
|
import { Side } from '../rail/side/side.js';
|
|
7
7
|
import { UtilityStrip } from '../rail/utility_strip/utility_strip.js';
|
|
8
|
-
import { Title } from '../../typography/index.js';
|
|
9
|
-
import { HBody } from '../body/h_body.js';
|
|
10
|
-
import { VBody } from '../body/v_body.js';
|
|
8
|
+
import { BodyText, Title } from '../../typography/index.js';
|
|
11
9
|
import { Body } from '../body/body.js';
|
|
10
|
+
import { VStack } from '../../stacks/v_stack.js';
|
|
11
|
+
import { Scaffold } from '../scaffold/scaffold.js';
|
|
12
12
|
|
|
13
13
|
const meta: Meta<typeof Rail> = {
|
|
14
14
|
title: 'Layouts/Rail',
|
|
@@ -48,11 +48,16 @@ export const HorizontalContent: Story = {
|
|
|
48
48
|
<UtilityStrip>
|
|
49
49
|
<Title>Utility Strip</Title>
|
|
50
50
|
</UtilityStrip>
|
|
51
|
-
<
|
|
52
|
-
<
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
51
|
+
<Body>
|
|
52
|
+
<Rail>
|
|
53
|
+
<VStack minWidth="200px">
|
|
54
|
+
<BodyText>Body + Rail</BodyText>
|
|
55
|
+
</VStack>
|
|
56
|
+
<SBLayoutContent />
|
|
57
|
+
<SBLayoutContent />
|
|
58
|
+
<SBLayoutContent />
|
|
59
|
+
</Rail>
|
|
60
|
+
</Body>
|
|
56
61
|
<Side width="200px">Side</Side>
|
|
57
62
|
</Rail>
|
|
58
63
|
</LayoutStoryDecorator>
|
|
@@ -66,11 +71,13 @@ export const VerticalContent: Story = {
|
|
|
66
71
|
<UtilityStrip>
|
|
67
72
|
<Title>Utility Strip</Title>
|
|
68
73
|
</UtilityStrip>
|
|
69
|
-
<
|
|
70
|
-
<
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
+
<Body>
|
|
75
|
+
<Scaffold>
|
|
76
|
+
<SBLayoutContent />
|
|
77
|
+
<SBLayoutContent />
|
|
78
|
+
<SBLayoutContent />
|
|
79
|
+
</Scaffold>
|
|
80
|
+
</Body>
|
|
74
81
|
<Side width="200px">Side</Side>
|
|
75
82
|
</Rail>
|
|
76
83
|
</LayoutStoryDecorator>
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import { Scaffold } from '../scaffold/scaffold.js';
|
|
2
2
|
import { Header } from '../header/header.js';
|
|
3
3
|
import { UtilityBar } from '../utility_bar/utility_bar.js';
|
|
4
|
-
import { VBody } from '../body/v_body.js';
|
|
5
4
|
import { Footer } from '../footer/footer.js';
|
|
6
5
|
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
7
6
|
|
|
8
7
|
import { LayoutStoryDecorator } from './utils/layout_theme_provider.js';
|
|
9
8
|
import { SBLayoutContent } from './utils/content.js';
|
|
10
|
-
import { HBody } from '../body/h_body.js';
|
|
11
9
|
import { VStack } from '../../stacks/v_stack.js';
|
|
12
10
|
import { Body } from '../body/body.js';
|
|
11
|
+
import { Rail } from '../rail/rail.js';
|
|
12
|
+
import { Section } from '../section/section.js';
|
|
13
|
+
import { BodyText } from '../../typography/index.js';
|
|
14
|
+
import { Heading } from '../section/heading.js';
|
|
13
15
|
|
|
14
16
|
const meta: Meta<typeof Scaffold> = {
|
|
15
17
|
title: 'Layouts/Scaffold',
|
|
@@ -50,20 +52,30 @@ export const VerticalContent: Story = {
|
|
|
50
52
|
<Scaffold height="100vh">
|
|
51
53
|
<Header>Header</Header>
|
|
52
54
|
<UtilityBar>Utility Bar</UtilityBar>
|
|
53
|
-
<
|
|
54
|
-
<
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
55
|
+
<Body>
|
|
56
|
+
<Scaffold>
|
|
57
|
+
<VStack>
|
|
58
|
+
<BodyText>Body + Scaffold</BodyText>
|
|
59
|
+
</VStack>
|
|
60
|
+
<Section>
|
|
61
|
+
<Heading>Section 1 - A</Heading>
|
|
62
|
+
<SBLayoutContent />
|
|
63
|
+
<Section>
|
|
64
|
+
<Heading>Section 1 - B</Heading>
|
|
65
|
+
<SBLayoutContent />
|
|
66
|
+
</Section>
|
|
67
|
+
</Section>
|
|
68
|
+
<Section>
|
|
69
|
+
<Heading>Section 2</Heading>
|
|
70
|
+
<SBLayoutContent />
|
|
71
|
+
<SBLayoutContent />
|
|
72
|
+
</Section>
|
|
73
|
+
</Scaffold>
|
|
74
|
+
</Body>
|
|
62
75
|
</Scaffold>
|
|
63
76
|
</LayoutStoryDecorator>
|
|
64
77
|
),
|
|
65
78
|
};
|
|
66
|
-
|
|
67
79
|
export const HorizontalContent: Story = {
|
|
68
80
|
args: {
|
|
69
81
|
height: '100vh',
|
|
@@ -73,16 +85,16 @@ export const HorizontalContent: Story = {
|
|
|
73
85
|
<Scaffold height="100vh">
|
|
74
86
|
<Header>Header</Header>
|
|
75
87
|
<UtilityBar>Utility Bar</UtilityBar>
|
|
76
|
-
<
|
|
77
|
-
<
|
|
78
|
-
<
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
</
|
|
88
|
+
<Body>
|
|
89
|
+
<Rail>
|
|
90
|
+
<VStack minWidth="200px">
|
|
91
|
+
<BodyText>Body + Rail</BodyText>
|
|
92
|
+
</VStack>
|
|
93
|
+
<SBLayoutContent />
|
|
94
|
+
<SBLayoutContent />
|
|
95
|
+
<SBLayoutContent />
|
|
96
|
+
</Rail>
|
|
97
|
+
</Body>
|
|
86
98
|
<Footer>Footer</Footer>
|
|
87
99
|
</Scaffold>
|
|
88
100
|
</LayoutStoryDecorator>
|