From 3c4260951e0c480d52f233ba872c685e3423a6e8 Mon Sep 17 00:00:00 2001 From: Pius Rubangakene Date: Thu, 25 Apr 2024 22:39:29 +0300 Subject: [PATCH] (feat) O3-3109 deprecate type within inbuiltControls (#229) --- .../inbuilt-components/inbuiltControls.ts | 54 +++++++------------ src/registry/registry.ts | 7 +-- 2 files changed, 22 insertions(+), 39 deletions(-) diff --git a/src/registry/inbuilt-components/inbuiltControls.ts b/src/registry/inbuilt-components/inbuiltControls.ts index 592ee049b..6cf625844 100644 --- a/src/registry/inbuilt-components/inbuiltControls.ts +++ b/src/registry/inbuilt-components/inbuiltControls.ts @@ -26,96 +26,78 @@ import UiSelectExtended from '../../components/inputs/ui-select-extended/ui-sele export const inbuiltControls: Array>> = [ { - name: 'TextField', + name: 'text', component: TextField, - type: 'text', }, { - name: 'Radio', + name: 'radio', component: Radio, - type: 'radio', }, { - name: 'DateField', + name: 'date', component: DateField, - type: 'date', }, { - name: 'NumberField', + name: 'number', component: NumberField, - type: 'number', alias: 'numeric', }, { - name: 'MultiSelect', + name: 'checkbox', component: MultiSelect, - type: 'checkbox', alias: 'multiCheckbox', }, { - name: 'ContentSwitcher', + name: 'content-switcher', component: ContentSwitcher, - type: 'content-switcher', }, { - name: 'Dropdown', + name: 'select', component: Dropdown, - type: 'select', }, { - name: 'TextArea', + name: 'textarea', component: TextArea, - type: 'textarea', }, { - name: 'Toggle', + name: 'toggle', component: Toggle, - type: 'toggle', }, { - name: 'ObsGroup', + name: 'group', component: ObsGroup, - type: 'group', }, { - name: 'Repeat', + name: 'repeating', component: Repeat, - type: 'repeating', }, { - name: 'FixedValue', + name: 'fixed-value', component: FixedValue, - type: 'fixed-value', }, { - name: 'Markdown', + name: 'markdown', component: Markdown, - type: 'markdown', }, { - name: 'ExtensionParcel', + name: 'extension-widget', component: ExtensionParcel, - type: 'extension-widget', }, { - name: 'DateField', + name: 'datetime', component: DateField, - type: 'datetime', }, { - name: 'UiSelectExtended', + name: 'ui-select-extended', component: UiSelectExtended, - type: 'ui-select-extended', }, { - name: 'File', + name: 'file', component: File, - type: 'file', }, { - name: 'WorkspaceLauncher', + name: 'workspace-launcher', component: WorkspaceLauncher, - type: 'workspace-launcher', }, ...controlTemplates.map((template) => ({ name: `${template.name}Control`, diff --git a/src/registry/registry.ts b/src/registry/registry.ts index 3999dea2e..bb0ab7296 100644 --- a/src/registry/registry.ts +++ b/src/registry/registry.ts @@ -40,7 +40,6 @@ export interface FieldSubmissionHandlerRegistration extends ComponentRegistratio type: string; } - export interface FormsRegistryStoreState { controls: CustomControlRegistration[]; fieldValidators: ComponentRegistration[]; @@ -116,11 +115,13 @@ export async function getRegisteredControl(renderType: string) { if (registryCache.controls[renderType]) { return registryCache.controls[renderType]; } - let component = inbuiltControls.find((item) => item.type === renderType || item?.alias === renderType)?.component; + let component = inbuiltControls.find( + (control) => control.name === renderType || control?.alias === renderType, + )?.component; // if undefined, try serching through the registered custom controls if (!component) { const importedControl = await getFormsStore() - .controls.find((item) => item.type === renderType || item?.alias === renderType) + .controls.find((control) => control.name === renderType || control?.alias === renderType) ?.load?.(); component = importedControl?.default; }