Skip to content

feat(form): integrate sc into ew/nx2#508

Open
kozmaadrian wants to merge 22 commits into
mainfrom
form-ew
Open

feat(form): integrate sc into ew/nx2#508
kozmaadrian wants to merge 22 commits into
mainfrom
form-ew

Conversation

@kozmaadrian

@kozmaadrian kozmaadrian commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Port the structured-content form block into nx2

Summary

Ports the schema-driven form block from nx/blocks/form (v1) into nx2/blocks/form, rebuilt to nx2 conventions and Spectrum 2 design.

How it was ported

Engine — vendored da-sc-sdk. The structured-content engine is vendored into nx2/deps/da-sc-sdk (with a build:da-sc-sdk:nx2 script).

Utils — cloned onto the nx2 api. The form's utils/ (context, da-api, persistence, schemas) were brought over and adapted to the nx2 utility/api layer (loadStyle, hashChange, daFetch, …).

Fields — rebuilt as Spectrum 2 web components. Each field is its own Lit element module under fields/:

  • sl-input, sl-picker, sl-checkbox, sl-button (accent/secondary variants), sl-number-field.
  • A shared defaults module supplies the common field chrome (label, required marker, error text, description slot), adopted alongside each field's own stylesheet via adoptedStyleSheets + the loadStyle(import.meta.url) convention.
  • No Spectrum Web Components dependency — Spectrum 2 design is expressed purely through --s2-* tokens (per AGENTS.md: "Spectrum design, not Spectrum libraries").
  • Each consumer imports the field modules it renders directly (the editor imports all five; the shell imports the picker + button it uses) — no central barrel.

Views — cloned with S2 styling. editor, sidebar, and preview, plus the array UI (array-menu, reorder), restyled to Spectrum 2.

Icons load from .svg files through the themeable icon() helper (currentColor), matching the nx2 icon convention.

Shell — ctx-driven nx-form. form.js is a thin Lit shell: it reads the hash, resolves schema/document context, instantiates the engine, wires editor/sidebar/preview, and attaches persistence (cleaned up on teardown).

Preview / publish open at the structured-content renderer URL (via the ew-actions integration).

Conventions followed

  • nx2 lazy-loading (dynamic imports in firstUpdated, null-checked usage).
  • Spectrum 2 via --s2-* tokens; light/dark through light-dark().
  • Self-contained, per-element field modules (portable to a shared location)

Test url: https://da.live/formnx2?nx=form-ew#/exp-workspace/frescopa/forms/ai-evolution

The chat window is gated by the ew.enabled flag.

Screen 0: Chat deactivated

Screenshot 2026-06-25 at 11 09 10 am

Screen 1: Select Schema

screen-select-schema

Screen 2: Empty document

empty-sc-document

Screen 3: Existing document

existing-sc-document

@aem-code-sync

aem-code-sync Bot commented Jun 12, 2026

Copy link
Copy Markdown

Hello, I'm the AEM Code Sync Bot and I will run some actions to deploy your branch.
In case there are problems, just click the checkbox below to rerun the respective action.

  • Re-sync branch
Commits

Comment thread nx2/blocks/ew-actions/ew-actions.js Outdated
Comment thread nx2/utils/aem-preview-publish.js Outdated
* @param {{ aemPath: string, action: 'preview' | 'publish' }} params
* @returns {string | null} e.g. https://da-sc.adobeaem.workers.dev/preview/kozmaadrian/da-sc/forms/x
*/
export function buildScRendererUrl({ aemPath, action }) {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file location should be scoped to the SC block. It looks to be purely for SC.

The filename is also a bit misleading as it looks like it implies overlap with api.js.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes lets move this to the block 👍

@kozmaadrian kozmaadrian marked this pull request as ready for review June 16, 2026 09:12
Comment thread nx2/blocks/form/icons.js
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants