@stonecrop/beam 0.2.50 → 0.2.52

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,29 @@
1
+ import mqtt from 'mqtt';
2
+ import { onMounted, onUnmounted, ref } from 'vue';
3
+ export const useMqttStream = (options) => {
4
+ const client = ref(null);
5
+ const messages = ref({});
6
+ onMounted(() => {
7
+ client.value = mqtt.connect(options);
8
+ if (!options.topics) {
9
+ options.topics = ['#'];
10
+ }
11
+ for (const topic of options.topics) {
12
+ client.value.subscribe(topic, err => {
13
+ if (err) {
14
+ throw err;
15
+ }
16
+ });
17
+ }
18
+ client.value.on('message', (topic, message) => {
19
+ if (!messages.value[topic]) {
20
+ messages.value[topic] = [];
21
+ }
22
+ messages.value[topic].push(message.toString());
23
+ });
24
+ });
25
+ onUnmounted(() => {
26
+ client.value.end();
27
+ });
28
+ return { messages };
29
+ };
package/dist/index.js CHANGED
@@ -1,8 +1,15 @@
1
1
  import ActionFooter from '@/components/ActionFooter.vue';
2
- import BeamMetadata from './components/BeamMetadata.vue';
2
+ import BeamArrow from '@/components/BeamArrow.vue';
3
+ import BeamBtn from '@/components/BeamBtn.vue';
4
+ import BeamFilter from '@/components/BeamFilter.vue';
5
+ import BeamFilterOption from '@/components/BeamFilterOption.vue';
6
+ import BeamHeading from '@/components/BeamHeading.vue';
7
+ import BeamMetadata from '@/components/BeamMetadata.vue';
3
8
  import BeamModal from '@/components/BeamModal.vue';
4
9
  import BeamModalOutlet from '@/components/BeamModalOutlet.vue';
10
+ import BeamProgress from '@/components/BeamProgress.vue';
5
11
  import Confirm from '@/components/Confirm.vue';
12
+ import FixedTop from '@/components/FixedTop.vue';
6
13
  import ItemCheck from '@/components/ItemCheck.vue';
7
14
  import ItemCount from '@/components/ItemCount.vue';
8
15
  import ListAnchor from '@/components/ListAnchor.vue';
@@ -10,11 +17,9 @@ import ListItem from '@/components/ListItem.vue';
10
17
  import ListView from '@/components/ListView.vue';
11
18
  import Navbar from '@/components/Navbar.vue';
12
19
  import ScanInput from '@/components/ScanInput.vue';
13
- import SplitColumn from './components/SplitColumn.vue';
14
- import BeamHeading from './components/BeamHeading.vue';
15
- import BeamArrow from './components/BeamArrow.vue';
16
- import BeamBtn from './components/BeamBtn.vue';
17
- import BeamProgress from './components/BeamProgress.vue';
20
+ import SplitColumn from '@/components/SplitColumn.vue';
21
+ import ToggleArrow from '@/components/ToggleArrow.vue';
22
+ import { useMqttStream } from '@/composables/mqtt';
18
23
  import 'themes/beam.css';
19
24
  /**
20
25
  * Install all Beam components
@@ -23,10 +28,17 @@ import 'themes/beam.css';
23
28
  */
