@propelinc/citrus-ui 0.3.5 → 0.3.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@propelinc/citrus-ui",
3
- "version": "0.3.5",
3
+ "version": "0.3.7",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/propelinc/citrus-ui"
@@ -19,7 +19,7 @@
19
19
  <script lang="ts">
20
20
  import { Component, Vue, Prop } from 'vue-property-decorator';
21
21
 
22
- @Component({ name: 'CCheckbox' })
22
+ @Component({ name: 'CCheckbox', inheritAttrs: false })
23
23
  export default class CCheckbox extends Vue {
24
24
  @Prop({ type: Boolean, default: false }) value!: boolean;
25
25
  @Prop({ type: Array, default: () => [] }) rules!: ((value: string) => string | boolean)[];
@@ -1,9 +1,9 @@
1
1
  <template>
2
- <form-field :field-id="id" :disabled="disabled" :label="label">
2
+ <form-field :data-test="dataTest" :field-id="id" :disabled="disabled" :label="label">
3
3
  <select-input
4
4
  :id="id"
5
5
  v-bind="$attrs"
6
- data-test="select-field"
6
+ :data-test="`${dataTest}-select`"
7
7
  class="select__field"
8
8
  :class="{ 'select__field--disabled': disabled }"
9
9
  outlined
@@ -15,18 +15,18 @@
15
15
  :items="items"
16
16
  validate-on-blur
17
17
  :hide-details="rules.length === 0"
18
- @input="(value) => $emit('input', value)"
18
+ v-on="$listeners"
19
19
  >
20
20
  <template #append>
21
21
  <font-awesome-icon
22
22
  v-if="loading"
23
- data-test="select-field-icon-loading"
23
+ :data-test="`${dataTest}-icon-loading`"
24
24
  class="fa-spin select__field__icon"
25
25
  :icon="faSpinner"
26
26
  />
27
27
  <font-awesome-icon
28
28
  v-else
29
- data-test="select-field-icon"
29
+ :data-test="`${dataTest}-icon-dropdown`"
30
30
  class="select__field__icon"
31
31
  :icon="faChevronDown"
32
32
  />
@@ -43,7 +43,7 @@ import FormField from '@/components/helpers/FormField.vue';
43
43
  import SelectInput from '@/components/helpers/SelectInput.vue';
44
44
 
45
45
  // @ts-ignore
46
- @Component({ name: 'CSelect', components: { FormField, SelectInput } })
46
+ @Component({ name: 'CSelect', inheritAttrs: false, components: { FormField, SelectInput } })
47
47
  export default class CSelect extends Vue {
48
48
  faChevronDown = faChevronDown;
49
49
  faSpinner = faSpinner;
@@ -54,6 +54,7 @@ export default class CSelect extends Vue {
54
54
  @Prop({ type: Array, default: () => [] }) items!: { label: string; value: string }[];
55
55
  @Prop({ type: Boolean, default: false }) disabled!: boolean;
56
56
  @Prop({ type: String, default: '' }) value!: string;
57
+ @Prop({ type: String, default: 'select-field' }) dataTest!: string;
57
58
  @Prop({ type: Boolean, default: false }) loading!: boolean;
58
59
  @Prop({ type: Array, default: () => [] }) rules!: ((value: string) => string | boolean)[];
59
60
  }
@@ -1,9 +1,9 @@
1
1
  <template>
2
- <form-field :field-id="id" :disabled="disabled" :label="label">
2
+ <form-field :data-test="dataTest" :field-id="id" :disabled="disabled" :label="label">
3
3
  <v-textarea
4
4
  :id="id"
5
5
  v-bind="$attrs"
6
- data-test="text-area"
6
+ :data-test="`${dataTest}-input`"
7
7
  class="text-area__input"
8
8
  :class="{ 'text-area__input--disabled': disabled }"
9
9
  auto-grow
@@ -15,7 +15,7 @@
15
15
  :rules="rules"
16
16
  validate-on-blur
17
17
  :hide-details="rules.length === 0"
18
- @input="(value) => $emit('input', value)"
18
+ v-on="$listeners"
19
19
  />
20
20
  </form-field>
21
21
  </template>
@@ -25,13 +25,14 @@ import { Component, Vue, Prop } from 'vue-property-decorator';
25
25
 
26
26
  import FormField from '@/components/helpers/FormField.vue';
27
27
 
28
- @Component({ name: 'CTextArea', components: { FormField } })
28
+ @Component({ name: 'CTextArea', inheritAttrs: false, components: { FormField } })
29
29
  export default class CTextArea extends Vue {
30
30
  @Prop(String) label?: string;
31
31
  @Prop(String) placeholder?: string;
32
32
  @Prop({ type: String, required: true }) id!: string;
33
33
  @Prop({ type: Boolean, default: false }) disabled!: boolean;
34
34
  @Prop({ type: String, default: '' }) value!: string;
35
+ @Prop({ type: String, default: 'text-area' }) dataTest!: string;
35
36
  @Prop({ type: Array, default: () => [] }) rules!: ((value: string) => string | boolean)[];
36
37
  }
37
38
  </script>
@@ -40,6 +41,7 @@ export default class CTextArea extends Vue {
40
41
  @import '~@/styles/form-fields.less';
41
42
 
42
43
  .text-area__input {
44
+ .body();
43
45
  .form-field();
44
46
  }
45
47
 
@@ -1,43 +1,91 @@
1
1
  <template>
2
- <form-field :field-id="id" :disabled="disabled" :label="label">
2
+ <form-field :data-test="dataTest" :field-id="id" :disabled="disabled" :label="label">
3
3
  <v-text-field
4
4
  :id="id"
5
+ ref="input"
5
6
  v-bind="$attrs"
6
- data-test="text-field"
7
+ :data-test="`${dataTest}-input`"
7
8
  class="text-field__field"
8
9
  :class="{ 'text-field__field--disabled': disabled }"
9
10
  outlined
10
11
  single-line
11
12
  :placeholder="placeholder"
12
13
  :disabled="disabled"
13
- :type="type"
14
+ :inputmode="inputmode"
15
+ :type="_type"
14
16
  :value="value"
15
17
  :rules="rules"
16
18
  validate-on-blur
17
19
  :hide-details="rules.length === 0"
18
- @input="(value) => $emit('input', value)"
20
+ v-on="$listeners"
19
21
  >
20
22
  <template #append>
21
- <slot name="append" />
23
+ <slot name="append">
24
+ <button
25
+ v-if="hideable"
26
+ type="button"
27
+ :data-test="`${dataTest}-hide-toggle`"
28
+ @click="toggleHideInput"
29
+ >
30
+ <font-awesome-icon v-if="hideInput" :icon="faEye" />
31
+ <font-awesome-icon v-else :icon="faEyeSlash" />
32
+ </button>
33
+ </slot>
22
34
  </template>
23
35
  </v-text-field>
24
36
  </form-field>
25
37
  </template>
26
38
 
27
39
  <script lang="ts">
40
+ import { faEye, faEyeSlash } from '@fortawesome/pro-light-svg-icons';
41
+ import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
28
42
  import { Component, Vue, Prop } from 'vue-property-decorator';
29
43
 
30
44
  import FormField from '@/components/helpers/FormField.vue';
31
45
 
32
- @Component({ name: 'CTextField', components: { FormField } })
46
+ type VTextField = Vue & { focus: () => void };
47
+
48
+ @Component({ name: 'CTextField', inheritAttrs: false, components: { FormField, FontAwesomeIcon } })
33
49
  export default class CTextField extends Vue {
50
+ faEye = faEye;
51
+ faEyeSlash = faEyeSlash;
52
+
34
53
  @Prop(String) label?: string;
35
54
  @Prop(String) placeholder?: string;
36
55
  @Prop({ type: String, required: true }) id!: string;
37
56
  @Prop({ type: String, default: 'text' }) type!: string;
57
+ /** HTML property that tells browser what kind of data is being entered.
58
+ * Be sure to set this if you're using an hideable input, so the keyboard doesn't change as the user toggles. */
59
+ @Prop(String) inputmode?: string;
38
60
  @Prop({ type: Boolean, default: false }) disabled!: boolean;
61
+ @Prop({ type: Boolean, default: false }) hideable!: boolean;
62
+ @Prop({ type: Boolean, default: true }) hideByDefault!: boolean;
39
63
  @Prop({ type: String, default: '' }) value!: string;
64
+ @Prop({ type: String, default: 'text-field' }) dataTest!: string;
40
65
  @Prop({ type: Array, default: () => [] }) rules!: ((value: string) => string | boolean)[];
66
+
67
+ hideInput: boolean = false;
68
+
69
+ created(): void {
70
+ this.hideInput = this.hideByDefault;
71
+ }
72
+
73
+ get _type(): string {
74
+ return this.hideInput && this.hideable ? 'password' : this.type;
75
+ }
76
+
77
+ toggleHideInput(): void {
78
+ if (!this.hideable) {
79
+ return;
80
+ }
81
+
82
+ this.hideInput = !this.hideInput;
83
+ this.$emit('click:hide', this.hideInput);
84
+ }
85
+
86
+ focus(): void {
87
+ (this.$refs.input as VTextField).focus();
88
+ }
41
89
  }
42
90
  </script>
43
91
 
@@ -1,9 +1,9 @@
1
1
  <template>
2
- <fieldset class="form-field" :disabled="disabled">
2
+ <fieldset class="form-field" :data-test="dataTest" :disabled="disabled">
3
3
  <label
4
4
  v-if="label"
5
5
  :for="fieldId"
6
- data-test="form-field-label"
6
+ :data-test="`${dataTest}-label`"
7
7
  class="form-field__label"
8
8
  :class="{ 'form-field__label--disabled': disabled }"
9
9
  >
@@ -22,6 +22,7 @@ export default class FormField extends Vue {
22
22
  @Prop(String) label?: string;
23
23
  @Prop({ type: String, required: true }) fieldId!: string;
24
24
  @Prop({ type: Boolean, default: false }) disabled!: boolean;
25
+ @Prop({ type: String, default: 'form-field' }) dataTest!: string;
25
26
  }
26
27
  </script>
27
28