@cswni/prisma-utils 0.0.0-stage → 0.1.0-beta.20261019054624

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/cn.d.ts ADDED
@@ -0,0 +1,19 @@
1
+ import { type ClassValue } from "clsx";
2
+ /**
3
+ * Teaches tailwind-merge the Prisma token names; without it `text-label-m`
4
+ * is read as a colour and dropped when combined with `text-text-primary`.
5
+ */
6
+ export declare const twMergeConfig: {
7
+ extend: {
8
+ classGroups: {
9
+ "font-size": {
10
+ text: string[];
11
+ }[];
12
+ shadow: {
13
+ shadow: string[];
14
+ }[];
15
+ };
16
+ };
17
+ };
18
+ export declare function cn(...inputs: ClassValue[]): string;
19
+ //# sourceMappingURL=cn.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cn.d.ts","sourceRoot":"","sources":["../src/cn.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,KAAK,UAAU,EAAE,MAAM,MAAM,CAAC;AAG7C;;;GAGG;AACH,eAAO,MAAM,aAAa;;;;;;;;;;;CA+BzB,CAAC;AAIF,wBAAgB,EAAE,CAAC,GAAG,MAAM,EAAE,UAAU,EAAE,UAEzC"}
package/dist/cn.js ADDED
@@ -0,0 +1,43 @@
1
+ import { clsx } from "clsx";
2
+ import { extendTailwindMerge } from "tailwind-merge";
3
+ /**
4
+ * Teaches tailwind-merge the Prisma token names; without it `text-label-m`
5
+ * is read as a colour and dropped when combined with `text-text-primary`.
6
+ */
7
+ export const twMergeConfig = {
8
+ extend: {
9
+ classGroups: {
10
+ "font-size": [
11
+ {
12
+ text: [
13
+ "display-l",
14
+ "display-m",
15
+ "display-s",
16
+ "heading-h1",
17
+ "heading-h2",
18
+ "heading-h3",
19
+ "heading-h4",
20
+ "body-l",
21
+ "body-m",
22
+ "body-s",
23
+ "body-m-strong",
24
+ "body-s-strong",
25
+ "label-l",
26
+ "label-m",
27
+ "label-s",
28
+ "caption",
29
+ "overline",
30
+ "code-m",
31
+ "code-s",
32
+ ],
33
+ },
34
+ ],
35
+ shadow: [{ shadow: ["flat", "raised", "card", "dropdown", "dialog"] }],
36
+ },
37
+ },
38
+ };
39
+ const twMerge = extendTailwindMerge(twMergeConfig);
40
+ export function cn(...inputs) {
41
+ return twMerge(clsx(inputs));
42
+ }
43
+ //# sourceMappingURL=cn.js.map
package/dist/cn.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cn.js","sourceRoot":"","sources":["../src/cn.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAmB,MAAM,MAAM,CAAC;AAC7C,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAErD;;;GAGG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,MAAM,EAAE;QACN,WAAW,EAAE;YACX,WAAW,EAAE;gBACX;oBACE,IAAI,EAAE;wBACJ,WAAW;wBACX,WAAW;wBACX,WAAW;wBACX,YAAY;wBACZ,YAAY;wBACZ,YAAY;wBACZ,YAAY;wBACZ,QAAQ;wBACR,QAAQ;wBACR,QAAQ;wBACR,eAAe;wBACf,eAAe;wBACf,SAAS;wBACT,SAAS;wBACT,SAAS;wBACT,SAAS;wBACT,UAAU;wBACV,QAAQ;wBACR,QAAQ;qBACT;iBACF;aACF;YACD,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,CAAC,EAAE,CAAC;SACvE;KACF;CACF,CAAC;AAEF,MAAM,OAAO,GAAG,mBAAmB,CAAC,aAAa,CAAC,CAAC;AAEnD,MAAM,UAAU,EAAE,CAAC,GAAG,MAAoB;IACxC,OAAO,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;AAC/B,CAAC"}
@@ -0,0 +1,6 @@
1
+ import { type ReactNode } from "react";
2
+ export declare function createCompoundContext<T>(displayName: string): readonly [({ value, children, }: {
3
+ value: T;
4
+ children: ReactNode;
5
+ }) => import("react").JSX.Element, () => T & ({} | undefined)];
6
+ //# sourceMappingURL=create-compound-context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-compound-context.d.ts","sourceRoot":"","sources":["../src/create-compound-context.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA6B,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAElE,wBAAgB,qBAAqB,CAAC,CAAC,EAAE,WAAW,EAAE,MAAM,oCAevD;IACD,KAAK,EAAE,CAAC,CAAC;IACT,QAAQ,EAAE,SAAS,CAAC;CACrB,8DAKF"}
@@ -0,0 +1,18 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { createContext, useContext } from "react";
3
+ export function createCompoundContext(displayName) {
4
+ const Ctx = createContext(null);
5
+ Ctx.displayName = displayName;
6
+ function useCompoundContext() {
7
+ const value = useContext(Ctx);
8
+ if (value === null) {
9
+ throw new Error(`${displayName} must be used within its provider`);
10
+ }
11
+ return value;
12
+ }
13
+ function CompoundProvider({ value, children, }) {
14
+ return _jsx(Ctx.Provider, { value: value, children: children });
15
+ }
16
+ return [CompoundProvider, useCompoundContext];
17
+ }
18
+ //# sourceMappingURL=create-compound-context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-compound-context.js","sourceRoot":"","sources":["../src/create-compound-context.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAE,UAAU,EAAkB,MAAM,OAAO,CAAC;AAElE,MAAM,UAAU,qBAAqB,CAAI,WAAmB;IAC1D,MAAM,GAAG,GAAG,aAAa,CAAW,IAAI,CAAC,CAAC;IAC1C,GAAG,CAAC,WAAW,GAAG,WAAW,CAAC;IAE9B,SAAS,kBAAkB;QACzB,MAAM,KAAK,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC;QAC9B,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;YACnB,MAAM,IAAI,KAAK,CAAC,GAAG,WAAW,mCAAmC,CAAC,CAAC;QACrE,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,SAAS,gBAAgB,CAAC,EACxB,KAAK,EACL,QAAQ,GAIT;QACC,OAAO,KAAC,GAAG,CAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,YAAG,QAAQ,GAAgB,CAAC;IAC/D,CAAC;IAED,OAAO,CAAC,gBAAgB,EAAE,kBAAkB,CAAU,CAAC;AACzD,CAAC"}
@@ -0,0 +1,4 @@
1
+ export { cn, twMergeConfig } from "./cn.js";
2
+ export { createCompoundContext } from "./create-compound-context.js";
3
+ export { createMask, type Mask } from "./mask.js";
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,EAAE,UAAU,EAAE,KAAK,IAAI,EAAE,MAAM,WAAW,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,4 @@
1
+ export { cn, twMergeConfig } from "./cn.js";
2
+ export { createCompoundContext } from "./create-compound-context.js";
3
+ export { createMask } from "./mask.js";
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,EAAE,UAAU,EAAa,MAAM,WAAW,CAAC"}
package/dist/mask.d.ts ADDED
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Input masks from a pattern string. Tokens: `0` digit, `A` letter (uppercased),
3
+ * `*` letter or digit. Any other character is a literal the mask inserts by itself.
4
+ *
5
+ * `createMask("000-000000-0000A").format("0011503900012k")` → `"001-150390-0012K"`.
6
+ */
7
+ export type Mask = {
8
+ readonly pattern: string;
9
+ /** Applies the mask to free text (typed or pasted). Characters that do not fit are dropped. */
10
+ format: (raw: string) => string;
11
+ /** Characters typed by the user, without literals. */
12
+ unmask: (masked: string) => string;
13
+ /** `true` when every token of the pattern is filled. */
14
+ isComplete: (masked: string) => boolean;
15
+ /** Caret position in `masked` right after the `count`-th significant character. */
16
+ caretAfter: (masked: string, count: number) => number;
17
+ /** Significant characters before `caret` in raw text that survive the mask. */
18
+ countBefore: (raw: string, caret: number) => number;
19
+ };
20
+ export declare function createMask(pattern: string): Mask;
21
+ //# sourceMappingURL=mask.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mask.d.ts","sourceRoot":"","sources":["../src/mask.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,MAAM,IAAI,GAAG;IACjB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,+FAA+F;IAC/F,MAAM,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,CAAC;IAChC,sDAAsD;IACtD,MAAM,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,MAAM,CAAC;IACnC,wDAAwD;IACxD,UAAU,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC;IACxC,mFAAmF;IACnF,UAAU,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;IACtD,+EAA+E;IAC/E,WAAW,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;CACrD,CAAC;AAiBF,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAuDhD"}
package/dist/mask.js ADDED
@@ -0,0 +1,72 @@
1
+ const DIGIT = /^\d$/;
2
+ const LETTER = /^\p{L}$/u;
3
+ function isToken(char) {
4
+ return char === "0" || char === "A" || char === "*";
5
+ }
6
+ /** Returns the character as the slot stores it, or `null` when it does not fit. */
7
+ function accept(token, char) {
8
+ if (token === "0")
9
+ return DIGIT.test(char) ? char : null;
10
+ if (token === "A")
11
+ return LETTER.test(char) ? char.toUpperCase() : null;
12
+ if (DIGIT.test(char))
13
+ return char;
14
+ return LETTER.test(char) ? char.toUpperCase() : null;
15
+ }
16
+ export function createMask(pattern) {
17
+ const tokenCount = [...pattern].filter((char) => isToken(char)).length;
18
+ function format(raw) {
19
+ let output = "";
20
+ let pendingLiterals = "";
21
+ let position = 0;
22
+ for (const char of raw) {
23
+ while (position < pattern.length && !isToken(pattern[position])) {
24
+ pendingLiterals += pattern[position];
25
+ position += 1;
26
+ }
27
+ const token = pattern[position];
28
+ if (token === undefined)
29
+ break;
30
+ const accepted = accept(token, char);
31
+ if (accepted === null)
32
+ continue;
33
+ output += pendingLiterals + accepted;
34
+ pendingLiterals = "";
35
+ position += 1;
36
+ }
37
+ return output;
38
+ }
39
+ function unmask(masked) {
40
+ let output = "";
41
+ for (let index = 0; index < masked.length; index += 1) {
42
+ if (isToken(pattern[index]))
43
+ output += masked[index];
44
+ }
45
+ return output;
46
+ }
47
+ function isComplete(masked) {
48
+ return format(masked) === masked && unmask(masked).length === tokenCount;
49
+ }
50
+ function caretAfter(masked, count) {
51
+ if (count <= 0)
52
+ return 0;
53
+ let seen = 0;
54
+ for (let index = 0; index < masked.length; index += 1) {
55
+ if (!isToken(pattern[index]))
56
+ continue;
57
+ seen += 1;
58
+ if (seen === count) {
59
+ let caret = index + 1;
60
+ while (caret < masked.length && !isToken(pattern[caret]))
61
+ caret += 1;
62
+ return caret;
63
+ }
64
+ }
65
+ return masked.length;
66
+ }
67
+ function countBefore(raw, caret) {
68
+ return unmask(format(raw.slice(0, caret))).length;
69
+ }
70
+ return { pattern, format, unmask, isComplete, caretAfter, countBefore };
71
+ }
72
+ //# sourceMappingURL=mask.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mask.js","sourceRoot":"","s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C,KAAK,CAAC,CAAC;gBAAE,SAAS;YACvC,IAAI,IAAI,CAAC,CAAC;YACV,IAAI,IAAI,KAAK,KAAK,EAAE,CAAC;gBACnB,IAAI,KAAK,GAAG,KAAK,GAAG,CAAC,CAAC;gBACtB,OAAO,KAAK,GAAG,MAAM,CAAC,MAAM,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;oBAAE,KAAK,IAAI,CAAC,CAAC;gBACrE,OAAO,KAAK,CAAC;YACf,CAAC;QACH,CAAC;QACD,OAAO,MAAM,CAAC,MAAM,CAAC;IACvB,CAAC;IAED,SAAS,WAAW,CAAC,GAAW,EAAE,KAAa;QAC7C,OAAO,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;IACpD,CAAC;IAED,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,WAAW,EAAE,CAAC;AAC1E,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,34 @@
1
1
  {
2
2
  "name": "@cswni/prisma-utils",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.1.0-beta.20261019054624",
4
+ "files": [
5
+ "dist"
6
+ ],
7
+ "type": "module",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js"
12
+ }
13
+ },
14
+ "dependencies": {
15
+ "clsx": "^2.1.1",
16
+ "tailwind-merge": "^3.3.1"
17
+ },
18
+ "peerDependencies": {
19
+ "react": "^19.0.0"
20
+ },
21
+ "author": "Hexalis",
22
+ "repository": {
23
+ "type": "git",
24
+ "url": "git+https://github.com/hexalis/prisma-design-system.git"
25
+ },
26
+ "publishConfig": {
27
+ "access": "public"
28
+ },
29
+ "scripts": {
30
+ "build": "tsc -p tsconfig.json",
31
+ "typecheck": "tsc -p tsconfig.json --noEmit",
32
+ "test": "vitest run"
33
+ }
6
34
  }
package/README.md DELETED
@@ -1,3 +0,0 @@
1
- # Temporary Holding Version
2
-
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.