Skip to content

Commit 629bc39

Browse files
committed
feat(output): Add components to editor
1 parent c2ba491 commit 629bc39

File tree

2 files changed

+29
-13
lines changed

2 files changed

+29
-13
lines changed

src/composables/useInputEditor.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ export function useInputEditor() {
33

44
const primeInputNames = [...primeInputWithOptionNames, 'AutoComplete', 'Checkbox', 'ColorPicker', 'DatePicker', 'Editor', 'InputMask', 'InputNumber', 'InputOtp', 'InputText', 'Knob', 'Password', 'Rating', 'Slider', 'Textarea', 'ToggleButton', 'ToggleSwitch'].sort()
55

6+
const primeOutputNames = ['OutputBoolean', 'OutputDate', 'OutputDuration', 'OutputLink', 'OutputList', 'OutputNumber', 'OutputText']
7+
68
function generateSchemaItemId(): string {
79
return `id-${Math.random().toString(36).substring(2, 15)}`
810
}
@@ -84,5 +86,5 @@ export function useInputEditor() {
8486
return { ...schema, _dollar_formkit: formkitInput }
8587
}
8688

87-
return { primeInputNames, generateSchemaItemId, editorDataToSchema, editorDataToJson, editorDataToCode: editorDataToObject, schemaToEditorData }
89+
return { primeInputNames, primeOutputNames, generateSchemaItemId, editorDataToSchema, editorDataToJson, editorDataToCode: editorDataToObject, schemaToEditorData }
8890
}

src/composables/useInputEditorSchema.ts

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { useInputEditor } from './useInputEditor'
33

44
export function useInputEditorSchema() {
55
const { addElement, addList, addListGroup, addComponent } = useFormKitSchema()
6-
const { primeInputNames } = useInputEditor()
6+
const { primeInputNames, primeOutputNames } = useInputEditor()
77
function addFlexElement(children: any[]) {
88
return addElement('div', children, { style: 'max-width: 40rem;display: flex;gap: 1rem;' })
99
}
@@ -52,7 +52,7 @@ export function useInputEditorSchema() {
5252

5353
]
5454

55-
function editorSchema(inputOptions: any[] = primeInputOptions(primeInputNames)) {
55+
function editorSchema(inputOptions: any[] = primeInputOptions([...primeInputNames, ...primeOutputNames])) {
5656
return [
5757
addGridElement([
5858

@@ -65,6 +65,7 @@ export function useInputEditorSchema() {
6565
optionLabel: 'label',
6666
optionValue: 'value',
6767
options: inputOptions,
68+
filter: true,
6869
key: 'schema_inputSelection',
6970
preserve: true,
7071
},
@@ -208,20 +209,33 @@ export function useInputEditorSchema() {
208209
{
209210
$formkit: 'primeInputText',
210211
if: '$get(selectButton).value === \'showDisplay\'',
211-
name: 'icon',
212-
label: 'Icon',
213-
key: 'schema_icon',
212+
name: 'prefixIcon',
213+
label: 'Prefix Icon',
214+
key: 'schema_prefix_icon',
214215
preserve: true,
215216
},
216217
{
217-
$formkit: 'primeSelect',
218+
$formkit: 'primeInputText',
218219
if: '$get(selectButton).value === \'showDisplay\'',
219-
name: 'iconPosition',
220-
label: 'Icon Position',
221-
optionLabel: 'label',
222-
optionValue: 'value',
223-
options: positionOptions,
224-
key: 'schema_iconPosition',
220+
name: 'prefix',
221+
label: 'Prefix',
222+
key: 'schema_prefix',
223+
preserve: true,
224+
},
225+
{
226+
$formkit: 'primeInputText',
227+
if: '$get(selectButton).value === \'showDisplay\'',
228+
name: 'suffix',
229+
label: 'Suffix',
230+
key: 'schema_suffix',
231+
preserve: true,
232+
},
233+
{
234+
$formkit: 'primeInputText',
235+
if: '$get(selectButton).value === \'showDisplay\'',
236+
name: 'suffixIcon',
237+
label: 'Suffix Icon',
238+
key: 'schema_suffix_icon',
225239
preserve: true,
226240
},
227241
{

0 commit comments

Comments
 (0)