@choice-ui/react 1.9.6 → 1.9.8
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/components/button/dist/index.d.ts +9 -2
- package/dist/components/button/dist/index.js +19 -45
- package/dist/components/checkbox/dist/index.d.ts +1 -10
- package/dist/components/checkbox/dist/index.js +5 -49
- package/dist/components/code-block/dist/index.d.ts +14 -11
- package/dist/components/code-block/dist/index.js +93 -120
- package/dist/components/colors/dist/index.d.ts +6 -39
- package/dist/components/colors/src/color-image-paint/color-image-paint.js +2 -2
- package/dist/components/dropdown/dist/index.d.ts +0 -6
- package/dist/components/dropdown/dist/index.js +10 -20
- package/dist/components/emoji-picker/dist/index.d.ts +1 -30
- package/dist/components/emoji-picker/dist/index.js +44 -148
- package/dist/components/form/src/adapters/range-adapter.js +2 -2
- package/dist/components/icon-button/dist/index.d.ts +1 -1
- package/dist/components/icon-button/dist/index.js +0 -39
- package/dist/components/list/dist/index.d.ts +1 -1
- package/dist/components/md-render/dist/index.d.ts +1 -2
- package/dist/components/md-render/dist/index.js +9 -5
- package/dist/components/menus/dist/index.d.ts +0 -5
- package/dist/components/menus/dist/index.js +3 -32
- package/dist/components/modal/dist/index.js +2 -2
- package/dist/components/notifications/dist/index.d.ts +5 -1
- package/dist/components/numeric-input/dist/index.d.ts +10 -25
- package/dist/components/numeric-input/dist/index.js +10 -68
- package/dist/components/numeric-input/src/context/numeric-input-context.d.ts +1 -0
- package/dist/components/numeric-input/src/hooks/use-input-interactions.d.ts +3 -1
- package/dist/components/numeric-input/src/hooks/use-numeric-input.d.ts +1 -0
- package/dist/components/numeric-input/src/hooks/use-numeric-input.js +36 -13
- package/dist/components/numeric-input/src/numeric-input.d.ts +1 -0
- package/dist/components/numeric-input/src/numeric-input.js +4 -0
- package/dist/components/panel/dist/index.d.ts +16 -16
- package/dist/components/picture-preview/dist/index.d.ts +0 -5
- package/dist/components/picture-preview/dist/index.js +140 -287
- package/dist/components/popover/dist/index.d.ts +0 -5
- package/dist/components/popover/dist/index.js +2 -21
- package/dist/components/radio/dist/index.d.ts +1 -9
- package/dist/components/radio/dist/index.js +6 -50
- package/dist/components/range/dist/index.d.ts +20 -276
- package/dist/components/range/dist/index.js +616 -1044
- package/dist/components/scroll-area/dist/index.d.ts +27 -4
- package/dist/components/scroll-area/dist/index.js +123 -96
- package/dist/components/separator/dist/index.d.ts +8 -1
- package/dist/components/splitter/dist/index.d.ts +1 -1
- package/dist/components/text-field/dist/index.d.ts +3 -2
- package/dist/components/text-field/dist/index.js +19 -4
- package/dist/components/textarea/dist/index.js +1 -3
- package/dist/components/tooltip/dist/index.d.ts +0 -2
- package/dist/components/tooltip/dist/index.js +5 -23
- package/package.json +1 -1
- package/dist/components/toast/dist/index.d.ts +0 -274
- package/dist/components/virtual-select/dist/index.d.ts +0 -48
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { TooltipProps } from '../../tooltip/src';
|
|
2
|
-
import { default as
|
|
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
|
|
5
|
+
import * as react 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:
|
|
14
|
+
declare const NumericInputElement: react.MemoExoticComponent<react.ForwardRefExoticComponent<NumericInputElementProps & react.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:
|
|
20
|
+
declare const NumericInputMenuTrigger: react.ForwardRefExoticComponent<Omit<NumericInputMenuTriggerProps, "ref"> & react.RefAttributes<HTMLButtonElement>>;
|
|
21
21
|
interface NumericInputMenuActionPromptProps extends HTMLProps<HTMLDivElement> {
|
|
22
22
|
children?: React.ReactNode;
|
|
23
23
|
className?: string;
|
|
24
24
|
}
|
|
25
|
-
declare const NumericInputMenuActionPrompt:
|
|
25
|
+
declare const NumericInputMenuActionPrompt: react.ForwardRefExoticComponent<Omit<NumericInputMenuActionPromptProps, "ref"> & react.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:
|
|
33
|
+
declare const NumericInputVariable: react.ForwardRefExoticComponent<NumericInputVariableProps & react.RefAttributes<HTMLDivElement>>;
|
|
34
34
|
|
|
35
35
|
type NumericInputValue = string | number | (string | number | undefined)[] | Record<string, number>;
|
|
36
36
|
type NumberResult = {
|
|
@@ -58,13 +58,12 @@ interface NumericInputContextValue {
|
|
|
58
58
|
readOnly?: boolean;
|
|
59
59
|
selected?: boolean;
|
|
60
60
|
shiftStep?: number;
|
|
61
|
-
size?: "default" | "large";
|
|
62
61
|
step?: number;
|
|
63
62
|
value?: NumericInputValue;
|
|
64
63
|
variant?: "default" | "light" | "dark" | "reset";
|
|
65
64
|
}
|
|
66
65
|
|
|
67
|
-
interface NumericInputProps extends NumericInputContextValue, Omit<HTMLProps<HTMLInputElement>, "value" | "defaultValue" | "onChange" | "children" | "max" | "min" | "step" | "disabled" | "id"
|
|
66
|
+
interface NumericInputProps extends NumericInputContextValue, Omit<HTMLProps<HTMLInputElement>, "value" | "defaultValue" | "onChange" | "children" | "max" | "min" | "step" | "disabled" | "id"> {
|
|
68
67
|
children?: ReactNode;
|
|
69
68
|
className?: string;
|
|
70
69
|
classNames?: {
|
|
@@ -75,9 +74,9 @@ interface NumericInputProps extends NumericInputContextValue, Omit<HTMLProps<HTM
|
|
|
75
74
|
id?: string;
|
|
76
75
|
onChange?: (value: NumericInputValue, detail: NumericChangeDetail) => void;
|
|
77
76
|
tooltip?: TooltipProps;
|
|
78
|
-
triggerRef?:
|
|
77
|
+
triggerRef?: react__default.RefObject<HTMLDivElement> | ((el: HTMLDivElement | null) => void);
|
|
79
78
|
}
|
|
80
|
-
interface NumericInputComponent extends
|
|
79
|
+
interface NumericInputComponent extends react__default.ForwardRefExoticComponent<NumericInputProps & react__default.RefAttributes<HTMLInputElement>> {
|
|
81
80
|
ActionPrompt: typeof NumericInputMenuActionPrompt;
|
|
82
81
|
MenuTrigger: typeof NumericInputMenuTrigger;
|
|
83
82
|
Prefix: typeof NumericInputElement;
|
|
@@ -86,18 +85,4 @@ interface NumericInputComponent extends React__default.ForwardRefExoticComponent
|
|
|
86
85
|
}
|
|
87
86
|
declare const NumericInput: NumericInputComponent;
|
|
88
87
|
|
|
89
|
-
|
|
90
|
-
* Hook for handling long press on numeric input increment/decrement buttons.
|
|
91
|
-
* Triggers the callback immediately on press, then repeatedly after a delay.
|
|
92
|
-
*
|
|
93
|
-
* @param callback - Function to call on press and during long press
|
|
94
|
-
* @param delay - Interval between repeated calls (default: 150ms)
|
|
95
|
-
* @param initialDelay - Delay before starting repeated calls (default: 400ms)
|
|
96
|
-
*/
|
|
97
|
-
declare function useNumericLongPress(callback: () => void, delay?: number, initialDelay?: number): {
|
|
98
|
-
onMouseDown: () => void;
|
|
99
|
-
onMouseUp: () => void;
|
|
100
|
-
onMouseLeave: () => void;
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
export { type NumberResult, type NumericChangeDetail, NumericInput, NumericInputElement, type NumericInputElementProps, NumericInputMenuTrigger, type NumericInputMenuTriggerProps, type NumericInputProps, type NumericInputValue, NumericInputVariable, type NumericInputVariableProps, useNumericLongPress };
|
|
88
|
+
export { type NumberResult, type NumericChangeDetail, NumericInput, NumericInputElement, type NumericInputElementProps, NumericInputMenuTrigger, type NumericInputMenuTriggerProps, type NumericInputProps, type NumericInputValue, NumericInputVariable, type NumericInputVariableProps };
|
|
@@ -22,9 +22,9 @@ function useNumericInputContext() {
|
|
|
22
22
|
}
|
|
23
23
|
var NumericInputTv = tcv({
|
|
24
24
|
slots: {
|
|
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"
|
|
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"
|
|
28
28
|
},
|
|
29
29
|
variants: {
|
|
30
30
|
variant: {
|
|
@@ -39,18 +39,6 @@ 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
|
-
},
|
|
54
42
|
prefixElement: {
|
|
55
43
|
true: {},
|
|
56
44
|
false: {}
|
|
@@ -173,7 +161,6 @@ var NumericInputTv = tcv({
|
|
|
173
161
|
],
|
|
174
162
|
defaultVariants: {
|
|
175
163
|
variant: "default",
|
|
176
|
-
size: "default",
|
|
177
164
|
selected: false,
|
|
178
165
|
disabled: false,
|
|
179
166
|
focused: false
|
|
@@ -185,10 +172,6 @@ var NumericInputMenuTriggerTv = tcv({
|
|
|
185
172
|
disabled: {
|
|
186
173
|
true: ""
|
|
187
174
|
},
|
|
188
|
-
size: {
|
|
189
|
-
default: "",
|
|
190
|
-
large: ""
|
|
191
|
-
},
|
|
192
175
|
type: {
|
|
193
176
|
menu: "",
|
|
194
177
|
action: ""
|
|
@@ -236,7 +219,6 @@ var NumericInputMenuTriggerTv = tcv({
|
|
|
236
219
|
],
|
|
237
220
|
defaultVariants: {
|
|
238
221
|
disabled: false,
|
|
239
|
-
size: "default",
|
|
240
222
|
type: "menu",
|
|
241
223
|
variant: "default"
|
|
242
224
|
}
|
|
@@ -341,21 +323,17 @@ var NumericInputVariableTv = tcv({
|
|
|
341
323
|
}
|
|
342
324
|
});
|
|
343
325
|
var NumericInputElementTv = tcv({
|
|
344
|
-
base: ["select-none", "z-2", "flex flex-none items-center justify-center"],
|
|
326
|
+
base: ["select-none", "z-2 h-6 w-6", "flex flex-none items-center justify-center"],
|
|
345
327
|
variants: {
|
|
346
328
|
type: {
|
|
347
329
|
handler: "select-none",
|
|
348
|
-
action: "",
|
|
349
|
-
menu: ""
|
|
330
|
+
action: "[grid-area:action]",
|
|
331
|
+
menu: "ml-px [grid-area:action]"
|
|
350
332
|
},
|
|
351
333
|
position: {
|
|
352
334
|
prefix: "rounded-l-md",
|
|
353
335
|
suffix: "rounded-r-md"
|
|
354
336
|
},
|
|
355
|
-
size: {
|
|
356
|
-
default: "h-6 w-6",
|
|
357
|
-
large: "h-8 w-8"
|
|
358
|
-
},
|
|
359
337
|
disabled: {
|
|
360
338
|
true: "text-disabled-foreground",
|
|
361
339
|
false: "text-secondary-foreground"
|
|
@@ -378,26 +356,6 @@ var NumericInputElementTv = tcv({
|
|
|
378
356
|
position: "suffix",
|
|
379
357
|
class: "[grid-area:suffix-handler]"
|
|
380
358
|
},
|
|
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
|
-
},
|
|
401
359
|
{
|
|
402
360
|
type: "handler",
|
|
403
361
|
disabled: false,
|
|
@@ -436,31 +394,25 @@ var NumericInputElementTv = tcv({
|
|
|
436
394
|
],
|
|
437
395
|
defaultVariants: {
|
|
438
396
|
disabled: false,
|
|
439
|
-
variant: "default"
|
|
440
|
-
size: "default"
|
|
397
|
+
variant: "default"
|
|
441
398
|
}
|
|
442
399
|
});
|
|
443
400
|
var NumericInputMenuActionPromptTv = tcv({
|
|
444
401
|
base: [
|
|
445
402
|
"[grid-area:action]",
|
|
446
|
-
"pr-2",
|
|
403
|
+
"w-6 pr-2",
|
|
447
404
|
"flex items-center justify-center",
|
|
448
405
|
"rounded-r-md",
|
|
449
406
|
"pointer-events-none z-3"
|
|
450
407
|
],
|
|
451
408
|
variants: {
|
|
452
|
-
size: {
|
|
453
|
-
default: "w-6",
|
|
454
|
-
large: "w-8"
|
|
455
|
-
},
|
|
456
409
|
disabled: {
|
|
457
410
|
true: "text-secondary-foreground bg-default-background",
|
|
458
411
|
false: "bg-secondary-background group-focus-within/input:hidden group-hover/input:hidden"
|
|
459
412
|
}
|
|
460
413
|
},
|
|
461
414
|
defaultVariants: {
|
|
462
|
-
disabled: false
|
|
463
|
-
size: "default"
|
|
415
|
+
disabled: false
|
|
464
416
|
}
|
|
465
417
|
});
|
|
466
418
|
var NumericInputElement = memo(
|
|
@@ -471,7 +423,6 @@ var NumericInputElement = memo(
|
|
|
471
423
|
const tv = NumericInputElementTv({
|
|
472
424
|
type,
|
|
473
425
|
position,
|
|
474
|
-
size: context.size,
|
|
475
426
|
disabled: context.disabled,
|
|
476
427
|
variant: context.variant
|
|
477
428
|
});
|
|
@@ -499,7 +450,6 @@ var NumericInputMenuTrigger = forwardRef(
|
|
|
499
450
|
const context = useNumericInputContext();
|
|
500
451
|
const tv = NumericInputMenuTriggerTv({
|
|
501
452
|
type,
|
|
502
|
-
size: context.size,
|
|
503
453
|
disabled: context.disabled,
|
|
504
454
|
variant: context.variant
|
|
505
455
|
});
|
|
@@ -507,7 +457,6 @@ var NumericInputMenuTrigger = forwardRef(
|
|
|
507
457
|
IconButton,
|
|
508
458
|
{
|
|
509
459
|
ref,
|
|
510
|
-
size: context.size,
|
|
511
460
|
variant: type === "menu" ? context.disabled ? "ghost" : "solid" : void 0,
|
|
512
461
|
className: tcx(tv, className),
|
|
513
462
|
disabled: context.disabled,
|
|
@@ -525,10 +474,7 @@ var NumericInputMenuActionPrompt = forwardRef((props, ref) => {
|
|
|
525
474
|
"div",
|
|
526
475
|
{
|
|
527
476
|
ref,
|
|
528
|
-
className: tcx(
|
|
529
|
-
NumericInputMenuActionPromptTv({ size: context.size, disabled: context.disabled }),
|
|
530
|
-
className
|
|
531
|
-
),
|
|
477
|
+
className: tcx(NumericInputMenuActionPromptTv({ disabled: context.disabled }), className),
|
|
532
478
|
...rest,
|
|
533
479
|
children
|
|
534
480
|
}
|
|
@@ -1096,7 +1042,6 @@ var NumericInputBase = forwardRef((props, ref) => {
|
|
|
1096
1042
|
readOnly,
|
|
1097
1043
|
required,
|
|
1098
1044
|
shiftStep = 10,
|
|
1099
|
-
size = "default",
|
|
1100
1045
|
step = 1,
|
|
1101
1046
|
value,
|
|
1102
1047
|
variant = "default",
|
|
@@ -1149,7 +1094,6 @@ var NumericInputBase = forwardRef((props, ref) => {
|
|
|
1149
1094
|
const contextValue = useMemo(
|
|
1150
1095
|
() => ({
|
|
1151
1096
|
variant,
|
|
1152
|
-
size,
|
|
1153
1097
|
// State
|
|
1154
1098
|
value,
|
|
1155
1099
|
defaultValue,
|
|
@@ -1176,7 +1120,6 @@ var NumericInputBase = forwardRef((props, ref) => {
|
|
|
1176
1120
|
}),
|
|
1177
1121
|
[
|
|
1178
1122
|
variant,
|
|
1179
|
-
size,
|
|
1180
1123
|
value,
|
|
1181
1124
|
defaultValue,
|
|
1182
1125
|
disabled,
|
|
@@ -1232,7 +1175,6 @@ var NumericInputBase = forwardRef((props, ref) => {
|
|
|
1232
1175
|
const actionPromptNode = actionPrompt[0] || null;
|
|
1233
1176
|
const tv = NumericInputTv({
|
|
1234
1177
|
variant,
|
|
1235
|
-
size,
|
|
1236
1178
|
selected: selected || handlerPressed,
|
|
1237
1179
|
focused,
|
|
1238
1180
|
disabled,
|
|
@@ -11,6 +11,7 @@ export interface NumericInputContextValue {
|
|
|
11
11
|
max?: number;
|
|
12
12
|
min?: number;
|
|
13
13
|
onChange?: (value: NumericInputValue, detail: NumericChangeDetail) => void;
|
|
14
|
+
onChangeEnd?: (value: NumericInputValue, detail: NumericChangeDetail) => void;
|
|
14
15
|
onEmpty?: () => void;
|
|
15
16
|
onIsEditingChange?: (isEditing: boolean) => void;
|
|
16
17
|
onPressEnd?: PressMoveProps["onPressEnd"];
|
|
@@ -17,7 +17,9 @@ interface UseInputInteractionsProps<T extends NumericInputValue> {
|
|
|
17
17
|
setDisplayValue: (value: string) => void;
|
|
18
18
|
setIsFocused: (focused: boolean) => void;
|
|
19
19
|
setValue: (value: NumberResult | ((prev: NumberResult | undefined) => NumberResult)) => void;
|
|
20
|
-
updateValue: (updateFn?: (value: number) => number
|
|
20
|
+
updateValue: (updateFn?: (value: number) => number, options?: {
|
|
21
|
+
source?: "drag" | "keyboard";
|
|
22
|
+
}) => void;
|
|
21
23
|
value?: T;
|
|
22
24
|
}
|
|
23
25
|
/**
|
|
@@ -10,6 +10,7 @@ interface UseNumericInputProps<T extends NumericInputValue> extends Omit<HTMLPro
|
|
|
10
10
|
max?: number;
|
|
11
11
|
min?: number;
|
|
12
12
|
onChange?: (value: T, obj: NumberResult) => void;
|
|
13
|
+
onChangeEnd?: (value: T, obj: NumberResult) => void;
|
|
13
14
|
onEmpty?: () => void;
|
|
14
15
|
onPressEnd?: PressMoveProps["onPressEnd"];
|
|
15
16
|
onPressStart?: PressMoveProps["onPressStart"];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useRef, useState,
|
|
1
|
+
import { useRef, useState, useCallback, useEffect } from "react";
|
|
2
2
|
import { dealWithNumericInputValue } from "../utils/numeric-value-processor.js";
|
|
3
3
|
import { useInputInteractions } from "./use-input-interactions.js";
|
|
4
4
|
import { useNumericValueProcessing } from "./use-numeric-value-processing.js";
|
|
@@ -21,11 +21,15 @@ function useNumericInput(props) {
|
|
|
21
21
|
step = 1,
|
|
22
22
|
value,
|
|
23
23
|
onChange,
|
|
24
|
+
onChangeEnd,
|
|
24
25
|
onEmpty,
|
|
25
26
|
onPressEnd,
|
|
26
27
|
onPressStart
|
|
27
28
|
} = props;
|
|
28
29
|
const innerRef = useRef(null);
|
|
30
|
+
const dragHasChangedRef = useRef(false);
|
|
31
|
+
const dragEndValueRef = useRef(void 0);
|
|
32
|
+
const dragEndDetailRef = useRef(void 0);
|
|
29
33
|
const [isFocused, setIsFocused] = useState(false);
|
|
30
34
|
const [displayValue, setDisplayValue] = useState("");
|
|
31
35
|
const { shiftPressed, metaPressed } = useModifierKeys(disabled);
|
|
@@ -43,6 +47,10 @@ function useNumericInput(props) {
|
|
|
43
47
|
defaultValue: defaultValuePre,
|
|
44
48
|
allowEmpty: true
|
|
45
49
|
});
|
|
50
|
+
const mapResultToOutputValue = useCallback(
|
|
51
|
+
(result) => typeof value === "string" ? result.string : typeof value === "number" ? result.array[0] : Array.isArray(value) ? result.array : result.object,
|
|
52
|
+
[value]
|
|
53
|
+
);
|
|
46
54
|
useEffect(() => {
|
|
47
55
|
if (!innerValue) {
|
|
48
56
|
setDisplayValue("");
|
|
@@ -61,7 +69,7 @@ function useNumericInput(props) {
|
|
|
61
69
|
setDisplayValue(valuePre2.string);
|
|
62
70
|
}, [innerValue, expression, max, min, decimal, setValue]);
|
|
63
71
|
const updateValue = useCallback(
|
|
64
|
-
(updateFn) => {
|
|
72
|
+
(updateFn, options) => {
|
|
65
73
|
if (disabled || readOnly) return;
|
|
66
74
|
setValue((prev) => {
|
|
67
75
|
if (!prev) {
|
|
@@ -73,10 +81,13 @@ function useNumericInput(props) {
|
|
|
73
81
|
min,
|
|
74
82
|
decimal
|
|
75
83
|
});
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
84
|
+
const nextValue = mapResultToOutputValue(initialValue);
|
|
85
|
+
onChange == null ? void 0 : onChange(nextValue, initialValue);
|
|
86
|
+
if ((options == null ? void 0 : options.source) === "drag") {
|
|
87
|
+
dragHasChangedRef.current = true;
|
|
88
|
+
dragEndValueRef.current = nextValue;
|
|
89
|
+
dragEndDetailRef.current = initialValue;
|
|
90
|
+
}
|
|
80
91
|
return initialValue;
|
|
81
92
|
}
|
|
82
93
|
const valuePre2 = dealWithNumericInputValue({
|
|
@@ -100,15 +111,18 @@ function useNumericInput(props) {
|
|
|
100
111
|
return true;
|
|
101
112
|
})();
|
|
102
113
|
if (hasChanged) {
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
114
|
+
const nextValue = mapResultToOutputValue(valuePre2);
|
|
115
|
+
onChange == null ? void 0 : onChange(nextValue, valuePre2);
|
|
116
|
+
if ((options == null ? void 0 : options.source) === "drag") {
|
|
117
|
+
dragHasChangedRef.current = true;
|
|
118
|
+
dragEndValueRef.current = nextValue;
|
|
119
|
+
dragEndDetailRef.current = valuePre2;
|
|
120
|
+
}
|
|
107
121
|
}
|
|
108
122
|
return valuePre2;
|
|
109
123
|
});
|
|
110
124
|
},
|
|
111
|
-
[disabled, readOnly, setValue, max, min, decimal, onChange,
|
|
125
|
+
[disabled, readOnly, setValue, max, min, decimal, onChange, expressionRef, mapResultToOutputValue]
|
|
112
126
|
);
|
|
113
127
|
const { inputHandlers } = useInputInteractions({
|
|
114
128
|
inputRef: innerRef,
|
|
@@ -133,6 +147,9 @@ function useNumericInput(props) {
|
|
|
133
147
|
const { isPressed: handlerPressed, pressMoveProps } = usePressMove({
|
|
134
148
|
disabled,
|
|
135
149
|
onPressStart: (e) => {
|
|
150
|
+
dragHasChangedRef.current = false;
|
|
151
|
+
dragEndValueRef.current = void 0;
|
|
152
|
+
dragEndDetailRef.current = void 0;
|
|
136
153
|
const wasFocused = isFocused;
|
|
137
154
|
if (onPressStart && "nativeEvent" in e) {
|
|
138
155
|
onPressStart(e.nativeEvent);
|
|
@@ -158,12 +175,18 @@ function useNumericInput(props) {
|
|
|
158
175
|
onPressEnd(e.nativeEvent);
|
|
159
176
|
}
|
|
160
177
|
onPressEnd == null ? void 0 : onPressEnd(e);
|
|
178
|
+
if (dragHasChangedRef.current && dragEndValueRef.current !== void 0 && dragEndDetailRef.current !== void 0) {
|
|
179
|
+
onChangeEnd == null ? void 0 : onChangeEnd(dragEndValueRef.current, dragEndDetailRef.current);
|
|
180
|
+
}
|
|
181
|
+
dragHasChangedRef.current = false;
|
|
182
|
+
dragEndValueRef.current = void 0;
|
|
183
|
+
dragEndDetailRef.current = void 0;
|
|
161
184
|
},
|
|
162
185
|
onPressMoveLeft: (delta) => {
|
|
163
|
-
updateValue((value2) => value2 - delta * getCurrentStep());
|
|
186
|
+
updateValue((value2) => value2 - delta * getCurrentStep(), { source: "drag" });
|
|
164
187
|
},
|
|
165
188
|
onPressMoveRight: (delta) => {
|
|
166
|
-
updateValue((value2) => value2 + delta * getCurrentStep());
|
|
189
|
+
updateValue((value2) => value2 + delta * getCurrentStep(), { source: "drag" });
|
|
167
190
|
}
|
|
168
191
|
});
|
|
169
192
|
const inputProps = {
|
|
@@ -13,6 +13,7 @@ export interface NumericInputProps extends NumericInputContextValue, Omit<HTMLPr
|
|
|
13
13
|
disabled?: boolean;
|
|
14
14
|
id?: string;
|
|
15
15
|
onChange?: (value: NumericInputValue, detail: NumericChangeDetail) => void;
|
|
16
|
+
onChangeEnd?: (value: NumericInputValue, detail: NumericChangeDetail) => void;
|
|
16
17
|
tooltip?: TooltipProps;
|
|
17
18
|
triggerRef?: React.RefObject<HTMLDivElement> | ((el: HTMLDivElement | null) => void);
|
|
18
19
|
}
|
|
@@ -35,6 +35,7 @@ const NumericInputBase = forwardRef((props, ref) => {
|
|
|
35
35
|
selected = false,
|
|
36
36
|
tooltip,
|
|
37
37
|
onChange,
|
|
38
|
+
onChangeEnd,
|
|
38
39
|
onEmpty,
|
|
39
40
|
onPressEnd,
|
|
40
41
|
onPressStart,
|
|
@@ -58,6 +59,7 @@ const NumericInputBase = forwardRef((props, ref) => {
|
|
|
58
59
|
step,
|
|
59
60
|
value,
|
|
60
61
|
onChange,
|
|
62
|
+
onChangeEnd,
|
|
61
63
|
onEmpty,
|
|
62
64
|
onPressEnd,
|
|
63
65
|
onPressStart,
|
|
@@ -98,6 +100,7 @@ const NumericInputBase = forwardRef((props, ref) => {
|
|
|
98
100
|
expression,
|
|
99
101
|
// Event handling methods
|
|
100
102
|
onChange,
|
|
103
|
+
onChangeEnd,
|
|
101
104
|
onEmpty,
|
|
102
105
|
onPressStart,
|
|
103
106
|
onPressEnd,
|
|
@@ -122,6 +125,7 @@ const NumericInputBase = forwardRef((props, ref) => {
|
|
|
122
125
|
decimal,
|
|
123
126
|
expression,
|
|
124
127
|
onChange,
|
|
128
|
+
onChangeEnd,
|
|
125
129
|
onEmpty,
|
|
126
130
|
onPressStart,
|
|
127
131
|
onPressEnd,
|
|
@@ -11,20 +11,20 @@ interface PanelRowProps extends Omit<HTMLProps<HTMLFieldSetElement>, "title"> {
|
|
|
11
11
|
* @default "single"
|
|
12
12
|
* @description
|
|
13
13
|
* - `single`: `columns`: 1fr | `areas`: "label" "input" | `rows`: auto minmax(2rem, auto)
|
|
14
|
-
* - `two-columns`: `columns`: 1fr 1fr | `areas`: "label
|
|
14
|
+
* - `two-columns`: `columns`: 1fr 1fr | `areas`: "label label" "left right" | `rows`: auto minmax(2rem, auto)
|
|
15
15
|
* - `one-label-one-input`: `columns`: 8fr 20fr | `areas`: "label input" | `rows`: 2rem
|
|
16
|
-
* - `one-label-one-input-one-icon`: `columns`: 8fr 20fr
|
|
17
|
-
* - `one-label-two-input`: `columns`: 8fr
|
|
18
|
-
* - `one-icon-one-input`: `columns`:
|
|
19
|
-
* - `one-input-one-icon`: `columns`: 1fr
|
|
20
|
-
* - `one-input-two-icon`: `columns`: 1fr
|
|
21
|
-
* - `two-input-two-icon`: `columns`:
|
|
22
|
-
* - `two-input-one-icon`: `columns`: 1fr 1fr
|
|
23
|
-
* - `one-icon-one-input-
|
|
24
|
-
* - `
|
|
25
|
-
* - `
|
|
16
|
+
* - `one-label-one-input-one-icon`: `columns`: 8fr 20fr 2rem | `areas`: "label input icon" | `rows`: 2rem
|
|
17
|
+
* - `one-label-two-input`: `columns`: 8fr 1fr 1fr | `areas`: "label left right" | `rows`: 2rem
|
|
18
|
+
* - `one-icon-one-input`: `columns`: 2rem 1fr | `areas`: "icon input" | `rows`: 2rem
|
|
19
|
+
* - `one-input-one-icon`: `columns`: 1fr 2rem | `areas`: "input icon" | `rows`: 2rem
|
|
20
|
+
* - `one-input-two-icon`: `columns`: 1fr 1fr 2rem | `areas`: "input left icon" "input right icon" | `rows`: 2rem
|
|
21
|
+
* - `two-input-two-icon`: `columns`: 1fr 1fr 2rem | `areas`: "left icon right icon" | `rows`: 2rem
|
|
22
|
+
* - `two-input-one-icon`: `columns`: 2rem 1fr 1fr | `areas`: "icon left right" | `rows`: 2rem
|
|
23
|
+
* - `one-icon-one-input-two-icon`: `columns`: 2rem 1fr 2rem | `areas`: "icon input icon" | `rows`: 2rem
|
|
24
|
+
* - `two-input-one-icon-double-row`: `columns`: 1fr 1fr 2rem | `areas`: "left icon right icon" | `rows`: 2rem 2rem
|
|
25
|
+
* - `one-icon-one-input-two-icon-double-row`: `columns`: 2rem 1fr 2rem | `areas`: "icon input icon" | `rows`: 2rem 2rem
|
|
26
26
|
*/
|
|
27
|
-
type?: "single" | "two-columns" | "one-label-one-input" | "one-label-one-input-one-icon" | "one-label-two-input" | "one-icon-one-input" | "one-input-one-icon" | "one-input-two-icon" | "two-input-two-icon" | "two-input-one-icon" | "one-icon-one-input-
|
|
27
|
+
type?: "single" | "two-columns" | "one-label-one-input" | "one-label-one-input-one-icon" | "one-label-two-input" | "one-icon-one-input" | "one-input-one-icon" | "one-input-two-icon" | "two-input-two-icon" | "two-input-one-icon" | "one-icon-one-input-two-icon" | "two-input-one-icon-double-row";
|
|
28
28
|
}
|
|
29
29
|
declare const PanelRow: react.ForwardRefExoticComponent<Omit<PanelRowProps, "ref"> & react.RefAttributes<HTMLFieldSetElement>>;
|
|
30
30
|
|
|
@@ -83,8 +83,8 @@ declare const SortablePaneContext: react__default.Context<SortablePaneContextVal
|
|
|
83
83
|
declare const useSortablePane: () => SortablePaneContextValue;
|
|
84
84
|
|
|
85
85
|
interface PanelSortableProps<T extends SortableItem> {
|
|
86
|
-
className?: string;
|
|
87
86
|
children: react__default.ReactNode;
|
|
87
|
+
className?: string;
|
|
88
88
|
data: T[];
|
|
89
89
|
onDrop: (position: "top" | "bottom" | null, id: string, newIndex: number) => void;
|
|
90
90
|
onSelectedIdChange: (id: string | null) => void;
|
|
@@ -129,12 +129,12 @@ interface PanelProps extends Omit<HTMLProps<HTMLDivElement>, "title"> {
|
|
|
129
129
|
showLabels?: boolean;
|
|
130
130
|
triggerRef?: React.RefObject<HTMLDivElement>;
|
|
131
131
|
}
|
|
132
|
-
declare const PanelContent:
|
|
132
|
+
declare const PanelContent: ({ children, collapsible, title, otherChildren, }: {
|
|
133
133
|
children: React.ReactNode;
|
|
134
134
|
collapsible?: boolean;
|
|
135
135
|
otherChildren: React.ReactNode[];
|
|
136
136
|
title: React.ReactNode;
|
|
137
|
-
}
|
|
137
|
+
}) => react_jsx_runtime.JSX.Element;
|
|
138
138
|
interface PanelComponentProps extends React.ForwardRefExoticComponent<PanelProps & React.RefAttributes<HTMLDivElement>> {
|
|
139
139
|
Content: typeof PanelContent;
|
|
140
140
|
Label: typeof PanelLabel;
|
|
@@ -149,4 +149,4 @@ interface PanelComponentProps extends React.ForwardRefExoticComponent<PanelProps
|
|
|
149
149
|
declare const PanelBase: react.ForwardRefExoticComponent<Omit<PanelProps, "ref"> & react.RefAttributes<HTMLDivElement>>;
|
|
150
150
|
declare const Panel: PanelComponentProps;
|
|
151
151
|
|
|
152
|
-
export { Panel, PanelBase, PanelContext,
|
|
152
|
+
export { Panel, PanelBase, PanelContext, PanelLabel, PanelPreviewer, PanelRow, PanelRowLabel, PanelRowManyIcon, type PanelRowManyIconItem, type PanelRowManyIconProps, type PanelRowProps, PanelSortable, PanelSortableRow, PanelTitle, type SortableItem, SortablePaneContext, type SortablePaneContextValue, SortableRowDataContext, type SortableRowDataContextValue, usePanelContext, useSortablePane, useSortableRowItem };
|
|
@@ -14,11 +14,6 @@ interface PicturePreviewProps extends HTMLProps<HTMLDivElement> {
|
|
|
14
14
|
fileName?: string;
|
|
15
15
|
onClose?: () => void;
|
|
16
16
|
src: string;
|
|
17
|
-
control?: {
|
|
18
|
-
enable?: boolean;
|
|
19
|
-
position?: "top-left" | "top-right" | "bottom-left" | "bottom-right";
|
|
20
|
-
show?: "always" | "hover";
|
|
21
|
-
};
|
|
22
17
|
}
|
|
23
18
|
declare const PicturePreview: react.ForwardRefExoticComponent<Omit<PicturePreviewProps, "ref"> & react.RefAttributes<HTMLDivElement>>;
|
|
24
19
|
|