@multiplatform.one/forms 7.84.8 → 7.85.0
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/cjs/fields/OTPInput/index.cjs +9 -3
- package/dist/cjs/fields/OTPInput/index.native.js +9 -3
- package/dist/cjs/fields/OTPInput/index.native.js.map +1 -1
- package/dist/cjs/fields/OTPInput/otpCellEdge.cjs +49 -0
- package/dist/cjs/fields/OTPInput/otpCellEdge.native.js +53 -0
- package/dist/cjs/fields/OTPInput/otpCellEdge.native.js.map +1 -0
- package/dist/esm/fields/OTPInput/index.mjs +11 -5
- package/dist/esm/fields/OTPInput/index.mjs.map +1 -1
- package/dist/esm/fields/OTPInput/index.native.js +11 -5
- package/dist/esm/fields/OTPInput/index.native.js.map +1 -1
- package/dist/esm/fields/OTPInput/otpCellEdge.mjs +24 -0
- package/dist/esm/fields/OTPInput/otpCellEdge.mjs.map +1 -0
- package/dist/esm/fields/OTPInput/otpCellEdge.native.js +25 -0
- package/dist/esm/fields/OTPInput/otpCellEdge.native.js.map +1 -0
- package/dist/jsx/fields/OTPInput/index.mjs +11 -5
- package/dist/jsx/fields/OTPInput/index.mjs.map +1 -1
- package/dist/jsx/fields/OTPInput/index.native.js +9 -3
- package/dist/jsx/fields/OTPInput/index.native.js.map +1 -1
- package/dist/jsx/fields/OTPInput/otpCellEdge.mjs +24 -0
- package/dist/jsx/fields/OTPInput/otpCellEdge.mjs.map +1 -0
- package/dist/jsx/fields/OTPInput/otpCellEdge.native.js +53 -0
- package/dist/jsx/fields/OTPInput/otpCellEdge.native.js.map +1 -0
- package/package.json +8 -8
- package/src/fields/OTPInput/index.tsx +11 -9
- package/src/fields/OTPInput/otpCellEdge.spec.ts +40 -0
- package/src/fields/OTPInput/otpCellEdge.ts +21 -0
- package/types/fields/OTPInput/index.d.ts.map +1 -1
- package/types/fields/OTPInput/otpCellEdge.d.ts +12 -0
- package/types/fields/OTPInput/otpCellEdge.d.ts.map +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@multiplatform.one/forms",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.85.0",
|
|
4
4
|
"description": "Cross-platform form components with URL state management",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cross-platform",
|
|
@@ -57,10 +57,10 @@
|
|
|
57
57
|
},
|
|
58
58
|
"dependencies": {
|
|
59
59
|
"@floating-ui/react": "^0.27.20",
|
|
60
|
-
"@multiplatform.one/platform": "^7.
|
|
61
|
-
"@multiplatform.one/router": "^7.
|
|
62
|
-
"@multiplatform.one/table-primitives": "^7.
|
|
63
|
-
"@multiplatform.one/theme": "^7.
|
|
60
|
+
"@multiplatform.one/platform": "^7.85.0",
|
|
61
|
+
"@multiplatform.one/router": "^7.85.0",
|
|
62
|
+
"@multiplatform.one/table-primitives": "^7.85.0",
|
|
63
|
+
"@multiplatform.one/theme": "^7.85.0",
|
|
64
64
|
"@phosphor-icons/react": "^2.1.10",
|
|
65
65
|
"@tamagui/get-font-sized": "2.7.6",
|
|
66
66
|
"@tamagui/get-token": "2.7.6",
|
|
@@ -80,9 +80,9 @@
|
|
|
80
80
|
},
|
|
81
81
|
"devDependencies": {
|
|
82
82
|
"@expo/ui": "~55.0.17",
|
|
83
|
-
"@multiplatform.one/config": "7.
|
|
84
|
-
"@multiplatform.one/storybook": "7.
|
|
85
|
-
"@multiplatform.one/test-utils": "7.
|
|
83
|
+
"@multiplatform.one/config": "7.85.0",
|
|
84
|
+
"@multiplatform.one/storybook": "7.85.0",
|
|
85
|
+
"@multiplatform.one/test-utils": "7.85.0",
|
|
86
86
|
"@tamagui/build": "2.7.6",
|
|
87
87
|
"@tamagui/config": "2.7.6",
|
|
88
88
|
"@tamagui/vite-plugin": "2.7.6",
|
|
@@ -2,7 +2,7 @@ import { useTouchSurface } from "@multiplatform.one/theme";
|
|
|
2
2
|
import type { Validator } from "../../types";
|
|
3
3
|
|
|
4
4
|
import type { DeepKeys, DeepValue } from "@tanstack/form-core";
|
|
5
|
-
import {
|
|
5
|
+
import { useResolvedKnobs } from "@multiplatform.one/theme";
|
|
6
6
|
import {
|
|
7
7
|
type ClipboardEvent,
|
|
8
8
|
type ComponentProps,
|
|
@@ -30,10 +30,11 @@ import {
|
|
|
30
30
|
import type { FormFieldProps } from "../../fieldLayout";
|
|
31
31
|
import { Input as InputParts, InputContext } from "../../InputParts";
|
|
32
32
|
import { Skeleton } from "../../Skeleton";
|
|
33
|
-
import { formCommonColors
|
|
33
|
+
import { formCommonColors } from "../../shared/colorRamps";
|
|
34
34
|
import { t } from "../../shared/t";
|
|
35
35
|
import type { FieldComponentProps } from "../../types";
|
|
36
36
|
import { ensureOtpCellCss } from "./otpCellCss";
|
|
37
|
+
import { otpCellEdge } from "./otpCellEdge";
|
|
37
38
|
|
|
38
39
|
export type OTPInputProps<
|
|
39
40
|
TParentData extends Record<string, unknown> = Record<string, unknown>,
|
|
@@ -230,11 +231,12 @@ const OTPDigitInput = memo(function OTPDigitInput({
|
|
|
230
231
|
otpCellHeightPx(cellSize, hydrationTouch),
|
|
231
232
|
);
|
|
232
233
|
const isNumeric = type === "numeric";
|
|
233
|
-
const
|
|
234
|
-
|
|
235
|
-
: value
|
|
236
|
-
|
|
237
|
-
|
|
234
|
+
const cellEdge = otpCellEdge({
|
|
235
|
+
hasError: Boolean(hasError),
|
|
236
|
+
filled: Boolean(value),
|
|
237
|
+
hidden: knobProps.fieldEdge.hidden,
|
|
238
|
+
borderWidthStop: knobProps.borderWidthStop,
|
|
239
|
+
});
|
|
238
240
|
const firstCell = digitIndex === 0;
|
|
239
241
|
|
|
240
242
|
return (
|
|
@@ -256,8 +258,8 @@ const OTPDigitInput = memo(function OTPDigitInput({
|
|
|
256
258
|
// lift each cell off the page.
|
|
257
259
|
elevation={0}
|
|
258
260
|
shadowOpacity={0}
|
|
259
|
-
borderColor={
|
|
260
|
-
hoverStyle={{ borderColor:
|
|
261
|
+
borderColor={cellEdge.rest}
|
|
262
|
+
hoverStyle={{ borderColor: cellEdge.hover }}
|
|
261
263
|
// LC-40: forward `disabled` so each cell renders the washed chrome.
|
|
262
264
|
disabled={disabled}
|
|
263
265
|
// Web only: keep the Box out of the tab order. The focus handlers live
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { edgeColorAt } from "@multiplatform.one/theme";
|
|
2
|
+
import { describe, expect, it } from "vitest";
|
|
3
|
+
import { formCommonColors, formControlColors, formInputColors } from "../../shared/colorRamps";
|
|
4
|
+
import { otpCellEdge } from "./otpCellEdge";
|
|
5
|
+
|
|
6
|
+
const shown = { hasError: false, filled: false, hidden: false, borderWidthStop: "small" as const };
|
|
7
|
+
|
|
8
|
+
describe("otpCellEdge", () => {
|
|
9
|
+
it("keeps a hidden edge transparent at rest and on hover, filled or not", () => {
|
|
10
|
+
for (const filled of [false, true]) {
|
|
11
|
+
expect(otpCellEdge({ ...shown, filled, hidden: true, borderWidthStop: "none" })).toEqual({
|
|
12
|
+
rest: "transparent",
|
|
13
|
+
hover: "transparent",
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it("paints an error cell the error colour even under a hidden edge", () => {
|
|
19
|
+
for (const hidden of [false, true]) {
|
|
20
|
+
expect(otpCellEdge({ ...shown, hasError: true, hidden })).toEqual({
|
|
21
|
+
rest: formCommonColors.error,
|
|
22
|
+
hover: formCommonColors.error,
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it.each(["small", "medium", "large"] as const)(
|
|
28
|
+
"draws the base edge at the %s stop and the boundary once filled",
|
|
29
|
+
(borderWidthStop) => {
|
|
30
|
+
expect(otpCellEdge({ ...shown, borderWidthStop })).toEqual({
|
|
31
|
+
rest: edgeColorAt(formInputColors.border.base, borderWidthStop),
|
|
32
|
+
hover: formInputColors.border.hover,
|
|
33
|
+
});
|
|
34
|
+
expect(otpCellEdge({ ...shown, borderWidthStop, filled: true })).toEqual({
|
|
35
|
+
rest: formControlColors.boundary,
|
|
36
|
+
hover: formInputColors.border.hover,
|
|
37
|
+
});
|
|
38
|
+
},
|
|
39
|
+
);
|
|
40
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { edgeColorAt, type Knobs } from "@multiplatform.one/theme";
|
|
2
|
+
import { formCommonColors, formControlColors, formInputColors } from "../../shared/colorRamps";
|
|
3
|
+
|
|
4
|
+
export interface OtpCellEdgeInput {
|
|
5
|
+
readonly hasError: boolean;
|
|
6
|
+
readonly filled: boolean;
|
|
7
|
+
readonly hidden: boolean;
|
|
8
|
+
readonly borderWidthStop: Knobs["borderWidth"];
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function otpCellEdge({ hasError, filled, hidden, borderWidthStop }: OtpCellEdgeInput): {
|
|
12
|
+
rest: string;
|
|
13
|
+
hover: string;
|
|
14
|
+
} {
|
|
15
|
+
if (hasError) return { rest: formCommonColors.error, hover: formCommonColors.error };
|
|
16
|
+
if (hidden) return { rest: "transparent", hover: "transparent" };
|
|
17
|
+
const rest = filled
|
|
18
|
+
? formControlColors.boundary
|
|
19
|
+
: edgeColorAt(formInputColors.border.base, borderWidthStop);
|
|
20
|
+
return { rest, hover: formInputColors.border.hover };
|
|
21
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/fields/OTPInput/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE7C,OAAO,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAE/D,OAAO,EAEL,KAAK,cAAc,EASpB,MAAM,OAAO,CAAC;AAEf,OAAO,EAAE,KAAK,EAA0D,MAAM,SAAS,CAAC;AAWxF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAKxD,OAAO,KAAK,EAAE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GAAG,SAAS,GAAG,SAAS,EAC9E,KAAK,SAAS,SAAS,CAAC,WAAW,EAAE,KAAK,CAAC,GAAG,SAAS,CAAC,WAAW,EAAE,KAAK,CAAC,EAC3E,KAAK,EAAE,aAAa,CAAC,WAAW,EAAE,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,KAAK,CAAC,2CAuTjF"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type Knobs } from "@multiplatform.one/theme";
|
|
2
|
+
export interface OtpCellEdgeInput {
|
|
3
|
+
readonly hasError: boolean;
|
|
4
|
+
readonly filled: boolean;
|
|
5
|
+
readonly hidden: boolean;
|
|
6
|
+
readonly borderWidthStop: Knobs["borderWidth"];
|
|
7
|
+
}
|
|
8
|
+
export declare function otpCellEdge({ hasError, filled, hidden, borderWidthStop }: OtpCellEdgeInput): {
|
|
9
|
+
rest: string;
|
|
10
|
+
hover: string;
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=otpCellEdge.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"otpCellEdge.d.ts","sourceRoot":"","sources":["../../../src/fields/OTPInput/otpCellEdge.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,KAAK,KAAK,EAAE,MAAM,0BAA0B,CAAC;AAGnE,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,eAAe,EAAE,KAAK,CAAC,aAAa,CAAC,CAAC;CAChD;AAED,wBAAgB,WAAW,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,eAAe,EAAE,EAAE,gBAAgB,GAAG;IAC5F,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf,CAOA"}
|