{"id":27101323,"url":"https://github.com/gerardpaligot/jsonforms-kotlin","last_synced_at":"2025-04-12T03:59:06.500Z","repository":{"id":286272966,"uuid":"960920976","full_name":"GerardPaligot/jsonforms-kotlin","owner":"GerardPaligot","description":"Kotlin Multiplatform implementation of the JSONForms standard from the Eclipse Foundation","archived":false,"fork":false,"pushed_at":"2025-04-05T15:39:40.000Z","size":195,"stargazers_count":15,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-12T03:59:02.995Z","etag":null,"topics":["android","compose-multiplatform","ios","jsonforms","jvm","kotlin","kotlin-multiplatform"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/GerardPaligot.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-04-05T11:04:34.000Z","updated_at":"2025-04-11T05:52:32.000Z","dependencies_parsed_at":"2025-04-08T08:15:22.053Z","dependency_job_id":null,"html_url":"https://github.com/GerardPaligot/jsonforms-kotlin","commit_stats":null,"previous_names":["gerardpaligot/jsonforms-kotlin"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GerardPaligot%2Fjsonforms-kotlin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GerardPaligot%2Fjsonforms-kotlin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GerardPaligot%2Fjsonforms-kotlin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GerardPaligot%2Fjsonforms-kotlin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/GerardPaligot","download_url":"https://codeload.github.com/GerardPaligot/jsonforms-kotlin/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248514202,"owners_count":21116900,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","compose-multiplatform","ios","jsonforms","jvm","kotlin","kotlin-multiplatform"],"created_at":"2025-04-06T14:18:24.286Z","updated_at":"2025-04-12T03:59:06.482Z","avatar_url":"https://github.com/GerardPaligot.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"# jsonforms-kotlin\n\n[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)\n\n`jsonforms-kotlin` is a Kotlin Multiplatform implementation of the [JSONForms](https://jsonforms.io/) \nstandard from the Eclipse Foundation. It leverages the power of [Compose Multiplatform](https://www.jetbrains.com/lp/compose-multiplatform/) \nto render dynamic forms based on JSON Schemas and UI Schemas across various platforms, \nincluding Android, iOS, and the JVM.\n\n**Key aspects:**\n\n* **JSONForms Standard:** Adheres to the JSONForms specification, enabling declarative form definition and rendering.\n* **Kotlin Multiplatform:** Built with Kotlin Multiplatform, ensuring code reusability and maintainability across different target platforms.\n* **Compose Multiplatform:** Utilizes JetBrains' modern UI framework, Compose Multiplatform, for building native-like user interfaces on Android, iOS, and JVM.\n* **Renderers:** Provides built-in renderers for popular design systems, including Material 3 and the Apple ecosystem (via Compose Cupertino).\n* **Goal:** The primary goal of this library is to provide a flexible and platform-agnostic way to generate and manage forms within Kotlin Multiplatform applications, simplifying UI development for data entry and configuration.\n\n## Usage\n\nThis section demonstrates basic usage of the `jsonforms-kotlin` library with examples showcasing \nthe Material 3 and Cupertino renderers.\n\n**Common Setup:**\n\nBefore using any renderer, you'll typically need to define your JSON Schema and UI Schema:\n\n```kotlin\nval schema = Schema(\n    properties = persistentMapOf(\n        \"email\" to StringProperty(\n            pattern = \"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\\\.[a-zA-Z]{2,}\\$\"\n        ),\n        \"password\" to StringProperty()\n    ),\n    required = persistentListOf(\"email\", \"password\")\n)\nval uiSchema = VerticalLayout(\n    elements = persistentListOf(\n        Control(\n            scope = \"#/properties/email\",\n            label = \"Email\"\n        ),\n        Control(\n            scope = \"#/properties/password\",\n            label = \"Password\",\n            options = ControlOptions(format = Format.Password)\n        )\n    )\n)\n```\n\n**Using Material 3 Renderer**\n\nTo use the Material 3 renderer, ensure you have the corresponding dependency in your \n`build.gradle.kts` file (this will be detailed in the Download section later).\n\n```kotlin\nval state = rememberJsonFormState(initialValues = mutableMapOf())\nJsonForm(\n    schema = schema, // your schema\n    uiSchema = uiSchema, // your ui schema\n    state = state,\n    layoutContent = { Material3Layout(content = it) },\n    stringContent = { id -\u003e\n        val value = state[id].value as String?\n        val error = state.error(id = id).value\n        Material3StringProperty(\n            value = value,\n            error = error?.message,\n            onValueChange = {\n                state[id] = it\n            }\n        )\n    },\n    numberContent = { id -\u003e\n        val value = state[id].value as String?\n        val error = state.error(id = id).value\n        Material3NumberProperty(\n            value = value,\n            error = error?.message,\n            onValueChange = {\n                state[id] = it\n            }\n        )\n    },\n    booleanContent = { id -\u003e\n        val value = state[id].value as Boolean?\n        Material3BooleanProperty(\n            value = value,\n            onValueChange = {\n                state[id] = it\n            }\n        )\n    }\n)\n```\n\n![Material 3 Example](./captures/example-material3.png)\n\n**Using Cupertino Renderer**\n\nTo use the Cupertino renderer, ensure you have the corresponding dependency in your \n`build.gradle.kts` file (this will be detailed in the Download section later).\n\n```kotlin\nval state = rememberJsonFormState(initialValues = mutableMapOf())\nJsonForm(\n    schema = schema, // your schema\n    uiSchema = uiSchema, // your uischema\n    layoutContent = { CupertinoLayout(content = it) },\n    stringContent = { id -\u003e\n        val value = state[id].value as String?\n        val error = state.error(id = id).value\n        CupertinoStringProperty(\n            value = value,\n            error = error?.message,\n            onValueChange = {\n                state[id] = it\n            }\n        )\n    },\n    numberContent = { id -\u003e\n        val value = state[id].value as String?\n        val error = state.error(id = id).value\n        CupertinoNumberProperty(\n            value = value,\n            error = error?.message,\n            onValueChange = {\n                state[id] = it\n            }\n        )\n    },\n    booleanContent = { id -\u003e\n        val value = state[id].value as Boolean?\n        CupertinoBooleanProperty(\n            value = value ?: false,\n            onValueChange = {\n                state[id] = it\n            }\n        )\n    }\n)\n```\n\n![Cupertino Example](./captures/example-cupertino.png)\n\n## Architecture\n\n```mermaid\ngraph TD\n    material3 --\u003e ui\n    cupertino --\u003e ui\n    ui --\u003e shared\n```\n\nThis diagram illustrates the modular architecture of `jsonforms-kotlin`:\n\n* The `shared` module contains the core data models for JSON Schema, UI Schema, and the data handled by the forms.\n* The `ui` module provides the foundational `JsonForm` composable and defines the Renderer interface. It depends on the `shared` module for the models but remains agnostic of any specific UI design system.\n* The `material3` module implements a Renderer specifically for the [Material 3 design system](https://m3.material.io/). It depends on the `ui` module and provides Compose Multiplatform components that adhere to Material 3 guidelines.\n* The `cupertino` module implements a Renderer for the Apple ecosystem, leveraging the [compose-cupertino library](https://github.com/schott12521/compose-cupertino). It also depends on the `ui` module and offers Cupertino-style Compose Multiplatform components.\n\n## Download\n\nThe `jsonforms-kotlin` library is not yet available on Maven Central. However, it will be published there in the future.\n\nOnce available, you will be able to include it in your `build.gradle.kts` file like this:\n\n```kotlin\n// In your shared, Android, iOS, or JVM module's build.gradle.kts\ndependencies {\n    implementation(\"com.paligot.jsonforms.kotlin:core:VERSION\")\n    implementation(\"com.paligot.jsonforms.kotlin:ui:VERSION\")\n    implementation(\"com.paligot.jsonforms.kotlin:material3:VERSION\")\n    implementation(\"com.paligot.jsonforms.kotlin:cupertino:VERSION\")\n}\n```\n\n## License\n\n```\nCopyright 2025 Gérard Paligot.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\nhttp://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgerardpaligot%2Fjsonforms-kotlin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgerardpaligot%2Fjsonforms-kotlin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgerardpaligot%2Fjsonforms-kotlin/lists"}