Skip to content

Commit e281dd1

Browse files
committed
feat(editor): add option to display a text as number if possible
1 parent b656541 commit e281dd1

File tree

2 files changed

+28
-16
lines changed

2 files changed

+28
-16
lines changed

src/components/PrimeOutputNumber.vue

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,21 @@ const { hasPrefix, hasPrefixIcon, hasSuffix, hasSuffixIcon } = useFormKitSection
1212
const { n } = useI18n()
1313
1414
const converted = computed(() => {
15-
if (props?.context?._value) {
15+
const value = props?.context?._value
16+
if (value) {
1617
let result = ''
1718
const format = props?.context?.attrs?.format ? props?.context?.attrs?.format : 'short'
1819
try {
19-
result = n(props?.context?._value, format)
20+
result = n(value, format)
2021
}
2122
// eslint-disable-next-line unused-imports/no-unused-vars
2223
catch (e) {
24+
try {
25+
result = n(+value, format)
26+
}
27+
// eslint-disable-next-line unused-imports/no-unused-vars
28+
catch (e) {
29+
}
2330
}
2431
return result
2532
}

src/composables/useInputEditorSchema.ts

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,6 @@ export function useInputEditorSchema() {
4646
{ label: 'Submit', value: 'submit' },
4747
]
4848

49-
const positionOptions = [
50-
{ label: 'Left', value: 'left' },
51-
{ label: 'Right', value: 'right' },
52-
53-
]
54-
5549
function editorSchema(inputOptions: any[] = primeInputOptions([...primeInputNames, ...primeOutputNames])) {
5650
return [
5751
addGridElement([
@@ -107,14 +101,25 @@ export function useInputEditorSchema() {
107101
key: 'schema_help',
108102
preserve: true,
109103
},
110-
{
111-
$formkit: 'primeInputText',
112-
if: '$get(selectButton).value === \'showBasic\'',
113-
name: 'value',
114-
label: 'Input Value',
115-
key: 'schema_value',
116-
preserve: true,
117-
},
104+
addGridElement([
105+
106+
{
107+
$formkit: 'primeInputText',
108+
if: '$get(selectButton).value === \'showBasic\'',
109+
name: 'value',
110+
label: 'Input Value',
111+
key: 'schema_value',
112+
preserve: true,
113+
},
114+
{
115+
$formkit: 'primeInputText',
116+
if: '$get(selectButton).value === \'showBasic\'',
117+
name: 'format',
118+
label: 'Value Format',
119+
key: 'schema_format',
120+
preserve: true,
121+
},
122+
]),
118123
addGridElement([
119124
{
120125
$formkit: 'primeInputText',

0 commit comments

Comments
 (0)