From 70c7112732e04db812413c46a40c701bf791b05d Mon Sep 17 00:00:00 2001 From: Thanikan Date: Fri, 9 Oct 2026 19:43:41 +0530 Subject: [PATCH] docs: shorten npm READMEs and ship LICENSE with each package The published tarballs had no licence text: the only LICENSE lived at the repo root and `files` is a whitelist. They also showed long or stale READMEs. - Add a LICENSE to packages/auth and packages/jsonforms-renderers, copied from OpenNSW/core, so npm ships it. Fill in the copyright holder in the root LICENSE (it still had the Apache boilerplate placeholder). - Shorten each package README to what it is, install, a minimal example and absolute links to the details in this repo, since that is what npmjs.com shows. The jsonforms-renderers README imported a default export that does not exist; it now uses `radixRenderers` and the styles.css entry. - Move the detailed auth guide to packages/auth/docs/usage.md (not shipped). --- LICENSE | 2 +- packages/auth/LICENSE | 201 +++++++++++++++++++++++++ packages/auth/README.md | 62 +++----- packages/auth/docs/usage.md | 62 ++++++++ packages/jsonforms-renderers/LICENSE | 201 +++++++++++++++++++++++++ packages/jsonforms-renderers/README.md | 77 +++------- 6 files changed, 510 insertions(+), 95 deletions(-) create mode 100644 packages/auth/LICENSE create mode 100644 packages/auth/docs/usage.md create mode 100644 packages/jsonforms-renderers/LICENSE diff --git a/LICENSE b/LICENSE index 261eeb9..97cd0dd 100644 --- a/LICENSE +++ b/LICENSE @@ -186,7 +186,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright [yyyy] [name of copyright owner] + Copyright (c) 2026 Lanka Software Foundation Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/packages/auth/LICENSE b/packages/auth/LICENSE new file mode 100644 index 0000000..97cd0dd --- /dev/null +++ b/packages/auth/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright (c) 2026 Lanka Software Foundation + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/packages/auth/README.md b/packages/auth/README.md index bf984d1..99900a0 100644 --- a/packages/auth/README.md +++ b/packages/auth/README.md @@ -1,62 +1,42 @@ # @opennsw/auth -Shared OIDC setup for OpenNSW portals, on top of [`oidc-client-ts`](https://github.com/authts/oidc-client-ts). Auth state in React comes from [`react-oidc-context`](https://github.com/authts/react-oidc-context); this package covers what it does not: `UserManager` defaults, IdP config parsing, role mapping and bearer headers. +Shared OIDC setup for OpenNSW portals, on top of [`oidc-client-ts`](https://github.com/authts/oidc-client-ts): `UserManager` defaults, IdP config parsing, role mapping and bearer headers. Auth state in React comes from [`react-oidc-context`](https://github.com/authts/react-oidc-context). + +## Install ```sh pnpm add @opennsw/auth oidc-client-ts react-oidc-context ``` -## UserManager +`oidc-client-ts` `^3.0.0` is a peer dependency. + +## Use -```ts -import { createUserManager, parseExtraQueryParams, parseScopes } from '@opennsw/auth' +```tsx +import { createUserManager, parseScopes } from '@opennsw/auth' +import { AuthProvider } from 'react-oidc-context' -export const userManager = createUserManager({ +const userManager = createUserManager({ authority: 'https://idp.example', clientId: 'MY_APP', redirectUri: window.location.origin, scopes: parseScopes('openid, profile, email, role'), - extraQueryParams: parseExtraQueryParams('resource=https://api.example'), -}) -``` - -```tsx - - - -``` - -| Field | Default | -| ----------------------- | --------------------------------------------- | -| `postLogoutRedirectUri` | `redirectUri` | -| `scopes` | `['openid', 'profile', 'email']` | -| `storage` | `sessionStorage` | -| `automaticSilentRenew` | `true` | -| `userSettings` | Any other `UserManagerSettings`, applied last | - -`parseScopes` splits a comma- or space-separated list. `parseExtraQueryParams` reads a query string and throws if it sets a parameter the OIDC client owns, such as `redirect_uri` or `state`. - -## Roles - -```ts -import { createRoleMapper } from '@opennsw/auth' - -const mapRoles = createRoleMapper({ - claimName: 'roles', - roles: { trader: 'Trader', admin: 'NSW Admin' }, // app role → name in the claim }) -mapRoles(auth.user?.profile) // ('trader' | 'admin')[], in key order +export const Root = () => ( + + + +) ``` -## Requests +## Documentation -```ts -import { authHeader } from '@opennsw/auth' +Defaults, role mapping and authenticated requests: [usage guide](https://github.com/OpenNSW/ui-packages/blob/main/packages/auth/docs/usage.md). -fetch(url, { headers: { ...(await authHeader(userManager)) } }) // adds the token only while it is valid -``` +- [Source and issues](https://github.com/OpenNSW/ui-packages) +- [Release notes](https://github.com/OpenNSW/ui-packages/releases?q=auth) -## Development +## License -From the repo root: `pnpm --filter @opennsw/auth run test` (or `type-check`, `build`). Lint and formatting use the repo-wide config. +[Apache-2.0](https://github.com/OpenNSW/ui-packages/blob/main/LICENSE) diff --git a/packages/auth/docs/usage.md b/packages/auth/docs/usage.md new file mode 100644 index 0000000..3217c92 --- /dev/null +++ b/packages/auth/docs/usage.md @@ -0,0 +1,62 @@ +# @opennsw/auth usage + +Shared OIDC setup for OpenNSW portals, on top of [`oidc-client-ts`](https://github.com/authts/oidc-client-ts). Auth state in React comes from [`react-oidc-context`](https://github.com/authts/react-oidc-context); this package covers what it does not: `UserManager` defaults, IdP config parsing, role mapping and bearer headers. + +```sh +pnpm add @opennsw/auth oidc-client-ts react-oidc-context +``` + +## UserManager + +```ts +import { createUserManager, parseExtraQueryParams, parseScopes } from '@opennsw/auth' + +export const userManager = createUserManager({ + authority: 'https://idp.example', + clientId: 'MY_APP', + redirectUri: window.location.origin, + scopes: parseScopes('openid, profile, email, role'), + extraQueryParams: parseExtraQueryParams('resource=https://api.example'), +}) +``` + +```tsx + + + +``` + +| Field | Default | +| ----------------------- | --------------------------------------------- | +| `postLogoutRedirectUri` | `redirectUri` | +| `scopes` | `['openid', 'profile', 'email']` | +| `storage` | `sessionStorage` | +| `automaticSilentRenew` | `true` | +| `userSettings` | Any other `UserManagerSettings`, applied last | + +`parseScopes` splits a comma- or space-separated list. `parseExtraQueryParams` reads a query string and throws if it sets a parameter the OIDC client owns, such as `redirect_uri` or `state`. + +## Roles + +```ts +import { createRoleMapper } from '@opennsw/auth' + +const mapRoles = createRoleMapper({ + claimName: 'roles', + roles: { trader: 'Trader', admin: 'NSW Admin' }, // app role → name in the claim +}) + +mapRoles(auth.user?.profile) // ('trader' | 'admin')[], in key order +``` + +## Requests + +```ts +import { authHeader } from '@opennsw/auth' + +fetch(url, { headers: { ...(await authHeader(userManager)) } }) // adds the token only while it is valid +``` + +## Development + +From the repo root: `pnpm --filter @opennsw/auth run test` (or `type-check`, `build`). Lint and formatting use the repo-wide config. diff --git a/packages/jsonforms-renderers/LICENSE b/packages/jsonforms-renderers/LICENSE new file mode 100644 index 0000000..97cd0dd --- /dev/null +++ b/packages/jsonforms-renderers/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright (c) 2026 Lanka Software Foundation + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/packages/jsonforms-renderers/README.md b/packages/jsonforms-renderers/README.md index 03df5a5..cd3cd56 100644 --- a/packages/jsonforms-renderers/README.md +++ b/packages/jsonforms-renderers/README.md @@ -1,73 +1,44 @@ -# `@opennsw/jsonforms-renderers` +# @opennsw/jsonforms-renderers -Custom [JSON Schema Form (JSON Forms)](https://jsonforms.io/) renderers for React, styled with [Radix UI Themes](https://www.radix-ui.com/themes). +[JSON Forms](https://jsonforms.io/) renderers for React, built on [Radix Themes](https://www.radix-ui.com/themes) and used by the OpenNSW portals. They cover text, number, boolean, radio, select, search-select, date, file, array, spreadsheet, XML and computed controls, and the layouts. -This package provides a collection of JSON Forms controls and layout renderers tailored to match the visual styling, theme, and UX of the OpenNSW portal applications. +## Install -## Features - -- **Radix UI Integration**: All components are constructed using `@radix-ui/themes` and layout elements (`Box`, `Flex`, `Text`, etc.). -- **Native Date & Time Inputs**: Relies completely on native browser-supported picker interfaces (no heavy external date picker libraries like `react-day-picker` or Popover wrappers), ensuring a fast, lightweight, and responsive experience on desktop and mobile. -- **Custom File Uploader Control**: A rich, interactive file picker component (`FileControl`) supporting upload progression and state. -- **Pre-configured Tester Rankings**: Simplifies registration by bundling ready-to-use ranks and testers. - -## Available Renderers - -### Controls - -- **[DateControl](src/renderers/DateControl.tsx)**: Formats `date`, `time`, and `date-time` inputs. Combines native inputs that split space equally in `date-time` combination mode and expand to `100%` container width otherwise. -- **[TextControl](src/renderers/TextControl.tsx)**: Handles standard string schemas with optional placeholders. -- **[NumberControl](src/renderers/NumberControl.tsx)**: Handles numeric and integer inputs. -- **[BooleanControl](src/renderers/BooleanControl.tsx)**: Toggle switch control for boolean values. -- **[RadioControl](src/renderers/RadioControl.tsx)**: Option picker rendered as radio group buttons. -- **[SelectControl](src/renderers/SelectControl.tsx)**: Select drop-down control for `enum` or `oneOf` schemas. -- **[FileControl](src/renderers/FileControl.tsx)**: File picker control supporting custom attachments. - -### Layouts - -- **Vertical & Horizontal Layouts**: Renders standard JSON Forms layouts (`VerticalLayout`, `HorizontalLayout`). -- **Group Layout**: Standard boxed grouping for forms sections. -- **Categorization Layout**: Renders category schemas using tabbed views powered by Radix `Tabs.Root`. - ---- +```sh +pnpm add @opennsw/jsonforms-renderers +``` -## Installation & Setup +Peer dependencies: `react` and `react-dom` `^19.2`, `@jsonforms/core` and `@jsonforms/react` `^3.2.1`, `@radix-ui/themes` `^3.2.1` and `@radix-ui/react-icons` `^1.3.2`. -To use the custom renderers, register them inside the `` provider in your React application: +## Use ```tsx import { JsonForms } from '@jsonforms/react' -import { - materialCells, // fallback cells -} from '@jsonforms/material-renderers' // or other fallbacks -import openNswRenderers from '@opennsw/jsonforms-renderers' +import { Theme } from '@radix-ui/themes' +import { radixRenderers } from '@opennsw/jsonforms-renderers' +import '@radix-ui/themes/styles.css' +import '@opennsw/jsonforms-renderers/styles.css' -function App() { - const [data, setData] = useState({}) - - return ( +export const Form = ({ schema, uischema, data, onChange }) => ( + setData(data)} + renderers={radixRenderers} + onChange={({ data }) => onChange(data)} /> - ) -} + +) ``` -## Development +## Documentation -All standard commands should be executed from the portals monorepo root workspace using `pnpm`: +Each control, its `x-*` schema options and examples are documented in the repository: [packages/jsonforms-renderers/docs](https://github.com/OpenNSW/ui-packages/tree/main/packages/jsonforms-renderers/docs). -```bash -# Build the renderers package -pnpm --filter @opennsw/jsonforms-renderers build +- [Source and issues](https://github.com/OpenNSW/ui-packages) +- [Release notes](https://github.com/OpenNSW/ui-packages/releases?q=jsonforms-renderers) -# Run TypeScript type check -pnpm --filter @opennsw/jsonforms-renderers type-check +## License -# Lint files -pnpm --filter @opennsw/jsonforms-renderers lint -``` +[Apache-2.0](https://github.com/OpenNSW/ui-packages/blob/main/LICENSE)