{"_id":"@json-render/directives","_rev":"3-edc37410dde8007dd2ec71a5dd0abc00","name":"@json-render/directives","dist-tags":{"latest":"0.21.0"},"versions":{"0.19.0":{"name":"@json-render/directives","version":"0.19.0","keywords":["json-render","directives","format","i18n","math","generative-ui"],"license":"Apache-2.0","_id":"@json-render/directives@0.19.0","maintainers":[{"name":"matt.straka","email":"matt.j.straka@gmail.com"},{"name":"vercel-release-bot","email":"infra+release@vercel.com"},{"name":"ctate","email":"chris@ctate.dev"}],"homepage":"https://json-render.dev","bugs":{"url":"https://github.com/vercel-labs/json-render/issues"},"dist":{"shasum":"09eeaeefa24aa880394f08a16d9929222a82d60a","tarball":"https://registry.npmjs.org/@json-render/directives/-/directives-0.19.0.tgz","fileCount":9,"integrity":"sha512-JOBzXWpmvf5Bmy/NihFyfIK2+JXVwfbB2i8703tSJ3c3aatDsSL5yIwZ3+/I7qzLtIQFL6ubwk3DvdzOpOKBnQ==","signatures":[{"sig":"MEYCIQC3QnpJnQIa2yYqNe91htDy7gXx7r5sf62M3pgFHX05DAIhAMYjqkCZ9aP+1iGRYvw48Az68XNSoIxou6ZwbeynLEly","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":77907},"main":"./dist/index.js","_from":"file:/tmp/json-render-directives-0.19.0.tgz","types":"./dist/index.d.ts","module":"./dist/index.mjs","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.js"}},"scripts":{"dev":"tsup --watch","test":"vitest run","build":"tsup","typecheck":"tsc --noEmit"},"_npmUser":{"name":"ctate","email":"chris@ctate.dev"},"_resolved":"/tmp/json-render-directives-0.19.0.tgz","_integrity":"sha512-JOBzXWpmvf5Bmy/NihFyfIK2+JXVwfbB2i8703tSJ3c3aatDsSL5yIwZ3+/I7qzLtIQFL6ubwk3DvdzOpOKBnQ==","repository":{"url":"git+https://github.com/vercel-labs/json-render.git","type":"git","directory":"packages/directives"},"_npmVersion":"10.9.0","description":"Pre-built directives for @json-render/core — $format, $math, $concat, $count, $truncate, $pluralize, $join, and $t (i18n).","directories":{},"_nodeVersion":"22.12.0","dependencies":{"@json-render/core":"0.19.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"zod":"^4.3.6","tsup":"^8.0.2","vitest":"^4.0.17","typescript":"^5.4.5","@internal/typescript-config":"0.0.0"},"peerDependencies":{"zod":"^4.0.0"},"_npmOperationalInternal":{"tmp":"tmp/directives_0.19.0_1778131817520_0.32982957386814826","host":"s3://npm-registry-packages-npm-production"}},"0.20.0":{"name":"@json-render/directives","version":"0.20.0","keywords":["json-render","directives","format","i18n","math","generative-ui"],"license":"Apache-2.0","_id":"@json-render/directives@0.20.0","maintainers":[{"name":"matt.straka","email":"matt.j.straka@gmail.com"},{"name":"vercel-release-bot","email":"infra+release@vercel.com"},{"name":"ctate","email":"chris@ctate.dev"}],"homepage":"https://json-render.dev","bugs":{"url":"https://github.com/vercel-labs/json-render/issues"},"dist":{"shasum":"a78a4afa5c875324368676faff4d6d63c153fe9e","tarball":"https://registry.npmjs.org/@json-render/directives/-/directives-0.20.0.tgz","fileCount":9,"integrity":"sha512-SVKcYUBZbCP5OHUU0jObwFl1TNmUrUsJ+HF45crhY3V9c9q/Zs6OUOqwgPV7P9aYVKrk7JM1/vZzcjnsSPTeWg==","signatures":[{"sig":"MEUCIEvTleOb/CMXnYFEXxUGoDlRgOf2PEB+eULd7KlZwd3DAiEAp9jLj03umfaK8jmbcKbVufGUIXL2UiNKup5+OQA434M=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@json-render%2fdirectives@0.20.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":77907},"main":"./dist/index.js","_from":"file:/tmp/json-render-directives-0.20.0.tgz","types":"./dist/index.d.ts","module":"./dist/index.mjs","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.js"}},"scripts":{"dev":"tsup --watch","test":"vitest run","build":"tsup","typecheck":"tsc --noEmit"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:48071bfa-a008-4fa5-9306-d51bd0b943c0"}},"_resolved":"/tmp/json-render-directives-0.20.0.tgz","_integrity":"sha512-SVKcYUBZbCP5OHUU0jObwFl1TNmUrUsJ+HF45crhY3V9c9q/Zs6OUOqwgPV7P9aYVKrk7JM1/vZzcjnsSPTeWg==","repository":{"url":"git+https://github.com/vercel-labs/json-render.git","type":"git","directory":"packages/directives"},"_npmVersion":"11.17.0","description":"Pre-built directives for @json-render/core — $format, $math, $concat, $count, $truncate, $pluralize, $join, and $t (i18n).","directories":{},"_nodeVersion":"24.19.0","dependencies":{"@json-render/core":"0.20.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"zod":"^4.3.6","tsup":"^8.0.2","vitest":"^4.0.17","typescript":"^5.4.5","@internal/typescript-config":"0.0.0"},"peerDependencies":{"zod":"^4.0.0"},"_npmOperationalInternal":{"tmp":"tmp/directives_0.20.0_1787077377321_0.6755849353806838","host":"s3://npm-registry-packages-npm-production"}},"0.21.0":{"_id":"@json-render/directives@0.21.0","bugs":{"url":"https://github.com/vercel-labs/json-render/issues"},"dist":{"shasum":"351dcbf16423ae4dcb33ebe927a13caab16dbabd","tarball":"https://registry.npmjs.org/@json-render/directives/-/directives-0.21.0.tgz","fileCount":9,"integrity":"sha512-dplsE3R+JWjBTzsR00ifGae17kogEnX148+qDiyIUOpR4uEfasNrksGRSUvhsRHIpneHDGtdz0Ukx3IDEmmS8A==","signatures":[{"sig":"MEQCIAoLbPRqexnpGrI0HyZitzwfNztGQKYPrqnvQ1Jl/SdEAiAU/V/tXAq/8WokEwulgDJeH1dqe247oUYU/Q1OL1CXeg==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCICAmqXNQRPYA+uEOw+8GkobhB4MN+0r17d83EsGa6lxkAiEAh9+LjV6sUdJypR5hHfdiH/707ME1ZQ3Mt2bL7rtBdeI="}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@json-render%2fdirectives@0.21.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":77907},"main":"./dist/index.js","name":"@json-render/directives","_from":"file:/tmp/json-render-directives-0.21.0.tgz","types":"./dist/index.d.ts","module":"./dist/index.mjs","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.js"}},"license":"Apache-2.0","scripts":{"dev":"tsup --watch","test":"vitest run","build":"tsup","typecheck":"tsc --noEmit"},"version":"0.21.0","_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:48071bfa-a008-4fa5-9306-d51bd0b943c0"}},"homepage":"https://json-render.dev","keywords":["json-render","directives","format","i18n","math","generative-ui"],"_resolved":"/tmp/json-render-directives-0.21.0.tgz","_integrity":"sha512-dplsE3R+JWjBTzsR00ifGae17kogEnX148+qDiyIUOpR4uEfasNrksGRSUvhsRHIpneHDGtdz0Ukx3IDEmmS8A==","repository":{"url":"git+https://github.com/vercel-labs/json-render.git","type":"git","directory":"packages/directives"},"_npmVersion":"11.19.0","description":"Pre-built directives for @json-render/core — $format, $math, $concat, $count, $truncate, $pluralize, $join, and $t (i18n).","directories":{},"maintainers":[{"name":"matt.straka","email":"matt.j.straka@gmail.com"},{"name":"vercel-release-bot","email":"infra+release@vercel.com"},{"name":"ctate","email":"chris@ctate.dev"}],"_nodeVersion":"24.20.0","dependencies":{"@json-render/core":"0.21.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"zod":"^4.3.6","tsup":"^8.0.2","vitest":"^4.0.17","typescript":"^5.4.5","@internal/typescript-config":"0.0.0"},"peerDependencies":{"zod":"^4.0.0"},"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/directives_0.21.0_1789757477037_0.9401338603067364"}}},"time":{"created":"2026-05-07T05:30:17.424Z","modified":"2026-09-18T18:51:18.498Z","0.19.0":"2026-05-07T05:30:17.677Z","0.20.0":"2026-08-18T18:22:57.466Z","0.21.0":"2026-09-18T18:51:17.116Z"},"bugs":{"url":"https://github.com/vercel-labs/json-render/issues"},"license":"Apache-2.0","homepage":"https://json-render.dev","keywords":["json-render","directives","format","i18n","math","generative-ui"],"repository":{"url":"git+https://github.com/vercel-labs/json-render.git","type":"git","directory":"packages/directives"},"description":"Pre-built directives for @json-render/core — $format, $math, $concat, $count, $truncate, $pluralize, $join, and $t (i18n).","maintainers":[{"name":"matt.straka","email":"matt.j.straka@gmail.com"},{"name":"vercel-release-bot","email":"infra+release@vercel.com"},{"name":"ctate","email":"chris@ctate.dev"}],"readme":"# @json-render/directives\n\nPre-built custom directives for `@json-render/core`. Drop them into your catalog and renderer to add formatting, math, string manipulation, and i18n to your AI-generated UIs.\n\n## Install\n\n```bash\nnpm install @json-render/directives\n```\n\n## Quick Start\n\n```typescript\nimport { standardDirectives } from '@json-render/directives';\n\n// Wire into prompt generation\nconst prompt = catalog.prompt({ directives: standardDirectives });\n\n// Wire into the renderer\n<JSONUIProvider spec={spec} directives={directives}>\n  ...\n</JSONUIProvider>\n```\n\n## Available Directives\n\n### `$format` — Locale-aware value formatting\n\n```json\n{ \"$format\": \"currency\", \"value\": { \"$state\": \"/cart/total\" }, \"currency\": \"USD\" }\n{ \"$format\": \"date\", \"value\": { \"$state\": \"/user/createdAt\" } }\n{ \"$format\": \"number\", \"value\": 1234567, \"notation\": \"compact\" }\n{ \"$format\": \"percent\", \"value\": 0.75 }\n```\n\nFormats: `date`, `currency`, `number`, `percent`. The `value` field accepts any dynamic expression.\n\n### `$math` — Arithmetic operations\n\n```json\n{ \"$math\": \"add\", \"a\": { \"$state\": \"/subtotal\" }, \"b\": { \"$state\": \"/tax\" } }\n{ \"$math\": \"multiply\", \"a\": { \"$state\": \"/price\" }, \"b\": { \"$state\": \"/qty\" } }\n{ \"$math\": \"round\", \"a\": 3.7 }\n```\n\nOperations: `add`, `subtract`, `multiply`, `divide`, `mod`, `min`, `max`, `round`, `floor`, `ceil`, `abs`. Unary ops only use `a`.\n\n### `$concat` — String concatenation\n\n```json\n{ \"$concat\": [{ \"$state\": \"/user/firstName\" }, \" \", { \"$state\": \"/user/lastName\" }] }\n```\n\nEach element is resolved then joined into a single string.\n\n### `$count` — Array/string length\n\n```json\n{ \"$count\": { \"$state\": \"/cart/items\" } }\n```\n\nReturns the length of an array or string. Returns `0` for other types.\n\n### `$truncate` — Text truncation\n\n```json\n{ \"$truncate\": { \"$state\": \"/post/body\" }, \"length\": 140, \"suffix\": \"...\" }\n```\n\nDefault length is 100, default suffix is `\"...\"`.\n\n### `$pluralize` — Singular/plural forms\n\n```json\n{ \"$pluralize\": { \"$state\": \"/cart/itemCount\" }, \"one\": \"item\", \"other\": \"items\", \"zero\": \"no items\" }\n```\n\nOutputs: `\"3 items\"`, `\"1 item\"`, or `\"no items\"`. The `zero` form is optional.\n\n### `$join` — Join array elements\n\n```json\n{ \"$join\": { \"$state\": \"/tags\" }, \"separator\": \", \" }\n```\n\nDefault separator is `\", \"`.\n\n### `createI18nDirective` — Internationalization\n\n```typescript\nimport { createI18nDirective } from '@json-render/directives';\n\nconst t = createI18nDirective({\n  locale: 'en',\n  messages: {\n    en: { \"greeting\": \"Hello, {{name}}!\", \"checkout.submit\": \"Place Order\" },\n    es: { \"greeting\": \"Hola, {{name}}!\", \"checkout.submit\": \"Realizar Pedido\" },\n  },\n  fallbackLocale: 'en',\n});\n```\n\n```json\n{ \"$t\": \"checkout.submit\" }\n{ \"$t\": \"greeting\", \"params\": { \"name\": { \"$state\": \"/user/name\" } } }\n```\n\nThis is a factory function because it requires locale configuration at setup time.\n\n## Composition\n\nDirectives compose naturally — each resolver calls `resolvePropValue` on its inputs:\n\n```json\n{\n  \"$format\": \"currency\",\n  \"value\": { \"$math\": \"multiply\", \"a\": { \"$state\": \"/price\" }, \"b\": { \"$state\": \"/qty\" } },\n  \"currency\": \"USD\"\n}\n```\n\nThis resolves inside-out: `$math` first, then `$format` on the result.\n\n## License\n\nApache-2.0\n","readmeFilename":"README.md"}