@noya-app/noya-designsystem 0.1.95 → 0.1.97
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/.turbo/turbo-build.log +11 -11
- package/.turbo/turbo-typecheck.log +1 -0
- package/CHANGELOG.md +12 -0
- package/dist/index.d.mts +11 -3
- package/dist/index.d.ts +11 -3
- package/dist/index.js +26 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +26 -5
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -2
- package/src/components/InputField.tsx +42 -5
- package/src/components/__tests__/Card.test.tsx +2 -1
- package/src/components/__tests__/InputField.test.tsx +3 -1
- package/src/components/internal/__tests__/TextInput.test.tsx +2 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@noya-app/noya-designsystem",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.97",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"module": "./dist/index.mjs",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -22,7 +22,8 @@
|
|
|
22
22
|
"build:css": "tailwindcss -i ./src/index.css -o ./dist/index.css --postcss",
|
|
23
23
|
"build": "tsup",
|
|
24
24
|
"dev": "npm run build -- --watch",
|
|
25
|
-
"lint": "eslint . --max-warnings 0"
|
|
25
|
+
"lint": "eslint . --max-warnings 0",
|
|
26
|
+
"typecheck": "tsc --noEmit"
|
|
26
27
|
},
|
|
27
28
|
"dependencies": {
|
|
28
29
|
"@base-ui/react": "1.7.0",
|
|
@@ -36,7 +36,10 @@ type InputFieldContextValue = {
|
|
|
36
36
|
startRef: ForwardedRef<HTMLSpanElement>;
|
|
37
37
|
endRef: ForwardedRef<HTMLSpanElement>;
|
|
38
38
|
endWidth?: number;
|
|
39
|
-
} & Pick<
|
|
39
|
+
} & Pick<
|
|
40
|
+
InputFieldRootProps,
|
|
41
|
+
"endWidth" | "startWidth" | "startInset" | "size" | "id"
|
|
42
|
+
>;
|
|
40
43
|
|
|
41
44
|
const InputFieldContext = createContext<InputFieldContextValue>({
|
|
42
45
|
startWidth: undefined,
|
|
@@ -55,13 +58,26 @@ const noop = () => {};
|
|
|
55
58
|
export const getFieldSpacing = ({
|
|
56
59
|
endWidth = 0,
|
|
57
60
|
startWidth = 0,
|
|
61
|
+
startInset,
|
|
58
62
|
variant,
|
|
59
63
|
}: {
|
|
60
64
|
endWidth?: number;
|
|
61
65
|
startWidth?: number;
|
|
66
|
+
/** Custom left offset (px) of the start slot; when set, the input's left
|
|
67
|
+
* padding is derived from it (inset + start width + 5px gap, matching the
|
|
68
|
+
* inspector's 21px-swatch-at-3px reference geometry). */
|
|
69
|
+
startInset?: number;
|
|
62
70
|
variant?: InputFieldVariant;
|
|
63
71
|
}) => ({
|
|
64
|
-
paddingLeft: `${
|
|
72
|
+
paddingLeft: `${
|
|
73
|
+
variant === "bare"
|
|
74
|
+
? startWidth
|
|
75
|
+
: startInset !== undefined && startWidth
|
|
76
|
+
? startInset + startWidth + 5
|
|
77
|
+
: startWidth
|
|
78
|
+
? startWidth + 12
|
|
79
|
+
: 8
|
|
80
|
+
}px`,
|
|
65
81
|
paddingRight: `${variant === "bare" ? endWidth : endWidth ? endWidth + 12 : 8}px`,
|
|
66
82
|
});
|
|
67
83
|
|
|
@@ -223,7 +239,8 @@ const InputElement = forwardRef(
|
|
|
223
239
|
}: InputElementProps,
|
|
224
240
|
forwardedRef: ForwardedRef<any>
|
|
225
241
|
) => {
|
|
226
|
-
const { endWidth, inputRef, size, id, startWidth } =
|
|
242
|
+
const { endWidth, inputRef, size, id, startWidth, startInset } =
|
|
243
|
+
useInputFieldContext();
|
|
227
244
|
|
|
228
245
|
const ref = useMergeRefs(
|
|
229
246
|
attachInputRef ? inputRef : null,
|
|
@@ -234,6 +251,7 @@ const InputElement = forwardRef(
|
|
|
234
251
|
endWidth,
|
|
235
252
|
variant: $variant,
|
|
236
253
|
startWidth,
|
|
254
|
+
startInset,
|
|
237
255
|
});
|
|
238
256
|
|
|
239
257
|
const inputClassName = cx(
|
|
@@ -524,6 +542,10 @@ interface InputFieldRootProps {
|
|
|
524
542
|
label?: ReactNode;
|
|
525
543
|
width?: number;
|
|
526
544
|
startWidth?: number;
|
|
545
|
+
/** Left offset (px) of the start slot, replacing the default 6px — e.g. 3
|
|
546
|
+
* for the inspector's swatch-in-field geometry. Also tightens the input's
|
|
547
|
+
* derived left padding (see getFieldSpacing). */
|
|
548
|
+
startInset?: number;
|
|
527
549
|
endWidth?: number;
|
|
528
550
|
/** @default medium */
|
|
529
551
|
size?: InputSize;
|
|
@@ -544,6 +566,7 @@ function InputFieldRoot({
|
|
|
544
566
|
width,
|
|
545
567
|
sideOffset = 3,
|
|
546
568
|
startWidth: startWidthProp,
|
|
569
|
+
startInset,
|
|
547
570
|
endWidth: endWidthProp,
|
|
548
571
|
size = "medium",
|
|
549
572
|
renderPopoverContent,
|
|
@@ -588,6 +611,7 @@ function InputFieldRoot({
|
|
|
588
611
|
const contextValue = useMemo(
|
|
589
612
|
(): InputFieldContextValue => ({
|
|
590
613
|
startWidth,
|
|
614
|
+
startInset,
|
|
591
615
|
endWidth,
|
|
592
616
|
inputRef,
|
|
593
617
|
startRef,
|
|
@@ -597,7 +621,16 @@ function InputFieldRoot({
|
|
|
597
621
|
onFocusChange: handleFocusChange,
|
|
598
622
|
id: id ?? randomId,
|
|
599
623
|
}),
|
|
600
|
-
[
|
|
624
|
+
[
|
|
625
|
+
startWidth,
|
|
626
|
+
startInset,
|
|
627
|
+
endWidth,
|
|
628
|
+
size,
|
|
629
|
+
isFocused,
|
|
630
|
+
handleFocusChange,
|
|
631
|
+
id,
|
|
632
|
+
randomId,
|
|
633
|
+
]
|
|
601
634
|
);
|
|
602
635
|
|
|
603
636
|
const insetLabel = useMemo(
|
|
@@ -618,7 +651,11 @@ function InputFieldRoot({
|
|
|
618
651
|
>
|
|
619
652
|
{children}
|
|
620
653
|
{start && (
|
|
621
|
-
<span
|
|
654
|
+
<span
|
|
655
|
+
ref={startRef}
|
|
656
|
+
className={cx(startBaseStyles, startClassName)}
|
|
657
|
+
style={startInset !== undefined ? { left: startInset } : undefined}
|
|
658
|
+
>
|
|
622
659
|
{start}
|
|
623
660
|
</span>
|
|
624
661
|
)}
|
|
@@ -28,7 +28,8 @@ describe("Card", () => {
|
|
|
28
28
|
);
|
|
29
29
|
const card = getByTestId("card");
|
|
30
30
|
|
|
31
|
-
expect(
|
|
31
|
+
expect(ref.current).not.toBeNull();
|
|
32
|
+
expect(card).toBe(ref.current!);
|
|
32
33
|
expect(card.textContent).toBe("Content");
|
|
33
34
|
expect(card.className).toContain("n-border");
|
|
34
35
|
expect(card.className).toContain("n-p-4");
|
|
@@ -22,6 +22,8 @@ describe("InputField", () => {
|
|
|
22
22
|
inputRef.current = element;
|
|
23
23
|
input = element;
|
|
24
24
|
}}
|
|
25
|
+
value=""
|
|
26
|
+
onChange={() => {}}
|
|
25
27
|
width={240}
|
|
26
28
|
renderPopoverContent={() => <button>Result</button>}
|
|
27
29
|
/>
|
|
@@ -181,7 +183,7 @@ describe("InputField", () => {
|
|
|
181
183
|
const changes: Array<{ value: number; isEmpty: boolean }> = [];
|
|
182
184
|
|
|
183
185
|
function OptionalNumberInput() {
|
|
184
|
-
const [value, setValue] = useState<number>(42);
|
|
186
|
+
const [value, setValue] = useState<number | undefined>(42);
|
|
185
187
|
|
|
186
188
|
return (
|
|
187
189
|
<InputField.Root>
|
|
@@ -27,7 +27,7 @@ describe("submittable text input", () => {
|
|
|
27
27
|
});
|
|
28
28
|
|
|
29
29
|
test("change and blur, reset", () => {
|
|
30
|
-
const handleSubmit = (
|
|
30
|
+
const handleSubmit = (_value: string) => {};
|
|
31
31
|
|
|
32
32
|
const { container, rerender } = render(
|
|
33
33
|
<TextInput value="" onSubmit={handleSubmit} />
|
|
@@ -90,7 +90,7 @@ describe("submittable text input", () => {
|
|
|
90
90
|
});
|
|
91
91
|
|
|
92
92
|
test("change and submit, reset", () => {
|
|
93
|
-
const handleSubmit = (
|
|
93
|
+
const handleSubmit = (_value: string) => {};
|
|
94
94
|
|
|
95
95
|
const { container, rerender } = render(
|
|
96
96
|
<TextInput value="" onSubmit={handleSubmit} />
|