@clicktap/ui 1.1.1 → 2.0.3

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.
Files changed (51) hide show
  1. package/components/Accordion/Accordion.d.ts +76 -2
  2. package/components/Accordion/Accordion.js +1 -1
  3. package/components/Accordion/index.d.ts +2 -3
  4. package/components/Accordion/index.js +1 -1
  5. package/components/Badge/Badge.js +1 -1
  6. package/components/Badge/Badge.types.d.ts +27 -2
  7. package/components/Badge/index.js +1 -1
  8. package/components/Collapsible/Collapsible.js +1 -1
  9. package/components/Collection/CollectionFilters/CollectionFilters.js +1 -1
  10. package/components/Collection/CollectionFilters/index.js +1 -1
  11. package/components/Collection/index.js +1 -1
  12. package/components/ContextMenu/ContextMenu.js +1 -1
  13. package/components/DialogTrigger/DialogTrigger.d.ts +18 -10
  14. package/components/DialogTrigger/DialogTrigger.js +1 -1
  15. package/components/DialogTrigger/index.js +1 -1
  16. package/components/Drawer/Drawer.js +1 -1
  17. package/components/Menu/Menu.js +1 -1
  18. package/components/Meter/Meter.js +1 -1
  19. package/components/NumberTicker/DigitResolver.js +1 -1
  20. package/components/NumberTicker/NumberTicker.js +1 -1
  21. package/components/Pagination/Pagination.d.ts +27 -2
  22. package/components/Pagination/Pagination.js +1 -1
  23. package/components/Pagination/index.js +1 -1
  24. package/components/Progressbar/LinearProgressbar.js +1 -1
  25. package/components/Tabs/Tab.js +1 -1
  26. package/components/Tooltip/Tooltip.d.ts +9 -1
  27. package/components/Tooltip/Tooltip.js +1 -1
  28. package/components/Tooltip/Tooltip.types.d.ts +21 -2
  29. package/components/Tooltip/index.js +1 -1
  30. package/components/UploadImage/UploadImage.js +1 -1
  31. package/docs/migrations/2026/08/ui-2026-08-14-zod-error-map.md +104 -0
  32. package/docs/migrations/2026/08/ui-2026-08-21-graphql-client-string-documents.md +45 -0
  33. package/docs/migrations/2026/08/ui-2026-08-21-graphql-peer-covered.md +26 -0
  34. package/docs/migrations/2026/08/ui-2026-08-21-heroui-removed.md +54 -0
  35. package/docs/migrations/2026/08/ui-2026-08-21-lazymotion-m-components.md +54 -0
  36. package/docs/migrations/2026/08/ui-2026-08-21-modal-triggers-wired-explicitly.md +43 -0
  37. package/docs/migrations/2026/08/ui-2026-08-21-next-image-fallback-keeps-fill.md +38 -0
  38. package/docs/migrations/2026/08/ui-2026-08-22-accordion-divider-between-items.md +30 -0
  39. package/docs/migrations/2026/08/ui-2026-08-22-accordion-divider-class-ownership.md +14 -0
  40. package/docs/migrations/2026/08/ui-2026-08-22-react-aria-moves-as-one-version-set.md +46 -0
  41. package/docs/migrations/index.json +117 -2
  42. package/next/Image.js +1 -1
  43. package/package.json +10 -38
  44. package/utils/createAuthAwareGraphqlClient.d.ts +104 -16
  45. package/utils/createAuthAwareGraphqlClient.js +1 -56
  46. package/utils/zod/configureZodErrorMap.d.ts +115 -0
  47. package/utils/zod/configureZodErrorMap.js +1 -0
  48. package/utils/zod/index.d.ts +1 -0
  49. package/utils/zod/index.js +1 -0
  50. package/utils/zod.d.ts +1 -0
  51. package/utils/zod.js +1 -0
