diff --git a/app/src/components/v-input/readme.md b/app/src/components/v-input/readme.md index 0996e227d0..c0f740303d 100644 --- a/app/src/components/v-input/readme.md +++ b/app/src/components/v-input/readme.md @@ -24,6 +24,7 @@ You can add any custom (text) prefix/suffix to the value in the input using the | `slug` | Force the value to be URL safe | `false` | | `slug-separator` | What character to use as separator in slugs | `-` | | `active` | Force the focus state | `false` | +| `trim` | Trim the start and end whitespace | `false` | Note: all other attached attributes are bound to the input HTMLELement in the component. This allows you to attach any of the standard HTML attributes like `min`, `length`, or `pattern`. diff --git a/app/src/components/v-input/v-input.vue b/app/src/components/v-input/v-input.vue index 6dc5cc2a69..4c9ee4a898 100644 --- a/app/src/components/v-input/v-input.vue +++ b/app/src/components/v-input/v-input.vue @@ -121,6 +121,10 @@ export default defineComponent({ type: Boolean, default: false, }, + trim: { + type: Boolean, + default: true, + }, }, setup(props, { emit, listeners }) { const input = ref(null); @@ -177,20 +181,28 @@ export default defineComponent({ function emitValue(event: InputEvent) { let value = (event.target as HTMLInputElement).value; - if (props.slug === true) { - const endsWithSpace = value.endsWith(' '); - value = slugify(value, { separator: props.slugSeparator }); - if (endsWithSpace) value += props.slugSeparator; - } + if (props.type === 'number') { + emit('input', Number(value)); + } else { + if (props.trim === true) { + value = value.trim(); + } - if (props.dbSafe === true) { - value = value.toLowerCase(); - value = value.replace(/\s/g, '_'); - // Replace é -> e etc - value = value.normalize('NFD').replace(/[\u0300-\u036f]/g, ''); - } + if (props.slug === true) { + const endsWithSpace = value.endsWith(' '); + value = slugify(value, { separator: props.slugSeparator }); + if (endsWithSpace) value += props.slugSeparator; + } - emit('input', value); + if (props.dbSafe === true) { + value = value.toLowerCase(); + value = value.replace(/\s/g, '_'); + // Replace é -> e etc + value = value.normalize('NFD').replace(/[\u0300-\u036f]/g, ''); + } + + emit('input', value); + } } function stepUp() { @@ -200,8 +212,8 @@ export default defineComponent({ input.value.stepUp(); - if (input.value.value) { - return emit('input', input.value.value); + if (input.value.value != null) { + return emit('input', Number(input.value.value)); } } @@ -213,7 +225,7 @@ export default defineComponent({ input.value.stepDown(); if (input.value.value) { - return emit('input', input.value.value); + return emit('input', Number(input.value.value)); } else { return emit('input', props.min || 0); } diff --git a/app/src/displays/collection/index.ts b/app/src/displays/collection/index.ts index 1fe063767c..c99fcdf7bf 100644 --- a/app/src/displays/collection/index.ts +++ b/app/src/displays/collection/index.ts @@ -3,7 +3,8 @@ import DisplayCollection from './collection.vue'; export default defineDisplay(({ i18n }) => ({ id: 'collection', - name: i18n.t('collection'), + name: i18n.t('displays.collection.collection'), + description: i18n.t('displays.collection.description'), types: ['string'], icon: 'label', handler: DisplayCollection, @@ -15,9 +16,12 @@ export default defineDisplay(({ i18n }) => ({ meta: { interface: 'toggle', options: { - label: `Show the collection's icon`, + label: i18n.t('displays.collection.icon_label'), }, }, + schema: { + default_value: false, + }, }, ], })); diff --git a/app/src/displays/color-dot/color-dot.vue b/app/src/displays/color-dot/color-dot.vue index 6c5b5ff5b5..68b7b82b62 100644 --- a/app/src/displays/color-dot/color-dot.vue +++ b/app/src/displays/color-dot/color-dot.vue @@ -1,5 +1,5 @@