From bf7961021969e67eedda673e873822e542b05028 Mon Sep 17 00:00:00 2001 From: Jacob Rienstra Date: Mon, 20 Apr 2020 10:23:01 -0400 Subject: [PATCH] Text-input / v-input fixes (#386) * textinput fixes including masking trimming icons and fonts * removed masked attribute from v-input * added wrapper div * ugh * test fix * fixed all calls to monospace boolean except on textarea (in separate branch) * readonly * Remove unused wrapper div and rename readonly to disabled * Rename readonly to disabled in story * Prefer style over inline styles * Fix codesmell Co-authored-by: rijkvanzanten --- src/components/v-form/v-form.story.ts | 2 +- src/components/v-input/readme.md | 32 ++++++---- src/components/v-input/v-input.story.ts | 14 ++++- src/components/v-input/v-input.test.ts | 3 +- src/components/v-input/v-input.vue | 61 ++++++++++--------- src/components/v-select/readme.md | 14 +++-- src/components/v-select/v-select.vue | 27 ++++---- src/interfaces/text-input/index.ts | 37 +++++++++-- src/interfaces/text-input/readme.md | 12 ++++ src/interfaces/text-input/text-input.story.ts | 42 ++++++++++--- src/interfaces/text-input/text-input.test.ts | 8 +-- src/interfaces/text-input/text-input.vue | 51 +++++++++++++--- .../new-collection/new-collection.vue | 10 ++- .../components/field-select/field-select.vue | 13 +++- .../field-setup/field-setup-advanced.vue | 2 +- src/routes/install/install-database.vue | 8 ++- src/routes/install/install-project.vue | 8 ++- src/routes/install/install-welcome.vue | 6 +- 18 files changed, 248 insertions(+), 102 deletions(-) diff --git a/src/components/v-form/v-form.story.ts b/src/components/v-form/v-form.story.ts index ff8d819f19..5d2426d68f 100644 --- a/src/components/v-form/v-form.story.ts +++ b/src/components/v-form/v-form.story.ts @@ -43,7 +43,7 @@ export const collection = () => hidden_browse: false, required: false, options: { - monospace: true, + font: 'monospace', }, locked: false, translation: null, diff --git a/src/components/v-input/readme.md b/src/components/v-input/readme.md index ac27597212..878956fb83 100644 --- a/src/components/v-input/readme.md +++ b/src/components/v-input/readme.md @@ -13,30 +13,33 @@ The HTML `` element supports a huge amount of attributes and events. In o You can add any custom (text) prefix/suffix to the value in the input using the `prefix` and `suffix` slots. ## Props -| Prop | Description | Default | -|------------------|------------------------------------------------|---------| -| `autofocus` | Autofocusses the input on render | `false` | -| `disabled` | Set the disabled state for the input | `false` | -| `monospace` | Render the entered value in the monospace font | `false` | -| `full-width` | Render the input with 100% width | `false` | -| `prefix` | Prefix the users value with a value | -- | -| `suffix` | Show a value at the end of the input | -- | -| `slug` | Force the value to be URL safe | `false` | -| `slug-separator` | What character to use as separator in slugs | `-` | + +| Prop | Description | Default | +| ---------------- | ------------------------------------------- | ------- | +| `autofocus` | Autofocusses the input on render | `false` | +| `disabled` | Set the disabled state for the input | `false` | +| `full-width` | Render the input with 100% width | `false` | +| `prefix` | Prefix the users value with a value | -- | +| `suffix` | Show a value at the end of the input | -- | +| `slug` | Force the value to be URL safe | `false` | +| `slug-separator` | What character to use as separator in slugs | `-` | +| `trim` | Trim leading and trailing whitespace | `true` | 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`. ## Slots + | Slot | Description | Data | -|-----------------|---------------------------------------------------|--------------------------------------------------| +| --------------- | ------------------------------------------------- | ------------------------------------------------ | | `prepend-outer` | Before the input | `{ disabled: boolean, value: string | number; }` | | `prepend` | In the input, before the value, before the prefix | `{ disabled: boolean, value: string | number; }` | | `append` | In the input, after the value, after the suffix | `{ disabled: boolean, value: string | number; }` | | `append-outer` | After the input | `{ disabled: boolean, value: string | number; }` | ## Events + | Events | Description | Value | -|-----------------------|----------------------------------------------|-------| +| --------------------- | -------------------------------------------- | ----- | | `input` | Updates `v-model` | `any` | | `click:append` | User clicks on content of inner append slot | -- | | `click:prepend` | User clicks on content of inner prepend slot | -- | @@ -46,4 +49,7 @@ Note: all other attached attributes are bound to the input HTMLELement in the co Note: all other listeners are bound to the input HTMLElement, allowing you to handle everything from `keydown` to `emptied`. ## CSS Variables -n/a + +| Variable | Default | +| ----------------------- | -------------------------- | +| `--v-input-font-family` | `var(--family-sans-serif)` | diff --git a/src/components/v-input/v-input.story.ts b/src/components/v-input/v-input.story.ts index d2b2a4f5b9..a27a0f54e8 100644 --- a/src/components/v-input/v-input.story.ts +++ b/src/components/v-input/v-input.story.ts @@ -1,4 +1,4 @@ -import { withKnobs, text } from '@storybook/addon-knobs'; +import { withKnobs, text, boolean } from '@storybook/addon-knobs'; import Vue from 'vue'; import VInput from './v-input.vue'; import markdown from './readme.md'; @@ -22,13 +22,21 @@ export default { export const basic = () => defineComponent({ components: { RawValue }, + props: { + placeholder: { + default: text('Placeholder', 'Enter a value...', 'Options'), + }, + trim: { + default: boolean('Trim', false, 'Options'), + }, + }, setup() { const value = ref(null); return { value }; }, template: `
- + {{ value }}
`, @@ -42,7 +50,7 @@ export const monospace = () => ({ }, template: `
- +
`, }); diff --git a/src/components/v-input/v-input.test.ts b/src/components/v-input/v-input.test.ts index e523c355e1..51546810e8 100644 --- a/src/components/v-input/v-input.test.ts +++ b/src/components/v-input/v-input.test.ts @@ -54,12 +54,11 @@ describe('Input', () => { it('Sets the correct classes based on props', async () => { component.setProps({ disabled: true, - monospace: true, }); await component.vm.$nextTick(); - expect(component.find('.input').classes()).toEqual(['input', 'disabled', 'monospace']); + expect(component.find('.input').classes()).toEqual(['input', 'disabled']); }); it('Emits just the value for the input event', async () => { diff --git a/src/components/v-input/v-input.vue b/src/components/v-input/v-input.vue index 8e123da656..4db0faa9f7 100644 --- a/src/components/v-input/v-input.vue +++ b/src/components/v-input/v-input.vue @@ -1,3 +1,4 @@ +f