@carbonbits/sixr 1.0.4 → 1.2.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.
@@ -0,0 +1,28 @@
1
+ import { z } from 'zod';
2
+
3
+ /**
4
+ * The design checks `/.+@.+\..+/` rather than anything stricter, which accepts
5
+ * the addresses people actually type and leaves real verification to the
6
+ * confirmation email. Kept deliberately, in place of `z.email()`.
7
+ */
8
+ declare const emailSchema: z.ZodString;
9
+ /** At least 8 characters, upper and lower case, and a number or symbol. */
10
+ declare const passwordSchema: z.ZodString;
11
+ /**
12
+ * Eight characters, displayed as `XXXX-XXXX`. The separator is presentational,
13
+ * so it is stripped before the length is counted and the parsed value comes
14
+ * back normalised and upper-cased.
15
+ */
16
+ declare const verificationCodeSchema: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
17
+ /** Recovery codes; the design enables the button at 6 characters. */
18
+ declare const backupCodeSchema: z.ZodString;
19
+ /** Free-text profile fields — the design only requires them to be non-empty. */
20
+ declare const fullNameSchema: z.ZodString;
21
+ declare const jobTitleSchema: z.ZodString;
22
+ /**
23
+ * Optional in the design, and used for recovery and alerts only, so this stays
24
+ * permissive: digits, spaces and the usual punctuation, in any arrangement.
25
+ */
26
+ declare const phoneSchema: z.ZodString;
27
+
28
+ export { backupCodeSchema, emailSchema, fullNameSchema, jobTitleSchema, passwordSchema, phoneSchema, verificationCodeSchema };
@@ -0,0 +1,28 @@
1
+ import { z } from 'zod';
2
+
3
+ /**
4
+ * The design checks `/.+@.+\..+/` rather than anything stricter, which accepts
5
+ * the addresses people actually type and leaves real verification to the
6
+ * confirmation email. Kept deliberately, in place of `z.email()`.
7
+ */
8
+ declare const emailSchema: z.ZodString;
9
+ /** At least 8 characters, upper and lower case, and a number or symbol. */
10
+ declare const passwordSchema: z.ZodString;
11
+ /**
12
+ * Eight characters, displayed as `XXXX-XXXX`. The separator is presentational,
13
+ * so it is stripped before the length is counted and the parsed value comes
14
+ * back normalised and upper-cased.
15
+ */
16
+ declare const verificationCodeSchema: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
17
+ /** Recovery codes; the design enables the button at 6 characters. */
18
+ declare const backupCodeSchema: z.ZodString;
19
+ /** Free-text profile fields — the design only requires them to be non-empty. */
20
+ declare const fullNameSchema: z.ZodString;
21
+ declare const jobTitleSchema: z.ZodString;
22
+ /**
23
+ * Optional in the design, and used for recovery and alerts only, so this stays
24
+ * permissive: digits, spaces and the usual punctuation, in any arrangement.
25
+ */
26
+ declare const phoneSchema: z.ZodString;
27
+
28
+ export { backupCodeSchema, emailSchema, fullNameSchema, jobTitleSchema, passwordSchema, phoneSchema, verificationCodeSchema };
@@ -0,0 +1,35 @@
1
+ import { z } from 'zod';
2
+
3
+ // src/validation/index.ts
4
+ var REQUIRED = 1;
5
+ var MIN_PASSWORD_LENGTH = 8;
6
+ var VERIFICATION_CODE_LENGTH = 8;
7
+ var MIN_BACKUP_CODE_LENGTH = 6;
8
+ var MIN_PHONE_LENGTH = 7;
9
+ var EMAIL_PATTERN = /.+@.+\..+/;
10
+ var UPPER_CASE = /[A-Z]/;
11
+ var LOWER_CASE = /[a-z]/;
12
+ var DIGIT = /[0-9]/;
13
+ var SYMBOL = /[^A-Za-z0-9]/;
14
+ var SEPARATORS = /-/g;
15
+ var PHONE_PATTERN = new RegExp(`^[+]?[\\d\\s().-]{${MIN_PHONE_LENGTH},}$`);
16
+ var emailSchema = z.string().trim().min(REQUIRED, "Enter your work email").regex(EMAIL_PATTERN, "Enter a valid email address");
17
+ var passwordSchema = z.string().min(MIN_PASSWORD_LENGTH, "Use at least 8 characters").refine(
18
+ (value) => UPPER_CASE.test(value) && LOWER_CASE.test(value),
19
+ "Use both upper and lower case letters"
20
+ ).refine(
21
+ (value) => DIGIT.test(value) || SYMBOL.test(value),
22
+ "Add a number or symbol"
23
+ );
24
+ var verificationCodeSchema = z.string().transform((value) => value.replace(SEPARATORS, "").toUpperCase()).refine(
25
+ (value) => value.length === VERIFICATION_CODE_LENGTH,
26
+ "Enter the 8-character code"
27
+ );
28
+ var backupCodeSchema = z.string().trim().min(MIN_BACKUP_CODE_LENGTH, "Enter a backup code");
29
+ var fullNameSchema = z.string().trim().min(REQUIRED, "Enter your full name");
30
+ var jobTitleSchema = z.string().trim().min(REQUIRED, "Enter your job title");
31
+ var phoneSchema = z.string().trim().regex(PHONE_PATTERN, "Enter a valid mobile number");
32
+
33
+ export { backupCodeSchema, emailSchema, fullNameSchema, jobTitleSchema, passwordSchema, phoneSchema, verificationCodeSchema };
34
+ //# sourceMappingURL=validation.js.map
35
+ //# sourceMappingURL=validation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/validation/index.ts"],"names":[],"mappings":";;;AAYA,IAAM,QAAA,GAAW,CAAA;AACjB,IAAM,mBAAA,GAAsB,CAAA;AAC5B,IAAM,wBAAA,GAA2B,CAAA;AACjC,IAAM,sBAAA,GAAyB,CAAA;AAC/B,IAAM,gBAAA,GAAmB,CAAA;AAEzB,IAAM,aAAA,GAAgB,WAAA;AACtB,IAAM,UAAA,GAAa,OAAA;AACnB,IAAM,UAAA,GAAa,OAAA;AACnB,IAAM,KAAA,GAAQ,OAAA;AACd,IAAM,MAAA,GAAS,cAAA;AACf,IAAM,UAAA,GAAa,IAAA;AACnB,IAAM,aAAA,GAAgB,IAAI,MAAA,CAAO,CAAA,kBAAA,EAAqB,gBAAgB,CAAA,GAAA,CAAK,CAAA;AAOpE,IAAM,WAAA,GAAc,CAAA,CACxB,MAAA,EAAO,CACP,IAAA,EAAK,CACL,GAAA,CAAI,QAAA,EAAU,uBAAuB,CAAA,CACrC,KAAA,CAAM,aAAA,EAAe,6BAA6B;AAG9C,IAAM,iBAAiB,CAAA,CAC3B,MAAA,GACA,GAAA,CAAI,mBAAA,EAAqB,2BAA2B,CAAA,CACpD,MAAA;AAAA,EACC,CAAC,UAAU,UAAA,CAAW,IAAA,CAAK,KAAK,CAAA,IAAK,UAAA,CAAW,KAAK,KAAK,CAAA;AAAA,EAC1D;AACF,CAAA,CACC,MAAA;AAAA,EACC,CAAC,UAAU,KAAA,CAAM,IAAA,CAAK,KAAK,CAAA,IAAK,MAAA,CAAO,KAAK,KAAK,CAAA;AAAA,EACjD;AACF;AAOK,IAAM,sBAAA,GAAyB,CAAA,CACnC,MAAA,EAAO,CACP,UAAU,CAAC,KAAA,KAAU,KAAA,CAAM,OAAA,CAAQ,UAAA,EAAY,EAAE,CAAA,CAAE,WAAA,EAAa,CAAA,CAChE,MAAA;AAAA,EACC,CAAC,KAAA,KAAU,KAAA,CAAM,MAAA,KAAW,wBAAA;AAAA,EAC5B;AACF;AAGK,IAAM,gBAAA,GAAmB,EAC7B,MAAA,EAAO,CACP,MAAK,CACL,GAAA,CAAI,wBAAwB,qBAAqB;AAG7C,IAAM,cAAA,GAAiB,EAC3B,MAAA,EAAO,CACP,MAAK,CACL,GAAA,CAAI,UAAU,sBAAsB;AAEhC,IAAM,cAAA,GAAiB,EAC3B,MAAA,EAAO,CACP,MAAK,CACL,GAAA,CAAI,UAAU,sBAAsB;AAMhC,IAAM,WAAA,GAAc,EACxB,MAAA,EAAO,CACP,MAAK,CACL,KAAA,CAAM,eAAe,6BAA6B","file":"validation.js","sourcesContent":["import { z } from \"zod\";\n\n/**\n * Field rules taken from the Carbonbits V1 auth design, which validates inline\n * as you type. The predicates here are the ones that screen actually applies —\n * kept in one place so a form built from `TextInput` agrees with the design\n * rather than re-deriving the rules per screen.\n *\n * These are ordinary zod schemas: extend them with `.refine`, swap a message\n * with `.min(8, \"…\")`, or ignore them and pass your own.\n */\n\nconst REQUIRED = 1;\nconst MIN_PASSWORD_LENGTH = 8;\nconst VERIFICATION_CODE_LENGTH = 8;\nconst MIN_BACKUP_CODE_LENGTH = 6;\nconst MIN_PHONE_LENGTH = 7;\n\nconst EMAIL_PATTERN = /.+@.+\\..+/;\nconst UPPER_CASE = /[A-Z]/;\nconst LOWER_CASE = /[a-z]/;\nconst DIGIT = /[0-9]/;\nconst SYMBOL = /[^A-Za-z0-9]/;\nconst SEPARATORS = /-/g;\nconst PHONE_PATTERN = new RegExp(`^[+]?[\\\\d\\\\s().-]{${MIN_PHONE_LENGTH},}$`);\n\n/**\n * The design checks `/.+@.+\\..+/` rather than anything stricter, which accepts\n * the addresses people actually type and leaves real verification to the\n * confirmation email. Kept deliberately, in place of `z.email()`.\n */\nexport const emailSchema = z\n .string()\n .trim()\n .min(REQUIRED, \"Enter your work email\")\n .regex(EMAIL_PATTERN, \"Enter a valid email address\");\n\n/** At least 8 characters, upper and lower case, and a number or symbol. */\nexport const passwordSchema = z\n .string()\n .min(MIN_PASSWORD_LENGTH, \"Use at least 8 characters\")\n .refine(\n (value) => UPPER_CASE.test(value) && LOWER_CASE.test(value),\n \"Use both upper and lower case letters\",\n )\n .refine(\n (value) => DIGIT.test(value) || SYMBOL.test(value),\n \"Add a number or symbol\",\n );\n\n/**\n * Eight characters, displayed as `XXXX-XXXX`. The separator is presentational,\n * so it is stripped before the length is counted and the parsed value comes\n * back normalised and upper-cased.\n */\nexport const verificationCodeSchema = z\n .string()\n .transform((value) => value.replace(SEPARATORS, \"\").toUpperCase())\n .refine(\n (value) => value.length === VERIFICATION_CODE_LENGTH,\n \"Enter the 8-character code\",\n );\n\n/** Recovery codes; the design enables the button at 6 characters. */\nexport const backupCodeSchema = z\n .string()\n .trim()\n .min(MIN_BACKUP_CODE_LENGTH, \"Enter a backup code\");\n\n/** Free-text profile fields — the design only requires them to be non-empty. */\nexport const fullNameSchema = z\n .string()\n .trim()\n .min(REQUIRED, \"Enter your full name\");\n\nexport const jobTitleSchema = z\n .string()\n .trim()\n .min(REQUIRED, \"Enter your job title\");\n\n/**\n * Optional in the design, and used for recovery and alerts only, so this stays\n * permissive: digits, spaces and the usual punctuation, in any arrangement.\n */\nexport const phoneSchema = z\n .string()\n .trim()\n .regex(PHONE_PATTERN, \"Enter a valid mobile number\");\n"]}
package/package.json CHANGED
@@ -1,82 +1,133 @@
1
1
  {
2
2
  "name": "@carbonbits/sixr",
3
- "version": "1.0.4",
3
+ "version": "1.2.0",
4
4
  "description": "e-commerce geared component library",
5
5
  "homepage": "https://carbonbits.co.ke/sixr",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/carbonbits/sixr.git"
9
+ },
10
+ "bugs": {
11
+ "url": "https://github.com/carbonbits/sixr/issues"
12
+ },
6
13
  "license": "MIT",
