@milktop/react-ui 0.3.29 → 0.3.30
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.
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
* - `allowMouseWheel`: scroll over the focused input to step
|
|
14
14
|
* - `steppers`: false to hide the buttons
|
|
15
15
|
* - `name`: for plain form posts
|
|
16
|
+
* - `autoFocus`: focuses the input, in a Dialog or Popover too
|
|
16
17
|
*
|
|
17
18
|
* By hand, with Ark's parts:
|
|
18
19
|
*
|
|
@@ -43,7 +44,7 @@ export type NumberInputProps = Omit<Ark.RootProps, 'value' | 'defaultValue' | 'o
|
|
|
43
44
|
placeholder?: string;
|
|
44
45
|
classes?: Classes<'root' | 'label' | 'control' | 'icon' | 'prefix' | 'input' | 'suffix' | 'decrementTrigger' | 'incrementTrigger'>;
|
|
45
46
|
};
|
|
46
|
-
declare function NumberInputShortcut({ label, value, defaultValue, onValueChange, prefix, suffix, icon, steppers, placeholder, locale: localeProp, formatOptions: formatProp, className, classes, ...rest }: NumberInputProps): import("react").JSX.Element;
|
|
47
|
+
declare function NumberInputShortcut({ label, value, defaultValue, onValueChange, prefix, suffix, icon, steppers, placeholder, locale: localeProp, formatOptions: formatProp, autoFocus, className, classes, ...rest }: NumberInputProps): import("react").JSX.Element;
|
|
47
48
|
export declare const NumberInput: typeof NumberInputShortcut & {
|
|
48
49
|
Root: import("react").ForwardRefExoticComponent<Ark.RootProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
49
50
|
Label: import("react").ForwardRefExoticComponent<Ark.LabelProps & import("react").RefAttributes<HTMLLabelElement>>;
|
|
@@ -14,6 +14,7 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
|
|
|
14
14
|
* - `allowMouseWheel`: scroll over the focused input to step
|
|
15
15
|
* - `steppers`: false to hide the buttons
|
|
16
16
|
* - `name`: for plain form posts
|
|
17
|
+
* - `autoFocus`: focuses the input, in a Dialog or Popover too
|
|
17
18
|
*
|
|
18
19
|
* By hand, with Ark's parts:
|
|
19
20
|
*
|
|
@@ -83,7 +84,7 @@ function numbers(locale, given) {
|
|
|
83
84
|
toText: (value) => (value == null ? '' : formatOptions ? format.format(value) : String(value)),
|
|
84
85
|
};
|
|
85
86
|
}
|
|
86
|
-
function NumberInputShortcut({ label = null, value, defaultValue, onValueChange, prefix = null, suffix = null, icon = null, steppers = true, placeholder = '', locale: localeProp, formatOptions: formatProp, className, classes, ...rest }) {
|
|
87
|
+
function NumberInputShortcut({ label = null, value, defaultValue, onValueChange, prefix = null, suffix = null, icon = null, steppers = true, placeholder = '', locale: localeProp, formatOptions: formatProp, autoFocus, className, classes, ...rest }) {
|
|
87
88
|
const t = useMessages();
|
|
88
89
|
const field = useFieldContext();
|
|
89
90
|
const part = partsOf('number-input', classes);
|
|
@@ -110,7 +111,7 @@ function NumberInputShortcut({ label = null, value, defaultValue, onValueChange,
|
|
|
110
111
|
onValueChange?.(number, details);
|
|
111
112
|
}
|
|
112
113
|
return (_jsxs(Ark.Root, { ...(t.zag.numberInput && { translations: t.zag.numberInput }), ...rest, ...part('root'), className: cx(className, classes?.root), locale: locale, ...(formatOptions && { formatOptions }), value: text, onValueChange: change, children: [label && !field && _jsx(Ark.Label, { ...part('label'), children: label }), _jsxs(Ark.Control, { ...part('control'), children: [icon ? _jsx("iconify-icon", { ...part('icon'), icon: icon, "aria-hidden": "true" })
|
|
113
|
-
: prefix != null && _jsx("span", { ...part('prefix'), children: prefix }), _jsx(Ark.Input, { ...part('input'), placeholder: placeholder, ref: inputRef }), suffix != null && _jsx("span", { ...part('suffix'), children: suffix }), steppers && _jsxs(_Fragment, { children: [_jsx(Ark.DecrementTrigger, { ...part('decrement-trigger'), children: _jsx("iconify-icon", { icon: "lucide:minus" }) }), _jsx(Ark.IncrementTrigger, { ...part('increment-trigger'), children: _jsx("iconify-icon", { icon: "lucide:plus" }) })] })] })] }));
|
|
114
|
+
: prefix != null && _jsx("span", { ...part('prefix'), children: prefix }), _jsx(Ark.Input, { ...part('input'), placeholder: placeholder, ref: inputRef, autoFocus: autoFocus, "data-autofocus": autoFocus || undefined }), suffix != null && _jsx("span", { ...part('suffix'), children: suffix }), steppers && _jsxs(_Fragment, { children: [_jsx(Ark.DecrementTrigger, { ...part('decrement-trigger'), children: _jsx("iconify-icon", { icon: "lucide:minus" }) }), _jsx(Ark.IncrementTrigger, { ...part('increment-trigger'), children: _jsx("iconify-icon", { icon: "lucide:plus" }) })] })] })] }));
|
|
114
115
|
}
|
|
115
116
|
export const NumberInput = withParts(NumberInputShortcut, {
|
|
116
117
|
Root: Ark.Root,
|