@ledgerhq/lumen-ui-react 0.1.54 → 0.1.56
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/lib/Components/core/Card/Card.d.ts.map +1 -1
- package/dist/lib/Components/core/Card/Card.js +29 -25
- package/dist/lib/Components/core/SearchInput/types.d.ts +2 -2
- package/dist/lib/Components/core/SearchInput/types.d.ts.map +1 -1
- package/dist/lib/Components/core/SegmentedControl/SegmentedControl.d.ts +1 -1
- package/dist/lib/Components/core/SegmentedControl/SegmentedControl.d.ts.map +1 -1
- package/dist/lib/Components/core/SegmentedControl/SegmentedControl.js +242 -97
- package/dist/lib/Components/core/SegmentedControl/SegmentedControlContext.d.ts +2 -1
- package/dist/lib/Components/core/SegmentedControl/SegmentedControlContext.d.ts.map +1 -1
- package/dist/lib/Components/core/SegmentedControl/types.d.ts +4 -3
- package/dist/lib/Components/core/SegmentedControl/types.d.ts.map +1 -1
- package/dist/lib/Components/core/SegmentedControl/usePillElementLayoutEffect.js +13 -12
- package/dist/lib/Components/core/SegmentedControl/useScrollArrows.d.ts +16 -0
- package/dist/lib/Components/core/SegmentedControl/useScrollArrows.d.ts.map +1 -0
- package/dist/lib/Components/core/SegmentedControl/useScrollArrows.js +51 -0
- package/dist/lib/Components/core/TextInput/types.d.ts +1 -2
- package/dist/lib/Components/core/TextInput/types.d.ts.map +1 -1
- package/dist/lib/Components/internal/BaseInput/BaseInput.d.ts +2 -16
- package/dist/lib/Components/internal/BaseInput/BaseInput.d.ts.map +1 -1
- package/dist/lib/Components/internal/BaseInput/BaseInput.js +141 -168
- package/dist/lib/Components/internal/BaseInput/BaseInputCounter.d.ts +8 -0
- package/dist/lib/Components/internal/BaseInput/BaseInputCounter.d.ts.map +1 -0
- package/dist/lib/Components/internal/BaseInput/BaseInputCounter.js +8 -0
- package/dist/lib/Components/internal/BaseInput/BaseInputHelperText.d.ts +8 -0
- package/dist/lib/Components/internal/BaseInput/BaseInputHelperText.d.ts.map +1 -0
- package/dist/lib/Components/internal/BaseInput/BaseInputHelperText.js +37 -0
- package/dist/lib/Components/internal/BaseInput/BaseInputLabel.d.ts +8 -0
- package/dist/lib/Components/internal/BaseInput/BaseInputLabel.d.ts.map +1 -0
- package/dist/lib/Components/internal/BaseInput/BaseInputLabel.js +48 -0
- package/dist/lib/Components/internal/BaseInput/BaseInputMultiline.d.ts +9 -0
- package/dist/lib/Components/internal/BaseInput/BaseInputMultiline.d.ts.map +1 -0
- package/dist/lib/Components/internal/BaseInput/BaseInputMultiline.js +88 -0
- package/dist/lib/Components/internal/BaseInput/BaseInputSingleLine.d.ts +8 -0
- package/dist/lib/Components/internal/BaseInput/BaseInputSingleLine.d.ts.map +1 -0
- package/dist/lib/Components/internal/BaseInput/BaseInputSingleLine.js +25 -0
- package/dist/lib/Components/internal/BaseInput/types.d.ts +72 -1
- package/dist/lib/Components/internal/BaseInput/types.d.ts.map +1 -1
- package/dist/lib/Components/internal/BaseInput/useAutosizeTextarea/index.d.ts +2 -0
- package/dist/lib/Components/internal/BaseInput/useAutosizeTextarea/index.d.ts.map +1 -0
- package/dist/lib/Components/internal/BaseInput/useAutosizeTextarea/useAutosizeTextarea.d.ts +20 -0
- package/dist/lib/Components/internal/BaseInput/useAutosizeTextarea/useAutosizeTextarea.d.ts.map +1 -0
- package/dist/lib/Components/internal/BaseInput/useAutosizeTextarea/useAutosizeTextarea.js +49 -0
- package/dist/lib/Components/internal/BaseInput/useBaseInputValue/useBaseInputValue.d.ts +26 -0
- package/dist/lib/Components/internal/BaseInput/useBaseInputValue/useBaseInputValue.d.ts.map +1 -0
- package/dist/lib/Components/internal/BaseInput/useBaseInputValue/useBaseInputValue.js +35 -0
- package/dist/package.json +3 -3
- package/package.json +2 -2
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { jsxs as m, Fragment as g, jsx as i } from "react/jsx-runtime";
|
|
2
|
+
import { useMergedRef as b, cn as u } from "../../../../libs/utils-shared/dist/index.js";
|
|
3
|
+
import { cva as x } from "class-variance-authority";
|
|
4
|
+
import { useRef as v, useLayoutEffect as w } from "react";
|
|
5
|
+
import { useAutosizeTextarea as C } from "./useAutosizeTextarea/useAutosizeTextarea.js";
|
|
6
|
+
const c = x(
|
|
7
|
+
[
|
|
8
|
+
"w-full flex-1 resize-none bg-transparent body-1 wrap-break-word whitespace-pre-wrap text-base caret-active outline-hidden transition-colors",
|
|
9
|
+
"group-has-disabled:cursor-not-allowed group-has-disabled:text-disabled",
|
|
10
|
+
"placeholder:text-muted group-has-disabled:placeholder:text-disabled"
|
|
11
|
+
],
|
|
12
|
+
{
|
|
13
|
+
variants: {
|
|
14
|
+
hasLabel: {
|
|
15
|
+
true: "body-2",
|
|
16
|
+
false: ""
|
|
17
|
+
},
|
|
18
|
+
scrollbarWidth: {
|
|
19
|
+
auto: "scrollbar-custom pe-8",
|
|
20
|
+
none: "scrollbar-none"
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
defaultVariants: {
|
|
24
|
+
hasLabel: !1,
|
|
25
|
+
scrollbarWidth: "auto"
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
), R = (s, r) => {
|
|
29
|
+
const t = v(!1), o = (e) => {
|
|
30
|
+
const a = e.target, n = "isComposing" in e.nativeEvent && e.nativeEvent.isComposing === !0;
|
|
31
|
+
t.current = !n && a.value.endsWith(`
|
|
32
|
+
`) && a.selectionStart === a.value.length, r?.(e);
|
|
33
|
+
};
|
|
34
|
+
return w(() => {
|
|
35
|
+
if (!t.current) return;
|
|
36
|
+
t.current = !1;
|
|
37
|
+
const e = s.current;
|
|
38
|
+
!e || document.activeElement !== e || (e.scrollTop = e.scrollHeight);
|
|
39
|
+
}), o;
|
|
40
|
+
}, I = ({
|
|
41
|
+
ref: s,
|
|
42
|
+
className: r,
|
|
43
|
+
hasLabel: t = !1,
|
|
44
|
+
minLines: o = 1,
|
|
45
|
+
maxLines: e,
|
|
46
|
+
scrollbarWidth: a = "auto",
|
|
47
|
+
onChange: n,
|
|
48
|
+
...d
|
|
49
|
+
}) => {
|
|
50
|
+
const { textareaRef: l, shadowRef: f } = C({
|
|
51
|
+
minLines: o,
|
|
52
|
+
maxLines: e
|
|
53
|
+
}), p = b(s, l), h = R(l, n);
|
|
54
|
+
return /* @__PURE__ */ m(g, { children: [
|
|
55
|
+
/* @__PURE__ */ i(
|
|
56
|
+
"textarea",
|
|
57
|
+
{
|
|
58
|
+
ref: p,
|
|
59
|
+
rows: o,
|
|
60
|
+
className: u(
|
|
61
|
+
"peer",
|
|
62
|
+
c({ hasLabel: t, scrollbarWidth: a }),
|
|
63
|
+
t && "mt-16",
|
|
64
|
+
r
|
|
65
|
+
),
|
|
66
|
+
onChange: h,
|
|
67
|
+
...d
|
|
68
|
+
}
|
|
69
|
+
),
|
|
70
|
+
/* @__PURE__ */ i(
|
|
71
|
+
"textarea",
|
|
72
|
+
{
|
|
73
|
+
ref: f,
|
|
74
|
+
"aria-hidden": !0,
|
|
75
|
+
readOnly: !0,
|
|
76
|
+
tabIndex: -1,
|
|
77
|
+
className: u(
|
|
78
|
+
c({ hasLabel: t, scrollbarWidth: a }),
|
|
79
|
+
r,
|
|
80
|
+
"invisible absolute top-0 left-0 h-0 transform-gpu overflow-hidden py-0"
|
|
81
|
+
)
|
|
82
|
+
}
|
|
83
|
+
)
|
|
84
|
+
] });
|
|
85
|
+
};
|
|
86
|
+
export {
|
|
87
|
+
I as BaseInputMultiline
|
|
88
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { BaseInputSingleLineProps } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* The single-line control rendered inside `BaseInput`.
|
|
4
|
+
*
|
|
5
|
+
* @internal
|
|
6
|
+
*/
|
|
7
|
+
export declare const BaseInputSingleLine: ({ ref, className, hasLabel, ...props }: BaseInputSingleLineProps) => import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
//# sourceMappingURL=BaseInputSingleLine.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BaseInputSingleLine.d.ts","sourceRoot":"","sources":["../../../../../src/lib/Components/internal/BaseInput/BaseInputSingleLine.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAC;AAWxD;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,GAAI,wCAKjC,wBAAwB,4CAQ1B,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { jsx as d } from "react/jsx-runtime";
|
|
2
|
+
import { cn as e } from "../../../../libs/utils-shared/dist/index.js";
|
|
3
|
+
const r = e(
|
|
4
|
+
"peer w-full flex-1 bg-muted body-1 text-base caret-active outline-hidden transition-colors",
|
|
5
|
+
"group-hover:bg-muted-hover group-disabled:bg-disabled",
|
|
6
|
+
"group-has-disabled:cursor-not-allowed group-has-disabled:bg-disabled group-has-disabled:text-disabled",
|
|
7
|
+
"placeholder:text-muted group-has-disabled:placeholder:text-disabled",
|
|
8
|
+
"[&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:appearance-none",
|
|
9
|
+
"truncate"
|
|
10
|
+
), l = ({
|
|
11
|
+
ref: t,
|
|
12
|
+
className: a,
|
|
13
|
+
hasLabel: o = !1,
|
|
14
|
+
...s
|
|
15
|
+
}) => /* @__PURE__ */ d(
|
|
16
|
+
"input",
|
|
17
|
+
{
|
|
18
|
+
ref: t,
|
|
19
|
+
className: e(r, o && "pt-12 body-2", a),
|
|
20
|
+
...s
|
|
21
|
+
}
|
|
22
|
+
);
|
|
23
|
+
export {
|
|
24
|
+
l as BaseInputSingleLine
|
|
25
|
+
};
|
|
@@ -1,5 +1,10 @@
|
|
|
1
|
-
import { ComponentPropsWithRef, ReactNode } from 'react';
|
|
1
|
+
import { ComponentPropsWithRef, InputHTMLAttributes, ReactNode, Ref } from 'react';
|
|
2
2
|
export type BaseInputStatus = 'error' | 'success';
|
|
3
|
+
export type BaseInputElement = HTMLInputElement | HTMLTextAreaElement;
|
|
4
|
+
/**
|
|
5
|
+
* Visibility of the scroll affordance once the field reaches `maxLines`.
|
|
6
|
+
*/
|
|
7
|
+
export type BaseInputScrollbarWidth = 'none' | 'auto';
|
|
3
8
|
export type BaseInputProps = {
|
|
4
9
|
/**
|
|
5
10
|
* The label text that floats above the input when focused or filled.
|
|
@@ -37,6 +42,7 @@ export type BaseInputProps = {
|
|
|
37
42
|
prefix?: ReactNode;
|
|
38
43
|
/**
|
|
39
44
|
* Optional function to extend the default clear behavior with custom logic
|
|
45
|
+
* Called after the field is emptied. Clearing always calls `onChange` first
|
|
40
46
|
*/
|
|
41
47
|
onClear?: () => void;
|
|
42
48
|
/**
|
|
@@ -60,7 +66,72 @@ export type BaseInputProps = {
|
|
|
60
66
|
* Additional class names to apply to the label element
|
|
61
67
|
*/
|
|
62
68
|
labelClassName?: string;
|
|
69
|
+
/**
|
|
70
|
+
* Renders a multi-line `textarea` that auto-grows between `minLines` and `maxLines`
|
|
71
|
+
* @default false
|
|
72
|
+
*/
|
|
73
|
+
multiline?: boolean;
|
|
74
|
+
/**
|
|
75
|
+
* Minimum height of the field, in lines. Ignored unless `multiline` is set.
|
|
76
|
+
* @default 1
|
|
77
|
+
*/
|
|
78
|
+
minLines?: number;
|
|
79
|
+
/**
|
|
80
|
+
* Growth ceiling, in lines; past it the field scrolls internally. Unbounded when
|
|
81
|
+
* omitted. Ignored unless `multiline` is set.
|
|
82
|
+
*/
|
|
83
|
+
maxLines?: number;
|
|
84
|
+
/**
|
|
85
|
+
* Controls whether the Lumen thin scrollbar is visible once the field reaches
|
|
86
|
+
* `maxLines`. Ignored unless `multiline` is set.
|
|
87
|
+
* @default 'auto'
|
|
88
|
+
*/
|
|
89
|
+
scrollbarWidth?: BaseInputScrollbarWidth;
|
|
90
|
+
} & Omit<InputHTMLAttributes<BaseInputElement>, 'size' | 'prefix'> & {
|
|
91
|
+
ref?: Ref<BaseInputElement>;
|
|
92
|
+
};
|
|
93
|
+
export type BaseInputSingleLineProps = {
|
|
94
|
+
/**
|
|
95
|
+
* Whether a floating label sits above the value, reserving vertical space at
|
|
96
|
+
* the top of the input.
|
|
97
|
+
* @default false
|
|
98
|
+
*/
|
|
99
|
+
hasLabel?: boolean;
|
|
63
100
|
} & Omit<ComponentPropsWithRef<'input'>, 'size' | 'prefix'>;
|
|
101
|
+
export type BaseInputMultilineProps = {
|
|
102
|
+
/**
|
|
103
|
+
* Whether a floating label sits above the value, reserving vertical space at
|
|
104
|
+
* the top of the field.
|
|
105
|
+
* @default false
|
|
106
|
+
*/
|
|
107
|
+
hasLabel?: boolean;
|
|
108
|
+
} & Pick<BaseInputProps, 'minLines' | 'maxLines' | 'scrollbarWidth'> & Omit<ComponentPropsWithRef<'textarea'>, 'rows' | 'cols'>;
|
|
109
|
+
export type BaseInputLabelProps = {
|
|
110
|
+
/**
|
|
111
|
+
* Id of the input the label describes.
|
|
112
|
+
*/
|
|
113
|
+
htmlFor: string;
|
|
114
|
+
/**
|
|
115
|
+
* Keeps the label in its floated position even while the placeholder shows,
|
|
116
|
+
* used when a label and a placeholder are displayed together.
|
|
117
|
+
* @default false
|
|
118
|
+
*/
|
|
119
|
+
floated?: boolean;
|
|
120
|
+
/**
|
|
121
|
+
* Pins the resting position to the first line instead of centering it, for a
|
|
122
|
+
* field that can grow past a single line.
|
|
123
|
+
* @default false
|
|
124
|
+
*/
|
|
125
|
+
multiline?: boolean;
|
|
126
|
+
/**
|
|
127
|
+
* Additional class names to apply to the label element.
|
|
128
|
+
*/
|
|
129
|
+
className?: string;
|
|
130
|
+
/**
|
|
131
|
+
* The label copy.
|
|
132
|
+
*/
|
|
133
|
+
children: ReactNode;
|
|
134
|
+
} & Pick<BaseInputProps, 'status'>;
|
|
64
135
|
export type BaseInputHelperTextProps = {
|
|
65
136
|
/**
|
|
66
137
|
* The id linking the helper text to the input via `aria-describedby`.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/lib/Components/internal/BaseInput/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/lib/Components/internal/BaseInput/types.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/lib/Components/internal/BaseInput/useAutosizeTextarea/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { RefObject } from 'react';
|
|
2
|
+
type UseAutosizeTextareaArgs = {
|
|
3
|
+
minLines: number;
|
|
4
|
+
maxLines: number | undefined;
|
|
5
|
+
};
|
|
6
|
+
type UseAutosizeTextareaReturn = {
|
|
7
|
+
textareaRef: RefObject<HTMLTextAreaElement | null>;
|
|
8
|
+
shadowRef: RefObject<HTMLTextAreaElement | null>;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Grows a `textarea` between `minLines` and `maxLines`, measuring on an off-screen
|
|
12
|
+
* clone so the visible field is never collapsed and re-grown.
|
|
13
|
+
*
|
|
14
|
+
* Ported from MUI's `TextareaAutosize` (MIT).
|
|
15
|
+
*
|
|
16
|
+
* @internal
|
|
17
|
+
*/
|
|
18
|
+
export declare const useAutosizeTextarea: ({ minLines, maxLines, }: UseAutosizeTextareaArgs) => UseAutosizeTextareaReturn;
|
|
19
|
+
export {};
|
|
20
|
+
//# sourceMappingURL=useAutosizeTextarea.d.ts.map
|
package/dist/lib/Components/internal/BaseInput/useAutosizeTextarea/useAutosizeTextarea.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useAutosizeTextarea.d.ts","sourceRoot":"","sources":["../../../../../../src/lib/Components/internal/BaseInput/useAutosizeTextarea/useAutosizeTextarea.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAiBvC,KAAK,uBAAuB,GAAG;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;CAC9B,CAAC;AAEF,KAAK,yBAAyB,GAAG;IAC/B,WAAW,EAAE,SAAS,CAAC,mBAAmB,GAAG,IAAI,CAAC,CAAC;IACnD,SAAS,EAAE,SAAS,CAAC,mBAAmB,GAAG,IAAI,CAAC,CAAC;CAClD,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,mBAAmB,GAAI,yBAGjC,uBAAuB,KAAG,yBA8G5B,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { debounce as E } from "../../../../../libs/utils-shared/dist/index.js";
|
|
2
|
+
import { useRef as u, useCallback as g, useLayoutEffect as w } from "react";
|
|
3
|
+
const z = 166, p = "x", d = (o) => Number.parseInt(o, 10) || 0, O = ({
|
|
4
|
+
minLines: o,
|
|
5
|
+
maxLines: h
|
|
6
|
+
}) => {
|
|
7
|
+
const i = u(null), m = u(null), s = u(null), l = u(-1), c = g(() => {
|
|
8
|
+
const t = i.current, e = m.current;
|
|
9
|
+
if (!t || !e) return;
|
|
10
|
+
const r = window.getComputedStyle(t);
|
|
11
|
+
if (r.width === "0px") return;
|
|
12
|
+
e.style.width = r.width, e.value = t.value || p, e.value.endsWith(`
|
|
13
|
+
`) && (e.value += " ");
|
|
14
|
+
const b = e.scrollHeight;
|
|
15
|
+
e.value = p;
|
|
16
|
+
const f = e.scrollHeight;
|
|
17
|
+
let n = Math.max(o * f, b);
|
|
18
|
+
h && (n = Math.min(h * f, n)), n = Math.max(n, f);
|
|
19
|
+
const x = d(r.paddingTop) + d(r.paddingBottom), R = d(r.borderTopWidth) + d(r.borderBottomWidth), y = r.boxSizing === "border-box" ? x + R : 0;
|
|
20
|
+
return {
|
|
21
|
+
height: n + y,
|
|
22
|
+
// A pixel of tolerance absorbs subpixel rounding.
|
|
23
|
+
fits: Math.abs(n - b) <= 1
|
|
24
|
+
};
|
|
25
|
+
}, [o, h]), a = g(() => {
|
|
26
|
+
const t = i.current, e = c();
|
|
27
|
+
!t || !e || (s.current !== e.height && (s.current = e.height, t.style.height = `${e.height}px`), t.style.overflow = e.fits ? "hidden" : "");
|
|
28
|
+
}, [c]), v = g(() => {
|
|
29
|
+
const t = c();
|
|
30
|
+
return t !== void 0 && s.current !== null && s.current !== t.height;
|
|
31
|
+
}, [c]);
|
|
32
|
+
return w(a), w(() => {
|
|
33
|
+
const t = i.current;
|
|
34
|
+
if (!t) return;
|
|
35
|
+
const e = E(a, z);
|
|
36
|
+
window.addEventListener("resize", e);
|
|
37
|
+
let r;
|
|
38
|
+
return typeof ResizeObserver < "u" && (r = new ResizeObserver(() => {
|
|
39
|
+
v() && (r?.unobserve(t), cancelAnimationFrame(l.current), a(), l.current = requestAnimationFrame(() => {
|
|
40
|
+
r?.observe(t);
|
|
41
|
+
}));
|
|
42
|
+
}), r.observe(t)), () => {
|
|
43
|
+
e.cancel(), cancelAnimationFrame(l.current), window.removeEventListener("resize", e), r?.disconnect();
|
|
44
|
+
};
|
|
45
|
+
}, [a, v]), { textareaRef: i, shadowRef: m };
|
|
46
|
+
};
|
|
47
|
+
export {
|
|
48
|
+
O as useAutosizeTextarea
|
|
49
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ChangeEventHandler, RefCallback, RefObject } from 'react';
|
|
2
|
+
import { BaseInputElement, BaseInputProps } from '../types';
|
|
3
|
+
type UseBaseInputValueArgs = {
|
|
4
|
+
value: BaseInputProps['value'];
|
|
5
|
+
defaultValue: BaseInputProps['defaultValue'];
|
|
6
|
+
onChange: ChangeEventHandler<BaseInputElement> | undefined;
|
|
7
|
+
onClear: (() => void) | undefined;
|
|
8
|
+
ref: BaseInputProps['ref'];
|
|
9
|
+
};
|
|
10
|
+
type UseBaseInputValueReturn = {
|
|
11
|
+
inputRef: RefObject<BaseInputElement | null>;
|
|
12
|
+
composedRef: RefCallback<BaseInputElement>;
|
|
13
|
+
currentValue: string;
|
|
14
|
+
hasContent: boolean;
|
|
15
|
+
handleChange: ChangeEventHandler<BaseInputElement>;
|
|
16
|
+
handleClear: () => void;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Tracks the input value for `BaseInput` and implements the clear button, in both
|
|
20
|
+
* controlled and uncontrolled mode.
|
|
21
|
+
*
|
|
22
|
+
* @internal
|
|
23
|
+
*/
|
|
24
|
+
export declare const useBaseInputValue: ({ value, defaultValue, onChange, onClear, ref, }: UseBaseInputValueArgs) => UseBaseInputValueReturn;
|
|
25
|
+
export {};
|
|
26
|
+
//# sourceMappingURL=useBaseInputValue.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useBaseInputValue.d.ts","sourceRoot":"","sources":["../../../../../../src/lib/Components/internal/BaseInput/useBaseInputValue/useBaseInputValue.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAEV,kBAAkB,EAClB,WAAW,EACX,SAAS,EACV,MAAM,OAAO,CAAC;AAEf,OAAO,KAAK,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAEjE,KAAK,qBAAqB,GAAG;IAC3B,KAAK,EAAE,cAAc,CAAC,OAAO,CAAC,CAAC;IAC/B,YAAY,EAAE,cAAc,CAAC,cAAc,CAAC,CAAC;IAC7C,QAAQ,EAAE,kBAAkB,CAAC,gBAAgB,CAAC,GAAG,SAAS,CAAC;IAC3D,OAAO,EAAE,CAAC,MAAM,IAAI,CAAC,GAAG,SAAS,CAAC;IAClC,GAAG,EAAE,cAAc,CAAC,KAAK,CAAC,CAAC;CAC5B,CAAC;AAEF,KAAK,uBAAuB,GAAG;IAC7B,QAAQ,EAAE,SAAS,CAAC,gBAAgB,GAAG,IAAI,CAAC,CAAC;IAC7C,WAAW,EAAE,WAAW,CAAC,gBAAgB,CAAC,CAAC;IAC3C,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,OAAO,CAAC;IACpB,YAAY,EAAE,kBAAkB,CAAC,gBAAgB,CAAC,CAAC;IACnD,WAAW,EAAE,MAAM,IAAI,CAAC;CACzB,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,GAAI,kDAM/B,qBAAqB,KAAG,uBAkE1B,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { useMergedRef as g } from "../../../../../libs/utils-shared/dist/index.js";
|
|
2
|
+
import { useRef as v, useState as h } from "react";
|
|
3
|
+
const b = ({
|
|
4
|
+
value: o,
|
|
5
|
+
defaultValue: u,
|
|
6
|
+
onChange: c,
|
|
7
|
+
onClear: l,
|
|
8
|
+
ref: a
|
|
9
|
+
}) => {
|
|
10
|
+
const e = v(null), n = o !== void 0, [i, r] = h(
|
|
11
|
+
u?.toString() ?? ""
|
|
12
|
+
), p = (t) => {
|
|
13
|
+
n || r(t.target.value), c?.(t);
|
|
14
|
+
}, s = n ? o?.toString() ?? "" : i, d = s.length > 0, f = () => {
|
|
15
|
+
if (!e.current) return;
|
|
16
|
+
const t = e.current instanceof window.HTMLTextAreaElement ? window.HTMLTextAreaElement.prototype : window.HTMLInputElement.prototype;
|
|
17
|
+
Object.getOwnPropertyDescriptor(
|
|
18
|
+
t,
|
|
19
|
+
"value"
|
|
20
|
+
)?.set?.call(e.current, ""), n || r("");
|
|
21
|
+
const w = new Event("input", { bubbles: !0 });
|
|
22
|
+
e.current.dispatchEvent(w), e.current.focus(), l?.();
|
|
23
|
+
}, m = g(a, e);
|
|
24
|
+
return {
|
|
25
|
+
inputRef: e,
|
|
26
|
+
composedRef: m,
|
|
27
|
+
currentValue: s,
|
|
28
|
+
hasContent: d,
|
|
29
|
+
handleChange: p,
|
|
30
|
+
handleClear: f
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
export {
|
|
34
|
+
b as useBaseInputValue
|
|
35
|
+
};
|
package/dist/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ledgerhq/lumen-ui-react",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.55",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"keywords": [
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
]
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@ledgerhq/lumen-utils-shared": "0.1.
|
|
46
|
+
"@ledgerhq/lumen-utils-shared": "0.1.11",
|
|
47
47
|
"i18next": "^23.7.0",
|
|
48
48
|
"react-i18next": "^14.0.0"
|
|
49
49
|
},
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"@radix-ui/react-tooltip": "^1.2.8",
|
|
57
57
|
"class-variance-authority": "^0.7.1",
|
|
58
58
|
"@tanstack/react-table": "^8.21.3",
|
|
59
|
-
"@ledgerhq/lumen-design-core": "0.1.
|
|
59
|
+
"@ledgerhq/lumen-design-core": "0.1.26",
|
|
60
60
|
"clsx": "^2.1.1",
|
|
61
61
|
"react": "^18.0.0 || ^19.0.0",
|
|
62
62
|
"react-dom": "^18.0.0 || ^19.0.0",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ledgerhq/lumen-ui-react",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.56",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"keywords": [
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"@radix-ui/react-tooltip": "^1.2.8",
|
|
57
57
|
"class-variance-authority": "^0.7.1",
|
|
58
58
|
"@tanstack/react-table": "^8.21.3",
|
|
59
|
-
"@ledgerhq/lumen-design-core": "0.1.
|
|
59
|
+
"@ledgerhq/lumen-design-core": "0.1.27",
|
|
60
60
|
"clsx": "^2.1.1",
|
|
61
61
|
"react": "^18.0.0 || ^19.0.0",
|
|
62
62
|
"react-dom": "^18.0.0 || ^19.0.0",
|