@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.
Files changed (165) hide show
  1. package/dist/form/field/h_field/h_field.d.ts.map +1 -1
  2. package/dist/form/field/h_field/h_field.js +33 -35
  3. package/dist/form/field/h_field/h_field.js.map +1 -1
  4. package/dist/form/field/v_field/v_field.d.ts.map +1 -1
  5. package/dist/form/field/v_field/v_field.js +34 -36
  6. package/dist/form/field/v_field/v_field.js.map +1 -1
  7. package/dist/frame.css +1 -1
  8. package/dist/inputs/color_input/color_input.d.ts.map +1 -1
  9. package/dist/inputs/color_input/color_input.js +47 -46
  10. package/dist/inputs/color_input/color_input.js.map +1 -1
  11. package/dist/inputs/combo_box/combo_box.d.ts.map +1 -1
  12. package/dist/inputs/combo_box/combo_box.js +61 -58
  13. package/dist/inputs/combo_box/combo_box.js.map +1 -1
  14. package/dist/inputs/index.d.ts +1 -0
  15. package/dist/inputs/index.d.ts.map +1 -1
  16. package/dist/inputs/index.js +34 -31
  17. package/dist/inputs/index.js.map +1 -1
  18. package/dist/inputs/input/input.js +9 -9
  19. package/dist/inputs/input/input.js.map +1 -1
  20. package/dist/inputs/input_group/input_group.d.ts +5 -0
  21. package/dist/inputs/input_group/input_group.d.ts.map +1 -0
  22. package/dist/inputs/input_group/input_group.js +20 -0
  23. package/dist/inputs/input_group/input_group.js.map +1 -0
  24. package/dist/inputs/phone_number_input/countries_phone_information.d.ts +2 -2
  25. package/dist/inputs/phone_number_input/countries_phone_information.d.ts.map +1 -1
  26. package/dist/inputs/phone_number_input/countries_phone_information.js +5 -353
  27. package/dist/inputs/phone_number_input/countries_phone_information.js.map +1 -1
  28. package/dist/inputs/phone_number_input/phone_number_context.d.ts +24 -0
  29. package/dist/inputs/phone_number_input/phone_number_context.d.ts.map +1 -0
  30. package/dist/inputs/phone_number_input/phone_number_context.js +23 -0
  31. package/dist/inputs/phone_number_input/phone_number_context.js.map +1 -0
  32. package/dist/inputs/phone_number_input/phone_number_country_select_adapter.d.ts +19 -0
  33. package/dist/inputs/phone_number_input/phone_number_country_select_adapter.d.ts.map +1 -0
  34. package/dist/inputs/phone_number_input/phone_number_country_select_adapter.js +77 -0
  35. package/dist/inputs/phone_number_input/phone_number_country_select_adapter.js.map +1 -0
  36. package/dist/inputs/phone_number_input/phone_number_input.d.ts +16 -14
  37. package/dist/inputs/phone_number_input/phone_number_input.d.ts.map +1 -1
  38. package/dist/inputs/phone_number_input/phone_number_input.js +104 -274
  39. package/dist/inputs/phone_number_input/phone_number_input.js.map +1 -1
  40. package/dist/inputs/phone_number_input/phone_number_input_adapter.d.ts +6 -0
  41. package/dist/inputs/phone_number_input/phone_number_input_adapter.d.ts.map +1 -0
  42. package/dist/inputs/phone_number_input/phone_number_input_adapter.js +95 -0
  43. package/dist/inputs/phone_number_input/phone_number_input_adapter.js.map +1 -0
  44. package/dist/inputs/phone_number_input/sip_input.d.ts +12 -0
  45. package/dist/inputs/phone_number_input/sip_input.d.ts.map +1 -0
  46. package/dist/inputs/phone_number_input/sip_input.js +111 -0
  47. package/dist/inputs/phone_number_input/sip_input.js.map +1 -0
  48. package/dist/inputs/select/select.d.ts.map +1 -1
  49. package/dist/inputs/select/select.js +3 -2
  50. package/dist/inputs/select/select.js.map +1 -1
  51. package/dist/inputs/suggestions/suggestion_list.d.ts +4 -1
  52. package/dist/inputs/suggestions/suggestion_list.d.ts.map +1 -1
  53. package/dist/inputs/suggestions/suggestion_list.js +120 -111
  54. package/dist/inputs/suggestions/suggestion_list.js.map +1 -1
  55. package/dist/inputs/textarea/textarea.js +8 -8
  56. package/dist/inputs/textarea/textarea.js.map +1 -1
  57. package/dist/inputs/unit_input/unit_input.d.ts.map +1 -1
  58. package/dist/inputs/unit_input/unit_input.js +39 -39
  59. package/dist/inputs/unit_input/unit_input.js.map +1 -1
  60. package/dist/overlay/frame/frame.d.ts +8 -4
  61. package/dist/overlay/frame/frame.d.ts.map +1 -1
  62. package/dist/overlay/frame/frame.js +87 -23
  63. package/dist/overlay/frame/frame.js.map +1 -1
  64. package/dist/overlay/popper/base/dismissal_decorator.js.map +1 -1
  65. package/dist/overlay/popper/legacy/popper.d.ts.map +1 -1
  66. package/dist/overlay/popper/legacy/popper.js +52 -50
  67. package/dist/overlay/popper/legacy/popper.js.map +1 -1
  68. package/dist/phone_number_input.css +1 -1
  69. package/dist/stacks/box/bottom_resize_handle.d.ts +1 -1
  70. package/dist/stacks/box/bottom_resize_handle.d.ts.map +1 -1
  71. package/dist/stacks/box/bottom_resize_handle.js.map +1 -1
  72. package/dist/stacks/box/box.d.ts +2 -2
  73. package/dist/stacks/box/box.d.ts.map +1 -1
  74. package/dist/stacks/box/box.js.map +1 -1
  75. package/dist/stacks/box/end_resize_handle.d.ts +1 -1
  76. package/dist/stacks/box/end_resize_handle.d.ts.map +1 -1
  77. package/dist/stacks/box/end_resize_handle.js.map +1 -1
  78. package/dist/stacks/box/left_resize_handle.d.ts +1 -1
  79. package/dist/stacks/box/left_resize_handle.d.ts.map +1 -1
  80. package/dist/stacks/box/left_resize_handle.js.map +1 -1
  81. package/dist/stacks/box/resize_handlers.d.ts +2 -2
  82. package/dist/stacks/box/resize_handlers.d.ts.map +1 -1
  83. package/dist/stacks/box/resize_handlers.js +32 -32
  84. package/dist/stacks/box/resize_handlers.js.map +1 -1
  85. package/dist/stacks/box/right_resize_handle.d.ts +1 -1
  86. package/dist/stacks/box/right_resize_handle.d.ts.map +1 -1
  87. package/dist/stacks/box/right_resize_handle.js.map +1 -1
  88. package/dist/stacks/box/start_resize_handle.d.ts +1 -1
  89. package/dist/stacks/box/start_resize_handle.d.ts.map +1 -1
  90. package/dist/stacks/box/start_resize_handle.js +4 -4
  91. package/dist/stacks/box/start_resize_handle.js.map +1 -1
  92. package/dist/stacks/box/top_resize_handle.d.ts +1 -1
  93. package/dist/stacks/box/top_resize_handle.d.ts.map +1 -1
  94. package/dist/stacks/box/top_resize_handle.js +4 -4
  95. package/dist/stacks/box/top_resize_handle.js.map +1 -1
  96. package/dist/stacks/h_collapsible_box.js +18 -18
  97. package/dist/stacks/h_collapsible_box.js.map +1 -1
  98. package/dist/stacks/v_collapsible_box.js +18 -18
  99. package/dist/stacks/v_collapsible_box.js.map +1 -1
  100. package/dist/suggestion_list.css +1 -1
  101. package/dist/surfaces/window/window.d.ts +1 -1
  102. package/dist/surfaces/window/window.d.ts.map +1 -1
  103. package/dist/surfaces/window/window.js +20 -10
  104. package/dist/surfaces/window/window.js.map +1 -1
  105. package/dist/themes/stylesheets/reset.css +1 -1
  106. package/dist/themes/stylesheets/reset.js +8 -1
  107. package/dist/themes/stylesheets/reset.js.map +1 -1
  108. package/dist/themes/themes/ergo/ergo_theme.css +1 -1
  109. package/dist/themes/themes/ergo/ergo_theme.js +183 -18
  110. package/dist/themes/themes/ergo/ergo_theme.js.map +1 -1
  111. package/dist/typography/body_text/body_text.d.ts.map +1 -1
  112. package/dist/typography/body_text/body_text.js +12 -10
  113. package/dist/typography/body_text/body_text.js.map +1 -1
  114. package/dist/utils/dnd/hooks/use_drag_container.d.ts.map +1 -1
  115. package/dist/utils/dnd/hooks/use_drag_container.js +22 -19
  116. package/dist/utils/dnd/hooks/use_drag_container.js.map +1 -1
  117. package/package.json +4 -2
  118. package/src/form/field/h_field/h_field.tsx +0 -4
  119. package/src/form/field/v_field/v_field.stories.tsx +8 -0
  120. package/src/form/field/v_field/v_field.tsx +1 -4
  121. package/src/form/field_set/field_set.stories.tsx +2 -1
  122. package/src/inputs/__docs__/inputs.mdx +81 -0
  123. package/src/inputs/__docs__/inputs.stories.tsx +268 -0
  124. package/src/inputs/color_input/color_input.tsx +17 -17
  125. package/src/inputs/combo_box/combo_box.tsx +17 -13
  126. package/src/inputs/index.ts +2 -0
  127. package/src/inputs/input/input.tsx +1 -1
  128. package/src/inputs/input_group/input_group.tsx +26 -0
  129. package/src/inputs/phone_number_input/countries_phone_information.ts +6 -353
  130. package/src/inputs/phone_number_input/phone_number_context.tsx +32 -0
  131. package/src/inputs/phone_number_input/phone_number_country_select_adapter.tsx +126 -0
  132. package/src/inputs/phone_number_input/phone_number_input.module.css +5 -63
  133. package/src/inputs/phone_number_input/phone_number_input.stories.tsx +180 -150
  134. package/src/inputs/phone_number_input/phone_number_input.tsx +133 -400
  135. package/src/inputs/phone_number_input/phone_number_input_adapter.tsx +123 -0
  136. package/src/inputs/phone_number_input/sip_input.tsx +147 -0
  137. package/src/inputs/select/select.tsx +13 -14
  138. package/src/inputs/suggestions/suggestion_list.module.css +1 -0
  139. package/src/inputs/suggestions/suggestion_list.stories.tsx +12 -8
  140. package/src/inputs/suggestions/suggestion_list.tsx +24 -3
  141. package/src/inputs/textarea/textarea.tsx +1 -1
  142. package/src/inputs/unit_input/unit_input.tsx +17 -17
  143. package/src/overlay/frame/frame.module.css +2 -4
  144. package/src/overlay/frame/frame.stories.tsx +13 -10
  145. package/src/overlay/frame/frame.tsx +123 -15
  146. package/src/overlay/popper/base/dismissal_decorator.tsx +1 -1
  147. package/src/overlay/popper/legacy/popper.tsx +5 -1
  148. package/src/stacks/box/bottom_resize_handle.tsx +6 -1
  149. package/src/stacks/box/box.tsx +12 -2
  150. package/src/stacks/box/end_resize_handle.tsx +6 -1
  151. package/src/stacks/box/left_resize_handle.tsx +6 -1
  152. package/src/stacks/box/resize_handlers.ts +20 -8
  153. package/src/stacks/box/right_resize_handle.tsx +6 -1
  154. package/src/stacks/box/start_resize_handle.tsx +7 -2
  155. package/src/stacks/box/top_resize_handle.tsx +7 -2
  156. package/src/stacks/h_collapsible_box.tsx +2 -2
  157. package/src/stacks/v_collapsible_box.tsx +2 -2
  158. package/src/surfaces/window/window.tsx +14 -4
  159. package/src/themes/stories/controls_fieldset.tsx +1 -1
  160. package/src/themes/stylesheets/reset.css +8 -1
  161. package/src/themes/themes/ergo/ergo_theme.css +183 -18
  162. package/src/typography/body_text/body_text.tsx +2 -0
  163. package/src/utils/dnd/__stories__/draggable.stories.tsx +14 -8
  164. package/src/utils/dnd/hooks/use_drag_container.ts +13 -3
  165. package/src/inputs/phone_number_input/__tests__/utils.test.ts +0 -52
