-
Notifications
You must be signed in to change notification settings - Fork 811
Forms: Add 17 RC release notes and backoffice extension points #7621
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 6 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
463df21
Updated documentation to match npm package
rickbutterfield 1b86574
Updated documentation to show how to use npm package
rickbutterfield b6de3d5
Undo change to v16 docs
rickbutterfield dd44207
Merge branch 'main' into forms/17-rc
rickbutterfield 6c5645b
Add TSConfig / Vite config info
rickbutterfield a1671ff
Add links for Vite Package Setup article
rickbutterfield 228aa19
Apply suggestions from code review
eshanrnh 0dc49ef
Update 16/umbraco-forms/developer/extending/README.md
eshanrnh ec4bc19
Update 17/umbraco-forms/developer/extending/README.md
eshanrnh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,65 @@ | ||
| # Extending | ||
|
|
||
| Umbraco Forms functionality can be extended in different ways. In this section we focus on techniques available to a back-end/C# developer. | ||
| Umbraco Forms functionality can be extended in different ways. | ||
|
|
||
| For front-end extensions, specifically via theming, see the [Themes](../themes.md) section. | ||
|
|
||
| ## Extending the Backoffice | ||
| Umbraco Forms publishes an NPM package called `@umbraco-forms/backoffice` that holds typings and other niceties to build extensions. | ||
|
|
||
| {% hint style="warning" %} | ||
| Ensure that you install the version of the Backoffice package compatible with your Umbraco Forms installation. You can find the appropriate version on the [@umbraco-forms/backoffice npm page](https://www.npmjs.com/package/@umbraco-forms/backoffice). | ||
| {% endhint %} | ||
|
|
||
| You can install this package by running the command: | ||
|
|
||
| ```bash | ||
| npm install -D @umbraco-forms/[email protected] | ||
| ``` | ||
|
|
||
| This will add a package to your devDependencies containing the TypeScript definitions for Umbraco Forms. | ||
|
|
||
| **TSConfig** | ||
eshanrnh marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| Make sure to configure your TypeScript compiler so it includes the Global Types from the package. This enables you to utilize the declared Extension Types. If your project is using other Packages that provide their Extension Types, list these as well. | ||
eshanrnh marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| In your `tsconfig.json` file, add the array `types` inside `compilerOptions`, with the entry of `@umbraco-forms/backoffice`: | ||
|
|
||
| ```json | ||
| { | ||
| "compilerOptions": { | ||
| ... | ||
| "types": [ | ||
| ... | ||
| "@umbraco-forms/backoffice" | ||
| ] | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| **Take extra care when using Vite** | ||
eshanrnh marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| It is important that this namespace is ignored in your bundler. If you are using Vite, you can add the following to your `vite.config.ts` file: | ||
|
|
||
| ```ts | ||
| import { defineConfig } from "vite"; | ||
|
|
||
| export default defineConfig({ | ||
| // other config | ||
| // ... | ||
| // add this to your config | ||
| build: { | ||
| rollupOptions: { | ||
| external: [/^@umbraco/], | ||
| }, | ||
| } | ||
| }); | ||
| ``` | ||
|
|
||
| This ensures that the Umbraco Backoffice packages are not bundled with your package. | ||
|
|
||
| Read more about using Vite with Umbraco in the [Vite Package Setup](../../../umbraco-cms/customizing/development-flow/vite-package-setup.md) article. | ||
eshanrnh marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ## Developing Custom Providers | ||
|
|
||
| Although the Forms package comes with many fields, workflows and other built-in types, you can still create and develop your own if needed. | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -172,6 +172,18 @@ With Forms 14+, aspects of the presentation and functionality of the custom fiel | |
|
|
||
| To create custom backoffice components for Umbraco 14, it's recommended to use a front-end build setup using Vite, TypeScript, and Lit. For more information, see the [Extension with Vite, TypeScript, and Lit](https://app.gitbook.com/s/G1Byxw7XfiZAj8zDMCTD/tutorials/creating-your-first-extension#extension-with-vite-typescript-and-lit) article. | ||
|
|
||
| The examples here are using the `@umbraco-forms/backoffice` package to get access to Forms-specific types and contexts. It is recommended to install this package as a development dependency in your project. | ||
|
|
||
| {% hint style="warning" %} | ||
| Ensure that you install the version of the Backoffice package compatible with your Umbraco Forms installation. You can find the appropriate version on the [@umbraco-forms/backoffice npm page](https://www.npmjs.com/package/@umbraco-forms/backoffice). | ||
eshanrnh marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| {% endhint %} | ||
|
|
||
| ```bash | ||
| npm install -D @umbraco-forms/[email protected] | ||
| ``` | ||
|
|
||
| This will add a package to your devDependencies containing the TypeScript definitions for Umbraco Forms. | ||
|
|
||
| To display a name and description on a custom field, you need to register a JavaScript file as shown in the [Localization](https://app.gitbook.com/s/7MBVdnTbFiAgWuRsHpNS/customizing/extending-overview/extension-types/localization) article. | ||
|
|
||
| ### Field Preview | ||
|
|
@@ -240,14 +252,14 @@ And it is registered via a manifest: | |
| import MyFieldPreviewSliderElement from './slider-preview.element.js'; | ||
|
|
||
| const sliderPreviewManifest = { | ||
| type: "formsFieldPreview", | ||
| alias: "My.FieldPreview.Slider", | ||
| name: "Forms UUI Slider Field Preview", | ||
| api: MyFieldPreviewSliderElement, | ||
| element: () => import('./slider-preview.element.js') | ||
| }; | ||
|
|
||
| export const manifests = [sliderPreviewManifest]; | ||
| type: "formsFieldPreview", | ||
| alias: "My.FieldPreview.Slider", | ||
| name: "Forms UUI Slider Field Preview", | ||
| api: MyFieldPreviewSliderElement, | ||
| element: () => import('./slider-preview.element.js') | ||
| }; | ||
|
|
||
| export const manifests = [sliderPreviewManifest]; | ||
| ``` | ||
|
|
||
| ### Field Editor | ||
|
|
@@ -403,20 +415,23 @@ The following code shows the structure for these converter elements. | |
|
|
||
| ```javascript | ||
| import type { UmbPropertyValueData } from "@umbraco-cms/backoffice/property"; | ||
| import type { FormsSettingValueConverterApi, Setting } from "@umbraco-forms/backoffice"; | ||
|
|
||
| export class SliderSettingValueConverter { | ||
|
|
||
| async getSettingValueForEditor(setting, alias: string, value: string) { | ||
| export class SliderSettingValueConverter | ||
| implements FormsSettingValueConverterApi { | ||
| async getSettingValueForEditor(setting: Setting, alias: string, value: string) { | ||
| return Promise.resolve(value); | ||
| } | ||
|
|
||
| async getSettingValueForPersistence(setting, valueData: UmbPropertyValueData) { | ||
| return Promise.resolve(valueData.value); | ||
| async getSettingValueForPersistence(setting: Setting, valueData: UmbPropertyValueData) { | ||
| return Promise.resolve(valueData.value?.toString() || ""); | ||
| } | ||
|
|
||
| async getSettingPropertyConfig(setting, alias: string, values: UmbPropertyValueData[]) { | ||
| async getSettingPropertyConfig(setting: Setting, alias: string, values: UmbPropertyValueData[]) { | ||
| return Promise.resolve([]); | ||
| } | ||
|
|
||
| destroy(): void { } | ||
| } | ||
| ``` | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,65 @@ | ||
| # Extending | ||
|
|
||
| Umbraco Forms functionality can be extended in different ways. In this section we focus on techniques available to a back-end/C# developer. | ||
| Umbraco Forms functionality can be extended in different ways. | ||
|
|
||
| For front-end extensions, specifically via theming, see the [Themes](../themes.md) section. | ||
|
|
||
| ## Extending the Backoffice | ||
| Umbraco Forms publishes an NPM package called `@umbraco-forms/backoffice` that holds typings and other niceties to build extensions. | ||
|
|
||
| {% hint style="warning" %} | ||
| Ensure that you install the version of the Backoffice package compatible with your Umbraco Forms installation. You can find the appropriate version on the [@umbraco-forms/backoffice npm page](https://www.npmjs.com/package/@umbraco-forms/backoffice). | ||
eshanrnh marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| {% endhint %} | ||
|
|
||
| You can install this package by running the command: | ||
|
|
||
| ```bash | ||
| npm install -D @umbraco-forms/[email protected] | ||
| ``` | ||
|
|
||
| This will add a package to your devDependencies containing the TypeScript definitions for Umbraco Forms. | ||
|
|
||
| **TSConfig** | ||
eshanrnh marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| Make sure to configure your TypeScript compiler so it includes the Global Types from the package. This enables you to utilize the declared Extension Types. If your project is using other Packages that provide their Extension Types, list these as well. | ||
eshanrnh marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| In your `tsconfig.json` file, add the array `types` inside `compilerOptions`, with the entry of `@umbraco-forms/backoffice`: | ||
|
|
||
| ```json | ||
| { | ||
| "compilerOptions": { | ||
| ... | ||
| "types": [ | ||
| ... | ||
| "@umbraco-forms/backoffice" | ||
| ] | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| **Take extra care when using Vite** | ||
eshanrnh marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| It is important that this namespace is ignored in your bundler. If you are using Vite, you can add the following to your `vite.config.ts` file: | ||
|
|
||
| ```ts | ||
| import { defineConfig } from "vite"; | ||
|
|
||
| export default defineConfig({ | ||
| // other config | ||
| // ... | ||
| // add this to your config | ||
| build: { | ||
| rollupOptions: { | ||
| external: [/^@umbraco/], | ||
| }, | ||
| } | ||
| }); | ||
| ``` | ||
|
|
||
| This ensures that the Umbraco Backoffice packages are not bundled with your package. | ||
|
|
||
| Read more about using Vite with Umbraco in the [Vite Package Setup](../../../umbraco-cms/customizing/development-flow/vite-package-setup.md) article. | ||
eshanrnh marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ## Developing Custom Providers | ||
|
|
||
| Although the Forms package comes with many fields, workflows and other built-in types, you can still create and develop your own if needed. | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -172,6 +172,18 @@ With Forms 14+, aspects of the presentation and functionality of the custom fiel | |
|
|
||
| To create custom backoffice components for Umbraco 14, it's recommended to use a front-end build setup using Vite, TypeScript, and Lit. For more information, see the [Extension with Vite, TypeScript, and Lit](https://app.gitbook.com/s/G1Byxw7XfiZAj8zDMCTD/tutorials/creating-your-first-extension#extension-with-vite-typescript-and-lit) article. | ||
|
|
||
| The examples here are using the `@umbraco-forms/backoffice` package to get access to Forms-specific types and contexts. It is recommended to install this package as a development dependency in your project. | ||
|
|
||
| {% hint style="warning" %} | ||
| Ensure that you install the version of the Backoffice package compatible with your Umbraco Forms installation. You can find the appropriate version on the [@umbraco-forms/backoffice npm page](https://www.npmjs.com/package/@umbraco-forms/backoffice). | ||
eshanrnh marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| {% endhint %} | ||
|
|
||
| ```bash | ||
| npm install -D @umbraco-forms/[email protected] | ||
| ``` | ||
|
|
||
| This will add a package to your devDependencies containing the TypeScript definitions for Umbraco Forms. | ||
|
|
||
| To display a name and description on a custom field, you need to register a JavaScript file as shown in the [Localization](https://app.gitbook.com/s/7MBVdnTbFiAgWuRsHpNS/customizing/extending-overview/extension-types/localization) article. | ||
|
|
||
| ### Field Preview | ||
|
|
@@ -181,29 +193,24 @@ The alias of the preview to use is defined on the field type via the `PreviewVie | |
| A preview for our slider, representing the selected setting values could look as follows: | ||
|
|
||
| ```javascript | ||
| import { UmbElementMixin } from "@umbraco-cms/backoffice/element-api"; | ||
| import { | ||
| LitElement, | ||
| css, | ||
| customElement, | ||
| html, | ||
| property, | ||
| } from "@umbraco-cms/backoffice/external/lit"; | ||
| import { FormsFieldPreviewBaseElement } from "@umbraco-forms/backoffice"; | ||
|
|
||
| const elementName = "my-field-preview-slider"; | ||
|
|
||
| @customElement(elementName) | ||
| export class MyFieldPreviewSliderElement extends UmbElementMixin(LitElement) { | ||
| export class MyFieldPreviewSliderElement extends FormsFieldPreviewBaseElement { | ||
| @property() | ||
| settings = {}; | ||
|
|
||
| @property({ type: Array }) | ||
| prevalues = []; | ||
|
|
||
| getSettingValue(key: string) { | ||
| return this.settings[key]; | ||
| } | ||
|
|
||
| render() { | ||
| return html`<div | ||
| style="background-color:${this.getSettingValue("BgColor")}" | ||
|
|
@@ -238,16 +245,16 @@ And it is registered via a manifest: | |
|
|
||
| ```javascript | ||
| import MyFieldPreviewSliderElement from './slider-preview.element.js'; | ||
| import { ManifestFormsFieldPreview } from '@umbraco-forms/backoffice'; | ||
|
|
||
| const sliderPreviewManifest = { | ||
| type: "formsFieldPreview", | ||
| alias: "My.FieldPreview.Slider", | ||
| name: "Forms UUI Slider Field Preview", | ||
| api: MyFieldPreviewSliderElement, | ||
| element: () => import('./slider-preview.element.js') | ||
| }; | ||
| const sliderPreviewManifest: ManifestFormsFieldPreview = { | ||
| type: "formsFieldPreview", | ||
| alias: "My.FieldPreview.Slider", | ||
| name: "Forms UUI Slider Field Preview", | ||
| element: MyFieldPreviewSliderElement | ||
| }; | ||
|
|
||
| export const manifests = [sliderPreviewManifest]; | ||
| export const manifests = [sliderPreviewManifest]; | ||
| ``` | ||
|
|
||
| ### Field Editor | ||
|
|
@@ -403,29 +410,33 @@ The following code shows the structure for these converter elements. | |
|
|
||
| ```javascript | ||
| import type { UmbPropertyValueData } from "@umbraco-cms/backoffice/property"; | ||
| import type { FormsSettingValueConverterApi, Setting } from "@umbraco-forms/backoffice"; | ||
|
|
||
| export class SliderSettingValueConverter { | ||
|
|
||
| async getSettingValueForEditor(setting, alias: string, value: string) { | ||
| export class SliderSettingValueConverter | ||
| implements FormsSettingValueConverterApi { | ||
| async getSettingValueForEditor(setting: Setting, alias: string, value: string) { | ||
| return Promise.resolve(value); | ||
| } | ||
|
|
||
| async getSettingValueForPersistence(setting, valueData: UmbPropertyValueData) { | ||
| return Promise.resolve(valueData.value); | ||
| async getSettingValueForPersistence(setting: Setting, valueData: UmbPropertyValueData) { | ||
| return Promise.resolve(valueData.value?.toString() || ""); | ||
| } | ||
|
|
||
| async getSettingPropertyConfig(setting, alias: string, values: UmbPropertyValueData[]) { | ||
| async getSettingPropertyConfig(setting: Setting, alias: string, values: UmbPropertyValueData[]) { | ||
| return Promise.resolve([]); | ||
| } | ||
|
|
||
| destroy(): void { } | ||
| } | ||
| ``` | ||
|
|
||
| It's registered as follows. The `propertyEditorUiAlias` matches with the property editor UI that requires the conversions. | ||
|
|
||
| ```javascript | ||
| import { SliderSettingValueConverter } from "./slider-setting-value-converter.api"; | ||
| import { ManifestFormsSettingValueConverterPreview } from "@umbraco-forms/backoffice"; | ||
|
|
||
| const sliderValueConverterManifest = { | ||
| const sliderValueConverterManifest: ManifestFormsSettingValueConverterPreview = { | ||
| type: "formsSettingValueConverter", | ||
| alias: "My.SettingValueConverter.Slider", | ||
| name: "Slider Value Converter", | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.