@kahitsan/ksui 0.47.0 → 0.47.1
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kahitsan/ksui",
|
|
3
|
-
"version": "0.47.
|
|
3
|
+
"version": "0.47.1",
|
|
4
4
|
"description": "ksui is a standalone set of SolidJS UI components for KahitSan/Hilinga and any SolidJS app. Published to the public npm registry and consumed as a normal dependency. Ships source under a `solid` export condition so the consumer's vite-plugin-solid compiles it with only solid-js externalized; it depends on nothing but solid-js + lucide-solid and injects its own CSS.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.ts",
|
|
@@ -102,15 +102,19 @@ beforeEach(() => vi.unstubAllGlobals());
|
|
|
102
102
|
afterEach(() => vi.unstubAllGlobals());
|
|
103
103
|
|
|
104
104
|
describe("isValidTin", () => {
|
|
105
|
-
it("accepts 9
|
|
105
|
+
it("accepts 9 digits with a 3 or 5 digit branch code, dashes optional", () => {
|
|
106
106
|
expect(isValidTin("123456789")).toBe(true);
|
|
107
107
|
expect(isValidTin("123-456-789")).toBe(true);
|
|
108
108
|
expect(isValidTin("123-456-789-000")).toBe(true);
|
|
109
109
|
expect(isValidTin("123456789000")).toBe(true);
|
|
110
|
+
expect(isValidTin("123-456-789-00043")).toBe(true);
|
|
111
|
+
expect(isValidTin("12345678900043")).toBe(true);
|
|
110
112
|
});
|
|
111
113
|
it("rejects other lengths and non-digits", () => {
|
|
112
114
|
expect(isValidTin("12345678")).toBe(false);
|
|
113
115
|
expect(isValidTin("1234567890")).toBe(false);
|
|
116
|
+
expect(isValidTin("1234567890001")).toBe(false);
|
|
117
|
+
expect(isValidTin("123456789000430")).toBe(false);
|
|
114
118
|
expect(isValidTin("12a-456-789")).toBe(false);
|
|
115
119
|
});
|
|
116
120
|
it("treats blank as valid because the field is optional", () => {
|
|
@@ -833,14 +833,14 @@ export default function TransactionForm(props: TransactionFormProps) {
|
|
|
833
833
|
value={props.payeeTin ?? ""}
|
|
834
834
|
onInput={(e) => props.setPayeeTin!(e.currentTarget.value)}
|
|
835
835
|
class="w-full bg-[color-mix(in_srgb,var(--ks-overlay-surface,#18181b)_60%,transparent)] border border-[color-mix(in_srgb,var(--ks-border,rgba(39,39,42,0.5))_60%,transparent)] px-3 py-3 text-sm text-[var(--ks-fg,#ffffff)] ks-hud-clip-button focus:outline-none focus:border-[color-mix(in_srgb,var(--ks-focus-ring,#c9a961)_50%,transparent)]"
|
|
836
|
-
placeholder="000-000-000-
|
|
836
|
+
placeholder="000-000-000-00000"
|
|
837
837
|
/>
|
|
838
838
|
<Show when={!isValidTin(props.payeeTin ?? "")}>
|
|
839
839
|
<p
|
|
840
840
|
data-testid="form-payee-tin-error"
|
|
841
841
|
class="mt-1 text-[10px] text-[var(--ks-danger,#ef4444)]"
|
|
842
842
|
>
|
|
843
|
-
A TIN has 9 digits, or
|
|
843
|
+
A TIN has 9 digits, plus a 3 or 5 digit branch code.
|
|
844
844
|
</p>
|
|
845
845
|
</Show>
|
|
846
846
|
</FormField>
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
// Tax-ID helpers shared by the transaction form and its hosts, so both sides
|
|
2
2
|
// apply the same rule before a TIN is saved.
|
|
3
3
|
|
|
4
|
-
const TIN_PATTERN = /^\d{9}(\d{3})?$/;
|
|
4
|
+
const TIN_PATTERN = /^\d{9}(\d{3}|\d{5})?$/;
|
|
5
5
|
|
|
6
6
|
/** Trims the input and drops dashes and spaces: "123-456-789" -> "123456789". */
|
|
7
7
|
export function normalizeTin(value: string): string {
|
|
8
8
|
return value.replace(/[\s-]/g, "");
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
/** A TIN is 9 digits
|
|
11
|
+
/** A TIN is 9 digits plus an optional 3 or 5 digit branch code. Blank is valid (optional). */
|
|
12
12
|
export function isValidTin(value: string): boolean {
|
|
13
13
|
const digits = normalizeTin(value);
|
|
14
14
|
return digits === "" || TIN_PATTERN.test(digits);
|