@tcn/ui 0.10.0 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/form/field/h_field/h_field.d.ts.map +1 -1
- package/dist/form/field/h_field/h_field.js +33 -35
- package/dist/form/field/h_field/h_field.js.map +1 -1
- package/dist/form/field/v_field/v_field.d.ts.map +1 -1
- package/dist/form/field/v_field/v_field.js +34 -36
- package/dist/form/field/v_field/v_field.js.map +1 -1
- package/dist/frame.css +1 -1
- package/dist/inputs/color_input/color_input.d.ts.map +1 -1
- package/dist/inputs/color_input/color_input.js +47 -46
- package/dist/inputs/color_input/color_input.js.map +1 -1
- package/dist/inputs/combo_box/combo_box.d.ts.map +1 -1
- package/dist/inputs/combo_box/combo_box.js +61 -58
- package/dist/inputs/combo_box/combo_box.js.map +1 -1
- package/dist/inputs/index.d.ts +1 -0
- package/dist/inputs/index.d.ts.map +1 -1
- package/dist/inputs/index.js +34 -31
- package/dist/inputs/index.js.map +1 -1
- package/dist/inputs/input/input.js +9 -9
- package/dist/inputs/input/input.js.map +1 -1
- package/dist/inputs/input_group/input_group.d.ts +5 -0
- package/dist/inputs/input_group/input_group.d.ts.map +1 -0
- package/dist/inputs/input_group/input_group.js +20 -0
- package/dist/inputs/input_group/input_group.js.map +1 -0
- package/dist/inputs/phone_number_input/countries_phone_information.d.ts +2 -2
- package/dist/inputs/phone_number_input/countries_phone_information.d.ts.map +1 -1
- package/dist/inputs/phone_number_input/countries_phone_information.js +5 -353
- package/dist/inputs/phone_number_input/countries_phone_information.js.map +1 -1
- package/dist/inputs/phone_number_input/phone_number_context.d.ts +24 -0
- package/dist/inputs/phone_number_input/phone_number_context.d.ts.map +1 -0
- package/dist/inputs/phone_number_input/phone_number_context.js +23 -0
- package/dist/inputs/phone_number_input/phone_number_context.js.map +1 -0
- package/dist/inputs/phone_number_input/phone_number_country_select_adapter.d.ts +19 -0
- package/dist/inputs/phone_number_input/phone_number_country_select_adapter.d.ts.map +1 -0
- package/dist/inputs/phone_number_input/phone_number_country_select_adapter.js +77 -0
- package/dist/inputs/phone_number_input/phone_number_country_select_adapter.js.map +1 -0
- package/dist/inputs/phone_number_input/phone_number_input.d.ts +16 -14
- package/dist/inputs/phone_number_input/phone_number_input.d.ts.map +1 -1
- package/dist/inputs/phone_number_input/phone_number_input.js +104 -274
- package/dist/inputs/phone_number_input/phone_number_input.js.map +1 -1
- package/dist/inputs/phone_number_input/phone_number_input_adapter.d.ts +6 -0
- package/dist/inputs/phone_number_input/phone_number_input_adapter.d.ts.map +1 -0
- package/dist/inputs/phone_number_input/phone_number_input_adapter.js +95 -0
- package/dist/inputs/phone_number_input/phone_number_input_adapter.js.map +1 -0
- package/dist/inputs/phone_number_input/sip_input.d.ts +12 -0
- package/dist/inputs/phone_number_input/sip_input.d.ts.map +1 -0
- package/dist/inputs/phone_number_input/sip_input.js +111 -0
- package/dist/inputs/phone_number_input/sip_input.js.map +1 -0
- package/dist/inputs/select/select.d.ts.map +1 -1
- package/dist/inputs/select/select.js +3 -2
- package/dist/inputs/select/select.js.map +1 -1
- package/dist/inputs/suggestions/suggestion_list.d.ts +4 -1
- package/dist/inputs/suggestions/suggestion_list.d.ts.map +1 -1
- package/dist/inputs/suggestions/suggestion_list.js +120 -111
- package/dist/inputs/suggestions/suggestion_list.js.map +1 -1
- package/dist/inputs/textarea/textarea.js +8 -8
- package/dist/inputs/textarea/textarea.js.map +1 -1
- package/dist/inputs/unit_input/unit_input.d.ts.map +1 -1
- package/dist/inputs/unit_input/unit_input.js +39 -39
- package/dist/inputs/unit_input/unit_input.js.map +1 -1
- package/dist/overlay/frame/frame.d.ts +8 -4
- package/dist/overlay/frame/frame.d.ts.map +1 -1
- package/dist/overlay/frame/frame.js +87 -23
- package/dist/overlay/frame/frame.js.map +1 -1
- package/dist/overlay/popper/base/dismissal_decorator.js.map +1 -1
- package/dist/overlay/popper/legacy/popper.d.ts.map +1 -1
- package/dist/overlay/popper/legacy/popper.js +52 -50
- package/dist/overlay/popper/legacy/popper.js.map +1 -1
- package/dist/phone_number_input.css +1 -1
- package/dist/stacks/box/bottom_resize_handle.d.ts +1 -1
- package/dist/stacks/box/bottom_resize_handle.d.ts.map +1 -1
- package/dist/stacks/box/bottom_resize_handle.js.map +1 -1
- package/dist/stacks/box/box.d.ts +2 -2
- package/dist/stacks/box/box.d.ts.map +1 -1
- package/dist/stacks/box/box.js.map +1 -1
- package/dist/stacks/box/end_resize_handle.d.ts +1 -1
- package/dist/stacks/box/end_resize_handle.d.ts.map +1 -1
- package/dist/stacks/box/end_resize_handle.js.map +1 -1
- package/dist/stacks/box/left_resize_handle.d.ts +1 -1
- package/dist/stacks/box/left_resize_handle.d.ts.map +1 -1
- package/dist/stacks/box/left_resize_handle.js.map +1 -1
- package/dist/stacks/box/resize_handlers.d.ts +2 -2
- package/dist/stacks/box/resize_handlers.d.ts.map +1 -1
- package/dist/stacks/box/resize_handlers.js +32 -32
- package/dist/stacks/box/resize_handlers.js.map +1 -1
- package/dist/stacks/box/right_resize_handle.d.ts +1 -1
- package/dist/stacks/box/right_resize_handle.d.ts.map +1 -1
- package/dist/stacks/box/right_resize_handle.js.map +1 -1
- package/dist/stacks/box/start_resize_handle.d.ts +1 -1
- package/dist/stacks/box/start_resize_handle.d.ts.map +1 -1
- package/dist/stacks/box/start_resize_handle.js +4 -4
- package/dist/stacks/box/start_resize_handle.js.map +1 -1
- package/dist/stacks/box/top_resize_handle.d.ts +1 -1
- package/dist/stacks/box/top_resize_handle.d.ts.map +1 -1
- package/dist/stacks/box/top_resize_handle.js +4 -4
- package/dist/stacks/box/top_resize_handle.js.map +1 -1
- package/dist/stacks/h_collapsible_box.js +18 -18
- package/dist/stacks/h_collapsible_box.js.map +1 -1
- package/dist/stacks/v_collapsible_box.js +18 -18
- package/dist/stacks/v_collapsible_box.js.map +1 -1
- package/dist/suggestion_list.css +1 -1
- package/dist/surfaces/window/window.d.ts +1 -1
- package/dist/surfaces/window/window.d.ts.map +1 -1
- package/dist/surfaces/window/window.js +20 -10
- package/dist/surfaces/window/window.js.map +1 -1
- package/dist/themes/stylesheets/reset.css +1 -1
- package/dist/themes/stylesheets/reset.js +8 -1
- package/dist/themes/stylesheets/reset.js.map +1 -1
- package/dist/themes/themes/ergo/ergo_theme.css +1 -1
- package/dist/themes/themes/ergo/ergo_theme.js +183 -18
- package/dist/themes/themes/ergo/ergo_theme.js.map +1 -1
- package/dist/typography/body_text/body_text.d.ts.map +1 -1
- package/dist/typography/body_text/body_text.js +12 -10
- package/dist/typography/body_text/body_text.js.map +1 -1
- package/dist/utils/dnd/hooks/use_drag_container.d.ts.map +1 -1
- package/dist/utils/dnd/hooks/use_drag_container.js +22 -19
- package/dist/utils/dnd/hooks/use_drag_container.js.map +1 -1
- package/package.json +4 -2
- package/src/form/field/h_field/h_field.tsx +0 -4
- package/src/form/field/v_field/v_field.stories.tsx +8 -0
- package/src/form/field/v_field/v_field.tsx +1 -4
- package/src/form/field_set/field_set.stories.tsx +2 -1
- package/src/inputs/__docs__/inputs.mdx +81 -0
- package/src/inputs/__docs__/inputs.stories.tsx +268 -0
- package/src/inputs/color_input/color_input.tsx +17 -17
- package/src/inputs/combo_box/combo_box.tsx +17 -13
- package/src/inputs/index.ts +2 -0
- package/src/inputs/input/input.tsx +1 -1
- package/src/inputs/input_group/input_group.tsx +26 -0
- package/src/inputs/phone_number_input/countries_phone_information.ts +6 -353
- package/src/inputs/phone_number_input/phone_number_context.tsx +32 -0
- package/src/inputs/phone_number_input/phone_number_country_select_adapter.tsx +126 -0
- package/src/inputs/phone_number_input/phone_number_input.module.css +5 -63
- package/src/inputs/phone_number_input/phone_number_input.stories.tsx +180 -150
- package/src/inputs/phone_number_input/phone_number_input.tsx +133 -400
- package/src/inputs/phone_number_input/phone_number_input_adapter.tsx +123 -0
- package/src/inputs/phone_number_input/sip_input.tsx +147 -0
- package/src/inputs/select/select.tsx +13 -14
- package/src/inputs/suggestions/suggestion_list.module.css +1 -0
- package/src/inputs/suggestions/suggestion_list.stories.tsx +12 -8
- package/src/inputs/suggestions/suggestion_list.tsx +24 -3
- package/src/inputs/textarea/textarea.tsx +1 -1
- package/src/inputs/unit_input/unit_input.tsx +17 -17
- package/src/overlay/frame/frame.module.css +2 -4
- package/src/overlay/frame/frame.stories.tsx +13 -10
- package/src/overlay/frame/frame.tsx +123 -15
- package/src/overlay/popper/base/dismissal_decorator.tsx +1 -1
- package/src/overlay/popper/legacy/popper.tsx +5 -1
- package/src/stacks/box/bottom_resize_handle.tsx +6 -1
- package/src/stacks/box/box.tsx +12 -2
- package/src/stacks/box/end_resize_handle.tsx +6 -1
- package/src/stacks/box/left_resize_handle.tsx +6 -1
- package/src/stacks/box/resize_handlers.ts +20 -8
- package/src/stacks/box/right_resize_handle.tsx +6 -1
- package/src/stacks/box/start_resize_handle.tsx +7 -2
- package/src/stacks/box/top_resize_handle.tsx +7 -2
- package/src/stacks/h_collapsible_box.tsx +2 -2
- package/src/stacks/v_collapsible_box.tsx +2 -2
- package/src/surfaces/window/window.tsx +14 -4
- package/src/themes/stories/controls_fieldset.tsx +1 -1
- package/src/themes/stylesheets/reset.css +8 -1
- package/src/themes/themes/ergo/ergo_theme.css +183 -18
- package/src/typography/body_text/body_text.tsx +2 -0
- package/src/utils/dnd/__stories__/draggable.stories.tsx +14 -8
- package/src/utils/dnd/hooks/use_drag_container.ts +13 -3
- package/src/inputs/phone_number_input/__tests__/utils.test.ts +0 -52
|
@@ -34,15 +34,12 @@ export const VField = React.forwardRef(function VField(
|
|
|
34
34
|
) {
|
|
35
35
|
const [finalId] = useState(() => id || `v-field-${idIndex++}`);
|
|
36
36
|
const hasError = errorMessage ? true : false;
|
|
37
|
-
const labelId = `${finalId}-label`;
|
|
38
|
-
const descriptionId = `${finalId}-description`;
|
|
39
37
|
const state = locked ? 'locked' : loading ? 'loading' : hasError ? 'error' : 'default';
|
|
38
|
+
|
|
40
39
|
return (
|
|
41
40
|
<VStack
|
|
42
41
|
ref={ref}
|
|
43
42
|
as="div"
|
|
44
|
-
aria-labelledby={labelId}
|
|
45
|
-
aria-describedby={descriptionId}
|
|
46
43
|
data-locked={locked}
|
|
47
44
|
data-error={hasError}
|
|
48
45
|
data-loading={loading}
|
|
@@ -28,6 +28,7 @@ export default {
|
|
|
28
28
|
|
|
29
29
|
export function Baseline() {
|
|
30
30
|
const [multiselectValues, setMultiselectValues] = useState<string[]>([]);
|
|
31
|
+
const [phoneNumberValue, setPhoneNumberValue] = useState<string | undefined>(undefined);
|
|
31
32
|
const [freeformMultiselectValues, setFreeformMultiselectValues] = useState<string[]>(
|
|
32
33
|
[]
|
|
33
34
|
);
|
|
@@ -47,7 +48,7 @@ export function Baseline() {
|
|
|
47
48
|
</HField>
|
|
48
49
|
<Divider />
|
|
49
50
|
<HField label="Phone Number" id="field-4">
|
|
50
|
-
<PhoneNumberInput />
|
|
51
|
+
<PhoneNumberInput value={phoneNumberValue} onChange={setPhoneNumberValue} />
|
|
51
52
|
</HField>
|
|
52
53
|
<Divider />
|
|
53
54
|
<HField label="Unit" id="field-5">
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { Meta } from '@storybook/addon-docs/blocks';
|
|
2
|
+
import * as InputStories from './inputs.stories';
|
|
3
|
+
import { Showcase } from '../../actions/__docs__/components/showcase';
|
|
4
|
+
import { Gallery } from '../../actions/__docs__/components/gallery';
|
|
5
|
+
|
|
6
|
+
<Meta title="Catalog/Inputs" of={InputStories} />
|
|
7
|
+
|
|
8
|
+
# Inputs
|
|
9
|
+
|
|
10
|
+
Form controls and data entry components for user input.
|
|
11
|
+
|
|
12
|
+
- [Inputs](#inputs)
|
|
13
|
+
- [Text](#text)
|
|
14
|
+
- [Standard](#standard)
|
|
15
|
+
- [Specialized](#specialized)
|
|
16
|
+
- [Boolean](#boolean)
|
|
17
|
+
- [Date / Time](#date--time)
|
|
18
|
+
- [Selection](#selection)
|
|
19
|
+
- [Single / Constrained](#single--constrained)
|
|
20
|
+
- [Multiple](#multiple)
|
|
21
|
+
|
|
22
|
+
## Text
|
|
23
|
+
|
|
24
|
+
Free text entry and structured text input.
|
|
25
|
+
|
|
26
|
+
### Standard
|
|
27
|
+
|
|
28
|
+
<Gallery minColumnWidth="280px">
|
|
29
|
+
<Showcase title="Input" of={InputStories.InputBaseline} minWidth="240px" />
|
|
30
|
+
<Showcase title="Textarea" of={InputStories.TextareaBaseline} minWidth="280px" />
|
|
31
|
+
<Showcase title="Mask Input" of={InputStories.MaskInputBaseline} minWidth="200px" />
|
|
32
|
+
</Gallery>
|
|
33
|
+
|
|
34
|
+
### Specialized
|
|
35
|
+
|
|
36
|
+
<Gallery minColumnWidth="280px">
|
|
37
|
+
<Showcase title="Phone Number Input" of={InputStories.PhoneNumberInputBaseline} minWidth="200px" />
|
|
38
|
+
<Showcase title="Color Input" of={InputStories.ColorInputBaseline} minWidth="200px" />
|
|
39
|
+
<Showcase title="Unit Input" of={InputStories.UnitInputBaseline} minWidth="200px" />
|
|
40
|
+
<Showcase title="Slider" of={InputStories.SliderBaseline} minWidth="280px" />
|
|
41
|
+
</Gallery>
|
|
42
|
+
|
|
43
|
+
## Boolean
|
|
44
|
+
|
|
45
|
+
Toggle controls for on/off or true/false values.
|
|
46
|
+
|
|
47
|
+
<Gallery minColumnWidth="120px">
|
|
48
|
+
<Showcase title="Checkbox" of={InputStories.CheckboxBaseline} minWidth="120px" />
|
|
49
|
+
<Showcase title="Switch" of={InputStories.SwitchBaseline} minWidth="100px" />
|
|
50
|
+
</Gallery>
|
|
51
|
+
|
|
52
|
+
## Date / Time
|
|
53
|
+
|
|
54
|
+
Date and time selection.
|
|
55
|
+
|
|
56
|
+
<Gallery minColumnWidth="280px">
|
|
57
|
+
<Showcase title="Date Picker" of={InputStories.DatePickerBaseline} minWidth="280px" />
|
|
58
|
+
</Gallery>
|
|
59
|
+
|
|
60
|
+
## Selection
|
|
61
|
+
|
|
62
|
+
Components for choosing one or more values from options.
|
|
63
|
+
|
|
64
|
+
### Single / Constrained
|
|
65
|
+
|
|
66
|
+
Pick one value from a list, range, or specialized picker.
|
|
67
|
+
|
|
68
|
+
<Gallery minColumnWidth="320px">
|
|
69
|
+
<Showcase title="Select" of={InputStories.SelectBaseline} minWidth="320px" />
|
|
70
|
+
<Showcase title="Radio" of={InputStories.RadioBaseline} minWidth="320px" />
|
|
71
|
+
<Showcase title="ComboBox" of={InputStories.ComboBoxBaseline} minWidth="320px" />
|
|
72
|
+
</Gallery>
|
|
73
|
+
|
|
74
|
+
### Multiple
|
|
75
|
+
|
|
76
|
+
Pick multiple values from a list.
|
|
77
|
+
|
|
78
|
+
<Gallery minColumnWidth="220px">
|
|
79
|
+
<Showcase title="Multiselect" of={InputStories.MultiselectBaseline} minWidth="220px" />
|
|
80
|
+
<Showcase title="Multi ComboBox" of={InputStories.MultiComboBoxBaseline} minWidth="220px" />
|
|
81
|
+
</Gallery>
|
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import { Meta, StoryObj } from '@storybook/react-vite';
|
|
3
|
+
import { Input } from '../input/input.js';
|
|
4
|
+
import { Checkbox } from '../checkbox/checkbox.js';
|
|
5
|
+
import { Textarea } from '../textarea/textarea.js';
|
|
6
|
+
import { Select } from '../select/select.js';
|
|
7
|
+
import { Option } from '../options/option.js';
|
|
8
|
+
import { Switch } from '../switch/switch.js';
|
|
9
|
+
import { Slider } from '../slider/slider.js';
|
|
10
|
+
import { Radio } from '../radio/radio.js';
|
|
11
|
+
import { DatePicker } from '../date_picker/date_picker.js';
|
|
12
|
+
import { ColorInput } from '../color_input/color_input.js';
|
|
13
|
+
import { ComboBox } from '../combo_box/combo_box.js';
|
|
14
|
+
import { Multiselect } from '../multiselect/multiselect.js';
|
|
15
|
+
import { MaskInput } from '../mask_input/mask_input.js';
|
|
16
|
+
import { PhoneNumberInput } from '../phone_number_input/phone_number_input.js';
|
|
17
|
+
import { UnitInput } from '../unit_input/unit_input.js';
|
|
18
|
+
import { MultiComboBox } from '../multi_combo_box/multi_combo_box.js';
|
|
19
|
+
import { HStack } from '../../stacks/h_stack.js';
|
|
20
|
+
import { Footnote, Headline } from '../../typography/index.js';
|
|
21
|
+
import { ZStack } from '../../stacks/z_stack.js';
|
|
22
|
+
import { VStack } from '../../stacks/v_stack.js';
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Baseline stories for the inputs catalog. Used by inputs.mdx.
|
|
26
|
+
*/
|
|
27
|
+
const meta: Meta<typeof Input> = {
|
|
28
|
+
title: 'Catalog/Inputs',
|
|
29
|
+
component: Input,
|
|
30
|
+
parameters: {
|
|
31
|
+
docs: {
|
|
32
|
+
story: { exclude: ['style'] },
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
tags: ['!autodocs', '!dev'],
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export default meta;
|
|
39
|
+
type Story = StoryObj;
|
|
40
|
+
|
|
41
|
+
export const InputBaseline: Story = {
|
|
42
|
+
render: function InputBaseline() {
|
|
43
|
+
const [value, setValue] = useState('Hello world');
|
|
44
|
+
return <Input id="input-baseline" value={value} onChange={setValue} />;
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export const CheckboxBaseline: Story = {
|
|
49
|
+
render: function CheckboxBaseline() {
|
|
50
|
+
const [checked, setChecked] = useState(false);
|
|
51
|
+
return <Checkbox id="checkbox-baseline" checked={checked} onChange={setChecked} />;
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
export const TextareaBaseline: Story = {
|
|
56
|
+
render: function TextareaBaseline() {
|
|
57
|
+
const [value, setValue] = useState('');
|
|
58
|
+
return <Textarea id="textarea-baseline" value={value} onChange={setValue} />;
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
export const SelectBaseline: Story = {
|
|
63
|
+
render: function SelectBaseline() {
|
|
64
|
+
const [value, setValue] = useState('');
|
|
65
|
+
return (
|
|
66
|
+
<Select id="select-baseline" value={value} onChange={setValue} width="200px">
|
|
67
|
+
<Option value="apple" label="Apple" keywords={['fruit']}>
|
|
68
|
+
Apple
|
|
69
|
+
</Option>
|
|
70
|
+
<Option value="banana" label="Banana" keywords={['fruit']}>
|
|
71
|
+
Banana
|
|
72
|
+
</Option>
|
|
73
|
+
<Option value="cherry" label="Cherry" keywords={['fruit']}>
|
|
74
|
+
Cherry
|
|
75
|
+
</Option>
|
|
76
|
+
</Select>
|
|
77
|
+
);
|
|
78
|
+
},
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
export const SwitchBaseline: Story = {
|
|
82
|
+
render: function SwitchBaseline() {
|
|
83
|
+
const [checked, setChecked] = useState(false);
|
|
84
|
+
return <Switch id="switch-baseline" checked={checked} onChange={setChecked} />;
|
|
85
|
+
},
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
export const SliderBaseline: Story = {
|
|
89
|
+
render: function SliderBaseline() {
|
|
90
|
+
const [value, setValue] = useState('50');
|
|
91
|
+
return <Slider id="slider-baseline" value={value} onChange={setValue} />;
|
|
92
|
+
},
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
export const RadioBaseline: Story = {
|
|
96
|
+
render: function RadioBaseline() {
|
|
97
|
+
return (
|
|
98
|
+
<HStack height="auto" gap="8px">
|
|
99
|
+
<Radio name="demo" id="radio-baseline-1" value="a" label="Option A" />
|
|
100
|
+
<Radio name="demo" id="radio-baseline-2" value="b" label="Option B" />
|
|
101
|
+
<Radio name="demo" id="radio-baseline-3" value="c" label="Option C" />
|
|
102
|
+
</HStack>
|
|
103
|
+
);
|
|
104
|
+
},
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
export const DatePickerBaseline: Story = {
|
|
108
|
+
render: function DatePickerBaseline() {
|
|
109
|
+
return <DatePicker value={new Date()} showTime />;
|
|
110
|
+
},
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
export const ColorInputBaseline: Story = {
|
|
114
|
+
render: function ColorInputBaseline() {
|
|
115
|
+
const [value, setValue] = useState('#3b82f6');
|
|
116
|
+
return <ColorInput id="color-input-baseline" value={value} onChange={setValue} />;
|
|
117
|
+
},
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
export const ComboBoxBaseline: Story = {
|
|
121
|
+
render: function ComboBoxBaseline() {
|
|
122
|
+
const [value, setValue] = useState('');
|
|
123
|
+
return (
|
|
124
|
+
<ComboBox
|
|
125
|
+
id="combo-box-baseline"
|
|
126
|
+
value={value}
|
|
127
|
+
onChange={setValue}
|
|
128
|
+
onOptionSelect={setValue}
|
|
129
|
+
noOptionMatchedMessage="Press Enter for custom"
|
|
130
|
+
width="200px"
|
|
131
|
+
>
|
|
132
|
+
<Option value="John" label="John" keywords={['john']}>
|
|
133
|
+
John Doe
|
|
134
|
+
</Option>
|
|
135
|
+
<Option value="Jane" label="Jane" keywords={['jane']}>
|
|
136
|
+
Jane Smith
|
|
137
|
+
</Option>
|
|
138
|
+
<Option value="Bob" label="Bob" keywords={['bob']}>
|
|
139
|
+
Bob Wilson
|
|
140
|
+
</Option>
|
|
141
|
+
</ComboBox>
|
|
142
|
+
);
|
|
143
|
+
},
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
export const MultiselectBaseline: Story = {
|
|
147
|
+
render: function MultiselectBaseline() {
|
|
148
|
+
const [values, setValues] = useState<string[]>([]);
|
|
149
|
+
return (
|
|
150
|
+
<Multiselect
|
|
151
|
+
id="multiselect-baseline"
|
|
152
|
+
value={values}
|
|
153
|
+
onChange={setValues}
|
|
154
|
+
width="200px"
|
|
155
|
+
>
|
|
156
|
+
<Option value="1" label="First">
|
|
157
|
+
First
|
|
158
|
+
</Option>
|
|
159
|
+
<Option value="2" label="Second">
|
|
160
|
+
Second
|
|
161
|
+
</Option>
|
|
162
|
+
<Option value="3" label="Third">
|
|
163
|
+
Third
|
|
164
|
+
</Option>
|
|
165
|
+
</Multiselect>
|
|
166
|
+
);
|
|
167
|
+
},
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
export const MaskInputBaseline: Story = {
|
|
171
|
+
render: function MaskInputBaseline() {
|
|
172
|
+
const [value, setValue] = useState('');
|
|
173
|
+
return (
|
|
174
|
+
<MaskInput
|
|
175
|
+
id="mask-input-baseline"
|
|
176
|
+
value={value}
|
|
177
|
+
onChange={setValue}
|
|
178
|
+
mask={{ mask: '99/99/9999', placeholder: 'mm/dd/yyyy' }}
|
|
179
|
+
/>
|
|
180
|
+
);
|
|
181
|
+
},
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
export const PhoneNumberInputBaseline: Story = {
|
|
185
|
+
render: function PhoneNumberInputBaseline() {
|
|
186
|
+
const [value, setValue] = useState<string | undefined>(undefined);
|
|
187
|
+
return (
|
|
188
|
+
<PhoneNumberInput
|
|
189
|
+
id="phone-number-input-baseline"
|
|
190
|
+
value={value}
|
|
191
|
+
onChange={setValue}
|
|
192
|
+
/>
|
|
193
|
+
);
|
|
194
|
+
},
|
|
195
|
+
};
|
|
196
|
+
|
|
197
|
+
export const UnitInputBaseline: Story = {
|
|
198
|
+
render: function UnitInputBaseline() {
|
|
199
|
+
const [unit, setUnit] = useState({ value: 100, unit: 'px' });
|
|
200
|
+
return (
|
|
201
|
+
<UnitInput
|
|
202
|
+
id="unit-input-baseline"
|
|
203
|
+
value={unit.value}
|
|
204
|
+
unit={unit.unit}
|
|
205
|
+
onChange={(v, u) => setUnit({ value: v ?? 0, unit: u })}
|
|
206
|
+
width="120px"
|
|
207
|
+
>
|
|
208
|
+
<Option value="px" label="px" keywords={['pixel']}>
|
|
209
|
+
<HStack gap="8px" padding="4px" height="auto">
|
|
210
|
+
<ZStack minWidth="30px" width="auto">
|
|
211
|
+
<Headline>px</Headline>
|
|
212
|
+
</ZStack>
|
|
213
|
+
<VStack width="200px" hAlign="start" height="auto">
|
|
214
|
+
<Headline>Pixel</Headline>
|
|
215
|
+
<Footnote>1/96th of an inch</Footnote>
|
|
216
|
+
</VStack>
|
|
217
|
+
</HStack>
|
|
218
|
+
</Option>
|
|
219
|
+
<Option value="em" label="em" keywords={['em']}>
|
|
220
|
+
<HStack gap="8px" padding="4px" height="auto">
|
|
221
|
+
<ZStack minWidth="30px" width="auto">
|
|
222
|
+
<Headline>em</Headline>
|
|
223
|
+
</ZStack>
|
|
224
|
+
<VStack width="200px" hAlign="start" height="auto">
|
|
225
|
+
<Headline>Em</Headline>
|
|
226
|
+
<Footnote>Relative to font size</Footnote>
|
|
227
|
+
</VStack>
|
|
228
|
+
</HStack>
|
|
229
|
+
</Option>
|
|
230
|
+
<Option value="rem" label="rem" keywords={['rem']}>
|
|
231
|
+
<HStack gap="8px" padding="4px" height="auto">
|
|
232
|
+
<ZStack minWidth="30px" width="auto">
|
|
233
|
+
<Headline>rem</Headline>
|
|
234
|
+
</ZStack>
|
|
235
|
+
<VStack width="200px" hAlign="start" height="auto">
|
|
236
|
+
<Headline>Root Em</Headline>
|
|
237
|
+
<Footnote>Relative to root font</Footnote>
|
|
238
|
+
</VStack>
|
|
239
|
+
</HStack>
|
|
240
|
+
</Option>
|
|
241
|
+
</UnitInput>
|
|
242
|
+
);
|
|
243
|
+
},
|
|
244
|
+
};
|
|
245
|
+
|
|
246
|
+
export const MultiComboBoxBaseline: Story = {
|
|
247
|
+
render: function MultiComboBoxBaseline() {
|
|
248
|
+
const [values, setValues] = useState<string[]>([]);
|
|
249
|
+
return (
|
|
250
|
+
<MultiComboBox
|
|
251
|
+
id="multi-combo-box-baseline"
|
|
252
|
+
value={values}
|
|
253
|
+
onChange={setValues}
|
|
254
|
+
width="200px"
|
|
255
|
+
>
|
|
256
|
+
<Option value="1" label="First">
|
|
257
|
+
First
|
|
258
|
+
</Option>
|
|
259
|
+
<Option value="2" label="Second">
|
|
260
|
+
Second
|
|
261
|
+
</Option>
|
|
262
|
+
<Option value="3" label="Third">
|
|
263
|
+
Third
|
|
264
|
+
</Option>
|
|
265
|
+
</MultiComboBox>
|
|
266
|
+
);
|
|
267
|
+
},
|
|
268
|
+
};
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Box } from '../../stacks/box/box.js';
|
|
2
2
|
import { HStack } from '../../stacks/h_stack.js';
|
|
3
3
|
import { Spacer } from '../../stacks/spacer.js';
|
|
4
|
-
import { ZStack } from '../../stacks/z_stack.js';
|
|
5
4
|
import { clsx } from 'clsx';
|
|
6
5
|
import React, { useLayoutEffect, useRef, useState } from 'react';
|
|
7
6
|
import { HTMLAttributes } from 'react';
|
|
@@ -12,6 +11,7 @@ import { Input } from '../input/input.js';
|
|
|
12
11
|
import styles from './color_input.module.css';
|
|
13
12
|
|
|
14
13
|
import { Popper } from '../../overlay/popper/legacy/popper.js';
|
|
14
|
+
import { InputGroup } from '../input_group/input_group.js';
|
|
15
15
|
|
|
16
16
|
export interface ColorInputProps
|
|
17
17
|
extends Omit<HTMLAttributes<HTMLButtonElement>, 'onChange' | 'onError'> {
|
|
@@ -77,7 +77,7 @@ export function ColorInput({
|
|
|
77
77
|
|
|
78
78
|
return (
|
|
79
79
|
<>
|
|
80
|
-
<
|
|
80
|
+
<InputGroup
|
|
81
81
|
height="auto"
|
|
82
82
|
width={width}
|
|
83
83
|
minWidth={minWidth}
|
|
@@ -85,20 +85,20 @@ export function ColorInput({
|
|
|
85
85
|
className="tcn-color-input-wrapper"
|
|
86
86
|
{...props}
|
|
87
87
|
>
|
|
88
|
-
<
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
88
|
+
<Input
|
|
89
|
+
width="flex"
|
|
90
|
+
disabled={disabled}
|
|
91
|
+
value={value}
|
|
92
|
+
style={{
|
|
93
|
+
borderEndEndRadius: 0,
|
|
94
|
+
borderStartEndRadius: 0,
|
|
95
|
+
textAlign: 'start',
|
|
96
|
+
paddingInlineEnd: '8px',
|
|
97
|
+
}}
|
|
98
|
+
className="tcn-color-input"
|
|
99
|
+
onChange={onChange}
|
|
100
|
+
/>
|
|
101
|
+
|
|
102
102
|
<Button
|
|
103
103
|
disabled={disabled}
|
|
104
104
|
hierarchy={hierarchy}
|
|
@@ -133,7 +133,7 @@ export function ColorInput({
|
|
|
133
133
|
</HStack>
|
|
134
134
|
<Spacer width="4px" />
|
|
135
135
|
</Button>
|
|
136
|
-
</
|
|
136
|
+
</InputGroup>
|
|
137
137
|
<Popper
|
|
138
138
|
anchorElement={anchorElement}
|
|
139
139
|
onClose={closePicker}
|
|
@@ -29,6 +29,7 @@ export const ComboBox = React.forwardRef(function ComboBox(
|
|
|
29
29
|
ref: React.Ref<HTMLInputElement>
|
|
30
30
|
) {
|
|
31
31
|
const isAlreadyFocusedRef = useRef(false);
|
|
32
|
+
const [searchValue, setSearchValue] = useState(value);
|
|
32
33
|
const valueRef = useRef(value);
|
|
33
34
|
const isClosingRef = useRef(false);
|
|
34
35
|
const [anchorElement, setAnchorElement] = useState<HTMLInputElement | null>(null);
|
|
@@ -42,6 +43,7 @@ export const ComboBox = React.forwardRef(function ComboBox(
|
|
|
42
43
|
|
|
43
44
|
function closeSuggestions() {
|
|
44
45
|
isClosingRef.current = false;
|
|
46
|
+
setSearchValue('');
|
|
45
47
|
setIsSuggestionsOpen(false);
|
|
46
48
|
}
|
|
47
49
|
|
|
@@ -91,6 +93,8 @@ export const ComboBox = React.forwardRef(function ComboBox(
|
|
|
91
93
|
function handleKeyUp(event: React.KeyboardEvent<HTMLInputElement>) {
|
|
92
94
|
const key = event.key;
|
|
93
95
|
|
|
96
|
+
setSearchValue(event.currentTarget.value);
|
|
97
|
+
|
|
94
98
|
if (key === 'Enter') {
|
|
95
99
|
if (isSuggestionsOpen) {
|
|
96
100
|
closeSuggestions();
|
|
@@ -135,19 +139,19 @@ export const ComboBox = React.forwardRef(function ComboBox(
|
|
|
135
139
|
onMouseDown={handlMouseDown}
|
|
136
140
|
onMouseUp={handleMouseUp}
|
|
137
141
|
/>
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
142
|
+
<SuggestionList
|
|
143
|
+
open={isSuggestionsOpen}
|
|
144
|
+
anchorElement={anchorElement}
|
|
145
|
+
onClose={handleClose}
|
|
146
|
+
value={value}
|
|
147
|
+
initialSearchValue={searchValue}
|
|
148
|
+
trimCustomInput={trimCustomInput}
|
|
149
|
+
onOptionSelect={handleSelection}
|
|
150
|
+
noSuggestionMessage={noOptionMatchedMessage}
|
|
151
|
+
haveValueAsOption={true}
|
|
152
|
+
>
|
|
153
|
+
{children}
|
|
154
|
+
</SuggestionList>
|
|
151
155
|
</>
|
|
152
156
|
);
|
|
153
157
|
});
|
package/src/inputs/index.ts
CHANGED
|
@@ -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')}
|
|
25
|
+
className={clsx(styles.input, className, 'tcn-input', 'tcn-control')}
|
|
26
26
|
type={type}
|
|
27
27
|
ref={ref}
|
|
28
28
|
data-is-disabled={props.disabled || false}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { clsx } from 'clsx';
|
|
3
|
+
import { HStack, type HStackProps } from '../../stacks/h_stack.js';
|
|
4
|
+
|
|
5
|
+
export type InputGroupProps = HStackProps;
|
|
6
|
+
|
|
7
|
+
export const InputGroup = React.forwardRef<HTMLElement, InputGroupProps>(
|
|
8
|
+
function InputGroup(
|
|
9
|
+
{ children, as = 'div', className, ...props }: InputGroupProps,
|
|
10
|
+
ref
|
|
11
|
+
) {
|
|
12
|
+
const clonedChildren = React.Children.map(children, child =>
|
|
13
|
+
React.isValidElement(child)
|
|
14
|
+
? React.cloneElement(child, {
|
|
15
|
+
...child.props,
|
|
16
|
+
className: clsx(child.props.className, 'tcn-input-group-slot'),
|
|
17
|
+
})
|
|
18
|
+
: child
|
|
19
|
+
);
|
|
20
|
+
return (
|
|
21
|
+
<HStack ref={ref} as={as} className={clsx(className, 'tcn-input-group')} {...props}>
|
|
22
|
+
{clonedChildren}
|
|
23
|
+
</HStack>
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
);
|