# tangerine-community/tangy-form architecture

> Architecture diagram of the GitHub repository tangerine-community/tangy-form, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-05-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/tangerine-community/tangy-form
- Repository: https://github.com/tangerine-community/tangy-form

## Overview

1. **What this repository is**
   This is a UI component library for building multipage forms, centered on a custom element called `tangy-form`. It is not an application; it is a reusable Web Components package published to npm and consumed from `dist/bundle.js` or individual module files.

2. **Core runtime architecture**
   The main runtime boundary is the `tangy-form` container, which coordinates a tree of `tangy-form-item` children. Each form item wraps one or more input components and represents a page/step or logical unit of the form. The form exposes a `submit` event and a response model for consumer code.

3. **State management**
   Form state is managed with Redux, which is a key architectural choice in this repo. The central pieces are `tangy-form-reducer.js`, `tangy-form-response-model.js`, and `tangy-form.js`. Inputs report changes into the shared store, and the form reads back values, validity, and item state from that store to drive navigation and response generation.

4. **Form-item boundary and conditional logic**
   `tangy-form-item.js` is the main orchestration layer between the form container and the inputs. It exposes helper functions used in `tangy-if` and `valid-if` expressions, allowing item visibility and validation to depend on other answers. This is the primary place where dynamic form logic is evaluated.

5. **Input component subsystem**
   The `input/` directory contains the individual field types: text, checkbox, radio, select, GPS, location, date, timed questions, photo/video/audio capture, signature, QR, consent, gates, and several specialized variants. These are all separate custom elements that plug into the common form state contract rather than being tightly coupled to the form container.

6. **Shared input base layers**
   `tangy-input-base.js`, `tangy-input-lit-base.js`, `tangy-input-group.js`, `tangy-input-groups.js`, and `tangy-list-item.js` provide shared behavior and composition patterns for inputs and grouped choices. They reduce duplication across the many field types and define the common lifecycle for registering, reading, validating, and rendering responses.

7. **Response and presentation model**
   The library distinguishes between editable form mode and response-review mode. `enableItemReadOnly()`, `disableItemReadOnly()`, `hideItemButtons()`, and `showItemButtons()` are part of the presentation boundary that lets the same form render as a user-editable questionnaire or as a read-only response viewer. `tangy-complete-button.js` and `tangy-overlay.js` support this UI flow.

8. **Utility and integration helpers**
   The `util/` folder holds cross-cutting helpers for location lookup, templating, prompt utilities, DOM property handling, and media conversion (`webmToWavConverter.js`). These are supporting services rather than primary subsystems, but they matter because several input types depend on them, especially audio and location-based inputs.

9. **Styling and design system**
   Styling is centralized in `style/` via shared style modules such as `tangy-common-styles.js`, `tangy-element-styles.js`, and `mdc-select-style.js`. The library is designed around Material Design conventions and exposes theme variables for host applications to override. This means the visual system is intended to be customized at the app boundary, not inside each input.

10. **Build, packaging, and distribution**
   The package is built with webpack (`webpack.config.cjs`) into `dist/bundle.js`, which is the main distributable artifact. The repo also contains Polymer configuration (`polymer.json`), npm packaging metadata, and GitHub Actions/Travis workflows for CI and publishing. `index.js` and `index.html` act as top-level entry points for library usage and local demo hosting.

11. **Docs, demos, and verification**
   The `demo/` directory is a large set of scenario-specific HTML demos showing different input types, translations, theming, and validation patterns. `docs/` contains cookbook and generated reference material. `test/` mirrors many of the input types with focused component tests and stubbed fixtures, making it the main place to understand expected component behavior and integration points.

12. **External dependencies and runtime assumptions**
   The repo is built for browser execution using Custom Elements/Polymer, with Redux loaded as a global dependency in some integration modes. Consumers may need `webcomponents-loader.js` or `@webcomponents/webcomponentsjs` depending on their app stack. That dependency profile is important architecturally because the library is designed to slot into Angular, React, Vue, or plain HTML, but still expects a Web Components-capable runtime.