@@ -0,0 +1,115 @@
1
+ /**
2
+ * The shape of a zod 4 issue, to the extent this helper reads one.
3
+ *
4
+ * Declared structurally rather than imported from `zod` on purpose — see {@link configureZodErrorMap}.
5
+ */
6
+ export interface ZodIssueLike {
7
+ /** The value that failed. `undefined` means the key was never supplied. */
8
+ readonly input?: unknown;
9
+ readonly code?: string;
10
+ /** What was measured: `'string'`, `'number'`, `'array'`, … */
11
+ readonly origin?: string;
12
+ readonly minimum?: unknown;
13
+ readonly maximum?: unknown;
14
+ }
15
+ /**
16
+ * The one method this needs from the zod namespace.
17
+ *
18
+ * Structural, so any zod 4.x satisfies it and nothing here depends on a particular copy.
19
+ */
20
+ export interface ZodNamespaceLike {
21
+ config(config: {
22
+ customError: (issue: ZodIssueLike) => string | undefined;
23
+ }): unknown;
24
+ }
25
+ /**
26
+ * Messages for the constraint checks whose zod 4 defaults leak internals.
27
+ *
28
+ * Each is a function of the bound so a consumer can localise or reword without reimplementing the
29
+ * branching. A per-check message (`.min(8, '…')`) or a schema-level one always wins over these —
30
+ * that is the whole contract of the error map below.
31
+ */
32
+ export interface ZodConstraintMessages {
33
+ stringTooSmall: (minimum: number) => string;
34
+ stringTooBig: (maximum: number) => string;
35
+ numberTooSmall: (minimum: number) => string;
36
+ numberTooBig: (maximum: number) => string;
37
+ arrayTooSmall: (minimum: number) => string;
38
+ arrayTooBig: (maximum: number) => string;
39
+ }
40
+ export interface ConfigureZodErrorMapOptions {
41
+ /**
42
+ * Shown when the value is absent entirely. This is the one that matters most — see below.
43
+ *
44
+ * @default 'This field is required.'
45
+ */
46
+ required?: string;
47
+ /**
48
+ * Readable copy for the common constraint checks. Pass `false` to rewrite only the
49
+ * missing-value case and leave every other default alone.
50
+ *
51
+ * @default true
52
+ */
53
+ constraints?: boolean | Partial<ZodConstraintMessages>;
54
+ }
55
+ /**
56
+ * Install a global zod 4 error map that produces human-readable validation messages.
57
+ *
58
+ * ```ts
59
+ * import { z } from 'zod';
60
+ * import { configureZodErrorMap } from '@clicktap/ui/utils/zod';
61
+ *
62
+ * configureZodErrorMap(z);
63
+ * ```
64
+ *
65
+ * ## Why every app needs this
66
+ *
67
+ * zod 4 dropped zod 3's readable defaults. Verified against zod 4.4.3:
68
+ *
69
+ * ```
70
+ * undefined against z.string() -> "Invalid input: expected string, received undefined"
71
+ * z.string().min(8) -> "Too small: expected string to have >=8 characters"
72
+ * ```
73
+ *
74
+ * Both are developer output. Neither should reach a visitor.
75
+ *
76
+ * **The first cannot be fixed with per-field messages, which is the part that catches people out.**
77
+ * react-hook-form leaves an untouched field as `undefined` (inputs render `value ?? ''`), so
78
+ * `.min(1, '…')` and `.nonempty({ message })` only ever see an empty string — their message never
79
+ * applies to the missing case. Submitting an untouched form is the common path, so nearly every
80
+ * field in every app is exposed. It has to be fixed globally, which is what this does.
81
+ *
82
+ * ## Why you pass `z` in
83
+ *
84
+ * So this package does not depend on zod. A version is not the issue — two *copies* are: the map
85
+ * has to land on the zod instance your schemas were built with, and an app on zod 3 must be able to
86
+ * install `@clicktap/ui` without a stray zod 4 appearing in its type graph. (It does appear, and it
87
+ * breaks `zodResolver`, which is how this API was arrived at.) Passing the namespace makes the
88
+ * instance explicit and costs a consumer one argument.
89
+ *
90
+ * ## Precedence
91
+ *
92
+ * The map returns `undefined` for anything it does not handle, and zod then falls back to the
93
+ * message attached at the schema. So per-check messages keep winning:
94
+ *
95
+ * ```ts
96
+ * z.string().min(8, 'Pick a longer password.') // -> 'Pick a longer password.'
97
+ * z.string().min(8) // -> 'Must be at least 8 characters.'
98
+ * ```
99
+ *
100
+ * ## Where to call it
101
+ *
102
+ * Once per module registry. In a Next.js app that is **two** places, because server and browser
103
+ * bundles are separate registries and a module evaluated in one is not evaluated in the other:
104
+ *
105
+ * ```ts
106
+ * // app/layout.tsx — SSR and server actions
107
+ * // app/providers.tsx — 'use client', the browser
108
+ * configureZodErrorMap(z);
109
+ * ```
110
+ *
111
+ * It is a plain idempotent function rather than a side-effecting import on purpose: calling it
112
+ * twice is harmless, and an explicit call is not something a bundler can tree-shake away.
113
+ */
114
+ export declare function configureZodErrorMap(z: ZodNamespaceLike, options?: ConfigureZodErrorMapOptions): void;
115
+ export default configureZodErrorMap;
@@ -0,0 +1 @@
1
+ const a={stringTooSmall:r=>r===1?"This field is required.":`Must be at least ${r} characters.`,stringTooBig:r=>`Must be ${r} character${r===1?"":"s"} or fewer.`,numberTooSmall:r=>`Must be ${r} or more.`,numberTooBig:r=>`Must be ${r} or less.`,arrayTooSmall:r=>r===1?"Select at least one option.":`Select at least ${r} options.`,arrayTooBig:r=>`Select no more than ${r} option${r===1?"":"s"}.`};function m(r,n={}){const e=n.required??"This field is required.",i=n.constraints!==!1,t={...a,...typeof n.constraints=="object"?n.constraints:{}};r.config({customError:o=>{if(o.input===void 0)return e;if(i){if(o.code==="too_small"&&typeof o.minimum=="number"){if(o.origin==="string")return t.stringTooSmall(o.minimum);if(o.origin==="number")return t.numberTooSmall(o.minimum);if(o.origin==="array")return t.arrayTooSmall(o.minimum)}if(o.code==="too_big"&&typeof o.maximum=="number"){if(o.origin==="string")return t.stringTooBig(o.maximum);if(o.origin==="number")return t.numberTooBig(o.maximum);if(o.origin==="array")return t.arrayTooBig(o.maximum)}}}})}export{m as configureZodErrorMap,m as default};
@@ -0,0 +1 @@
1
+ export { configureZodErrorMap, type ConfigureZodErrorMapOptions, type ZodConstraintMessages, type ZodIssueLike, type ZodNamespaceLike, } from './configureZodErrorMap';
@@ -0,0 +1 @@
1
+ import{configureZodErrorMap as e}from"./configureZodErrorMap.js";export{e as configureZodErrorMap};
package/utils/zod.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from './zod/index';
package/utils/zod.js ADDED
@@ -0,0 +1 @@
1
+ export * from './zod/index.js';