@@ -152,13 +152,17 @@ export function Popper({
152
152
  };
153
153
 
154
154
  useLayoutEffect(() => {
155
- updatePosition();
156
155
  window.addEventListener('resize', updatePosition);
157
156
  return () => {
158
157
  window.removeEventListener('resize', updatePosition);
159
158
  };
160
159
  });
161
160
 
161
+ // biome-ignore lint/correctness/useExhaustiveDependencies: updatePosition depends on open and anchorElement
162
+ useLayoutEffect(() => {
163
+ updatePosition();
164
+ }, [open, anchorElement]);
165
+
162
166
  useLayoutEffect(() => {
163
167
  if (open) {
164
168
  activeElementRef.current = window.document.activeElement as HTMLElement;
@@ -7,7 +7,12 @@ import { createVerticalResizeHandler } from './resize_handlers.js';
7
7
  export interface BottomResizeHandleProps {
8
8
  targetRef: React.MutableRefObject<HTMLElement | null>;
9
9
  handleProps?: HandleProps;
10
- onHeightResize?: (height: number, origin: 'top' | 'bottom', delta: number) => void;
10
+ onHeightResize?: (
11
+ height: number,
12
+ origin: 'top' | 'bottom',
13
+ totalDelta: number,
14
+ currentDelta: number
15
+ ) => void;
11
16
  onHeightResizeEnd?: (height: number, origin: 'top' | 'bottom') => void;
12
17
  }
13
18
 
@@ -45,8 +45,18 @@ export interface BoxProps<T extends HTMLElement = HTMLElement> extends HTMLAttri
45
45
  enableResizeOnRight?: boolean;
46
46
  horizontalHandleProps?: HandleProps;
47
47
  verticalHandleProps?: HandleProps;
48
- onWidthResize?: (width: number, origin: 'left' | 'right', delta: number) => void;
49
- onHeightResize?: (height: number, origin: 'top' | 'bottom', delta: number) => void;
48
+ onWidthResize?: (
49
+ width: number,
50
+ origin: 'left' | 'right',
51
+ totalDelta: number,
52
+ currentDelta: number
53
+ ) => void;
54
+ onHeightResize?: (
55
+ height: number,
56
+ origin: 'top' | 'bottom',
57
+ totalDelta: number,
58
+ currentDelta: number
59
+ ) => void;
50
60
  onWidthResizeEnd?: (width: number, origin: 'left' | 'right') => void;
51
61
  onHeightResizeEnd?: (height: number, origin: 'top' | 'bottom') => void;
52
62
  }
@@ -7,7 +7,12 @@ import { createHorizontalResizeHandler } from './resize_handlers.js';
7
7
  export interface EndResizeHandleProps {
8
8
  targetRef: React.MutableRefObject<HTMLElement | null>;
9
9
  handleProps?: HandleProps;
10
- onWidthResize?: (width: number, origin: 'left' | 'right', delta: number) => void;
10
+ onWidthResize?: (
11
+ width: number,
12
+ origin: 'left' | 'right',
13
+ totalDelta: number,
14
+ currentDelta: number
15
+ ) => void;
11
16
  onWidthResizeEnd?: (width: number, origin: 'left' | 'right') => void;
12
17
  }
13
18
  export function EndResizeHandle({
@@ -7,7 +7,12 @@ import { createHorizontalResizeHandler } from './resize_handlers.js';
7
7
  export interface LeftResizeHandleProps {
8
8
  targetRef: React.MutableRefObject<HTMLElement | null>;
9
9
  handleProps?: HandleProps;
10
- onWidthResize?: (width: number, origin: 'left' | 'right', delta: number) => void;
10
+ onWidthResize?: (
11
+ width: number,
12
+ origin: 'left' | 'right',
13
+ totalDelta: number,
14
+ currentDelta: number
15
+ ) => void;
11
16
  onWidthResizeEnd?: (width: number, origin: 'left' | 'right') => void;
12
17
  }
13
18
  export function LeftResizeHandle({
@@ -9,7 +9,12 @@ function createVeil() {
9
9
 
10
10
  export function createHorizontalResizeHandler(
11
11
  targetRef: React.MutableRefObject<HTMLElement | null>,
12
- onWidthResize?: (width: number, origin: 'left' | 'right', delta: number) => void,
12
+ onWidthResize?: (
13
+ width: number,
14
+ origin: 'left' | 'right',
15
+ totalDelta: number,
16
+ currentDelta: number
17
+ ) => void,
13
18
  onWidthResizeEnd?: (width: number, origin: 'left' | 'right') => void,
14
19
  origin: 'left' | 'right' = 'right',
15
20
  invert = false,
@@ -35,13 +40,14 @@ export function createHorizontalResizeHandler(
35
40
  let width = startRect.width;
36
41
 
37
42
  const drag = (event: MouseEvent) => {
38
- const deltaX = direction * (event.clientX - startX);
39
- const newWidth = startRect.width + deltaX;
43
+ const totalDelta = direction * (event.clientX - startX);
44
+ const newWidth = startRect.width + totalDelta;
45
+ const currentDelta = newWidth - width;
40
46
 
41
47
  width = newWidth;
42
48
 
43
49
  box.style.width = `${newWidth}px`;
44
- onWidthResize?.(newWidth, origin, deltaX);
50
+ onWidthResize?.(newWidth, origin, totalDelta, currentDelta);
45
51
  event.stopPropagation();
46
52
  event.preventDefault();
47
53
  };
@@ -74,7 +80,12 @@ export function createHorizontalResizeHandler(
74
80
 
75
81
  export function createVerticalResizeHandler(
76
82
  targetRef: React.MutableRefObject<HTMLElement | null>,
77
- onHeightResize?: (height: number, origin: 'top' | 'bottom', delta: number) => void,
83
+ onHeightResize?: (
84
+ height: number,
85
+ origin: 'top' | 'bottom',
86
+ totalDelta: number,
87
+ currentDelta: number
88
+ ) => void,
78
89
  onHeightResizeEnd?: (height: number, origin: 'top' | 'bottom') => void,
79
90
  invert = false,
80
91
  origin: 'top' | 'bottom' = 'bottom'
@@ -95,11 +106,12 @@ export function createVerticalResizeHandler(
95
106
  let height = startRect.height;
96
107
 
97
108
  const drag = (event: MouseEvent) => {
98
- const deltaY = direction * (event.clientY - startY);
99
- const newHeight = startRect.height + deltaY;
109
+ const totalDelta = direction * (event.clientY - startY);
110
+ const newHeight = startRect.height + totalDelta;
111
+ const currentDelta = newHeight - height;
100
112
  height = newHeight;
101
113
  box.style.height = `${newHeight}px`;
102
- onHeightResize?.(newHeight, origin, deltaY);
114
+ onHeightResize?.(newHeight, origin, totalDelta, currentDelta);
103
115
  event.stopPropagation();
104
116
  event.preventDefault();
105
117
  };
@@ -7,7 +7,12 @@ import styles from './right_resize_handle.module.css';
7
7
  export interface RightResizeHandleProps {
8
8
  targetRef: React.MutableRefObject<HTMLElement | null>;
9
9
  handleProps?: HandleProps;
10
- onWidthResize?: (width: number, origin: 'left' | 'right', delta: number) => void;
10
+ onWidthResize?: (
11
+ width: number,
12
+ origin: 'left' | 'right',
13
+ totalDelta: number,
14
+ currentDelta: number
15
+ ) => void;
11
16
  onWidthResizeEnd?: (width: number, origin: 'left' | 'right') => void;
12
17
  }
13
18
  export function RightResizeHandle({
@@ -1,13 +1,18 @@
1
+ import { clsx } from 'clsx';
1
2
  import React from 'react';
2
3
  import { HandleProps } from './handle_props.js';
3
4
  import { createHorizontalResizeHandler } from './resize_handlers.js';
4
5
  import styles from './start_resize_handle.module.css';
5
- import { clsx } from 'clsx';
6
6
 
7
7
  export interface StartResizeHandleProps {
8
8
  targetRef: React.MutableRefObject<HTMLElement | null>;
9
9
  handleProps?: HandleProps;
10
- onWidthResize?: (width: number, origin: 'left' | 'right', delta: number) => void;
10
+ onWidthResize?: (
11
+ width: number,
12
+ origin: 'left' | 'right',
13
+ totalDelta: number,
14
+ currentDelta: number
15
+ ) => void;
11
16
  onWidthResizeEnd?: (width: number, origin: 'left' | 'right') => void;
12
17
  }
13
18
  export function StartResizeHandle({
@@ -1,13 +1,18 @@
1
+ import { clsx } from 'clsx';
1
2
  import React from 'react';
2
3
  import { HandleProps } from './handle_props.js';
3
4
  import { createVerticalResizeHandler } from './resize_handlers.js';
4
5
  import styles from './top_resize_handle.module.css';
5
- import { clsx } from 'clsx';
6
6
 
7
7
  export interface TopResizeHandleProps {
8
8
  targetRef: React.MutableRefObject<HTMLElement | null>;
9
9
  handleProps?: HandleProps;
10
- onHeightResize?: (height: number, origin: 'top' | 'bottom', delta: number) => void;
10
+ onHeightResize?: (
11
+ height: number,
12
+ origin: 'top' | 'bottom',
13
+ totalDelta: number,
14
+ currentDelta: number
15
+ ) => void;
11
16
  onHeightResizeEnd?: (height: number, origin: 'top' | 'bottom') => void;
12
17
  }
13
18
  export function TopResizeHandle({
@@ -32,9 +32,9 @@ export const HCollapsibleBox = React.forwardRef(function CollapsibleBox(
32
32
  data-is-collapsed={!open}
33
33
  data-collapse-orientation="horizontal"
34
34
  data-is-resizing={resizing}
35
- onWidthResize={(width, origin, delta) => {
35
+ onWidthResize={(width, origin, totalDelta, currentDelta) => {
36
36
  setIsResizing(true);
37
- props.onWidthResize?.(width, origin, delta);
37
+ props.onWidthResize?.(width, origin, totalDelta, currentDelta);
38
38
  }}
39
39
  onWidthResizeEnd={(width, origin) => {
40
40
  setIsResizing(false);
@@ -32,9 +32,9 @@ export const VCollapsibleBox = React.forwardRef(function CollapsibleBox(
32
32
  data-is-collapsed={!open}
33
33
  data-collapse-orientation="vertical"
34
34
  data-is-resizing={resizing}
35
- onHeightResize={(height, origin, delta) => {
35
+ onHeightResize={(height, origin, totalDelta, currentDelta) => {
36
36
  setIsResizing(true);
37
- props.onHeightResize?.(height, origin, delta);
37
+ props.onHeightResize?.(height, origin, totalDelta, currentDelta);
38
38
  }}
39
39
  onHeightResizeEnd={(height, origin) => {
40
40
  setIsResizing(false);
@@ -1,7 +1,7 @@
1
1
  import { clsx } from 'clsx';
2
2
  import React from 'react';
3
- import { Frame, type FrameOwnProps } from '../../overlay/frame/frame.js';
4
3
  import { Scaffold, type ScaffoldProps } from '../../layouts/scaffold/scaffold.js';
4
+ import { Frame, type FrameOwnProps } from '../../overlay/frame/frame.js';
5
5
 
6
6
  // Styles
7
7
  import styles from './window.module.css';
@@ -9,7 +9,17 @@ import styles from './window.module.css';
9
9
  export type WindowProps = FrameOwnProps & ScaffoldProps;
10
10
 
11
11
  export const Window = React.forwardRef<HTMLElement, WindowProps>(function Window(
12
- { children, className, isOpen, draggable = true, veil = false, ...props }: WindowProps,
12
+ {
13
+ children,
14
+ className,
15
+ isOpen,
16
+ draggable = true,
17
+ resizable = true,
18
+ veil = false,
19
+ width,
20
+ height,
21
+ ...props
22
+ }: WindowProps,
13
23
  ref
14
24
  ) {
15
25
  return (
@@ -18,8 +28,8 @@ export const Window = React.forwardRef<HTMLElement, WindowProps>(function Window
18
28
  draggable={draggable}
19
29
  veil={veil}
20
30
  className={clsx(styles['window'], 'tcn-surface', 'tcn-window', className)}
21
- width="auto"
22
- height="auto"
31
+ width={width}
32
+ height={height}
23
33
  >
24
34
  <Scaffold ref={ref} {...props}>
25
35
  {children}
@@ -30,7 +30,7 @@ export function ControlsFieldSet() {
30
30
  const [datePickerValueWithTime, setDatePickerValueWithTime] = useState<Date | null>(
31
31
  null
32
32
  );
33
- const [phoneNumberValue, setPhoneNumberValue] = useState<string>('');
33
+ const [phoneNumberValue, setPhoneNumberValue] = useState<string | undefined>(undefined);
34
34
 
35
35
  // Additional input state
36
36
  const [checkboxValue, setCheckboxValue] = useState<boolean>(false);
@@ -81,7 +81,8 @@
81
81
  mark,
82
82
  audio,
83
83
  button,
84
- video {
84
+ video,
85
+ dialog {
85
86
  margin: 0;
86
87
  padding: 0;
87
88
  border: 0;
@@ -134,4 +135,10 @@
134
135
  font: inherit;
135
136
  color: inherit;
136
137
  }
138
+ dialog {
139
+ max-width: none;
140
+ max-height: none;
141
+ background: transparent;
142
+ color: inherit;
143
+ }
137
144
  }
@@ -63,6 +63,10 @@
63
63
  --bar-lg: 40px;
64
64
  --bar-xl: 48px;
65
65
 
66
+ --action-sm: 20px;
67
+ --action-md: 24px;
68
+ --action-lg: 32px;
69
+
66
70
  /* Status Colors */
67
71
  --status-color-disabled: var(--ergo-grey-light);
68
72
  --status-color-info: var(--ergo-status-blue);
@@ -187,7 +191,6 @@
187
191
  * Primarily manages button dimensions and sizing ratios.
188
192
  */
189
193
  .tcn-base-button {
190
- /* TODO: btn size should look for "--tcn-action-size" variable before defaulting. */
191
194
  --btn-size-base: 26px;
192
195
  --btn-pad-base: 12px;
193
196
 
@@ -307,21 +310,23 @@
307
310
  box-shadow: 0px 4px 4px 0px rgba(0, 0, 0, 0.12);
308
311
 
309
312
  /* Increases the clickable area by 2px on hover to avoid click events not firing due to the button transform y - or slight mouse wiggles */
310
- &::before,
311
- &::after {
312
- content: "";
313
- position: absolute;
314
- left: 0;
315
- right: 0;
316
- height: 4px;
317
- }
318
-
319
- &::before {
320
- top: -2px;
321
- }
322
-
323
- &::after {
324
- bottom: -2px;
313
+ :not(.tcn-select) {
314
+ &::before,
315
+ &::after {
316
+ content: "";
317
+ position: absolute;
318
+ left: 0;
319
+ right: 0;
320
+ height: 4px;
321
+ }
322
+
323
+ &::before {
324
+ top: -2px;
325
+ }
326
+
327
+ &::after {
328
+ bottom: -2px;
329
+ }
325
330
  }
326
331
  }
327
332
 
@@ -598,8 +603,8 @@
598
603
  }
599
604
  }
600
605
 
601
- .tcn-frame[data-is-veil="true"] {
602
- background-color: rgba(0, 0, 0, 0.5);
606
+ .tcn-frame-dialog {
607
+ border: inherit;
603
608
  }
604
609
 
605
610
  .tcn-tooltip {
@@ -1025,4 +1030,164 @@
1025
1030
  color: var(--on-material);
1026
1031
  }
1027
1032
  }
1033
+
1034
+ /* ===== INPUTS ===== */
1035
+ .tcn-control {
1036
+ --act: var(--action);
1037
+ --mat: var(--material);
1038
+ --act-raised: color-mix(in srgb, var(--mat), var(--act) 12%);
1039
+
1040
+ font-size: 12px;
1041
+ border: 1px solid var(--ergo-grey);
1042
+ box-sizing: border-box;
1043
+ min-height: var(--action-md);
1044
+ border-radius: var(--shape-radius-medium);
1045
+ padding-inline: 4px;
1046
+ }
1047
+
1048
+ .tcn-control[data-is-disabled="false"]:hover {
1049
+ background: var(--act-raised);
1050
+ }
1051
+
1052
+ .tcn-control:focus-visible {
1053
+ outline: 2px solid var(--ergo-primary);
1054
+ outline-offset: 2px;
1055
+ }
1056
+
1057
+ .tcn-control:focus {
1058
+ border: 1px solid var(--act);
1059
+ }
1060
+
1061
+ .tcn-control::placeholder {
1062
+ color: var(--ergo-grey);
1063
+ }
1064
+
1065
+ .tcn-control[data-is-disabled="true"] {
1066
+ cursor: not-allowed;
1067
+ background: var(--material-disabled);
1068
+ color: var(--on-material-disabled);
1069
+ }
1070
+
1071
+ .tcn-control[data-is-disabled="true"]::placeholder {
1072
+ color: var(--on-material-disabled);
1073
+ }
1074
+
1075
+ .tcn-input {
1076
+ height: auto;
1077
+ }
1078
+
1079
+ .tcn-textarea,
1080
+ .tcn-input {
1081
+ cursor: text;
1082
+ }
1083
+
1084
+ .tcn-input-group {
1085
+ border-radius: var(--shape-radius-medium);
1086
+
1087
+ &:focus-within {
1088
+ outline: 2px solid var(--ergo-primary);
1089
+ outline-offset: 2px;
1090
+ }
1091
+
1092
+ .tcn-input-group-slot {
1093
+ z-index: 1;
1094
+ border-radius: 0;
1095
+ height: auto;
1096
+ min-height: var(--action-md);
1097
+ padding-block: 0;
1098
+ &:focus,
1099
+ &:focus-visible {
1100
+ z-index: 3;
1101
+ outline: none;
1102
+ }
1103
+ }
1104
+
1105
+ .tcn-input-group-slot:first-child {
1106
+ border-top-left-radius: var(--shape-radius-medium);
1107
+ border-bottom-left-radius: var(--shape-radius-medium);
1108
+ }
1109
+
1110
+ .tcn-input-group-slot:not(:last-child) {
1111
+ margin-right: -1px;
1112
+ }
1113
+
1114
+ .tcn-input-group-slot:last-child {
1115
+ border-top-right-radius: var(--shape-radius-medium);
1116
+ border-bottom-right-radius: var(--shape-radius-medium);
1117
+ }
1118
+
1119
+ .tcn-select,
1120
+ .tcn-button,
1121
+ .tcn-button[data-hierarchy] {
1122
+ border: 1px solid var(--ergo-grey);
1123
+ height: auto;
1124
+ min-height: var(--action-md);
1125
+ min-width: var(--action-md);
1126
+ box-sizing: border-box;
1127
+ &:hover,
1128
+ &[data-hover] {
1129
+ transform: none;
1130
+ }
1131
+ }
1132
+
1133
+ .tcn-select:focus-visible,
1134
+ .tcn-button:focus-visible,
1135
+ .tcn-button[data-hierarchy]:focus-visible {
1136
+ border-color: var(--ergo-primary);
1137
+ }
1138
+ }
1139
+
1140
+ .tcn-slider[data-is-disabled="true"] {
1141
+ &::-webkit-slider-runnable-track {
1142
+ background: var(--ergo-grey-light);
1143
+ }
1144
+
1145
+ &::-webkit-slider-thumb {
1146
+ background-color: var(--ergo-white);
1147
+ border: 1px solid var(--ergo-grey-light);
1148
+ }
1149
+ }
1150
+
1151
+ .tcn-checkbox {
1152
+ border-color: var(--ergo-primary);
1153
+
1154
+ &:focus-visible,
1155
+ &:focus {
1156
+ outline: 2px solid var(--ergo-primary);
1157
+ outline-offset: 2px;
1158
+ }
1159
+
1160
+ &[data-is-disabled="true"] {
1161
+ cursor: not-allowed;
1162
+ border-color: var(--material-disabled);
1163
+ }
1164
+
1165
+ &[data-checked="true"][data-is-disabled="true"] {
1166
+ background-color: var(--ergo-grey-light);
1167
+ }
1168
+
1169
+ &[data-checked="false"][data-is-disabled="true"] {
1170
+ background: var(--material);
1171
+ border-color: var(--ergo-grey-light);
1172
+ color: var(--ergo-grey-light);
1173
+ }
1174
+ }
1175
+
1176
+ .tcn-switch-wrapper[data-focused="true"][data-is-checked="false"],
1177
+ .tcn-switch-wrapper[data-focused="true"][data-is-checked="true"] {
1178
+ outline: 2px solid var(--ergo-primary);
1179
+ outline-offset: 2px;
1180
+ }
1181
+
1182
+ /* Quick fix to use some of the default module styles.*/
1183
+ .tcn-input,
1184
+ .tcn-select,
1185
+ .tcn-slider,
1186
+ .tcn-checkbox,
1187
+ .tcn-switch-wrapper,
1188
+ .tcn-date-picker,
1189
+ .tcn-date-picker-year-selector,
1190
+ .tcn-radio {
1191
+ --accent-color: var(--ergo-primary);
1192
+ }
1028
1193
  }
@@ -36,6 +36,7 @@ export const BodyText = React.forwardRef<HTMLDivElement, BodyTextProps>(function
36
36
  pad,
37
37
  selectable = true,
38
38
  breakWords = false,
39
+ ...props
39
40
  }: BodyTextProps,
40
41
  ref
41
42
  ) {
@@ -73,6 +74,7 @@ export const BodyText = React.forwardRef<HTMLDivElement, BodyTextProps>(function
73
74
  style={style}
74
75
  data-size={size}
75
76
  data-word-break={breakWords}
77
+ {...props}
76
78
  >
77
79
  {children}
78
80
  </div>
@@ -1,10 +1,11 @@
1
- import { Draggable } from '../draggable/draggable.js';
2
- import { useDragContainer } from '../context.js';
3
- import { VStack } from '../../../stacks/v_stack.js';
4
- import { DragHandle } from '../handle.js';
1
+ import { Button } from '../../../actions/button/button/button.js';
5
2
  import { Box } from '../../../stacks/box/box.js';
3
+ import { VStack } from '../../../stacks/v_stack.js';
4
+ import { ZStack } from '../../../stacks/z_stack.js';
6
5
  import { BodyText } from '../../../typography/index.js';
7
- import { Button } from '../../../actions/button/button/button.js';
6
+ import { useDragContainer } from '../context.js';
7
+ import { Draggable } from '../draggable/draggable.js';
8
+ import { DragHandle } from '../handle.js';
8
9
  import styles from './draggable_stories.module.css';
9
10
 
10
11
  export default {
@@ -60,13 +61,18 @@ function ResetPositionButton() {
60
61
 
61
62
  export const WithSetPosition = () => {
62
63
  return (
63
- <VStack minHeight="600px" height="100%" width="100%" gap="8px">
64
+ <ZStack minHeight="600px" height="100%" width="100%">
64
65
  <BodyText>
65
66
  Drag the box, then click &quot;Reset position&quot; to move it back to (0, 0).
66
67
  Dragging again should start from the new position.
67
68
  </BodyText>
68
69
  <Draggable>
69
- <Box width="400px" height="300px" className={styles['handle-container']}>
70
+ <Box
71
+ as="dialog"
72
+ width="400px"
73
+ height="300px"
74
+ className={styles['handle-container']}
75
+ >
70
76
  <VStack gap="8px" padding="8px">
71
77
  <DragHandle>
72
78
  <Box className={styles.handle} width="120px" padding="8px">
@@ -77,6 +83,6 @@ export const WithSetPosition = () => {
77
83
  </VStack>
78
84
  </Box>
79
85
  </Draggable>
80
- </VStack>
86
+ </ZStack>
81
87
  );
82
88
  };
@@ -1,7 +1,7 @@
1
1
  import { useCallback, useRef, useState } from 'react';
2
- import { useDraggable } from './use_draggable.js';
3
2
  import type { Position } from '../../index.js';
4
3
  import type { DragContainer } from '../types.js';
4
+ import { useDraggable } from './use_draggable.js';
5
5
 
6
6
  export interface UseDragContainerOptions {
7
7
  initialPosition?: Position;
@@ -10,7 +10,14 @@ export interface UseDragContainerOptions {
10
10
  export function useMakeDragContainer(options: UseDragContainerOptions): DragContainer {
11
11
  const [handles, setHandles] = useState<React.RefObject<HTMLElement>[]>([]);
12
12
  const positionRef = useRef<Position>(options.initialPosition ?? { x: 0, y: 0 });
13
+ /**
14
+ * The value that triggers re-renders. It’s updated in dragCallback so the UI
15
+ * moves while dragging, and it’s what the hook returns so the consumer can
16
+ * render the element at that position
17
+ * (e.g. style={{ left: position.x, top: position.y }}).
18
+ */
13
19
  const [position, setPosition] = useState(positionRef.current);
20
+
14
21
  const [isDragging, setIsDragging] = useState(false);
15
22
 
16
23
  useDraggable({
@@ -24,9 +31,12 @@ export function useMakeDragContainer(options: UseDragContainerOptions): DragCont
24
31
  y: positionRef.current.y + deltaY,
25
32
  });
26
33
  },
27
- endDragCallback: () => {
34
+ endDragCallback: (deltaX, deltaY) => {
35
+ positionRef.current = {
36
+ x: positionRef.current.x + deltaX,
37
+ y: positionRef.current.y + deltaY,
38
+ };
28
39
  setIsDragging(false);
29
- positionRef.current = position;
30
40
  },
31
41
  });
32
42