Main entry points: [`tangy-input-base.js`](https://github.com/tangerine-community/tangy-form/blob/master/tangy-input-base.js) (Input base), [`tangy-form.js`](https://github.com/tangerine-community/tangy-form/blob/master/tangy-form.js) (tangy-form), [`tangy-form-item.js`](https://github.com/tangerine-community/tangy-form/blob/master/tangy-form-item.js) (tangy-form-item), [`tangy-overlay.js`](https://github.com/tangerine-community/tangy-form/blob/master/tangy-overlay.js) (Presenters)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_core["Core form runtime"]
  node_tangy_form["tangy-form<br/>web component container<br/>[tangy-form.js]"]
  node_tangy_form_item["tangy-form-item<br/>item orchestrator<br/>[tangy-form-item.js]"]
  node_form_reducer["Reducer<br/>redux state"]
  node_response_model["Response model<br/>response shape"]
  node_item_helpers["Item helpers<br/>conditional logic"]
end

subgraph group_inputs["Input subsystem"]
  node_input_base["Input base<br/>shared base"]
  node_input_lit_base["Lit base<br/>shared base"]
  node_input_groups["Input groups<br/>composition"]
  node_input_group_sets["Group sets<br/>composition"]
  node_choice_items["List items<br/>choice rendering<br/>[tangy-list-item.js]"]
  node_text_and_choice_inputs["Text & choice<br/>field set<br/>[tangy-input.js]"]
  node_media_and_capture_inputs["Media capture<br/>field set"]
  node_location_and_time_inputs["Location & time<br/>field set<br/>[tangy-gps.js]"]
  node_specialized_inputs["Specialized inputs<br/>field set<br/>[tangy-consent.js]"]
end

subgraph group_support["Shared support"]
  node_presenters["Presenters<br/>ui controls<br/>[tangy-overlay.js]"]
  node_style_system["Style system<br/>css modules"]
  node_utils["Utilities<br/>helpers<br/>[t.js]"]
end

subgraph group_packaging["Build and distribution"]
  node_bundle["Bundle<br/>distribution artifact<br/>[bundle.js]"]
  node_entrypoints["Entrypoints<br/>package entry<br/>[index.js]"]
  node_demos_docs["Demos & docs<br/>examples<br/>[index.html]"]
  node_tests["Tests<br/>verification<br/>[index.html]"]
  node_ci_publish["CI & publish<br/>automation<br/>[npm-publish.yml]"]
end

node_tangy_form -->|"contains"| node_tangy_form_item
node_tangy_form -->|"uses state"| node_form_reducer
node_tangy_form -->|"builds response"| node_response_model
node_tangy_form_item -->|"evaluates logic"| node_item_helpers
node_tangy_form_item -->|"hosts inputs"| node_input_base
node_input_base -->|"dispatches"| node_form_reducer
node_input_base -->|"reads back"| node_response_model
node_input_lit_base -->|"extends"| node_input_base
node_input_groups -->|"composes"| node_choice_items
node_input_group_sets -->|"builds on"| node_input_groups
node_text_and_choice_inputs -->|"extends"| node_input_base
node_media_and_capture_inputs -->|"extends"| node_input_base
node_location_and_time_inputs -->|"extends"| node_input_base
node_specialized_inputs -->|"extends"| node_input_base
node_presenters -->|"presentation"| node_tangy_form
node_presenters -->|"controls UI"| node_tangy_form_item
node_style_system -->|"skins"| node_presenters
node_utils -->|"supports"| node_media_and_capture_inputs
node_utils -->|"supports"| node_location_and_time_inputs
node_entrypoints -->|"exposes"| node_bundle
node_demos_docs -.->|"demonstrates"| node_entrypoints
node_tests -.->|"verifies"| node_text_and_choice_inputs
node_tests -.->|"verifies"| node_tangy_form
node_ci_publish -->|"builds"| node_bundle

click node_tangy_form "https://github.com/tangerine-community/tangy-form/blob/master/tangy-form.js"
click node_tangy_form_item "https://github.com/tangerine-community/tangy-form/blob/master/tangy-form-item.js"
click node_form_reducer "https://github.com/tangerine-community/tangy-form/blob/master/tangy-form-reducer.js"
click node_response_model "https://github.com/tangerine-community/tangy-form/blob/master/tangy-form-response-model.js"
click node_item_helpers "https://github.com/tangerine-community/tangy-form/blob/master/tangy-form-item-callback-helpers.js"
click node_input_base "https://github.com/tangerine-community/tangy-form/blob/master/tangy-input-base.js"
click node_input_lit_base "https://github.com/tangerine-community/tangy-form/blob/master/tangy-input-lit-base.js"
click node_input_groups "https://github.com/tangerine-community/tangy-form/blob/master/tangy-input-group.js"
click node_input_group_sets "https://github.com/tangerine-community/tangy-form/blob/master/tangy-input-groups.js"
click node_choice_items "https://github.com/tangerine-community/tangy-form/blob/master/tangy-list-item.js"
click node_text_and_choice_inputs "https://github.com/tangerine-community/tangy-form/blob/master/input/tangy-input.js"
click node_media_and_capture_inputs "https://github.com/tangerine-community/tangy-form/blob/master/input/tangy-photo-capture.js"
click node_location_and_time_inputs "https://github.com/tangerine-community/tangy-form/blob/master/input/tangy-gps.js"
click node_specialized_inputs "https://github.com/tangerine-community/tangy-form/blob/master/input/tangy-consent.js"
click node_presenters "https://github.com/tangerine-community/tangy-form/blob/master/tangy-overlay.js"
click node_style_system "https://github.com/tangerine-community/tangy-form/blob/master/style/tangy-common-styles.js"
click node_utils "https://github.com/tangerine-community/tangy-form/blob/master/util/t.js"
click node_bundle "https://github.com/tangerine-community/tangy-form/blob/master/dist/bundle.js"
click node_entrypoints "https://github.com/tangerine-community/tangy-form/blob/master/index.js"
click node_demos_docs "https://github.com/tangerine-community/tangy-form/blob/master/demo/index.html"
click node_tests "https://github.com/tangerine-community/tangy-form/blob/master/test/index.html"
click node_ci_publish "https://github.com/tangerine-community/tangy-form/blob/master/.github/workflows/npm-publish.yml"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_tangy_form,node_tangy_form_item,node_form_reducer,node_response_model,node_item_helpers toneBlue
class node_input_base,node_input_lit_base,node_input_groups,node_input_group_sets,node_choice_items,node_text_and_choice_inputs,node_media_and_capture_inputs,node_location_and_time_inputs,node_specialized_inputs toneAmber
class node_presenters,node_style_system,node_utils toneMint
class node_bundle,node_entrypoints,node_demos_docs,node_tests,node_ci_publish toneRose
```

## Components

### Core form runtime

Container, item orchestration, state, and response model.

- [tangy-form](https://github.com/tangerine-community/tangy-form/blob/master/tangy-form.js): web component container · Top-level form boundary that coordinates item flow, submission, and response generation. · `tangy-form.js`
- [tangy-form-item](https://github.com/tangerine-community/tangy-form/blob/master/tangy-form-item.js): item orchestrator · Wraps logical form steps and mediates between the form container and nested inputs. · `tangy-form-item.js`
- [Reducer](https://github.com/tangerine-community/tangy-form/blob/master/tangy-form-reducer.js): redux state · Centralized state transitions for values, validity, and item state. · `tangy-form-reducer.js`
- [Response model](https://github.com/tangerine-community/tangy-form/blob/master/tangy-form-response-model.js): response shape · Builds the readback/submission representation of the form state. · `tangy-form-response-model.js`
- [Item helpers](https://github.com/tangerine-community/tangy-form/blob/master/tangy-form-item-callback-helpers.js): conditional logic · Helper functions exposed to tangy-if and valid-if expressions for dynamic visibility and validation. · `tangy-form-item-callback-helpers.js`

### Input subsystem

Field components and shared input base layers.

- [Input base](https://github.com/tangerine-community/tangy-form/blob/master/tangy-input-base.js): shared base · Common lifecycle and registration behavior for input components. · `tangy-input-base.js`
- [Lit base](https://github.com/tangerine-community/tangy-form/blob/master/tangy-input-lit-base.js): shared base · Lit-based variant of the common input foundation. · `tangy-input-lit-base.js`
- [Input groups](https://github.com/tangerine-community/tangy-form/blob/master/tangy-input-group.js): composition · Shared grouping and repeated-choice composition primitives. · `tangy-input-group.js`
- [Group sets](https://github.com/tangerine-community/tangy-form/blob/master/tangy-input-groups.js): composition · Higher-level container for grouped input collections. · `tangy-input-groups.js`
- [List items](https://github.com/tangerine-community/tangy-form/blob/master/tangy-list-item.js): choice rendering · Reusable list-item and choice rendering support. · `tangy-list-item.js`
- [Text & choice](https://github.com/tangerine-community/tangy-form/blob/master/input/tangy-input.js): field set · Core text, checkbox, radio, select, toggle, and prompt-style inputs. · `input/tangy-input.js`
- [Media capture](https://github.com/tangerine-community/tangy-form/blob/master/input/tangy-photo-capture.js): field set · Audio, video, photo, signature, QR, and related capture components. · `input/tangy-photo-capture.js`
- [Location & time](https://github.com/tangerine-community/tangy-form/blob/master/input/tangy-gps.js): field set · GPS, location, timed, date, partial-date, and related temporal/location components. · `input/tangy-gps.js`
- [Specialized inputs](https://github.com/tangerine-community/tangy-form/blob/master/input/tangy-consent.js): field set · Consent, gates, ACASI, keyboard, grids, and other specialized questionnaire variants. · `input/tangy-consent.js`

### Shared support

Styling, utilities, presentation helpers, and templating.

- [Presenters](https://github.com/tangerine-community/tangy-form/blob/master/tangy-overlay.js): ui controls · Complete button, overlay, list, and template helpers for read-only and interactive rendering. · `tangy-overlay.js`
- [Style system](https://github.com/tangerine-community/tangy-form/blob/master/style/tangy-common-styles.js): css modules · Shared styling modules and Material Design theming hooks. · `style/tangy-common-styles.js`
- [Utilities](https://github.com/tangerine-community/tangy-form/blob/master/util/t.js): helpers · Location, templating, DOM props, prompt, and media conversion helpers. · `util/t.js`

### Build and distribution

Packaging, bundling, demos, docs, and CI.

- [Bundle](https://github.com/tangerine-community/tangy-form/blob/master/dist/bundle.js): distribution artifact · Primary compiled browser deliverable consumed by host applications. · `dist/bundle.js`
- [Entrypoints](https://github.com/tangerine-community/tangy-form/blob/master/index.js): package entry · Top-level entry files for local hosting and package consumption. · `index.js`
- [Demos & docs](https://github.com/tangerine-community/tangy-form/blob/master/demo/index.html): examples · Scenario demos, cookbook docs, and reference material for usage and behavior. · `demo/index.html`
- [Tests](https://github.com/tangerine-community/tangy-form/blob/master/test/index.html): verification · Component tests and fixture-driven verification for inputs and form behavior. · `test/index.html`
- [CI & publish](https://github.com/tangerine-community/tangy-form/blob/master/.github/workflows/npm-publish.yml): automation · GitHub Actions, Travis, and package publishing workflows. · `.github/workflows/npm-publish.yml`

## Connections

- tangy-form → tangy-form-item: contains · The form coordinates a tree of form items.
- tangy-form → Reducer: uses state · Form actions are reduced into shared Redux state.
- tangy-form → Response model: builds response · Submission and review mode derive from the response model.
- tangy-form-item → Item helpers: evaluates logic · Item visibility and validation depend on helper-evaluated expressions.
- tangy-form-item → Input base: hosts inputs · Items render and register nested inputs through the shared input contract.
- Input base → Reducer: dispatches · Inputs report value and validity changes into the shared store.
- Input base → Response model: reads back · Inputs contribute to response serialization and review mode.
- Lit base → Input base: extends · Lit-based inputs reuse the same core behavior.
- Input groups → List items: composes · Grouped choice widgets reuse list-item rendering.
- Group sets → Input groups: builds on · Higher-level group sets organize repeated grouped inputs.
- Text & choice → Input base: extends · Common text and choice widgets share the base lifecycle.
- Media capture → Input base: extends · Capture components plug into the same form state contract.
- Location & time → Input base: extends · Location and temporal widgets share the base input contract.
- Specialized inputs → Input base: extends · Specialized questionnaire widgets still register through the same base layer.
- Presenters → tangy-form: presentation · Read-only and interactive modes are toggled through form presentation helpers.
- Presenters → tangy-form-item: controls UI · Item-level read-only and button visibility are managed at the item boundary.
- Style system → Presenters: skins · Shared styles and theme variables shape the rendered controls.
- Utilities → Media capture: supports · Media and location inputs depend on cross-cutting utilities.
- Utilities → Location & time: supports · Location lookup, templating, and time helpers are shared across inputs.
- Entrypoints → Bundle: exposes · Package entry points resolve to the built browser artifact.
- Demos & docs → Entrypoints: demonstrates · Demos and docs show how consumers load and use the package.
- Tests → Text & choice: verifies · Focused tests validate field behavior and integration contracts.
- Tests → tangy-form: verifies · Form-level tests cover orchestration and submission behavior.
- CI & publish → Bundle: builds · Automation produces and publishes the distribution artifact.