14
+ "type": "module",
15
+ "sideEffects": [
16
+ "**/*.css"
17
+ ],
7
18
  "files": [
8
- "dist/**"
19
+ "dist"
9
20
  ],
10
- "main": "dist/index.js",
21
+ "main": "./dist/index.cjs",
22
+ "module": "./dist/index.js",
23
+ "types": "./dist/index.d.ts",
24
+ "exports": {
25
+ ".": {
26
+ "import": {
27
+ "types": "./dist/index.d.ts",
28
+ "default": "./dist/index.js"
29
+ },
30
+ "require": {
31
+ "types": "./dist/index.d.cts",
32
+ "default": "./dist/index.cjs"
33
+ }
34
+ },
35
+ "./cart": {
36
+ "import": {
37
+ "types": "./dist/cart.d.ts",
38
+ "default": "./dist/cart.js"
39
+ },
40
+ "require": {
41
+ "types": "./dist/cart.d.cts",
42
+ "default": "./dist/cart.cjs"
43
+ }
44
+ },
45
+ "./text-input": {
46
+ "import": {
47
+ "types": "./dist/text-input.d.ts",
48
+ "default": "./dist/text-input.js"
49
+ },
50
+ "require": {
51
+ "types": "./dist/text-input.d.cts",
52
+ "default": "./dist/text-input.cjs"
53
+ }
54
+ },
55
+ "./validation": {
56
+ "import": {
57
+ "types": "./dist/validation.d.ts",
58
+ "default": "./dist/validation.js"
59
+ },
60
+ "require": {
61
+ "types": "./dist/validation.d.cts",
62
+ "default": "./dist/validation.cjs"
63
+ }
64
+ },
65
+ "./styles.css": "./dist/styles.css",
66
+ "./package.json": "./package.json"
67
+ },
11
68
  "publishConfig": {
12
69
  "access": "public"
13
70
  },
