@stonecrop/beam 0.2.53 → 0.2.54

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.
@@ -0,0 +1,14 @@
1
+ export type ListViewItem = {
2
+ description: string;
3
+ label: string;
4
+ checked?: boolean;
5
+ debounce?: number;
6
+ linkComponent?: string;
7
+ route?: string;
8
+ count?: {
9
+ count: number;
10
+ of: number;
11
+ uom: string;
12
+ };
13
+ };
14
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,YAAY,GAAG;IAC1B,WAAW,EAAE,MAAM,CAAA;IACnB,KAAK,EAAE,MAAM,CAAA;IACb,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,KAAK,CAAC,EAAE;QACP,KAAK,EAAE,MAAM,CAAA;QACb,EAAE,EAAE,MAAM,CAAA;QACV,GAAG,EAAE,MAAM,CAAA;KACX,CAAA;CACD,CAAA"}
File without changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stonecrop/beam",
3
- "version": "0.2.53",
3
+ "version": "0.2.54",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "author": {
@@ -29,6 +29,7 @@
29
29
  "src/*"
30
30
  ],
31
31
  "dependencies": {
32
+ "@vueuse/core": "^11.1.0",
32
33
  "mqtt": "^5.10.1",
33
34
  "onscan.js": "^1.5.2",
34
35
  "vue": "^3.5.6"
@@ -3,8 +3,9 @@
3
3
  <span
4
4
  :contenteditable="editable"
5
5
  :class="{ 'beam--alert': !isCountComplete }"
6
- @input="handleInput"
7
- @click="handleInput">
6
+ @click.stop.prevent="validate"
7
+ @input.stop.prevent="debouncedValidate"
8
+ @paste="validate">
8
9
  {{ count }}
9
10
  </span>
10
11
  <span>/{{ denominator }}</span>
@@ -13,25 +14,29 @@
13
14
  </template>
14
15
 
15
16
  <script setup lang="ts">
16
- import { computed } from 'vue'
17
+ import { useDebounceFn } from '@vueuse/core'
18
+ import { computed, type HTMLAttributes } from 'vue'
17
19
 
18
20
  const count = defineModel<number>({ required: true })
19
21
  const {
20
22
  denominator,
21
- uom = '',
23
+ debounce = 300,
22
24
  editable = true,
25
+ uom = '',
23
26
  } = defineProps<{
24
27
  denominator: number
28
+ debounce?: number
29
+ editable?: HTMLAttributes['contenteditable']
25
30
  uom?: string
26
- editable?: boolean
27
31
  }>()
28
32
 
29
33
  const isCountComplete = computed(() => count.value === denominator)
30
34
 
31
- const handleInput = (event: InputEvent | MouseEvent) => {
32
- event.preventDefault()
33
- event.stopPropagation()
34
- const newValue = Number((event.target as HTMLElement).innerHTML) || 0
35
+ const validate = (payload: ClipboardEvent | InputEvent | MouseEvent) => {
36
+ const newValue = Number((payload.target as HTMLElement).innerHTML) || 0
35
37
  count.value = Math.min(newValue, denominator)
36
38
  }
39
+
40
+ const debouncedRequest = useDebounceFn((payload: InputEvent) => validate(payload), debounce)
41
+ const debouncedValidate = async (payload: InputEvent) => await debouncedRequest(payload)
37
42
  </script>
@@ -8,9 +8,10 @@
8
8
  <ItemCount
9
9
  v-if="listItem.count"
10
10
  v-model="listItem.count.count"
11
+ :debounce="listItem.debounce"
11
12
  :denominator="listItem.count.of"
12
- :uom="listItem.count.uom"
13
- :editable="true" />
13
+ :editable="true"
14
+ :uom="listItem.count.uom" />
14
15
  <ItemCheck v-if="listItem.hasOwnProperty('checked')" v-model="listItem.checked" />
15
16
  </li>
16
17
  </template>
@@ -20,19 +21,9 @@ import { ref } from 'vue'
20
21
 
21
22
  import ItemCount from '@/components/ItemCount.vue'
22
23
  import ItemCheck from '@/components/ItemCheck.vue'
24
+ import type { ListViewItem } from '@/types'
23
25
 
24
- const { item } = defineProps<{
25
- item: {
26
- label: string
27
- description: string
28
- count?: {
29
- count: number
30
- of: number
31
- uom: string
32
- }
33
- checked?: boolean
34
- }
35
- }>()
26
+ const { item } = defineProps<{ item: ListViewItem }>()
36
27
 
37
28
  const listItem = ref(item)
38
29
  </script>
@@ -17,22 +17,9 @@
17
17
  import { onMounted, onUnmounted } from 'vue'
18
18
 
19
19
  import ListItem from '@/components/ListItem.vue'
20
+ import type { ListViewItem } from '@/types'
20
21
 
21
- defineProps<{
22
- items: {
23
- label: string
24
- description: string
25
- count?: {
26
- count: number
27
- of: number
28
- uom: string
29
- }
30
- checked?: boolean
31
- linkComponent?: string
32
- route?: string
33
- }[]
34
- }>()
35
-
22
+ defineProps<{ items: ListViewItem[] }>()
36
23
  const emit = defineEmits<{ scrollbottom: [] }>()
37
24
 
38
25
  onMounted(() => {
@@ -0,0 +1,13 @@
1
+ export type ListViewItem = {
2
+ description: string
3
+ label: string
4
+ checked?: boolean
5
+ debounce?: number
6
+ linkComponent?: string
7
+ route?: string
8
+ count?: {
9
+ count: number
10
+ of: number
11
+ uom: string
12
+ }
13
+ }