@choice-ui/react 2.0.0 → 2.0.2

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 (53) hide show
  1. package/dist/components/button/dist/index.d.ts +2 -9
  2. package/dist/components/button/dist/index.js +45 -19
  3. package/dist/components/checkbox/dist/index.d.ts +10 -1
  4. package/dist/components/checkbox/dist/index.js +49 -5
  5. package/dist/components/code-block/dist/index.d.ts +11 -14
  6. package/dist/components/code-block/dist/index.js +120 -93
  7. package/dist/components/colors/dist/index.d.ts +39 -6
  8. package/dist/components/colors/src/color-image-paint/color-image-paint.js +2 -2
  9. package/dist/components/dropdown/dist/index.d.ts +6 -0
  10. package/dist/components/dropdown/dist/index.js +20 -10
  11. package/dist/components/emoji-picker/dist/index.d.ts +30 -1
  12. package/dist/components/emoji-picker/dist/index.js +148 -44
  13. package/dist/components/form/src/adapters/range-adapter.js +2 -2
  14. package/dist/components/icon-button/dist/index.d.ts +1 -1
  15. package/dist/components/icon-button/dist/index.js +39 -0
  16. package/dist/components/list/dist/index.d.ts +1 -1
  17. package/dist/components/md-render/dist/index.d.ts +2 -1
  18. package/dist/components/md-render/dist/index.js +5 -9
  19. package/dist/components/md-render/src/components/markdown-block.d.ts +3 -0
  20. package/dist/components/md-render/src/md-render.js +4 -0
  21. package/dist/components/md-render/src/types.d.ts +3 -0
  22. package/dist/components/menus/dist/index.d.ts +5 -0
  23. package/dist/components/menus/dist/index.js +32 -3
  24. package/dist/components/modal/dist/index.js +2 -2
  25. package/dist/components/notifications/dist/index.d.ts +1 -5
  26. package/dist/components/numeric-input/dist/index.d.ts +27 -10
  27. package/dist/components/numeric-input/dist/index.js +132 -34
  28. package/dist/components/numeric-input/src/hooks/use-input-interactions.d.ts +3 -1
  29. package/dist/components/numeric-input/src/hooks/use-input-interactions.js +7 -3
  30. package/dist/components/numeric-input/src/hooks/use-numeric-input.js +15 -4
  31. package/dist/components/numeric-input/src/numeric-input.js +5 -4
  32. package/dist/components/numeric-input/src/utils/value-comparator.js +1 -5
  33. package/dist/components/panel/dist/index.d.ts +16 -16
  34. package/dist/components/picture-preview/dist/index.d.ts +5 -0
  35. package/dist/components/picture-preview/dist/index.js +287 -140
  36. package/dist/components/popover/dist/index.d.ts +5 -0
  37. package/dist/components/popover/dist/index.js +21 -2
  38. package/dist/components/radio/dist/index.d.ts +9 -1
  39. package/dist/components/radio/dist/index.js +50 -6
  40. package/dist/components/range/dist/index.d.ts +276 -20
  41. package/dist/components/range/dist/index.js +1030 -602
  42. package/dist/components/scroll-area/dist/index.d.ts +4 -27
  43. package/dist/components/scroll-area/dist/index.js +96 -123
  44. package/dist/components/separator/dist/index.d.ts +1 -8
  45. package/dist/components/splitter/dist/index.d.ts +1 -1
  46. package/dist/components/text-field/dist/index.d.ts +2 -3
  47. package/dist/components/text-field/dist/index.js +4 -19
  48. package/dist/components/textarea/dist/index.js +3 -1
  49. package/dist/components/toast/dist/index.d.ts +274 -0
  50. package/dist/components/tooltip/dist/index.d.ts +2 -0
  51. package/dist/components/tooltip/dist/index.js +23 -5
  52. package/dist/components/virtual-select/dist/index.d.ts +48 -0
  53. package/package.json +3 -3
@@ -15,7 +15,7 @@ var ModalTv = tcv({
15
15
  });