14
- "dependencies": {
15
- "@testing-library/jest-dom": "^5.14.1",
16
- "@testing-library/react": "^13.0.0",
17
- "@testing-library/user-event": "^13.2.1",
18
- "@types/jest": "^27.0.1",
19
- "@types/node": "^16.7.13",
20
- "@types/react": "^18.0.0",
21
- "@types/react-dom": "^18.0.0",
22
- "react": "^18.2.0",
23
- "react-dom": "^18.2.0",
24
- "react-scripts": "5.0.1",
25
- "typescript": "^4.4.2",
26
- "web-vitals": "^2.1.0"
71
+ "engines": {
72
+ "node": ">=20.19.0"
27
73
  },
74
+ "packageManager": "pnpm@12.4.2",
28
75
  "scripts": {
29
- "start": "react-scripts start",
30
- "build": "react-scripts build",
31
- "test": "react-scripts test",
32
- "eject": "react-scripts eject",
76
+ "build": "pnpm run build:js && pnpm run build:css",
77
+ "build:js": "rm -rf dist && tsup",
78
+ "build:css": "tailwindcss -i ./src/styles/index.css -o ./dist/styles.css --minify",
79
+ "typecheck": "tsc --noEmit",
80
+ "lint": "biome check --error-on-warnings",
81
+ "lint:fix": "biome check --write --error-on-warnings",
82
+ "format": "biome format --write",
83
+ "test": "vitest run",
84
+ "test:watch": "vitest",
33
85
  "storybook": "storybook dev -p 6006",
34
- "build-storybook": "storybook build"
86
+ "build-storybook": "storybook build",
87
+ "chromatic": "chromatic --exit-zero-on-changes"
35
88
  },
36
- "eslintConfig": {
37
- "extends": [
38
- "react-app",
39
- "react-app/jest"
40
- ],
41
- "overrides": [
42
- {
43
- "files": [
44
- "**/*.stories.*"
45
- ],
46
- "rules": {
47
- "import/no-anonymous-default-export": "off"
48
- }
49
- }
50
- ]
89
+ "peerDependencies": {
90
+ "react": "^19.0.0",
91
+ "react-dom": "^19.0.0",
92
+ "zod": "^4.0.0"
51
93
  },
52
- "browserslist": {
53
- "production": [
54
- ">0.2%",
55
- "not dead",
56
- "not op_mini all"
57
- ],
58
- "development": [
59
- "last 1 chrome version",
60
- "last 1 firefox version",
61
- "last 1 safari version"
62
- ]
94
+ "peerDependenciesMeta": {
95
+ "zod": {
96
+ "optional": true
97
+ }
63
98
  },
64
99
  "devDependencies": {
65
- "@semantic-release/git": "^10.0.1",
66
- "@storybook/addon-essentials": "^7.0.5",
67
- "@storybook/addon-interactions": "^7.0.5",
68
- "@storybook/addon-links": "^7.0.5",
69
- "@storybook/blocks": "^7.0.5",
70
- "@storybook/preset-create-react-app": "^7.0.5",
71
- "@storybook/react": "^7.0.5",
72
- "@storybook/react-webpack5": "^7.0.5",
73
- "@storybook/testing-library": "^0.0.14-next.2",
74
- "babel-plugin-named-exports-order": "^0.0.2",
75
- "chromatic": "^6.17.4",
76
- "prop-types": "^15.8.1",
77
- "semantic-release": "^21.0.1",
78
- "storybook": "^7.0.5",
79
- "webpack": "^5.79.0"
80
- },
81
- "readme": "ERROR: No README data found!"
100
+ "@biomejs/biome": "^2.5.14",
101
+ "@semantic-release/changelog": "^7.0.0",
102
+ "@semantic-release/exec": "^7.1.0",
103
+ "@semantic-release/git": "^11.0.1",
104
+ "@semantic-release/github": "^12.0.9",
105
+ "@semantic-release/npm": "^13.1.5",
106
+ "@storybook/addon-a11y": "^10.6.0",
107
+ "@storybook/addon-docs": "^10.6.0",
108
+ "@storybook/addon-links": "^10.6.0",
109
+ "@storybook/react-vite": "^10.6.0",
110
+ "@tailwindcss/cli": "^4.3.3",
111
+ "@tailwindcss/vite": "^4.3.3",
112
+ "@testing-library/dom": "^10.4.1",
113
+ "@testing-library/jest-dom": "^7.0.1",
114
+ "@testing-library/react": "^16.3.3",
115
+ "@testing-library/user-event": "^14.6.7",
116
+ "@types/react": "^19.3.0",
117
+ "@types/react-dom": "^19.3.0",
118
+ "@vitejs/plugin-react": "^6.1.1",
119
+ "chromatic": "^18.9.0",
120
+ "conventional-changelog-conventionalcommits": "^9.1.0",
121
+ "jsdom": "^30.1.0",
122
+ "react": "^19.3.0",
123
+ "react-dom": "^19.3.0",
124
+ "semantic-release": "^25.0.9",
125
+ "storybook": "^10.6.0",
126
+ "tailwindcss": "^4.3.3",
127
+ "tsup": "^8.5.1",
128
+ "typescript": "^6.0.3",
129
+ "vite": "^8.3.0",
130
+ "vitest": "^5.0.1",
131
+ "zod": "^4.0.0"
132
+ }
82
133
  }