@globalbrain/sefirot 2.0.0-draft.2 → 2.0.0-draft.3

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/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ # [2.0.0-draft.3](https://github.com/globalbrain/sefirot/compare/v2.0.0-draft.2...v2.0.0-draft.3) (2021-12-17)
2
+
3
+ ### Features
4
+
5
+ * **input-text:** emit "enter" and "blur" event ([a7b2b38](https://github.com/globalbrain/sefirot/commit/a7b2b38dc5f4880e7b680601be6e607d9b180c68))
6
+
1
7
  # [2.0.0-draft.2](https://github.com/globalbrain/sefirot/compare/v2.0.0-draft.1...v2.0.0-draft.2) (2021-12-14)
2
8
 
3
9
  ### Bug Fixes
@@ -37,7 +37,7 @@ defineProps({
37
37
 
38
38
  const emit = defineEmits(['update:modelValue'])
39
39
 
40
- function emitUpdate(value: string): void {
40
+ function emitUpdate(value: string | null): void {
41
41
  emit('update:modelValue', value ? Number(value): null)
42
42
  }
43
43
  </script>
@@ -16,6 +16,7 @@
16
16
  :value="modelValue"
17
17
  @input="emitInput"
18
18
  @blur="emitBlur"
19
+ @keypress.enter="emitEnter"
19
20
  >
20
21
  </SInputBase>
21
22
  </template>
@@ -40,7 +41,11 @@ const props = defineProps({
40
41
  validation: { type: Object as PropType<Validatable>, default: null }
41
42
  })
42
43
 
43
- const emit = defineEmits(['update:modelValue'])
44
+ const emit = defineEmits<{
45
+ (e: 'update:modelValue', value: string | null): void
46
+ (e: 'blur', value: string | null): void
47
+ (e: 'enter', value: string | null): void
48
+ }>()
44
49
 
45
50
  const classes = computed(() => [
46
51
  props.size,
@@ -52,11 +57,24 @@ function emitInput(e: Event): void {
52
57
  }
53
58
 
54
59
  function emitBlur(e: FocusEvent): void {
60
+ const value = getValue(e)
61
+
55
62
  props.validation?.$touch()
56
- emit('update:modelValue', getValue(e))
63
+
64
+ emit('update:modelValue', value)
65
+ emit('blur', value)
66
+ }
67
+
68
+ function emitEnter(e: KeyboardEvent): void {
69
+ const value = getValue(e)
70
+
71
+ props.validation?.$touch()
72
+
73
+ emit('update:modelValue', value)
74
+ emit('enter', value)
57
75
  }
58
76
 
59
- function getValue(e: Event | FocusEvent): string | null {
77
+ function getValue(e: Event | FocusEvent | KeyboardEvent): string | null {
60
78
  const value = (e.target as HTMLInputElement).value
61
79
 
62
80
  return value === '' ? null : value
@@ -14,7 +14,7 @@ export interface Search {
14
14
  placeholder: string
15
15
  missing: string
16
16
  value: Ref<string>
17
- onInput (text: string): void
17
+ onInput (text: string | null): void
18
18
  }
19
19
 
20
20
  export type Item = TextItem | UserItem
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@globalbrain/sefirot",
3
- "version": "2.0.0-draft.2",
3
+ "version": "2.0.0-draft.3",
4
4
  "description": "Vue Components for Global Brain Design System.",
5
5
  "files": [
6
6
  "lib"