16
16
  var ModalHeaderTv = tcv({
17
17
  slots: {
18
- root: "modal__header border-default-boundary w-full flex-none items-center border-b",
18
+ root: ["modal__header", "grid border-default-boundary w-full flex-none items-center border-b"],
19
19
  title: "text-body-medium flex min-w-0 items-center gap-2 p-2 font-strong [grid-area:title] select-none",
20
20
  close: "p-2 [grid-area:close]"
21
21
  },
@@ -30,7 +30,7 @@ var ModalHeaderTv = tcv({
30
30
  },
31
31
  close: {
32
32
  true: {
33
- root: "modal__header--action"
33
+ root: "grid-cols-[auto_1fr_2.5rem]"
34
34
  },
35
35
  false: {}
36
36
  }
@@ -1,7 +1,4 @@
1
1
  import { ToasterProps } from 'sonner';
2
- import * as react from 'react';
3
- import * as react_jsx_runtime from 'react/jsx-runtime';
4
-
5
2
  interface NotificationsProps extends Omit<ToasterProps, "id"> {
6
3
  actions?: (id: string | number) => {
7
4
  action?: {
@@ -20,7 +17,6 @@ interface NotificationsProps extends Omit<ToasterProps, "id"> {
20
17
  text?: string;
21
18
  toasterId?: string;
22
19
  }
23
- declare const Toast: react.MemoExoticComponent<(props: NotificationsProps) => react_jsx_runtime.JSX.Element>;
24
20
  declare function notifications(toast: Omit<NotificationsProps, "id">): string | number;
25
21
 
26
- export { type NotificationsProps, Toast, notifications };
22
+ export { type NotificationsProps, notifications };
@@ -1,8 +1,8 @@
1
1
  import { TooltipProps } from '../../tooltip/src';
2
- import { default as react__default, ReactNode, HTMLProps } from 'react';
2
+ import { default as React__default, ReactNode, HTMLProps } from 'react';
3
3
  import { IconButtonProps } from '../../icon-button/src';
4
4
  import { PressMoveProps } from '../../../../../shared/src';
5
- import * as react from 'react';
5
+ import * as React$1 from 'react';
6
6
 
7
7
  type ElementType = "action" | "handler" | "menu";
8
8
  interface NumericInputElementProps {
@@ -11,18 +11,18 @@ interface NumericInputElementProps {
11
11
  position?: "prefix" | "suffix";
12
12
  type?: ElementType;
13
13
  }
14
- declare const NumericInputElement: react.MemoExoticComponent<react.ForwardRefExoticComponent<NumericInputElementProps & react.RefAttributes<HTMLDivElement>>>;
14
+ declare const NumericInputElement: React$1.MemoExoticComponent<React$1.ForwardRefExoticComponent<NumericInputElementProps & React$1.RefAttributes<HTMLDivElement>>>;
15
15
 
16
16
  interface NumericInputMenuTriggerProps extends IconButtonProps {
17
17
  className?: string;
18
18
  type?: "menu" | "action";
19
19
  }
20
- declare const NumericInputMenuTrigger: react.ForwardRefExoticComponent<Omit<NumericInputMenuTriggerProps, "ref"> & react.RefAttributes<HTMLButtonElement>>;
20
+ declare const NumericInputMenuTrigger: React$1.ForwardRefExoticComponent<Omit<NumericInputMenuTriggerProps, "ref"> & React$1.RefAttributes<HTMLButtonElement>>;
21
21
  interface NumericInputMenuActionPromptProps extends HTMLProps<HTMLDivElement> {
22
22
  children?: React.ReactNode;
23
23
  className?: string;
24
24
  }
25
- declare const NumericInputMenuActionPrompt: react.ForwardRefExoticComponent<Omit<NumericInputMenuActionPromptProps, "ref"> & react.RefAttributes<HTMLDivElement>>;
25
+ declare const NumericInputMenuActionPrompt: React$1.ForwardRefExoticComponent<Omit<NumericInputMenuActionPromptProps, "ref"> & React$1.RefAttributes<HTMLDivElement>>;
26
26
 
27
27
  interface NumericInputVariableProps {
28
28
  className?: string;
@@ -30,7 +30,7 @@ interface NumericInputVariableProps {
30
30
  onClick?: (e: React.MouseEvent<HTMLDivElement>) => void;
31
31
  value?: number | null;
32
32
  }
33
- declare const NumericInputVariable: react.ForwardRefExoticComponent<NumericInputVariableProps & react.RefAttributes<HTMLDivElement>>;
33
+ declare const NumericInputVariable: React$1.ForwardRefExoticComponent<NumericInputVariableProps & React$1.RefAttributes<HTMLDivElement>>;
34
34
 
35
35
  type NumericInputValue = string | number | (string | number | undefined)[] | Record<string, number>;
36
36
  type NumberResult = {
@@ -51,6 +51,7 @@ interface NumericInputContextValue {
51
51
  max?: number;
52
52
  min?: number;
53
53
  onChange?: (value: NumericInputValue, detail: NumericChangeDetail) => void;
54
+ onChangeEnd?: (value: NumericInputValue, detail: NumericChangeDetail) => void;
54
55
  onEmpty?: () => void;
55
56
  onIsEditingChange?: (isEditing: boolean) => void;
56
57
  onPressEnd?: PressMoveProps["onPressEnd"];
@@ -58,12 +59,13 @@ interface NumericInputContextValue {
58
59
  readOnly?: boolean;
59
60
  selected?: boolean;
60
61
  shiftStep?: number;
62
+ size?: "default" | "large";
61
63
  step?: number;
62
64
  value?: NumericInputValue;
63
65
  variant?: "default" | "light" | "dark" | "reset";
64
66
  }
65
67
 
66
- interface NumericInputProps extends NumericInputContextValue, Omit<HTMLProps<HTMLInputElement>, "value" | "defaultValue" | "onChange" | "children" | "max" | "min" | "step" | "disabled" | "id"> {
68
+ interface NumericInputProps extends NumericInputContextValue, Omit<HTMLProps<HTMLInputElement>, "value" | "defaultValue" | "onChange" | "children" | "max" | "min" | "step" | "disabled" | "id" | "size"> {
67
69
  children?: ReactNode;
68
70
  className?: string;
69
71
  classNames?: {
@@ -73,10 +75,11 @@ interface NumericInputProps extends NumericInputContextValue, Omit<HTMLProps<HTM
73
75
  disabled?: boolean;
74
76
  id?: string;
75
77
  onChange?: (value: NumericInputValue, detail: NumericChangeDetail) => void;
78
+ onChangeEnd?: (value: NumericInputValue, detail: NumericChangeDetail) => void;
76
79
  tooltip?: TooltipProps;
77
- triggerRef?: react__default.RefObject<HTMLDivElement> | ((el: HTMLDivElement | null) => void);
80
+ triggerRef?: React__default.RefObject<HTMLDivElement> | ((el: HTMLDivElement | null) => void);
78
81
  }
79
- interface NumericInputComponent extends react__default.ForwardRefExoticComponent<NumericInputProps & react__default.RefAttributes<HTMLInputElement>> {
82
+ interface NumericInputComponent extends React__default.ForwardRefExoticComponent<NumericInputProps & React__default.RefAttributes<HTMLInputElement>> {
80
83
  ActionPrompt: typeof NumericInputMenuActionPrompt;
81
84
  MenuTrigger: typeof NumericInputMenuTrigger;
82
85
  Prefix: typeof NumericInputElement;
@@ -85,4 +88,18 @@ interface NumericInputComponent extends react__default.ForwardRefExoticComponent
85
88
  }
86
89
  declare const NumericInput: NumericInputComponent;
87
90
 
88
- export { type NumberResult, type NumericChangeDetail, NumericInput, NumericInputElement, type NumericInputElementProps, NumericInputMenuTrigger, type NumericInputMenuTriggerProps, type NumericInputProps, type NumericInputValue, NumericInputVariable, type NumericInputVariableProps };
91
+ /**
92
+ * Hook for handling long press on numeric input increment/decrement buttons.
93
+ * Triggers the callback immediately on press, then repeatedly after a delay.
94
+ *
95
+ * @param callback - Function to call on press and during long press
96
+ * @param delay - Interval between repeated calls (default: 150ms)
97
+ * @param initialDelay - Delay before starting repeated calls (default: 400ms)
98
+ */
99
+ declare function useNumericLongPress(callback: () => void, delay?: number, initialDelay?: number): {
100
+ onMouseDown: () => void;
101
+ onMouseUp: () => void;
102
+ onMouseLeave: () => void;
103
+ };
104
+
105
+ export { type NumberResult, type NumericChangeDetail, NumericInput, NumericInputElement, type NumericInputElementProps, NumericInputMenuTrigger, type NumericInputMenuTriggerProps, type NumericInputProps, type NumericInputValue, NumericInputVariable, type NumericInputVariableProps, useNumericLongPress };
@@ -1,5 +1,5 @@
1
1
  import { Tooltip } from "../../tooltip/dist/index.js";
2
- import { forwardRef, useRef, useState, useMemo, createContext, cloneElement, memo, useEffect, useCallback, Children, isValidElement, useContext } from "react";
2
+ import { forwardRef, useRef, useState, useMemo, createContext, cloneElement, memo, useCallback, useEffect, Children, isValidElement, useContext } from "react";
3
3
  import { useEventCallback } from "usehooks-ts";
4
4
  import { jsx, jsxs } from "react/jsx-runtime";
5
5
  import { IconButton } from "../../icon-button/dist/index.js";
@@ -22,9 +22,9 @@ function useNumericInputContext() {
22
22
  }
23
23
  var NumericInputTv = tcv({
24
24
  slots: {
25
- container: ["group/input grid h-6 before:border-transparent", "input__number"],
26
- input: ["peer", "h-6 w-full", "cursor-default appearance-none truncate"],
27
- tooltip: "col-span-3 col-start-1 row-start-1 h-6"
25
+ container: ["group/input grid before:border-transparent", "input__number"],
26
+ input: ["peer", "w-full", "cursor-default appearance-none truncate"],
27
+ tooltip: "col-span-3 col-start-1 row-start-1"
28
28
  },
29
29
  variants: {
30
30
  variant: {
@@ -39,6 +39,18 @@ var NumericInputTv = tcv({
39
39
  },
40
40
  reset: {}
41
41
  },
42
+ size: {
43
+ default: {
44
+ container: ["h-6", "input__number--default"],
45
+ input: "h-6",
46
+ tooltip: "h-6"
47
+ },
48
+ large: {
49
+ container: ["h-8", "input__number--large"],
50
+ input: "h-8",
51
+ tooltip: "h-8"
52
+ }
53
+ },
42
54
  prefixElement: {
43
55
  true: {},
44
56
  false: {}
@@ -161,6 +173,7 @@ var NumericInputTv = tcv({
161
173
  ],
162
174
  defaultVariants: {
163
175
  variant: "default",
176
+ size: "default",
164
177
  selected: false,
165
178
  disabled: false,
166
179
  focused: false
@@ -172,6 +185,10 @@ var NumericInputMenuTriggerTv = tcv({
172
185
  disabled: {
173
186
  true: ""
174
187
  },
188
+ size: {
189
+ default: "",
190
+ large: ""
191
+ },
175
192
  type: {
176
193
  menu: "",
177
194
  action: ""
@@ -219,6 +236,7 @@ var NumericInputMenuTriggerTv = tcv({
219
236
  ],
220
237
  defaultVariants: {
221
238
  disabled: false,
239
+ size: "default",
222
240
  type: "menu",
223
241
  variant: "default"
224
242
  }
@@ -323,17 +341,21 @@ var NumericInputVariableTv = tcv({
323
341
  }
324
342
  });
325
343
  var NumericInputElementTv = tcv({
326
- base: ["select-none", "z-2 h-6 w-6", "flex flex-none items-center justify-center"],
344
+ base: ["select-none", "z-2", "flex flex-none items-center justify-center"],
327
345
  variants: {
328
346
  type: {
329
347
  handler: "select-none",
330
- action: "[grid-area:action]",
331
- menu: "ml-px [grid-area:action]"
348
+ action: "",
349
+ menu: ""
332
350
  },
333
351
  position: {
334
352
  prefix: "rounded-l-md",
335
353
  suffix: "rounded-r-md"
336
354
  },
355
+ size: {
356
+ default: "h-6 w-6",
357
+ large: "h-8 w-8"
358
+ },
337
359
  disabled: {
338
360
  true: "text-disabled-foreground",
339
361
  false: "text-secondary-foreground"
@@ -356,6 +378,26 @@ var NumericInputElementTv = tcv({
356
378
  position: "suffix",
357
379
  class: "[grid-area:suffix-handler]"
358
380
  },
381
+ {
382
+ type: "action",
383
+ position: "prefix",
384
+ class: "[grid-area:prefix-handler]"
385
+ },
386
+ {
387
+ type: "action",
388
+ position: "suffix",
389
+ class: "[grid-area:action]"
390
+ },
391
+ {
392
+ type: "menu",
393
+ position: "prefix",
394
+ class: "[grid-area:prefix-handler]"
395
+ },
396
+ {
397
+ type: "menu",
398
+ position: "suffix",
399
+ class: "ml-px [grid-area:action]"
400
+ },
359
401
  {
360
402
  type: "handler",
361
403
  disabled: false,
@@ -394,25 +436,31 @@ var NumericInputElementTv = tcv({
394
436
  ],
395
437
  defaultVariants: {
396
438
  disabled: false,
397
- variant: "default"
439
+ variant: "default",
440
+ size: "default"
398
441
  }
399
442
  });
400
443
  var NumericInputMenuActionPromptTv = tcv({
401
444
  base: [
402
445
  "[grid-area:action]",
403
- "w-6 pr-2",
446
+ "pr-2",
404
447
  "flex items-center justify-center",
405
448
  "rounded-r-md",
406
449
  "pointer-events-none z-3"
407
450
  ],
408
451
  variants: {
452
+ size: {
453
+ default: "w-6",
454
+ large: "w-8"
455
+ },
409
456
  disabled: {
410
457
  true: "text-secondary-foreground bg-default-background",
411
458
  false: "bg-secondary-background group-focus-within/input:hidden group-hover/input:hidden"
412
459
  }
413
460
  },
414
461
  defaultVariants: {
415
- disabled: false
462
+ disabled: false,
463
+ size: "default"
416
464
  }
417
465
  });
418
466
  var NumericInputElement = memo(
@@ -423,6 +471,7 @@ var NumericInputElement = memo(
423
471
  const tv = NumericInputElementTv({
424
472
  type,
425
473
  position,
474
+ size: context.size,
426
475
  disabled: context.disabled,
427
476
  variant: context.variant
428
477
  });
@@ -450,6 +499,7 @@ var NumericInputMenuTrigger = forwardRef(
450
499
  const context = useNumericInputContext();
451
500
  const tv = NumericInputMenuTriggerTv({
452
501
  type,
502
+ size: context.size,
453
503
  disabled: context.disabled,
454
504
  variant: context.variant
455
505
  });
@@ -457,6 +507,7 @@ var NumericInputMenuTrigger = forwardRef(
457
507
  IconButton,
458
508
  {
459
509
  ref,
510
+ size: context.size,
460
511
  variant: type === "menu" ? context.disabled ? "ghost" : "solid" : void 0,
461
512
  className: tcx(tv, className),
462
513
  disabled: context.disabled,
@@ -474,7 +525,10 @@ var NumericInputMenuActionPrompt = forwardRef((props, ref) => {
474
525
  "div",
475
526
  {
476
527
  ref,
477
- className: tcx(NumericInputMenuActionPromptTv({ disabled: context.disabled }), className),
528
+ className: tcx(
529
+ NumericInputMenuActionPromptTv({ size: context.size, disabled: context.disabled }),
530
+ className
531
+ ),
478
532
  ...rest,
479
533
  children
480
534
  }
@@ -720,9 +774,6 @@ function compareNumberResults(result1, result2) {
720
774
  const isSameObject = compareNumericObjects(result1.object, result2.object);
721
775
  return isSameArray || isSameObject;
722
776
  }
723
- function isExpressionInput(displayValue, processedValue) {
724
- return displayValue !== processedValue.string;
725
- }
726
777
  function useInputInteractions({
727
778
  inputRef,
728
779
  displayValue,
@@ -733,6 +784,7 @@ function useInputInteractions({
733
784
  min,
734
785
  max,
735
786
  decimal,
787
+ defaultValue,
736
788
  disabled,
737
789
  readOnly,
738
790
  innerValue,
@@ -740,11 +792,14 @@ function useInputInteractions({
740
792
  updateValue,
741
793
  getCurrentStep,
742
794
  onChange,
795
+ onRawInputEditingChange,
743
796
  onEmpty,
744
797
  value
745
798
  }) {
746
799
  const initialValueRef = useRef("");
800
+ const outputShapeSource = value ?? defaultValue;
747
801
  const handleInputChange = useEventCallback((e) => {
802
+ onRawInputEditingChange == null ? void 0 : onRawInputEditingChange(true);
748
803
  setDisplayValue(e.target.value);
749
804
  });
750
805
  const handleInputFocus = useEventCallback((e) => {
@@ -753,6 +808,7 @@ function useInputInteractions({
753
808
  e.target.select();
754
809
  });
755
810
  const handleInputBlur = useEventCallback(() => {
811
+ onRawInputEditingChange == null ? void 0 : onRawInputEditingChange(false);
756
812
  setIsFocused(false);
757
813
  if (disabled || readOnly) return;
758
814
  try {
@@ -763,7 +819,6 @@ function useInputInteractions({
763
819
  min,
764
820
  decimal
765
821
  });
766
- const isExpressionInputValue = isExpressionInput(displayValue, valuePre);
767
822
  const isSameValue = compareNumberResults(innerValue, valuePre);
768
823
  if (isSameValue) {
769
824
  setDisplayValue(valuePre.string);
@@ -772,7 +827,7 @@ function useInputInteractions({
772
827
  }
773
828
  setValue(valuePre);
774
829
  onChange == null ? void 0 : onChange(
775
- typeof value === "string" ? valuePre.string : typeof value === "number" ? valuePre.array[0] : Array.isArray(value) ? valuePre.array : valuePre.object,
830
+ typeof outputShapeSource === "string" ? valuePre.string : typeof outputShapeSource === "number" ? valuePre.array[0] : Array.isArray(outputShapeSource) ? valuePre.array : valuePre.object,
776
831
  valuePre
777
832
  );
778
833
  setDisplayValue(valuePre.string);
@@ -865,11 +920,16 @@ function useNumericInput(props) {
865
920
  step = 1,
866
921
  value,
867
922
  onChange,
923
+ onChangeEnd,
868
924
  onEmpty,
869
925
  onPressEnd,
870
926
  onPressStart
871
927
  } = props;
872
928
  const innerRef = useRef(null);
929
+ const dragHasChangedRef = useRef(false);
930
+ const dragEndValueRef = useRef(void 0);
931
+ const dragEndDetailRef = useRef(void 0);
932
+ const hasPendingRawInputRef = useRef(false);
873
933
  const [isFocused, setIsFocused] = useState(false);
874
934
  const [displayValue, setDisplayValue] = useState("");
875
935
  const { shiftPressed, metaPressed } = useModifierKeys(disabled);
@@ -887,9 +947,16 @@ function useNumericInput(props) {
887
947
  defaultValue: defaultValuePre,
888
948
  allowEmpty: true
889
949
  });
950
+ const outputShapeSource = value ?? defaultValue;
951
+ const mapResultToOutputValue = useCallback(
952
+ (result) => typeof outputShapeSource === "string" ? result.string : typeof outputShapeSource === "number" ? result.array[0] : Array.isArray(outputShapeSource) ? result.array : result.object,
953
+ [outputShapeSource]
954
+ );
890
955
  useEffect(() => {
891
956
  if (!innerValue) {
892
- setDisplayValue("");
957
+ if (!hasPendingRawInputRef.current) {
958
+ setDisplayValue("");
959
+ }
893
960
  return;
894
961
  }
895
962
  const valuePre2 = dealWithNumericInputValue({
@@ -902,11 +969,14 @@ function useNumericInput(props) {
902
969
  if (JSON.stringify(valuePre2.object) !== JSON.stringify(innerValue.object)) {
903
970
  setValue(valuePre2);
904
971
  }
905
- setDisplayValue(valuePre2.string);
972
+ if (!hasPendingRawInputRef.current) {
973
+ setDisplayValue(valuePre2.string);
974
+ }
906
975
  }, [innerValue, expression, max, min, decimal, setValue]);
907
976
  const updateValue = useCallback(
908
- (updateFn) => {
977
+ (updateFn, options) => {
909
978
  if (disabled || readOnly) return;
979
+ hasPendingRawInputRef.current = false;
910
980
  setValue((prev) => {
911
981
  if (!prev) {
912
982
  const initialValue = dealWithNumericInputValue({
@@ -917,10 +987,13 @@ function useNumericInput(props) {
917
987
  min,
918
988
  decimal
919
989
  });
920
- onChange == null ? void 0 : onChange(
921
- typeof value === "string" ? initialValue.string : typeof value === "number" ? initialValue.array[0] : Array.isArray(value) ? initialValue.array : initialValue.object,
922
- initialValue
923
- );
990
+ const nextValue = mapResultToOutputValue(initialValue);
991
+ onChange == null ? void 0 : onChange(nextValue, initialValue);
992
+ if ((options == null ? void 0 : options.source) === "drag") {
993
+ dragHasChangedRef.current = true;
994
+ dragEndValueRef.current = nextValue;
995
+ dragEndDetailRef.current = initialValue;
996
+ }
924
997
  return initialValue;
925
998
  }
926
999
  const valuePre2 = dealWithNumericInputValue({
@@ -944,15 +1017,18 @@ function useNumericInput(props) {
944
1017
  return true;
945
1018
  })();
946
1019
  if (hasChanged) {
947
- onChange == null ? void 0 : onChange(
948
- typeof value === "string" ? valuePre2.string : typeof value === "number" ? valuePre2.array[0] : Array.isArray(value) ? valuePre2.array : valuePre2.object,
949
- valuePre2
950
- );
1020
+ const nextValue = mapResultToOutputValue(valuePre2);
1021
+ onChange == null ? void 0 : onChange(nextValue, valuePre2);
1022
+ if ((options == null ? void 0 : options.source) === "drag") {
1023
+ dragHasChangedRef.current = true;
1024
+ dragEndValueRef.current = nextValue;
1025
+ dragEndDetailRef.current = valuePre2;
1026
+ }
951
1027
  }
952
1028
  return valuePre2;
953
1029
  });
954
1030
  },
955
- [disabled, readOnly, setValue, max, min, decimal, onChange, value]
1031
+ [disabled, readOnly, setValue, max, min, decimal, onChange, expressionRef, mapResultToOutputValue]
956
1032
  );
957
1033
  const { inputHandlers } = useInputInteractions({
958
1034
  inputRef: innerRef,
@@ -964,6 +1040,7 @@ function useNumericInput(props) {
964
1040
  min,
965
1041
  max,
966
1042
  decimal,
1043
+ defaultValue,
967
1044
  disabled,
968
1045
  readOnly,
969
1046
  innerValue,
@@ -971,12 +1048,18 @@ function useNumericInput(props) {
971
1048
  updateValue,
972
1049
  getCurrentStep,
973
1050
  onChange,
1051
+ onRawInputEditingChange: (editing) => {
1052
+ hasPendingRawInputRef.current = editing;
1053
+ },
974
1054
  onEmpty,
975
1055
  value
976
1056
  });
977
1057
  const { isPressed: handlerPressed, pressMoveProps } = usePressMove({
978
1058
  disabled,
979
1059
  onPressStart: (e) => {
1060
+ dragHasChangedRef.current = false;
1061
+ dragEndValueRef.current = void 0;
1062
+ dragEndDetailRef.current = void 0;
980
1063
  const wasFocused = isFocused;
981
1064
  if (onPressStart && "nativeEvent" in e) {
982
1065
  onPressStart(e.nativeEvent);
@@ -1002,12 +1085,18 @@ function useNumericInput(props) {
1002
1085
  onPressEnd(e.nativeEvent);
1003
1086
  }
1004
1087
  onPressEnd == null ? void 0 : onPressEnd(e);
1088
+ if (dragHasChangedRef.current && dragEndValueRef.current !== void 0 && dragEndDetailRef.current !== void 0) {
1089
+ onChangeEnd == null ? void 0 : onChangeEnd(dragEndValueRef.current, dragEndDetailRef.current);
1090
+ }
1091
+ dragHasChangedRef.current = false;
1092
+ dragEndValueRef.current = void 0;
1093
+ dragEndDetailRef.current = void 0;
1005
1094
  },
1006
1095
  onPressMoveLeft: (delta) => {
1007
- updateValue((value2) => value2 - delta * getCurrentStep());
1096
+ updateValue((value2) => value2 - delta * getCurrentStep(), { source: "drag" });
1008
1097
  },
1009
1098
  onPressMoveRight: (delta) => {
1010
- updateValue((value2) => value2 + delta * getCurrentStep());
1099
+ updateValue((value2) => value2 + delta * getCurrentStep(), { source: "drag" });
1011
1100
  }
1012
1101
  });
1013
1102
  const inputProps = {
@@ -1042,6 +1131,7 @@ var NumericInputBase = forwardRef((props, ref) => {
1042
1131
  readOnly,
1043
1132
  required,
1044
1133
  shiftStep = 10,
1134
+ size = "default",
1045
1135
  step = 1,
1046
1136
  value,
1047
1137
  variant = "default",
@@ -1049,6 +1139,7 @@ var NumericInputBase = forwardRef((props, ref) => {
1049
1139
  selected = false,
1050
1140
  tooltip,
1051
1141
  onChange,
1142
+ onChangeEnd,
1052
1143
  onEmpty,
1053
1144
  onPressEnd,
1054
1145
  onPressStart,
@@ -1072,6 +1163,7 @@ var NumericInputBase = forwardRef((props, ref) => {
1072
1163
  step,
1073
1164
  value,
1074
1165
  onChange,
1166
+ onChangeEnd,
1075
1167
  onEmpty,
1076
1168
  onPressEnd,
1077
1169
  onPressStart,
@@ -1079,6 +1171,7 @@ var NumericInputBase = forwardRef((props, ref) => {
1079
1171
  });
1080
1172
  const { disableScrollProps } = useDisableScroll({ ref: inputRef });
1081
1173
  const [isFocused, setIsFocused] = useState(false);
1174
+ const mergedFocused = focused || isFocused;
1082
1175
  const handleFocus = useEventCallback((e) => {
1083
1176
  var _a;
1084
1177
  onIsEditingChange == null ? void 0 : onIsEditingChange(true);
@@ -1094,13 +1187,14 @@ var NumericInputBase = forwardRef((props, ref) => {
1094
1187
  const contextValue = useMemo(
1095
1188
  () => ({
1096
1189
  variant,
1190
+ size,
1097
1191
  // State
1098
1192
  value,
1099
1193
  defaultValue,
1100
1194
  disabled,
1101
1195
  readOnly,
1102
1196
  selected,
1103
- focused,
1197
+ focused: mergedFocused,
1104
1198
  handlerPressed,
1105
1199
  // Configuration
1106
1200
  min,
@@ -1111,6 +1205,7 @@ var NumericInputBase = forwardRef((props, ref) => {
1111
1205
  expression,
1112
1206
  // Event handling methods
1113
1207
  onChange,
1208
+ onChangeEnd,
1114
1209
  onEmpty,
1115
1210
  onPressStart,
1116
1211
  onPressEnd,
@@ -1120,12 +1215,13 @@ var NumericInputBase = forwardRef((props, ref) => {
1120
1215
  }),
1121
1216
  [
1122
1217
  variant,
1218
+ size,
1123
1219
  value,
1124
1220
  defaultValue,
1125
1221
  disabled,
1126
1222
  readOnly,
1127
1223
  selected,
1128
- focused,
1224
+ mergedFocused,
1129
1225
  handlerPressed,
1130
1226
  min,
1131
1227
  max,
@@ -1134,6 +1230,7 @@ var NumericInputBase = forwardRef((props, ref) => {
1134
1230
  decimal,
1135
1231
  expression,
1136
1232
  onChange,
1233
+ onChangeEnd,
1137
1234
  onEmpty,
1138
1235
  onPressStart,
1139
1236
  onPressEnd,
@@ -1175,8 +1272,9 @@ var NumericInputBase = forwardRef((props, ref) => {
1175
1272
  const actionPromptNode = actionPrompt[0] || null;
1176
1273
  const tv = NumericInputTv({
1177
1274
  variant,
1275
+ size,
1178
1276
  selected: selected || handlerPressed,
1179
- focused,
1277
+ focused: mergedFocused,
1180
1278
  disabled,
1181
1279
  prefixElement: !!prefixNode,
1182
1280
  suffixElement: !!suffixNode,
@@ -1219,7 +1317,7 @@ var NumericInputBase = forwardRef((props, ref) => {
1219
1317
  variableNode && cloneElement(variableNode, { hasPrefixElement: !!prefixNode }),
1220
1318
  actionPromptNode && cloneElement(actionPromptNode),
1221
1319
  suffixNode && cloneElement(suffixNode, { position: "suffix" }),
1222
- tooltip && !isFocused && /* @__PURE__ */ jsx(Tooltip, { ...tooltip, children: /* @__PURE__ */ jsx(
1320
+ tooltip && !mergedFocused && /* @__PURE__ */ jsx(Tooltip, { ...tooltip, children: /* @__PURE__ */ jsx(
1223
1321
  "span",
1224
1322
  {
1225
1323
  tabIndex: -1,
@@ -2,6 +2,7 @@ import { default as React, RefObject } from 'react';
2
2
  import { NumberResult, NumericInputValue } from '../types';
3
3
  interface UseInputInteractionsProps<T extends NumericInputValue> {
4
4
  decimal?: number;
5
+ defaultValue?: T;
5
6
  disabled?: boolean;
6
7
  displayValue: string;
7
8
  expression: string;
@@ -12,6 +13,7 @@ interface UseInputInteractionsProps<T extends NumericInputValue> {
12
13
  max?: number;
13
14
  min?: number;
14
15
  onChange?: (value: T, detail: NumberResult) => void;
16
+ onRawInputEditingChange?: (editing: boolean) => void;
15
17
  onEmpty?: () => void;
16
18
  readOnly?: boolean;
17
19
  setDisplayValue: (value: string) => void;
@@ -27,7 +29,7 @@ interface UseInputInteractionsProps<T extends NumericInputValue> {
27
29
  * @param props Input interaction configuration
28
30
  * @returns Input handlers and initial value reference
29
31
  */
30
- export declare function useInputInteractions<T extends NumericInputValue>({ inputRef, displayValue, setDisplayValue, isFocused, setIsFocused, expression, min, max, decimal, disabled, readOnly, innerValue, setValue, updateValue, getCurrentStep, onChange, onEmpty, value, }: UseInputInteractionsProps<T>): {
32
+ export declare function useInputInteractions<T extends NumericInputValue>({ inputRef, displayValue, setDisplayValue, isFocused, setIsFocused, expression, min, max, decimal, defaultValue, disabled, readOnly, innerValue, setValue, updateValue, getCurrentStep, onChange, onRawInputEditingChange, onEmpty, value, }: UseInputInteractionsProps<T>): {
31
33
  inputHandlers: {
32
34
  onChange: (e: React.ChangeEvent<HTMLInputElement>) => void;
33
35
  onFocus: (e: React.FocusEvent<HTMLInputElement, Element>) => void;