24
29
  function install(app /* options */) {
25
30
  app.component('ActionFooter', ActionFooter);
31
+ app.component('BeamArrow', BeamArrow);
32
+ app.component('BeamBtn', BeamBtn);
33
+ app.component('BeamFilter', BeamFilter);
34
+ app.component('BeamFilterOption', BeamFilterOption);
35
+ app.component('BeamHeading', BeamHeading);
26
36
  app.component('BeamMetadata', BeamMetadata);
27
37
  app.component('BeamModal', BeamModal);
28
38
  app.component('BeamModalOutlet', BeamModalOutlet);
39
+ app.component('BeamProgress', BeamProgress);
29
40
  app.component('Confirm', Confirm);
41
+ app.component('FixedTop', FixedTop);
30
42
  app.component('ItemCheck', ItemCheck);
31
43
  app.component('ItemCount', ItemCount);
32
44
  app.component('ListAnchor', ListAnchor);
@@ -35,9 +47,6 @@ function install(app /* options */) {
35
47
  app.component('Navbar', Navbar);
36
48
  app.component('ScanInput', ScanInput);
37
49
  app.component('SplitColumn', SplitColumn);
38
- app.component('BeamHeading', BeamHeading);
39
- app.component('BeamArrow', BeamArrow);
40
- app.component('BeamBtn', BeamBtn);
41
- app.component('BeamProgress', BeamProgress);
50
+ app.component('ToggleArrow', ToggleArrow);
42
51
  }
43
- export { ActionFooter, BeamMetadata, BeamModal, BeamModalOutlet, Confirm, ItemCheck, ItemCount, ListAnchor, ListItem, ListView, Navbar, ScanInput, SplitColumn, BeamHeading, BeamArrow, BeamBtn, BeamProgress, install, };
52
+ export { ActionFooter, BeamArrow, BeamBtn, BeamFilter, BeamFilterOption, BeamHeading, BeamMetadata, BeamModal, BeamModalOutlet, BeamProgress, Confirm, FixedTop, ItemCheck, ItemCount, ListAnchor, ListItem, ListView, Navbar, ScanInput, SplitColumn, ToggleArrow, install, useMqttStream, };
@@ -0,0 +1,9 @@
1
+ import { type IClientOptions } from 'mqtt';
2
+ interface IMqttStream extends IClientOptions {
3
+ topics?: string[];
4
+ }
5
+ export declare const useMqttStream: (options?: IMqttStream) => {
6
+ messages: import("vue").Ref<Record<string, string[]>, Record<string, string[]>>;
7
+ };
8
+ export {};
9
+ //# sourceMappingURL=mqtt.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mqtt.d.ts","sourceRoot":"","sources":["../../../src/composables/mqtt.ts"],"names":[],"mappings":"AAAA,OAAa,EAAmB,KAAK,cAAc,EAAE,MAAM,MAAM,CAAA;AAGjE,UAAU,WAAY,SAAQ,cAAc;IAC3C,MAAM,CAAC,EAAE,MAAM,EAAE,CAAA;CACjB;AAED,eAAO,MAAM,aAAa,aAAc,WAAW;;CAiClD,CAAA"}
@@ -1,9 +1,16 @@
1
1
  import { App } from 'vue';
2
2
  import ActionFooter from '@/components/ActionFooter.vue';
3
- import BeamMetadata from './components/BeamMetadata.vue';
3
+ import BeamArrow from '@/components/BeamArrow.vue';
4
+ import BeamBtn from '@/components/BeamBtn.vue';
5
+ import BeamFilter from '@/components/BeamFilter.vue';
6
+ import BeamFilterOption from '@/components/BeamFilterOption.vue';
7
+ import BeamHeading from '@/components/BeamHeading.vue';
8
+ import BeamMetadata from '@/components/BeamMetadata.vue';
4
9
  import BeamModal from '@/components/BeamModal.vue';
5
10
  import BeamModalOutlet from '@/components/BeamModalOutlet.vue';
11
+ import BeamProgress from '@/components/BeamProgress.vue';
6
12
  import Confirm from '@/components/Confirm.vue';
13
+ import FixedTop from '@/components/FixedTop.vue';
7
14
  import ItemCheck from '@/components/ItemCheck.vue';
8
15
  import ItemCount from '@/components/ItemCount.vue';
9
16
  import ListAnchor from '@/components/ListAnchor.vue';
@@ -11,11 +18,9 @@ import ListItem from '@/components/ListItem.vue';
11
18
  import ListView from '@/components/ListView.vue';
12
19
  import Navbar from '@/components/Navbar.vue';
13
20
  import ScanInput from '@/components/ScanInput.vue';
14
- import SplitColumn from './components/SplitColumn.vue';
15
- import BeamHeading from './components/BeamHeading.vue';
16
- import BeamArrow from './components/BeamArrow.vue';
17
- import BeamBtn from './components/BeamBtn.vue';
18
- import BeamProgress from './components/BeamProgress.vue';
21
+ import SplitColumn from '@/components/SplitColumn.vue';
22
+ import ToggleArrow from '@/components/ToggleArrow.vue';
23
+ import { useMqttStream } from '@/composables/mqtt';
19
24
  import 'themes/beam.css';
20
25
  /**
21
26
  * Install all Beam components
@@ -23,5 +28,5 @@ import 'themes/beam.css';
23
28
  * @public
24
29
  */
25
30
  declare function install(app: App): void;
26
- export { ActionFooter, BeamMetadata, BeamModal, BeamModalOutlet, Confirm, ItemCheck, ItemCount, ListAnchor, ListItem, ListView, Navbar, ScanInput, SplitColumn, BeamHeading, BeamArrow, BeamBtn, BeamProgress, install, };
31
+ export { ActionFooter, BeamArrow, BeamBtn, BeamFilter, BeamFilterOption, BeamHeading, BeamMetadata, BeamModal, BeamModalOutlet, BeamProgress, Confirm, FixedTop, ItemCheck, ItemCount, ListAnchor, ListItem, ListView, Navbar, ScanInput, SplitColumn, ToggleArrow, install, useMqttStream, };
27
32
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AAEzB,OAAO,YAAY,MAAM,+BAA+B,CAAA;AACxD,OAAO,YAAY,MAAM,+BAA+B,CAAA;AACxD,OAAO,SAAS,MAAM,4BAA4B,CAAA;AAClD,OAAO,eAAe,MAAM,kCAAkC,CAAA;AAC9D,OAAO,OAAO,MAAM,0BAA0B,CAAA;AAC9C,OAAO,SAAS,MAAM,4BAA4B,CAAA;AAClD,OAAO,SAAS,MAAM,4BAA4B,CAAA;AAClD,OAAO,UAAU,MAAM,6BAA6B,CAAA;AACpD,OAAO,QAAQ,MAAM,2BAA2B,CAAA;AAChD,OAAO,QAAQ,MAAM,2BAA2B,CAAA;AAChD,OAAO,MAAM,MAAM,yBAAyB,CAAA;AAC5C,OAAO,SAAS,MAAM,4BAA4B,CAAA;AAClD,OAAO,WAAW,MAAM,8BAA8B,CAAA;AACtD,OAAO,WAAW,MAAM,8BAA8B,CAAA;AACtD,OAAO,SAAS,MAAM,4BAA4B,CAAA;AAClD,OAAO,OAAO,MAAM,0BAA0B,CAAA;AAC9C,OAAO,YAAY,MAAM,+BAA+B,CAAA;AACxD,OAAO,iBAAiB,CAAA;AAExB;;;;GAIG;AACH,iBAAS,OAAO,CAAC,GAAG,EAAE,GAAG,QAkBxB;AAED,OAAO,EACN,YAAY,EACZ,YAAY,EACZ,SAAS,EACT,eAAe,EACf,OAAO,EACP,SAAS,EACT,SAAS,EACT,UAAU,EACV,QAAQ,EACR,QAAQ,EACR,MAAM,EACN,SAAS,EACT,WAAW,EACX,WAAW,EACX,SAAS,EACT,OAAO,EACP,YAAY,EACZ,OAAO,GACP,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AAEzB,OAAO,YAAY,MAAM,+BAA+B,CAAA;AACxD,OAAO,SAAS,MAAM,4BAA4B,CAAA;AAClD,OAAO,OAAO,MAAM,0BAA0B,CAAA;AAC9C,OAAO,UAAU,MAAM,6BAA6B,CAAA;AACpD,OAAO,gBAAgB,MAAM,mCAAmC,CAAA;AAChE,OAAO,WAAW,MAAM,8BAA8B,CAAA;AACtD,OAAO,YAAY,MAAM,+BAA+B,CAAA;AACxD,OAAO,SAAS,MAAM,4BAA4B,CAAA;AAClD,OAAO,eAAe,MAAM,kCAAkC,CAAA;AAC9D,OAAO,YAAY,MAAM,+BAA+B,CAAA;AACxD,OAAO,OAAO,MAAM,0BAA0B,CAAA;AAC9C,OAAO,QAAQ,MAAM,2BAA2B,CAAA;AAChD,OAAO,SAAS,MAAM,4BAA4B,CAAA;AAClD,OAAO,SAAS,MAAM,4BAA4B,CAAA;AAClD,OAAO,UAAU,MAAM,6BAA6B,CAAA;AACpD,OAAO,QAAQ,MAAM,2BAA2B,CAAA;AAChD,OAAO,QAAQ,MAAM,2BAA2B,CAAA;AAChD,OAAO,MAAM,MAAM,yBAAyB,CAAA;AAC5C,OAAO,SAAS,MAAM,4BAA4B,CAAA;AAClD,OAAO,WAAW,MAAM,8BAA8B,CAAA;AACtD,OAAO,WAAW,MAAM,8BAA8B,CAAA;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAClD,OAAO,iBAAiB,CAAA;AAExB;;;;GAIG;AACH,iBAAS,OAAO,CAAC,GAAG,EAAE,GAAG,QAsBxB;AAED,OAAO,EACN,YAAY,EACZ,SAAS,EACT,OAAO,EACP,UAAU,EACV,gBAAgB,EAChB,WAAW,EACX,YAAY,EACZ,SAAS,EACT,eAAe,EACf,YAAY,EACZ,OAAO,EACP,QAAQ,EACR,SAAS,EACT,SAAS,EACT,UAAU,EACV,QAAQ,EACR,QAAQ,EACR,MAAM,EACN,SAAS,EACT,WAAW,EACX,WAAW,EACX,OAAO,EACP,aAAa,GACb,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stonecrop/beam",
3
- "version": "0.2.50",
3
+ "version": "0.2.52",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "author": {
@@ -29,6 +29,7 @@
29
29
  "src/*"
30
30
  ],
31
31
  "dependencies": {
32
+ "mqtt": "^5.10.1",
32
33
  "onscan.js": "^1.5.2",
33
34
  "vue": "^3.5.6"
34
35
  },
@@ -10,10 +10,9 @@
10
10
  </template>
11
11
 
12
12
  <script setup lang="ts">
13
- defineProps({
14
- color: String,
15
- })
13
+ const { color } = defineProps<{ color?: string }>()
16
14
  </script>
15
+
17
16
  <style scoped>
18
17
  .beam_metadata_arrow {
19
18
  align-self: center;
@@ -22,11 +21,13 @@ defineProps({
22
21
  display: flex;
23
22
  align-items: center;
24
23
  }
24
+
25
25
  .beam_metadata_arrow-body {
26
26
  width: 100%;
27
27
  height: 10px;
28
28
  background: #c4c4c4;
29
29
  }
30
+
30
31
  .beam_metadata_arrow-head {
31
32
  & svg {
32
33
  width: 20px;
@@ -3,4 +3,3 @@
3
3
  <slot>Action</slot>
4
4
  </button>
5
5
  </template>
6
- <script setup lang="ts"></script>
@@ -0,0 +1,74 @@
1
+ <template>
2
+ <div ref="beam-filters" class="beam_filters" :style="{ height: isOpen ? '100%' : headerHeight }">
3
+ <div ref="beam-filters-header" @click="toggle" class="beam_filters-heading">
4
+ <ToggleArrow :open="isOpen" />
5
+ <BeamHeading> Filter </BeamHeading>
6
+ </div>
7
+ <div class="beam_filters-options">
8
+ <slot>
9
+ <p>OPTIONS GO HERE</p>
10
+ </slot>
11
+ </div>
12
+ </div>
13
+ </template>
14
+
15
+ <script setup lang="ts">
16
+ import { ref, onMounted, useTemplateRef } from 'vue'
17
+
18
+ const header = useTemplateRef('beam-filters-header')
19
+ const beamFilters = useTemplateRef('beam-filters')
20
+
21
+ const isOpen = ref(false)
22
+ const headerHeight = ref<string>()
23
+ const totalHeight = ref<string>()
24
+
25
+ const toggle = () => {
26
+ isOpen.value = !isOpen.value
27
+ }
28
+
29
+ onMounted(() => {
30
+ headerHeight.value = getTotalHeight(header.value)
31
+ totalHeight.value = getTotalHeight(beamFilters.value)
32
+ beamFilters.value.style.height = headerHeight.value
33
+ })
34
+
35
+ const getTotalHeight = (el: HTMLDivElement) => {
36
+ const height = el.getBoundingClientRect().height
37
+ const marginTop = parseInt(getComputedStyle(el).marginTop)
38
+ const marginBottom = parseInt(getComputedStyle(el).marginBottom)
39
+ return height + marginTop + marginBottom + 'px'
40
+ }
41
+ </script>
42
+
43
+ <style scoped>
44
+ .beam_filters {
45
+ overflow: hidden;
46
+ box-sizing: border-box;
47
+ transition: all 0.2s ease-in-out;
48
+ border-bottom: 1px solid var(--row-border-color);
49
+ background: white;
50
+ }
51
+
52
+ .beam_filters-heading {
53
+ background: var(--primary-color);
54
+ cursor: pointer;
55
+ display: flex;
56
+ align-items: center;
57
+ padding-left: 1rem;
58
+ box-sizing: border-box;
59
+ font-size: 1rem;
60
+ padding: 0 2rem;
61
+
62
+ & > h1 {
63
+ font-size: 1rem;
64
+ }
65
+ }
66
+
67
+ .beam_filters-options {
68
+ background: white;
69
+ margin: 1rem;
70
+ box-sizing: border-box;
71
+ padding: 0 2rem;
72
+ margin-bottom: 2rem;
73
+ }
74
+ </style>
@@ -0,0 +1,139 @@
1
+ <template>
2
+ <BeamHeading class="beam_filter-option-heading">{{ title }}</BeamHeading>
3
+ <div @click="toggle" class="beam_filter-option">
4
+ <div ref="select" class="beam_filter-option-select">
5
+ <div class="beam_filter-arrow">
6
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 35.36 70.71">
7
+ <polygon points="0 70.71 0 0 35.36 35.36 0 70.71" />
8
+ </svg>
9
+ </div>
10
+ <div class="beam_filter-label">
11
+ <label>{{ choice }}</label>
12
+ </div>
13
+ </div>
14
+ <ul ref="menu" v-if="open" class="beam_filter-select-menu">
15
+ <li
16
+ v-for="(opt, index) in choices"
17
+ :class="{ selected: choice == opt.choice }"
18
+ :data-value="opt.value"
19
+ :key="index"
20
+ class="beam_filter-select-option"
21
+ @click="updateValue(opt)">
22
+ {{ opt.choice }}
23
+ </li>
24
+ </ul>
25
+ </div>
26
+ </template>
27
+
28
+ <script setup lang="ts">
29
+ import { ref } from 'vue'
30
+
31
+ type Choice = {
32
+ choice: string
33
+ value: string
34
+ }
35
+
36
+ const { title = 'title', choices = [] } = defineProps<{
37
+ choices: Choice[]
38
+ title?: string
39
+ }>()
40
+
41
+ const open = ref(false)
42
+ const value = ref(choices[0].value)
43
+ const choice = ref(choices[0].choice)
44
+
45
+ const updateValue = (data: Choice) => {
46
+ choice.value = data.choice
47
+ value.value = data.value
48
+ }
49
+
50
+ const toggle = () => {
51
+ open.value = !open.value
52
+ }
53
+ </script>
54
+
55
+ <style scoped>
56
+ .beam_filter-option {
57
+ cursor: pointer;
58
+ position: relative;
59
+ margin-bottom: 1rem;
60
+ }
61
+
62
+ .beam_filter-option-heading {
63
+ font-size: 1rem;
64
+ padding-bottom: 0.25rem;
65
+ }
66
+
67
+ .beam_filter-option-select {
68
+ position: relative;
69
+ appearance: none;
70
+ border: 1px solid var(--row-border-color);
71
+ font-weight: bold;
72
+ color: var(--primary-text-color);
73
+ font-size: 0.8rem;
74
+ font-family: var(--font-family);
75
+ display: flex;
76
+ align-items: stretch;
77
+ }
78
+
79
+ label {
80
+ cursor: pointer;
81
+ padding: 0.5rem;
82
+ }
83
+
84
+ .beam_filter-arrow {
85
+ background: var(--primary-color);
86
+ color: var(--primary-text-color);
87
+ cursor: pointer;
88
+ display: flex;
89
+ align-items: center;
90
+ width: 5px;
91
+ padding: 0.5rem 0.7rem;
92
+ }
93
+
94
+ .beam_filter-label {
95
+ display: flex;
96
+ align-items: center;
97
+ }
98
+
99
+ svg {
100
+ fill: var(--primary-text-color);
101
+ width: 5px;
102
+ transform: rotate(90deg);
103
+ }
104
+
105
+ .beam_filter-select-menu {
106
+ /* position: absolute; */
107
+ z-index: 100;
108
+ border-top: none;
109
+ left: 0;
110
+ border: 1px solid var(--row-border-color);
111
+ padding: 0rem;
112
+ list-style: none;
113
+ width: 100%;
114
+ box-sizing: border-box;
115
+ max-height: 200px;
116
+ overflow-y: scroll;
117
+ margin: 0;
118
+ }
119
+
120
+ .beam_filter-select-option {
121
+ font-size: 0.8rem;
122
+ font-family: var(--font-family);
123
+ font-weight: bold;
124
+ color: var(--primary-text-color);
125
+ border-bottom: 1px solid var(--row-border-color);
126
+ padding: 0.5rem;
127
+ &:hover {
128
+ background: var(--primary-color);
129
+ }
130
+ }
131
+
132
+ .selected {
133
+ background: var(--row-border-color);
134
+
135
+ &:hover {
136
+ background: var(--row-border-color);
137
+ }
138
+ }
139
+ </style>
@@ -7,23 +7,17 @@
7
7
  <script setup lang="ts">
8
8
  import { computed } from 'vue'
9
9
 
10
- const props = defineProps({
11
- label: {
12
- type: String,
13
- default: 'Status',
14
- },
15
- progressMessage: {
16
- type: String,
17
- default: 'In Progress',
18
- },
19
- completeMessage: {
20
- type: String,
21
- default: 'Complete',
22
- },
23
- complete: Boolean,
24
- })
10
+ const {
11
+ label = 'Status',
12
+ progressMessage = 'In Progress',
13
+ completeMessage = 'Complete',
14
+ complete = false,
15
+ } = defineProps<{
16
+ label?: string
17
+ progressMessage?: string
18
+ completeMessage?: string
19
+ complete?: boolean
20
+ }>()
25
21
 
26
- const statusMessage = computed(() => {
27
- return props.complete ? props.completeMessage : props.progressMessage
28
- })
22
+ const statusMessage = computed(() => (complete ? completeMessage : progressMessage))
29
23
  </script>
@@ -0,0 +1,13 @@
1
+ <template>
2
+ <div class="fixed-top">
3
+ <slot></slot>
4
+ </div>
5
+ </template>
6
+
7
+ <style scoped>
8
+ .fixed-top {
9
+ position: sticky;
10
+ top: 0;
11
+ left: 0;
12
+ }
13
+ </style>
@@ -10,12 +10,14 @@
10
10
  </div>
11
11
  </div>
12
12
  </template>
13
+
13
14
  <script setup lang="ts">
14
- const props = defineProps<{
15
- justifyContent?: String
16
- alignItems?: String
15
+ const { justifyContent, alignItems } = defineProps<{
16
+ justifyContent?: string
17
+ alignItems?: string
17
18
  }>()
18
19
  </script>
20
+
19
21
  <style scoped>
20
22
  .two-column {
21
23
  display: flex;
@@ -29,6 +31,7 @@ const props = defineProps<{
29
31
  gap: 0;
30
32
  }
31
33
  }
34
+
32
35
  .column {
33
36
  flex-grow: 1;
34
37
  width: 50%;
@@ -36,6 +39,7 @@ const props = defineProps<{
36
39
  width: 100%;
37
40
  }
38
41
  }
42
+
39
43
  .column-right {
40
44
  text-align: right;
41
45
  @media screen and (max-width: 400px) {
@@ -0,0 +1,35 @@
1
+ <template>
2
+ <div class="arrow-icon" :class="{ open }">
3
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 35.36 70.71">
4
+ <polygon points="0 70.71 0 0 35.36 35.36 0 70.71" />
5
+ </svg>
6
+ </div>
7
+ </template>
8
+
9
+ <script setup lang="ts">
10
+ const { open } = defineProps<{ open: boolean }>()
11
+ </script>
12
+
13
+ <style scoped>
14
+ svg {
15
+ width: 100%;
16
+ overflow: visible;
17
+ fill: var(--primary-text-color);
18
+ }
19
+
20
+ .arrow-icon {
21
+ width: 0.4rem;
22
+ transform: rotate(0);
23
+ transform-origin: center;
24
+ position: relative;
25
+ transition: all 0.1s ease-in-out;
26
+ margin: 0.5rem;
27
+ cursor: pointer;
28
+ display: flex;
29
+ align-items: center;
30
+ }
31
+
32
+ .open {
33
+ transform: rotate(90deg);
34
+ }
35
+ </style>
@@ -0,0 +1,41 @@
1
+ import mqtt, { type MqttClient, type IClientOptions } from 'mqtt'
2
+ import { onMounted, onUnmounted, ref } from 'vue'
3
+
4
+ interface IMqttStream extends IClientOptions {
5
+ topics?: string[]
6
+ }
7
+
8
+ export const useMqttStream = (options?: IMqttStream) => {
9
+ const client = ref<MqttClient>(null)
10
+ const messages = ref<Record<string, string[]>>({})
11
+
12
+ onMounted(() => {
13
+ client.value = mqtt.connect(options)
14
+
15
+ if (!options.topics) {
16
+ options.topics = ['#']
17
+ }
18
+
19
+ for (const topic of options.topics) {
20
+ client.value.subscribe(topic, err => {
21
+ if (err) {
22
+ throw err
23
+ }
24
+ })
25
+ }
26
+
27
+ client.value.on('message', (topic, message) => {
28
+ if (!messages.value[topic]) {
29
+ messages.value[topic] = []
30
+ }
31
+
32
+ messages.value[topic].push(message.toString())
33
+ })
34
+ })
35
+
36
+ onUnmounted(() => {
37
+ client.value.end()
38
+ })
39
+
40
+ return { messages }
41
+ }
package/src/index.ts CHANGED
@@ -1,10 +1,17 @@
1
1
  import { App } from 'vue'
2
2
 
3
3
  import ActionFooter from '@/components/ActionFooter.vue'
4
- import BeamMetadata from './components/BeamMetadata.vue'
4
+ import BeamArrow from '@/components/BeamArrow.vue'
5
+ import BeamBtn from '@/components/BeamBtn.vue'
6
+ import BeamFilter from '@/components/BeamFilter.vue'
7
+ import BeamFilterOption from '@/components/BeamFilterOption.vue'
8
+ import BeamHeading from '@/components/BeamHeading.vue'
9
+ import BeamMetadata from '@/components/BeamMetadata.vue'
5
10
  import BeamModal from '@/components/BeamModal.vue'
6
11
  import BeamModalOutlet from '@/components/BeamModalOutlet.vue'
12
+ import BeamProgress from '@/components/BeamProgress.vue'
7
13
  import Confirm from '@/components/Confirm.vue'
14
+ import FixedTop from '@/components/FixedTop.vue'
8
15
  import ItemCheck from '@/components/ItemCheck.vue'
9
16
  import ItemCount from '@/components/ItemCount.vue'
10
17
  import ListAnchor from '@/components/ListAnchor.vue'
@@ -12,11 +19,9 @@ import ListItem from '@/components/ListItem.vue'
12
19
  import ListView from '@/components/ListView.vue'
13
20
  import Navbar from '@/components/Navbar.vue'
14
21
  import ScanInput from '@/components/ScanInput.vue'
15
- import SplitColumn from './components/SplitColumn.vue'
16
- import BeamHeading from './components/BeamHeading.vue'
17
- import BeamArrow from './components/BeamArrow.vue'
18
- import BeamBtn from './components/BeamBtn.vue'
19
- import BeamProgress from './components/BeamProgress.vue'
22
+ import SplitColumn from '@/components/SplitColumn.vue'
23
+ import ToggleArrow from '@/components/ToggleArrow.vue'
24
+ import { useMqttStream } from '@/composables/mqtt'
20
25
  import 'themes/beam.css'
21
26
 
22
27
  /**
@@ -26,10 +31,17 @@ import 'themes/beam.css'
26
31
  */
27
32
  function install(app: App /* options */) {
28
33
  app.component('ActionFooter', ActionFooter)
34
+ app.component('BeamArrow', BeamArrow)
35
+ app.component('BeamBtn', BeamBtn)
36
+ app.component('BeamFilter', BeamFilter)
37
+ app.component('BeamFilterOption', BeamFilterOption)
38
+ app.component('BeamHeading', BeamHeading)
29
39
  app.component('BeamMetadata', BeamMetadata)
30
40
  app.component('BeamModal', BeamModal)
31
41
  app.component('BeamModalOutlet', BeamModalOutlet)
42
+ app.component('BeamProgress', BeamProgress)
32
43
  app.component('Confirm', Confirm)
44
+ app.component('FixedTop', FixedTop)
33
45
  app.component('ItemCheck', ItemCheck)
34
46
  app.component('ItemCount', ItemCount)
35
47
  app.component('ListAnchor', ListAnchor)
@@ -38,18 +50,22 @@ function install(app: App /* options */) {
38
50
  app.component('Navbar', Navbar)
39
51
  app.component('ScanInput', ScanInput)
40
52
  app.component('SplitColumn', SplitColumn)
41
- app.component('BeamHeading', BeamHeading)
42
- app.component('BeamArrow', BeamArrow)
43
- app.component('BeamBtn', BeamBtn)
44
- app.component('BeamProgress', BeamProgress)
53
+ app.component('ToggleArrow', ToggleArrow)
45
54
  }
46
55
 
47
56
  export {
48
57
  ActionFooter,
58
+ BeamArrow,
59
+ BeamBtn,
60
+ BeamFilter,
61
+ BeamFilterOption,
62
+ BeamHeading,
49
63
  BeamMetadata,
50
64
  BeamModal,
51
65
  BeamModalOutlet,
66
+ BeamProgress,
52
67
  Confirm,
68
+ FixedTop,
53
69
  ItemCheck,
54
70
  ItemCount,
55
71
  ListAnchor,
@@ -58,9 +74,7 @@ export {
58
74
  Navbar,
59
75
  ScanInput,
60
76
  SplitColumn,
61
- BeamHeading,
62
- BeamArrow,
63
- BeamBtn,
64
- BeamProgress,
77
+ ToggleArrow,
65
78
  install,
79
+ useMqttStream,
66
80
  }