diff --git a/beam/src/components/BeamDayDivider.vue b/beam/src/components/BeamDayDivider.vue index e1414528..b9efe471 100644 --- a/beam/src/components/BeamDayDivider.vue +++ b/beam/src/components/BeamDayDivider.vue @@ -7,7 +7,7 @@ diff --git a/beam/src/components/ListView.vue b/beam/src/components/ListView.vue index cbf150a6..44d87c67 100644 --- a/beam/src/components/ListView.vue +++ b/beam/src/components/ListView.vue @@ -1,6 +1,6 @@ + diff --git a/beam/src/composables/mqtt.ts b/beam/src/composables/mqtt.ts index 03026b29..a560dfdd 100644 --- a/beam/src/composables/mqtt.ts +++ b/beam/src/composables/mqtt.ts @@ -9,7 +9,14 @@ import { IMqttStream } from '../types' * @returns MQTT stream messages * @beta */ -export const useMqttStream = (options: IMqttStream) => { +export const useMqttStream = async (options: IMqttStream) => { + if (options.host && options.port) { + const portActive = await isPortActive(options.host, options.port) + if (!portActive) { + return + } + } + const client = ref() const messages = ref>({}) @@ -43,3 +50,52 @@ export const useMqttStream = (options: IMqttStream) => { return { messages } } + +/** + * Check if a local port has a service running + * @param host the host to check + * @param port the port to check + * @returns true if the port has a service running, false otherwise + * + * @beta + */ +export const isPortActive = async (host: string, port: number) => { + try { + const controller = new AbortController() + // Set a timeout of 2 seconds + const timeoutId = setTimeout(() => controller.abort(), 2000) + + try { + await fetch(`${host}:${port}`, { + mode: 'no-cors', // This allows checking without CORS issues + signal: controller.signal, + }) + + clearTimeout(timeoutId) + // If we get any response, the port is in use + return true + } catch (error) { + clearTimeout(timeoutId) + if (error instanceof DOMException && error.name === 'AbortError') { + // Timeout - port is probably not in use + return false + } + + // For connection refused errors, we need to check the error message + // as different browsers handle this differently + const errorString = String(error) + if ( + errorString.includes('NetworkError') || + errorString.includes('Failed to fetch') || + errorString.includes('net::ERR_CONNECTION_REFUSED') + ) { + return false + } + + // If we get here, there might be something running on the port + return true + } + } catch (error) { + return false + } +} diff --git a/beam/src/index.ts b/beam/src/index.ts index b46ceaab..b74f9a0e 100644 --- a/beam/src/index.ts +++ b/beam/src/index.ts @@ -24,7 +24,7 @@ import SegmentedDisplay from './components/SegmentedDisplay.vue' import SplitColumn from './components/SplitColumn.vue' import ToggleArrow from './components/ToggleArrow.vue' import { useMqttStream } from './composables/mqtt' -export type { IMqttStream, ListViewItem } from './types' +export type * from './types' import '../themes/beam.css' /** diff --git a/beam/src/types/index.ts b/beam/src/types/index.ts index c7cd97b0..bc28169f 100644 --- a/beam/src/types/index.ts +++ b/beam/src/types/index.ts @@ -1,32 +1,70 @@ import type { IClientOptions } from 'mqtt' /** - * @beta + * @public */ export type ListViewItem = { - description: string - label: string - + barcode?: string checked?: boolean count?: { count: number of: number - uom: string + uom?: string } date?: string dateFormat?: string debounce?: number + description?: string + label?: string linkComponent?: string route?: string } -type RGB = `rgb(${number}, ${number}, ${number})` -type HSL = `hsl(${number}, ${number}%, ${number}%)` -type HSLA = `hsl(${number}, ${number}%, ${number}%), ${number}` -type RGBA = `rgba(${number}, ${number}, ${number}, ${number})` -type HEX = `#${string}` +// TODO: the `string` at the end should be replaced by `DataType.Color` +// in the `csstype` lib but import seems to be missing +/** + * @public + */ +export type BeamColor = RGB | RGBA | HEX | HSL | HSLA | string + +/** + * @public + */ +export type BeamFilterChoice = { + label: string + value: string +} + +/** + * RGB color string representation + * @public + */ +export type RGB = `rgb(${number}, ${number}, ${number})` + +/** + * RGBA color string representation + * @public + */ +export type RGBA = `rgba(${number}, ${number}, ${number}, ${number})` + +/** + * HSL color string representation + * @public + */ +export type HSL = `hsl(${number}, ${number}%, ${number}%)` + +/** + * HSLA color string representation + * @public + */ +export type HSLA = `hsl(${number}, ${number}%, ${number}%), ${number}` + +/** + * HEX color string representation + * @public + */ +export type HEX = `#${string}` -export type Color = RGB | RGBA | HEX | HSL | HSLA | string /** * MQTT stream options * @public diff --git a/common/reviews/api/beam.api.md b/common/reviews/api/beam.api.md index fab283ee..77498fa2 100644 --- a/common/reviews/api/beam.api.md +++ b/common/reviews/api/beam.api.md @@ -37,10 +37,19 @@ export { BeamArrow } export { BeamBtn } +// @public (undocumented) +export type BeamColor = RGB | RGBA | HEX | HSL | HSLA | string; + export { BeamDayDivider } export { BeamFilter } +// @public (undocumented) +export type BeamFilterChoice = { + label: string; + value: string; +}; + export { BeamFilterOption } export { BeamHeading } @@ -57,6 +66,15 @@ export { Confirm } export { FixedTop } +// @public +export type HEX = `#${string}`; + +// @public +export type HSL = `hsl(${number}, ${number}%, ${number}%)`; + +// @public +export type HSLA = `hsl(${number}, ${number}%, ${number}%), ${number}`; + // @public export interface IMqttStream extends IClientOptions { // (undocumented) @@ -76,25 +94,32 @@ export { ListItem } export { ListView } -// @beta (undocumented) +// @public (undocumented) export type ListViewItem = { - description: string; - label: string; + barcode?: string; checked?: boolean; count?: { count: number; of: number; - uom: string; + uom?: string; }; date?: string; dateFormat?: string; debounce?: number; + description?: string; + label?: string; linkComponent?: string; route?: string; }; export { Navbar } +// @public +export type RGB = `rgb(${number}, ${number}, ${number})`; + +// @public +export type RGBA = `rgba(${number}, ${number}, ${number}, ${number})`; + export { ScanInput } export { SegmentedDisplay } @@ -104,9 +129,9 @@ export { SplitColumn } export { ToggleArrow } // @beta -export const useMqttStream: (options: IMqttStream) => { +export const useMqttStream: (options: IMqttStream) => Promise<{ messages: Ref, Record>; -}; +} | undefined>; // (No @packageDocumentation comment for this package) diff --git a/docs/beam/beam.beamcolor.md b/docs/beam/beam.beamcolor.md new file mode 100644 index 00000000..e8b1e548 --- /dev/null +++ b/docs/beam/beam.beamcolor.md @@ -0,0 +1,14 @@ + + +[Home](./index.md) > [@stonecrop/beam](./beam.md) > [BeamColor](./beam.beamcolor.md) + +## BeamColor type + + +**Signature:** + +```typescript +export type BeamColor = RGB | RGBA | HEX | HSL | HSLA | string; +``` +**References:** [RGB](./beam.rgb.md), [RGBA](./beam.rgba.md), [HEX](./beam.hex.md), [HSL](./beam.hsl.md), [HSLA](./beam.hsla.md) + diff --git a/docs/beam/beam.beamfilterchoice.md b/docs/beam/beam.beamfilterchoice.md new file mode 100644 index 00000000..539ad12d --- /dev/null +++ b/docs/beam/beam.beamfilterchoice.md @@ -0,0 +1,15 @@ + + +[Home](./index.md) > [@stonecrop/beam](./beam.md) > [BeamFilterChoice](./beam.beamfilterchoice.md) + +## BeamFilterChoice type + + +**Signature:** + +```typescript +export type BeamFilterChoice = { + label: string; + value: string; +}; +``` diff --git a/docs/beam/beam.hex.md b/docs/beam/beam.hex.md new file mode 100644 index 00000000..43a3a2b9 --- /dev/null +++ b/docs/beam/beam.hex.md @@ -0,0 +1,13 @@ + + +[Home](./index.md) > [@stonecrop/beam](./beam.md) > [HEX](./beam.hex.md) + +## HEX type + +HEX color string representation + +**Signature:** + +```typescript +export type HEX = `#${string}`; +``` diff --git a/docs/beam/beam.hsl.md b/docs/beam/beam.hsl.md new file mode 100644 index 00000000..aeae50cc --- /dev/null +++ b/docs/beam/beam.hsl.md @@ -0,0 +1,13 @@ + + +[Home](./index.md) > [@stonecrop/beam](./beam.md) > [HSL](./beam.hsl.md) + +## HSL type + +HSL color string representation + +**Signature:** + +```typescript +export type HSL = `hsl(${number}, ${number}%, ${number}%)`; +``` diff --git a/docs/beam/beam.hsla.md b/docs/beam/beam.hsla.md new file mode 100644 index 00000000..11026bcc --- /dev/null +++ b/docs/beam/beam.hsla.md @@ -0,0 +1,13 @@ + + +[Home](./index.md) > [@stonecrop/beam](./beam.md) > [HSLA](./beam.hsla.md) + +## HSLA type + +HSLA color string representation + +**Signature:** + +```typescript +export type HSLA = `hsl(${number}, ${number}%, ${number}%), ${number}`; +``` diff --git a/docs/beam/beam.listviewitem.md b/docs/beam/beam.listviewitem.md index 964252b9..a4b9f026 100644 --- a/docs/beam/beam.listviewitem.md +++ b/docs/beam/beam.listviewitem.md @@ -4,25 +4,23 @@ ## ListViewItem type -> This API is provided as a beta preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. -> - **Signature:** ```typescript export type ListViewItem = { - description: string; - label: string; + barcode?: string; checked?: boolean; count?: { count: number; of: number; - uom: string; + uom?: string; }; date?: string; dateFormat?: string; debounce?: number; + description?: string; + label?: string; linkComponent?: string; route?: string; }; diff --git a/docs/beam/beam.md b/docs/beam/beam.md index 3a7eaa62..dd394bfb 100644 --- a/docs/beam/beam.md +++ b/docs/beam/beam.md @@ -82,12 +82,86 @@ Description +[BeamColor](./beam.beamcolor.md) + + + + + + + + + +[BeamFilterChoice](./beam.beamfilterchoice.md) + + + + + + + + + +[HEX](./beam.hex.md) + + + + +HEX color string representation + + + + + +[HSL](./beam.hsl.md) + + + + +HSL color string representation + + + + + +[HSLA](./beam.hsla.md) + + + + +HSLA color string representation + + + + + [ListViewItem](./beam.listviewitem.md) -**_(BETA)_** + + + + + +[RGB](./beam.rgb.md) + + + + +RGB color string representation + + + + + +[RGBA](./beam.rgba.md) + + + + +RGBA color string representation diff --git a/docs/beam/beam.rgb.md b/docs/beam/beam.rgb.md new file mode 100644 index 00000000..560287e9 --- /dev/null +++ b/docs/beam/beam.rgb.md @@ -0,0 +1,13 @@ + + +[Home](./index.md) > [@stonecrop/beam](./beam.md) > [RGB](./beam.rgb.md) + +## RGB type + +RGB color string representation + +**Signature:** + +```typescript +export type RGB = `rgb(${number}, ${number}, ${number})`; +``` diff --git a/docs/beam/beam.rgba.md b/docs/beam/beam.rgba.md new file mode 100644 index 00000000..549da792 --- /dev/null +++ b/docs/beam/beam.rgba.md @@ -0,0 +1,13 @@ + + +[Home](./index.md) > [@stonecrop/beam](./beam.md) > [RGBA](./beam.rgba.md) + +## RGBA type + +RGBA color string representation + +**Signature:** + +```typescript +export type RGBA = `rgba(${number}, ${number}, ${number}, ${number})`; +``` diff --git a/docs/beam/beam.usemqttstream.md b/docs/beam/beam.usemqttstream.md index b3ca6987..724509e7 100644 --- a/docs/beam/beam.usemqttstream.md +++ b/docs/beam/beam.usemqttstream.md @@ -12,9 +12,9 @@ Use MQTT stream **Signature:** ```typescript -useMqttStream: (options: IMqttStream) => { +useMqttStream: (options: IMqttStream) => Promise<{ messages: import("vue").Ref, Record>; -} +} | undefined> ``` ## Parameters @@ -54,7 +54,7 @@ MQTT stream options **Returns:** -{ messages: import("vue").Ref<Record<string, string\[\]>, Record<string, string\[\]>>; } +Promise<{ messages: import("vue").Ref<Record<string, string\[\]>, Record<string, string\[\]>>; } \| undefined> MQTT stream messages diff --git a/examples/beam/components.story.vue b/examples/beam/components.story.vue index dae2f478..2fe8419b 100644 --- a/examples/beam/components.story.vue +++ b/examples/beam/components.story.vue @@ -90,6 +90,7 @@ import { reactive } from 'vue' const workOrder = reactive({ complete: false, }) + const displayOptions = reactive({ displayColor: '--sc-segmented-display-background', textColor: '--sc-segmented-display-color', diff --git a/examples/beam/data/items.json b/examples/beam/data/items.json index c9cc9e9d..86621b04 100644 --- a/examples/beam/data/items.json +++ b/examples/beam/data/items.json @@ -30,84 +30,84 @@ "barcode": "5564269659609843627" }, { - "barcode": "6281478257437327897", - "label": "Item 1", + "barcode": "6281478257437327898", + "label": "Item 5", "description": "iPhone this and that", "count": { "count": 0, "of": 2 }, "linkComponent": "ListAnchor", "route": "/item1" }, { - "barcode": "6281478257437327897", - "label": "Item 1 Long Title: Including Subtitle to demonstrate ellipsis", + "barcode": "6281478257437327899", + "label": "Item 6 Long Title: Including Subtitle to demonstrate ellipsis", "description": "iPhone this and that", "count": { "count": 0, "of": 3 }, "linkComponent": "ListAnchor", "route": "/item1" }, { - "label": "Item 2", + "label": "Item 7", "description": "More descriptions of stuff", "count": { "count": 3, "of": 3 }, "linkComponent": "ListAnchor", "route": "/item2" }, { - "label": "Item 3", + "label": "Item 8", "description": "", "count": { "count": 1, "of": 6 }, "linkComponent": "ListAnchor", "route": "/item3" }, { - "label": "Item 4", + "label": "Item 9", "description": "iPhone this and that plus even more text to demonstrate ellipsis and great savings! on things you can't see or touch", "count": { "count": 0, "of": 3 }, "linkComponent": "div", "route": "/item4", - "barcode": "5564269659609843627" + "barcode": "5564269659609843628" }, { - "barcode": "6281478257437327897", - "label": "Item 1", + "barcode": "6281478257437327900", + "label": "Item 10", "description": "iPhone this and that", "count": { "count": 0, "of": 2 }, "linkComponent": "ListAnchor", "route": "/item1" }, { - "barcode": "6281478257437327897", - "label": "Item 1 Long Title: Including Subtitle to demonstrate ellipsis", + "barcode": "6281478257437327901", + "label": "Item 11 Long Title: Including Subtitle to demonstrate ellipsis", "description": "iPhone this and that", "count": { "count": 0, "of": 3 }, "linkComponent": "ListAnchor", "route": "/item1" }, { - "label": "Item 2", + "label": "Item 12", "description": "More descriptions of stuff", "count": { "count": 3, "of": 3 }, "linkComponent": "ListAnchor", "route": "/item2" }, { - "label": "Item 3", + "label": "Item 13", "description": "", "count": { "count": 1, "of": 6 }, "linkComponent": "ListAnchor", "route": "/item3" }, { - "label": "Item 4", + "label": "Item 14", "description": "iPhone this and that plus even more text to demonstrate ellipsis and great savings! on things you can't see or touch", "count": { "count": 0, "of": 3 }, "linkComponent": "div", "route": "/item4", - "barcode": "5564269659609843627" + "barcode": "5564269659609843629" }, { - "barcode": "6281478257437327897", - "label": "Item 1", + "barcode": "6281478257437327902", + "label": "Item 15", "description": "iPhone this and that", "count": { "count": 0, "of": 2 }, "linkComponent": "ListAnchor", diff --git a/examples/beam/default.story.vue b/examples/beam/default.story.vue index 39ce3822..9a029a8b 100644 --- a/examples/beam/default.story.vue +++ b/examples/beam/default.story.vue @@ -118,17 +118,18 @@ + { label: 'All', value: 'all' }, + { label: 'Complete', value: 'complete' }, + { label: 'Incomplete', value: 'incomplete' }, + ]" + @select="filterItems" /> @@ -142,7 +143,7 @@