@tcn/ui 0.9.0 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bar.css +1 -0
- package/dist/body.css +1 -1
- package/dist/body.module-BbFZ7KNP.js +5 -0
- package/dist/body.module-BbFZ7KNP.js.map +1 -0
- package/dist/divider.css +1 -1
- package/dist/footer.css +1 -1
- package/dist/form/field/h_field/h_field.d.ts.map +1 -1
- package/dist/form/field/h_field/h_field.js +33 -35
- package/dist/form/field/h_field/h_field.js.map +1 -1
- package/dist/form/field/v_field/v_field.d.ts.map +1 -1
- package/dist/form/field/v_field/v_field.js +34 -36
- package/dist/form/field/v_field/v_field.js.map +1 -1
- package/dist/frame.css +1 -1
- package/dist/inputs/color_input/color_input.d.ts.map +1 -1
- package/dist/inputs/color_input/color_input.js +47 -46
- package/dist/inputs/color_input/color_input.js.map +1 -1
- package/dist/inputs/combo_box/combo_box.d.ts.map +1 -1
- package/dist/inputs/combo_box/combo_box.js +61 -58
- package/dist/inputs/combo_box/combo_box.js.map +1 -1
- package/dist/inputs/index.d.ts +1 -0
- package/dist/inputs/index.d.ts.map +1 -1
- package/dist/inputs/index.js +34 -31
- package/dist/inputs/index.js.map +1 -1
- package/dist/inputs/input/input.js +9 -9
- package/dist/inputs/input/input.js.map +1 -1
- package/dist/inputs/input_group/input_group.d.ts +5 -0
- package/dist/inputs/input_group/input_group.d.ts.map +1 -0
- package/dist/inputs/input_group/input_group.js +20 -0
- package/dist/inputs/input_group/input_group.js.map +1 -0
- package/dist/inputs/phone_number_input/countries_phone_information.d.ts +2 -2
- package/dist/inputs/phone_number_input/countries_phone_information.d.ts.map +1 -1
- package/dist/inputs/phone_number_input/countries_phone_information.js +5 -353
- package/dist/inputs/phone_number_input/countries_phone_information.js.map +1 -1
- package/dist/inputs/phone_number_input/phone_number_context.d.ts +24 -0
- package/dist/inputs/phone_number_input/phone_number_context.d.ts.map +1 -0
- package/dist/inputs/phone_number_input/phone_number_context.js +23 -0
- package/dist/inputs/phone_number_input/phone_number_context.js.map +1 -0
- package/dist/inputs/phone_number_input/phone_number_country_select_adapter.d.ts +19 -0
- package/dist/inputs/phone_number_input/phone_number_country_select_adapter.d.ts.map +1 -0
- package/dist/inputs/phone_number_input/phone_number_country_select_adapter.js +77 -0
- package/dist/inputs/phone_number_input/phone_number_country_select_adapter.js.map +1 -0
- package/dist/inputs/phone_number_input/phone_number_input.d.ts +16 -14
- package/dist/inputs/phone_number_input/phone_number_input.d.ts.map +1 -1
- package/dist/inputs/phone_number_input/phone_number_input.js +104 -274
- package/dist/inputs/phone_number_input/phone_number_input.js.map +1 -1
- package/dist/inputs/phone_number_input/phone_number_input_adapter.d.ts +6 -0
- package/dist/inputs/phone_number_input/phone_number_input_adapter.d.ts.map +1 -0
- package/dist/inputs/phone_number_input/phone_number_input_adapter.js +95 -0
- package/dist/inputs/phone_number_input/phone_number_input_adapter.js.map +1 -0
- package/dist/inputs/phone_number_input/sip_input.d.ts +12 -0
- package/dist/inputs/phone_number_input/sip_input.d.ts.map +1 -0
- package/dist/inputs/phone_number_input/sip_input.js +111 -0
- package/dist/inputs/phone_number_input/sip_input.js.map +1 -0
- package/dist/inputs/select/select.d.ts.map +1 -1
- package/dist/inputs/select/select.js +3 -2
- package/dist/inputs/select/select.js.map +1 -1
- package/dist/inputs/suggestions/suggestion_list.d.ts +4 -1
- package/dist/inputs/suggestions/suggestion_list.d.ts.map +1 -1
- package/dist/inputs/suggestions/suggestion_list.js +120 -111
- package/dist/inputs/suggestions/suggestion_list.js.map +1 -1
- package/dist/inputs/textarea/textarea.js +8 -8
- package/dist/inputs/textarea/textarea.js.map +1 -1
- package/dist/inputs/unit_input/unit_input.d.ts.map +1 -1
- package/dist/inputs/unit_input/unit_input.js +39 -39
- package/dist/inputs/unit_input/unit_input.js.map +1 -1
- package/dist/layouts/bar/bar.d.ts +5 -0
- package/dist/layouts/bar/bar.d.ts.map +1 -0
- package/dist/layouts/bar/bar.js +20 -0
- package/dist/layouts/bar/bar.js.map +1 -0
- package/dist/layouts/body/body.d.ts +2 -2
- package/dist/layouts/body/body.d.ts.map +1 -1
- package/dist/layouts/body/body.js +12 -12
- package/dist/layouts/body/body.js.map +1 -1
- package/dist/layouts/body/h_body.d.ts.map +1 -1
- package/dist/layouts/body/h_body.js +18 -12
- package/dist/layouts/body/h_body.js.map +1 -1
- package/dist/layouts/body/v_body.d.ts.map +1 -1
- package/dist/layouts/body/v_body.js +16 -10
- package/dist/layouts/body/v_body.js.map +1 -1
- package/dist/layouts/footer/footer.d.ts +2 -3
- package/dist/layouts/footer/footer.d.ts.map +1 -1
- package/dist/layouts/footer/footer.js +7 -7
- package/dist/layouts/footer/footer.js.map +1 -1
- package/dist/layouts/header/header.d.ts +2 -2
- package/dist/layouts/header/header.d.ts.map +1 -1
- package/dist/layouts/header/header.js +13 -21
- package/dist/layouts/header/header.js.map +1 -1
- package/dist/layouts/index.d.ts +0 -1
- package/dist/layouts/index.d.ts.map +1 -1
- package/dist/layouts/index.js +17 -19
- package/dist/layouts/index.js.map +1 -1
- package/dist/layouts/rail/rail.js +41 -41
- package/dist/layouts/rail/rail.js.map +1 -1
- package/dist/layouts/rail/side/side.d.ts.map +1 -1
- package/dist/layouts/rail/side/side.js +1 -1
- package/dist/layouts/rail/side/side.js.map +1 -1
- package/dist/layouts/rail/utility_strip/utility_strip.d.ts.map +1 -1
- package/dist/layouts/rail/utility_strip/utility_strip.js +21 -17
- package/dist/layouts/rail/utility_strip/utility_strip.js.map +1 -1
- package/dist/layouts/scaffold/scaffold.js +32 -32
- package/dist/layouts/scaffold/scaffold.js.map +1 -1
- package/dist/layouts/utility_bar/utility_bar.d.ts +2 -2
- package/dist/layouts/utility_bar/utility_bar.d.ts.map +1 -1
- package/dist/layouts/utility_bar/utility_bar.js +17 -19
- package/dist/layouts/utility_bar/utility_bar.js.map +1 -1
- package/dist/overlay/frame/frame.d.ts +8 -4
- package/dist/overlay/frame/frame.d.ts.map +1 -1
- package/dist/overlay/frame/frame.js +87 -23
- package/dist/overlay/frame/frame.js.map +1 -1
- package/dist/overlay/popper/base/dismissal_decorator.js.map +1 -1
- package/dist/overlay/popper/legacy/popper.d.ts.map +1 -1
- package/dist/overlay/popper/legacy/popper.js +52 -50
- package/dist/overlay/popper/legacy/popper.js.map +1 -1
- package/dist/panel.css +1 -0
- package/dist/phone_number_input.css +1 -1
- package/dist/rail.css +1 -1
- package/dist/scaffold.css +1 -1
- package/dist/side.css +1 -1
- package/dist/stacks/box/bottom_resize_handle.d.ts +2 -2
- package/dist/stacks/box/bottom_resize_handle.d.ts.map +1 -1
- package/dist/stacks/box/bottom_resize_handle.js +12 -10
- package/dist/stacks/box/bottom_resize_handle.js.map +1 -1
- package/dist/stacks/box/box.d.ts +4 -4
- package/dist/stacks/box/box.d.ts.map +1 -1
- package/dist/stacks/box/box.js +26 -26
- package/dist/stacks/box/box.js.map +1 -1
- package/dist/stacks/box/end_resize_handle.d.ts +2 -2
- package/dist/stacks/box/end_resize_handle.d.ts.map +1 -1
- package/dist/stacks/box/end_resize_handle.js +6 -5
- package/dist/stacks/box/end_resize_handle.js.map +1 -1
- package/dist/stacks/box/left_resize_handle.d.ts +2 -2
- package/dist/stacks/box/left_resize_handle.d.ts.map +1 -1
- package/dist/stacks/box/left_resize_handle.js +10 -9
- package/dist/stacks/box/left_resize_handle.js.map +1 -1
- package/dist/stacks/box/resize_handlers.d.ts +2 -2
- package/dist/stacks/box/resize_handlers.d.ts.map +1 -1
- package/dist/stacks/box/resize_handlers.js +32 -32
- package/dist/stacks/box/resize_handlers.js.map +1 -1
- package/dist/stacks/box/right_resize_handle.d.ts +2 -2
- package/dist/stacks/box/right_resize_handle.d.ts.map +1 -1
- package/dist/stacks/box/right_resize_handle.js +6 -5
- package/dist/stacks/box/right_resize_handle.js.map +1 -1
- package/dist/stacks/box/start_resize_handle.d.ts +2 -2
- package/dist/stacks/box/start_resize_handle.d.ts.map +1 -1
- package/dist/stacks/box/start_resize_handle.js +6 -6
- package/dist/stacks/box/start_resize_handle.js.map +1 -1
- package/dist/stacks/box/top_resize_handle.d.ts +2 -2
- package/dist/stacks/box/top_resize_handle.d.ts.map +1 -1
- package/dist/stacks/box/top_resize_handle.js +6 -5
- package/dist/stacks/box/top_resize_handle.js.map +1 -1
- package/dist/stacks/h_collapsible_box.d.ts.map +1 -1
- package/dist/stacks/h_collapsible_box.js +25 -25
- package/dist/stacks/h_collapsible_box.js.map +1 -1
- package/dist/stacks/v_collapsible_box.js +25 -25
- package/dist/stacks/v_collapsible_box.js.map +1 -1
- package/dist/suggestion_list.css +1 -1
- package/dist/surfaces/index.d.ts +1 -2
- package/dist/surfaces/index.d.ts.map +1 -1
- package/dist/surfaces/index.js +18 -20
- package/dist/surfaces/index.js.map +1 -1
- package/dist/surfaces/panel/panel.d.ts +5 -0
- package/dist/surfaces/panel/panel.d.ts.map +1 -0
- package/dist/surfaces/panel/panel.js +19 -0
- package/dist/surfaces/panel/panel.js.map +1 -0
- package/dist/surfaces/pop_confirm/pop_confirm.js +2 -3
- package/dist/surfaces/pop_confirm/pop_confirm.js.map +1 -1
- package/dist/surfaces/window/window.d.ts +1 -1
- package/dist/surfaces/window/window.d.ts.map +1 -1
- package/dist/surfaces/window/window.js +20 -10
- package/dist/surfaces/window/window.js.map +1 -1
- package/dist/themes/stylesheets/reset.css +1 -1
- package/dist/themes/stylesheets/reset.js +8 -1
- package/dist/themes/stylesheets/reset.js.map +1 -1
- package/dist/themes/theme.d.ts +2 -1
- package/dist/themes/theme.d.ts.map +1 -1
- package/dist/themes/theme.js +16 -9
- package/dist/themes/theme.js.map +1 -1
- package/dist/themes/themes/ergo/ergo_theme.css +1 -1
- package/dist/themes/themes/ergo/ergo_theme.js +210 -18
- package/dist/themes/themes/ergo/ergo_theme.js.map +1 -1
- package/dist/typography/body_text/body_text.d.ts.map +1 -1
- package/dist/typography/body_text/body_text.js +12 -10
- package/dist/typography/body_text/body_text.js.map +1 -1
- package/dist/utils/dnd/hooks/use_drag_container.d.ts.map +1 -1
- package/dist/utils/dnd/hooks/use_drag_container.js +22 -19
- package/dist/utils/dnd/hooks/use_drag_container.js.map +1 -1
- package/package.json +4 -2
- package/src/form/field/h_field/h_field.tsx +0 -4
- package/src/form/field/v_field/v_field.stories.tsx +8 -0
- package/src/form/field/v_field/v_field.tsx +1 -4
- package/src/form/field_set/field_set.stories.tsx +2 -1
- package/src/inputs/__docs__/inputs.mdx +81 -0
- package/src/inputs/__docs__/inputs.stories.tsx +268 -0
- package/src/inputs/color_input/color_input.tsx +17 -17
- package/src/inputs/combo_box/combo_box.tsx +17 -13
- package/src/inputs/index.ts +2 -0
- package/src/inputs/input/input.tsx +1 -1
- package/src/inputs/input_group/input_group.tsx +26 -0
- package/src/inputs/phone_number_input/countries_phone_information.ts +6 -353
- package/src/inputs/phone_number_input/phone_number_context.tsx +32 -0
- package/src/inputs/phone_number_input/phone_number_country_select_adapter.tsx +126 -0
- package/src/inputs/phone_number_input/phone_number_input.module.css +5 -63
- package/src/inputs/phone_number_input/phone_number_input.stories.tsx +180 -150
- package/src/inputs/phone_number_input/phone_number_input.tsx +133 -400
- package/src/inputs/phone_number_input/phone_number_input_adapter.tsx +123 -0
- package/src/inputs/phone_number_input/sip_input.tsx +147 -0
- package/src/inputs/select/select.tsx +13 -14
- package/src/inputs/suggestions/suggestion_list.module.css +1 -0
- package/src/inputs/suggestions/suggestion_list.stories.tsx +12 -8
- package/src/inputs/suggestions/suggestion_list.tsx +24 -3
- package/src/inputs/textarea/textarea.tsx +1 -1
- package/src/inputs/unit_input/unit_input.tsx +17 -17
- package/src/layouts/__stories__/composed.stories.tsx +0 -55
- package/src/layouts/__stories__/rail.stories.tsx +78 -0
- package/src/layouts/__stories__/scaffold.stories.tsx +90 -0
- package/src/layouts/__stories__/utils/content.tsx +27 -0
- package/src/layouts/__stories__/utils/layout_theme.css +88 -0
- package/src/layouts/__stories__/utils/layout_theme_provider.tsx +11 -0
- package/src/layouts/__stories__/utils.tsx +6 -6
- package/src/layouts/{utility_bar/utility_bar.module.css → bar/bar.module.css} +2 -1
- package/src/layouts/bar/bar.tsx +23 -0
- package/src/layouts/body/body.module.css +9 -4
- package/src/layouts/body/body.tsx +7 -6
- package/src/layouts/body/h_body.module.css +1 -2
- package/src/layouts/body/h_body.tsx +9 -4
- package/src/layouts/body/v_body.tsx +9 -4
- package/src/layouts/divider/divider.module.css +1 -1
- package/src/layouts/footer/footer.module.css +0 -3
- package/src/layouts/footer/footer.tsx +5 -6
- package/src/layouts/header/header.tsx +6 -15
- package/src/layouts/index.ts +0 -1
- package/src/layouts/rail/rail.module.css +9 -5
- package/src/layouts/rail/rail.tsx +1 -1
- package/src/layouts/rail/side/side.module.css +0 -1
- package/src/layouts/rail/side/side.tsx +1 -2
- package/src/layouts/rail/utility_strip/utility_strip.module.css +5 -0
- package/src/layouts/rail/utility_strip/utility_strip.tsx +4 -1
- package/src/layouts/scaffold/scaffold.module.css +10 -7
- package/src/layouts/scaffold/scaffold.tsx +1 -1
- package/src/layouts/utility_bar/utility_bar.tsx +6 -9
- package/src/overlay/frame/frame.module.css +2 -4
- package/src/overlay/frame/frame.stories.tsx +13 -10
- package/src/overlay/frame/frame.tsx +124 -16
- package/src/overlay/popper/base/dismissal_decorator.tsx +1 -1
- package/src/overlay/popper/legacy/popper.tsx +5 -1
- package/src/stacks/box/bottom_resize_handle.tsx +12 -5
- package/src/stacks/box/box.tsx +18 -14
- package/src/stacks/box/end_resize_handle.tsx +11 -6
- package/src/stacks/box/left_resize_handle.tsx +9 -3
- package/src/stacks/box/resize_handlers.ts +27 -13
- package/src/stacks/box/right_resize_handle.tsx +9 -3
- package/src/stacks/box/start_resize_handle.tsx +9 -4
- package/src/stacks/box/top_resize_handle.tsx +10 -4
- package/src/stacks/collapsible_box.stories.tsx +11 -11
- package/src/stacks/h_collapsible_box.tsx +5 -5
- package/src/stacks/v_collapsible_box.tsx +4 -4
- package/src/surfaces/index.ts +1 -2
- package/src/surfaces/panel/__stories__/panel.stories.tsx +12 -12
- package/src/surfaces/panel/__stories__/panel_stories.module.css +3 -3
- package/src/surfaces/panel/panel.module.css +1 -6
- package/src/surfaces/panel/panel.tsx +22 -0
- package/src/surfaces/window/window.tsx +14 -4
- package/src/themes/stories/controls_fieldset.tsx +1 -1
- package/src/themes/stylesheets/reset.css +8 -1
- package/src/themes/theme.tsx +6 -2
- package/src/themes/themes/ergo/__stories__/material.stories.tsx +15 -16
- package/src/themes/themes/ergo/ergo_theme.css +210 -18
- package/src/typography/body_text/body_text.tsx +2 -0
- package/src/utils/dnd/__stories__/draggable.stories.tsx +14 -8
- package/src/utils/dnd/hooks/use_drag_container.ts +13 -3
- package/dist/h_body.css +0 -1
- package/dist/h_panel.css +0 -1
- package/dist/header.css +0 -1
- package/dist/layouts/rail/main/main.d.ts +0 -6
- package/dist/layouts/rail/main/main.d.ts.map +0 -1
- package/dist/layouts/rail/main/main.js +0 -21
- package/dist/layouts/rail/main/main.js.map +0 -1
- package/dist/main.css +0 -1
- package/dist/surfaces/panel/h_panel.d.ts +0 -9
- package/dist/surfaces/panel/h_panel.d.ts.map +0 -1
- package/dist/surfaces/panel/h_panel.js +0 -60
- package/dist/surfaces/panel/h_panel.js.map +0 -1
- package/dist/surfaces/panel/v_panel.d.ts +0 -5
- package/dist/surfaces/panel/v_panel.d.ts.map +0 -1
- package/dist/surfaces/panel/v_panel.js +0 -19
- package/dist/surfaces/panel/v_panel.js.map +0 -1
- package/dist/utility_bar.css +0 -1
- package/dist/v_body.css +0 -1
- package/src/inputs/phone_number_input/__tests__/utils.test.ts +0 -52
- package/src/layouts/header/header.module.css +0 -8
- package/src/layouts/rail/__stories__/rail.stories.tsx +0 -64
- package/src/layouts/rail/__stories__/rail_stories.module.css +0 -25
- package/src/layouts/rail/main/main.module.css +0 -7
- package/src/layouts/rail/main/main.tsx +0 -26
- package/src/layouts/scaffold/__stories__/scaffold.stories.tsx +0 -53
- package/src/layouts/scaffold/__stories__/scaffold_stories.module.css +0 -31
- package/src/surfaces/panel/h_panel.tsx +0 -65
- package/src/surfaces/panel/v_panel.tsx +0 -20
|
@@ -1,44 +1,47 @@
|
|
|
1
|
-
import { useState as s, useRef as
|
|
2
|
-
import { useDraggable as
|
|
3
|
-
function
|
|
4
|
-
const [
|
|
5
|
-
|
|
6
|
-
handles:
|
|
1
|
+
import { useState as s, useRef as y, useCallback as o } from "react";
|
|
2
|
+
import { useDraggable as D } from "./use_draggable.js";
|
|
3
|
+
function C(u) {
|
|
4
|
+
const [l, a] = s([]), n = y(u.initialPosition ?? { x: 0, y: 0 }), [g, i] = s(n.current), [f, c] = s(!1);
|
|
5
|
+
D({
|
|
6
|
+
handles: l,
|
|
7
7
|
startDragCallback: () => {
|
|
8
|
-
|
|
8
|
+
c(!0);
|
|
9
9
|
},
|
|
10
10
|
dragCallback: (t, e) => {
|
|
11
|
-
|
|
11
|
+
i({
|
|
12
12
|
x: n.current.x + t,
|
|
13
13
|
y: n.current.y + e
|
|
14
14
|
});
|
|
15
15
|
},
|
|
16
|
-
endDragCallback: () => {
|
|
17
|
-
|
|
16
|
+
endDragCallback: (t, e) => {
|
|
17
|
+
n.current = {
|
|
18
|
+
x: n.current.x + t,
|
|
19
|
+
y: n.current.y + e
|
|
20
|
+
}, c(!1);
|
|
18
21
|
}
|
|
19
22
|
});
|
|
20
|
-
const
|
|
23
|
+
const x = o(
|
|
21
24
|
(t) => {
|
|
22
|
-
|
|
25
|
+
i((e) => {
|
|
23
26
|
const r = typeof t == "function" ? t(e) : t;
|
|
24
27
|
return n.current = r, r;
|
|
25
28
|
});
|
|
26
29
|
},
|
|
27
30
|
[]
|
|
28
|
-
),
|
|
31
|
+
), d = o((t) => {
|
|
29
32
|
a((e) => [...e, t]);
|
|
30
|
-
}, []),
|
|
33
|
+
}, []), p = o((t) => {
|
|
31
34
|
a((e) => e.filter((r) => r !== t));
|
|
32
35
|
}, []);
|
|
33
36
|
return {
|
|
34
|
-
registerHandle:
|
|
35
|
-
unregisterHandle:
|
|
36
|
-
position:
|
|
37
|
+
registerHandle: d,
|
|
38
|
+
unregisterHandle: p,
|
|
39
|
+
position: g,
|
|
37
40
|
isDragging: f,
|
|
38
|
-
setPosition:
|
|
41
|
+
setPosition: x
|
|
39
42
|
};
|
|
40
43
|
}
|
|
41
44
|
export {
|
|
42
|
-
|
|
45
|
+
C as useMakeDragContainer
|
|
43
46
|
};
|
|
44
47
|
//# sourceMappingURL=use_drag_container.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use_drag_container.js","sources":["../../../../src/utils/dnd/hooks/use_drag_container.ts"],"sourcesContent":["import { useCallback, useRef, useState } from 'react';\nimport {
|
|
1
|
+
{"version":3,"file":"use_drag_container.js","sources":["../../../../src/utils/dnd/hooks/use_drag_container.ts"],"sourcesContent":["import { useCallback, useRef, useState } from 'react';\nimport type { Position } from '../../index.js';\nimport type { DragContainer } from '../types.js';\nimport { useDraggable } from './use_draggable.js';\n\nexport interface UseDragContainerOptions {\n initialPosition?: Position;\n}\n\nexport function useMakeDragContainer(options: UseDragContainerOptions): DragContainer {\n const [handles, setHandles] = useState<React.RefObject<HTMLElement>[]>([]);\n const positionRef = useRef<Position>(options.initialPosition ?? { x: 0, y: 0 });\n /**\n * The value that triggers re-renders. It’s updated in dragCallback so the UI\n * moves while dragging, and it’s what the hook returns so the consumer can\n * render the element at that position\n * (e.g. style={{ left: position.x, top: position.y }}).\n */\n const [position, setPosition] = useState(positionRef.current);\n\n const [isDragging, setIsDragging] = useState(false);\n\n useDraggable({\n handles: handles,\n startDragCallback: () => {\n setIsDragging(true);\n },\n dragCallback: (deltaX, deltaY) => {\n setPosition({\n x: positionRef.current.x + deltaX,\n y: positionRef.current.y + deltaY,\n });\n },\n endDragCallback: (deltaX, deltaY) => {\n positionRef.current = {\n x: positionRef.current.x + deltaX,\n y: positionRef.current.y + deltaY,\n };\n setIsDragging(false);\n },\n });\n\n const setPositionState = useCallback(\n (value: Position | ((prev: Position) => Position)) => {\n setPosition(prev => {\n const next = typeof value === 'function' ? value(prev) : value;\n positionRef.current = next;\n return next;\n });\n },\n []\n );\n\n const registerHandle = useCallback((handle: React.RefObject<HTMLElement>) => {\n setHandles(prev => [...prev, handle]);\n }, []);\n\n const unregisterHandle = useCallback((handle: React.RefObject<HTMLElement>) => {\n setHandles(prev => prev.filter(h => h !== handle));\n }, []);\n\n return {\n registerHandle,\n unregisterHandle,\n position,\n isDragging,\n setPosition: setPositionState,\n };\n}\n"],"names":["useMakeDragContainer","options","handles","setHandles","useState","positionRef","useRef","position","setPosition","isDragging","setIsDragging","useDraggable","deltaX","deltaY","setPositionState","useCallback","value","prev","next","registerHandle","handle","unregisterHandle","h"],"mappings":";;AASO,SAASA,EAAqBC,GAAiD;AACpF,QAAM,CAACC,GAASC,CAAU,IAAIC,EAAyC,CAAA,CAAE,GACnEC,IAAcC,EAAiBL,EAAQ,mBAAmB,EAAE,GAAG,GAAG,GAAG,GAAG,GAOxE,CAACM,GAAUC,CAAW,IAAIJ,EAASC,EAAY,OAAO,GAEtD,CAACI,GAAYC,CAAa,IAAIN,EAAS,EAAK;AAElD,EAAAO,EAAa;AAAA,IACX,SAAAT;AAAA,IACA,mBAAmB,MAAM;AACvB,MAAAQ,EAAc,EAAI;AAAA,IACpB;AAAA,IACA,cAAc,CAACE,GAAQC,MAAW;AAChC,MAAAL,EAAY;AAAA,QACV,GAAGH,EAAY,QAAQ,IAAIO;AAAA,QAC3B,GAAGP,EAAY,QAAQ,IAAIQ;AAAA,MAAA,CAC5B;AAAA,IACH;AAAA,IACA,iBAAiB,CAACD,GAAQC,MAAW;AACnC,MAAAR,EAAY,UAAU;AAAA,QACpB,GAAGA,EAAY,QAAQ,IAAIO;AAAA,QAC3B,GAAGP,EAAY,QAAQ,IAAIQ;AAAA,MAAA,GAE7BH,EAAc,EAAK;AAAA,IACrB;AAAA,EAAA,CACD;AAED,QAAMI,IAAmBC;AAAA,IACvB,CAACC,MAAqD;AACpD,MAAAR,EAAY,CAAAS,MAAQ;AAClB,cAAMC,IAAO,OAAOF,KAAU,aAAaA,EAAMC,CAAI,IAAID;AACzD,eAAAX,EAAY,UAAUa,GACfA;AAAA,MACT,CAAC;AAAA,IACH;AAAA,IACA,CAAA;AAAA,EAAC,GAGGC,IAAiBJ,EAAY,CAACK,MAAyC;AAC3E,IAAAjB,EAAW,CAAAc,MAAQ,CAAC,GAAGA,GAAMG,CAAM,CAAC;AAAA,EACtC,GAAG,CAAA,CAAE,GAECC,IAAmBN,EAAY,CAACK,MAAyC;AAC7E,IAAAjB,EAAW,OAAQc,EAAK,OAAO,CAAAK,MAAKA,MAAMF,CAAM,CAAC;AAAA,EACnD,GAAG,CAAA,CAAE;AAEL,SAAO;AAAA,IACL,gBAAAD;AAAA,IACA,kBAAAE;AAAA,IACA,UAAAd;AAAA,IACA,YAAAE;AAAA,IACA,aAAaK;AAAA,EAAA;AAEjB;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tcn/ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "",
|
|
6
6
|
"author": "TCN",
|
|
@@ -140,8 +140,10 @@
|
|
|
140
140
|
"dependencies": {
|
|
141
141
|
"@fontsource/lato": "^5.2.7",
|
|
142
142
|
"clsx": "^2.1.1",
|
|
143
|
+
"libphonenumber-js": "^1.12.38",
|
|
143
144
|
"react-color": "^2.19.3",
|
|
144
|
-
"
|
|
145
|
+
"react-phone-number-input": "^3.4.16",
|
|
146
|
+
"@tcn/icons": "2.3.0",
|
|
145
147
|
"@tcn/state": "1.2.0"
|
|
146
148
|
},
|
|
147
149
|
"scripts": {
|
|
@@ -33,8 +33,6 @@ export const HField = React.forwardRef(function HField(
|
|
|
33
33
|
ref: React.Ref<HTMLDivElement>
|
|
34
34
|
) {
|
|
35
35
|
const [finalId] = useState(() => id || `h-field-${idIndex++}`);
|
|
36
|
-
const labelId = `${finalId}-label`;
|
|
37
|
-
const descriptionId = `${finalId}-description`;
|
|
38
36
|
const hasError = errorMessage ? true : false;
|
|
39
37
|
const state = locked ? 'locked' : loading ? 'loading' : hasError ? 'error' : 'default';
|
|
40
38
|
|
|
@@ -42,8 +40,6 @@ export const HField = React.forwardRef(function HField(
|
|
|
42
40
|
<HStack
|
|
43
41
|
ref={ref}
|
|
44
42
|
as="div"
|
|
45
|
-
aria-labelledby={labelId}
|
|
46
|
-
aria-describedby={descriptionId}
|
|
47
43
|
data-locked={locked}
|
|
48
44
|
data-error={hasError}
|
|
49
45
|
data-loading={loading}
|
|
@@ -94,6 +94,14 @@ export function Baseline() {
|
|
|
94
94
|
>
|
|
95
95
|
<Input defaultValue="Disabled value" />
|
|
96
96
|
</VField>
|
|
97
|
+
<Divider horizontal />
|
|
98
|
+
<VField
|
|
99
|
+
label="Aria enabled"
|
|
100
|
+
description="This field demonstrates the use of aria-labelledby and aria-describedby."
|
|
101
|
+
id="field-8"
|
|
102
|
+
>
|
|
103
|
+
<Input aria-labelledby="field-8-label" aria-describedby="field-8-description" />
|
|
104
|
+
</VField>
|
|
97
105
|
</FieldSet>
|
|
98
106
|
);
|
|
99
107
|
}
|
|
@@ -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}
|