@seamapi/react 4.14.0 → 5.0.0

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.
Files changed (86) hide show
  1. package/README.md +2 -3
  2. package/dist/elements.js +9525 -10202
  3. package/dist/elements.js.map +1 -1
  4. package/dist/index.css +0 -345
  5. package/dist/index.css.map +1 -1
  6. package/dist/index.min.css +1 -1
  7. package/dist/index.min.css.map +1 -1
  8. package/lib/seam/components/index.d.ts +0 -2
  9. package/lib/seam/components/index.js +0 -2
  10. package/lib/seam/components/index.js.map +1 -1
  11. package/lib/version.d.ts +1 -1
  12. package/lib/version.js +1 -1
  13. package/lib/version.js.map +1 -1
  14. package/package.json +1 -1
  15. package/src/lib/seam/components/elements.ts +0 -2
  16. package/src/lib/seam/components/index.ts +0 -2
  17. package/src/lib/version.ts +1 -1
  18. package/src/styles/_main.scss +0 -4
  19. package/lib/seam/components/SupportedDeviceTable/FilterCategoryMenu.d.ts +0 -20
  20. package/lib/seam/components/SupportedDeviceTable/FilterCategoryMenu.js +0 -22
  21. package/lib/seam/components/SupportedDeviceTable/FilterCategoryMenu.js.map +0 -1
  22. package/lib/seam/components/SupportedDeviceTable/HiddenDevicesOverlay.d.ts +0 -6
  23. package/lib/seam/components/SupportedDeviceTable/HiddenDevicesOverlay.js +0 -8
  24. package/lib/seam/components/SupportedDeviceTable/HiddenDevicesOverlay.js.map +0 -1
  25. package/lib/seam/components/SupportedDeviceTable/ShowAllDevicesButton.d.ts +0 -9
  26. package/lib/seam/components/SupportedDeviceTable/ShowAllDevicesButton.js +0 -14
  27. package/lib/seam/components/SupportedDeviceTable/ShowAllDevicesButton.js.map +0 -1
  28. package/lib/seam/components/SupportedDeviceTable/SupportedDeviceContent.d.ts +0 -13
  29. package/lib/seam/components/SupportedDeviceTable/SupportedDeviceContent.js +0 -58
  30. package/lib/seam/components/SupportedDeviceTable/SupportedDeviceContent.js.map +0 -1
  31. package/lib/seam/components/SupportedDeviceTable/SupportedDeviceContentRows.d.ts +0 -7
  32. package/lib/seam/components/SupportedDeviceTable/SupportedDeviceContentRows.js +0 -6
  33. package/lib/seam/components/SupportedDeviceTable/SupportedDeviceContentRows.js.map +0 -1
  34. package/lib/seam/components/SupportedDeviceTable/SupportedDeviceFilterArea.d.ts +0 -12
  35. package/lib/seam/components/SupportedDeviceTable/SupportedDeviceFilterArea.js +0 -58
  36. package/lib/seam/components/SupportedDeviceTable/SupportedDeviceFilterArea.js.map +0 -1
  37. package/lib/seam/components/SupportedDeviceTable/SupportedDeviceManufacturerSection.d.ts +0 -8
  38. package/lib/seam/components/SupportedDeviceTable/SupportedDeviceManufacturerSection.js +0 -39
  39. package/lib/seam/components/SupportedDeviceTable/SupportedDeviceManufacturerSection.js.map +0 -1
  40. package/lib/seam/components/SupportedDeviceTable/SupportedDeviceRow.d.ts +0 -10
  41. package/lib/seam/components/SupportedDeviceTable/SupportedDeviceRow.js +0 -35
  42. package/lib/seam/components/SupportedDeviceTable/SupportedDeviceRow.js.map +0 -1
  43. package/lib/seam/components/SupportedDeviceTable/SupportedDeviceTable.d.ts +0 -11
  44. package/lib/seam/components/SupportedDeviceTable/SupportedDeviceTable.js +0 -20
  45. package/lib/seam/components/SupportedDeviceTable/SupportedDeviceTable.js.map +0 -1
  46. package/lib/seam/components/SupportedDeviceTable/SupportedDeviceTableManufacturerKeys.d.ts +0 -6
  47. package/lib/seam/components/SupportedDeviceTable/SupportedDeviceTableManufacturerKeys.js +0 -21
  48. package/lib/seam/components/SupportedDeviceTable/SupportedDeviceTableManufacturerKeys.js.map +0 -1
  49. package/lib/seam/components/SupportedDeviceTable/use-device-model.d.ts +0 -7
  50. package/lib/seam/components/SupportedDeviceTable/use-device-model.js +0 -21
  51. package/lib/seam/components/SupportedDeviceTable/use-device-model.js.map +0 -1
  52. package/lib/seam/components/SupportedDeviceTable/use-device-models.d.ts +0 -7
  53. package/lib/seam/components/SupportedDeviceTable/use-device-models.js +0 -30
  54. package/lib/seam/components/SupportedDeviceTable/use-device-models.js.map +0 -1
  55. package/lib/seam/components/SupportedDeviceTable/use-filtered-device-models.d.ts +0 -15
  56. package/lib/seam/components/SupportedDeviceTable/use-filtered-device-models.js +0 -45
  57. package/lib/seam/components/SupportedDeviceTable/use-filtered-device-models.js.map +0 -1
  58. package/lib/seam/components/SupportedDeviceTable/use-filtered-manufacturers.d.ts +0 -10
  59. package/lib/seam/components/SupportedDeviceTable/use-filtered-manufacturers.js +0 -42
  60. package/lib/seam/components/SupportedDeviceTable/use-filtered-manufacturers.js.map +0 -1
  61. package/lib/seam/components/SupportedDeviceTable/use-manufacturer.d.ts +0 -7
  62. package/lib/seam/components/SupportedDeviceTable/use-manufacturer.js +0 -17
  63. package/lib/seam/components/SupportedDeviceTable/use-manufacturer.js.map +0 -1
  64. package/lib/seam/components/SupportedDeviceTable/use-manufacturers.d.ts +0 -7
  65. package/lib/seam/components/SupportedDeviceTable/use-manufacturers.js +0 -26
  66. package/lib/seam/components/SupportedDeviceTable/use-manufacturers.js.map +0 -1
  67. package/src/lib/seam/components/SupportedDeviceTable/FilterCategoryMenu.tsx +0 -78
  68. package/src/lib/seam/components/SupportedDeviceTable/HiddenDevicesOverlay.tsx +0 -13
  69. package/src/lib/seam/components/SupportedDeviceTable/ShowAllDevicesButton.tsx +0 -32
  70. package/src/lib/seam/components/SupportedDeviceTable/SupportedDeviceContent.tsx +0 -161
  71. package/src/lib/seam/components/SupportedDeviceTable/SupportedDeviceContentRows.tsx +0 -22
  72. package/src/lib/seam/components/SupportedDeviceTable/SupportedDeviceFilterArea.tsx +0 -145
  73. package/src/lib/seam/components/SupportedDeviceTable/SupportedDeviceManufacturerSection.tsx +0 -109
  74. package/src/lib/seam/components/SupportedDeviceTable/SupportedDeviceRow.tsx +0 -93
  75. package/src/lib/seam/components/SupportedDeviceTable/SupportedDeviceTable.element.ts +0 -15
  76. package/src/lib/seam/components/SupportedDeviceTable/SupportedDeviceTable.tsx +0 -70
  77. package/src/lib/seam/components/SupportedDeviceTable/SupportedDeviceTableManufacturerKeys.element.ts +0 -9
  78. package/src/lib/seam/components/SupportedDeviceTable/SupportedDeviceTableManufacturerKeys.tsx +0 -64
  79. package/src/lib/seam/components/SupportedDeviceTable/use-device-model.ts +0 -44
  80. package/src/lib/seam/components/SupportedDeviceTable/use-device-models.ts +0 -57
  81. package/src/lib/seam/components/SupportedDeviceTable/use-filtered-device-models.ts +0 -88
  82. package/src/lib/seam/components/SupportedDeviceTable/use-filtered-manufacturers.ts +0 -69
  83. package/src/lib/seam/components/SupportedDeviceTable/use-manufacturer.ts +0 -40
  84. package/src/lib/seam/components/SupportedDeviceTable/use-manufacturers.ts +0 -53
  85. package/src/styles/_supported-device-table-manufacturer-keys.scss +0 -20
  86. package/src/styles/_supported-device-table.scss +0 -412
@@ -1,93 +0,0 @@
1
- import type { DeviceModel } from '@seamapi/types/devicedb'
2
- import classNames from 'classnames'
3
-
4
- import { DotDivider } from 'lib/ui/layout/DotDivider.js'
5
-
6
- interface SupportedDeviceRowProps {
7
- deviceModel: DeviceModel
8
- }
9
-
10
- export function SupportedDeviceRow({
11
- deviceModel,
12
- }: SupportedDeviceRowProps): JSX.Element {
13
- return (
14
- <div className='seam-row'>
15
- <ImageColumn deviceModel={deviceModel} />
16
- <ModelColumn deviceModel={deviceModel} />
17
- <StatusColumn deviceModel={deviceModel} />
18
- </div>
19
- )
20
- }
21
-
22
- export function ImageColumn({
23
- deviceModel,
24
- }: SupportedDeviceRowProps): JSX.Element {
25
- return (
26
- <div className='seam-col seam-device-image-col'>
27
- <div className='seam-image-box'>
28
- <img
29
- width={40}
30
- src={deviceModel.aesthetic_variants[0]?.images[0]?.url}
31
- />
32
- </div>
33
- </div>
34
- )
35
- }
36
-
37
- export function ModelColumn({
38
- deviceModel,
39
- }: SupportedDeviceRowProps): JSX.Element {
40
- const sku = deviceModel.aesthetic_variants[0]?.manufacturer_sku
41
- const connection =
42
- deviceModel.main_connection_type === 'unknown'
43
- ? null
44
- : deviceModel.main_connection_type
45
- return (
46
- <div className='seam-col seam-model-col'>
47
- <div className='seam-model-name'>
48
- <div className='seam-truncated-text'>{deviceModel.display_name}</div>
49
- </div>
50
- <div className='seam-model-id'>
51
- <div className='seam-truncated-text'>
52
- {sku}
53
- {sku != null && connection != null && <DotDivider />}
54
- {connection}
55
- </div>
56
- </div>
57
- </div>
58
- )
59
- }
60
-
61
- export function StatusColumn({
62
- deviceModel,
63
- }: SupportedDeviceRowProps): JSX.Element {
64
- const statusColor =
65
- supportLevelColors[deviceModel.manufacturer.integration] ?? 'unknown'
66
-
67
- return (
68
- <div className='seam-col seam-status-col'>
69
- <div className={classNames('seam-status-pill', `status-${statusColor}`)}>
70
- <span>{status[deviceModel.manufacturer.integration]}</span>
71
- </div>
72
- </div>
73
- )
74
- }
75
-
76
- const supportLevelColors: Record<
77
- DeviceModel['manufacturer']['integration'],
78
- 'green' | 'blue' | 'unknown'
79
- > = {
80
- stable: 'green',
81
- beta: 'blue',
82
- planned: 'unknown',
83
- unsupported: 'unknown',
84
- inquire: 'unknown',
85
- }
86
-
87
- const status: Record<DeviceModel['manufacturer']['integration'], string> = {
88
- stable: 'LIVE',
89
- beta: 'BETA',
90
- unsupported: 'Inquire',
91
- planned: 'Inquire',
92
- inquire: 'Inquire',
93
- }
@@ -1,15 +0,0 @@
1
- import type { ElementProps } from 'lib/element.js'
2
-
3
- import type { SupportedDeviceTableProps } from './SupportedDeviceTable.js'
4
-
5
- export const name = 'seam-supported-device-table'
6
-
7
- export const props: ElementProps<SupportedDeviceTableProps> = {
8
- disableFilter: 'boolean',
9
- manufacturers: 'array',
10
- excludedManufacturers: 'array',
11
- includeIf: 'array',
12
- excludeIf: 'array',
13
- }
14
-
15
- export { SupportedDeviceTable as Component } from './SupportedDeviceTable.js'
@@ -1,70 +0,0 @@
1
- import classNames from 'classnames'
2
- import { useState } from 'react'
3
-
4
- import {
5
- type CommonProps,
6
- withRequiredCommonProps,
7
- } from 'lib/seam/components/common-props.js'
8
- import { SupportedDeviceContent } from 'lib/seam/components/SupportedDeviceTable/SupportedDeviceContent.js'
9
- import { SupportedDeviceFilterArea } from 'lib/seam/components/SupportedDeviceTable/SupportedDeviceFilterArea.js'
10
- import type { DeviceModelFilters } from 'lib/seam/components/SupportedDeviceTable/use-filtered-device-models.js'
11
- import { useComponentTelemetry } from 'lib/telemetry/index.js'
12
-
13
- export interface SupportedDeviceTableProps extends CommonProps {
14
- disableFilter?: boolean
15
- manufacturers?: string[] | null
16
- excludedManufacturers?: string[]
17
- includeIf?: string[] | null
18
- excludeIf?: string[]
19
- }
20
-
21
- export const NestedSupportedDeviceTable =
22
- withRequiredCommonProps(SupportedDeviceTable)
23
-
24
- export function SupportedDeviceTable({
25
- disableFilter = false,
26
- manufacturers = null,
27
- excludedManufacturers = [],
28
- includeIf = null,
29
- excludeIf = [],
30
- className,
31
- }: SupportedDeviceTableProps = {}): JSX.Element {
32
- useComponentTelemetry('SupportedDeviceTable')
33
-
34
- const [filterValue, setFilterValue] = useState('')
35
- const [filters, setFilters] = useState<DeviceModelFilters>({
36
- supportedOnly: true,
37
- manufacturer: null,
38
- })
39
-
40
- return (
41
- <div
42
- className={classNames(
43
- 'seam-supported-device-table-content-wrap',
44
- className
45
- )}
46
- >
47
- {!disableFilter && (
48
- <SupportedDeviceFilterArea
49
- filterValue={filterValue}
50
- setFilterValue={setFilterValue}
51
- filters={filters}
52
- setFilters={setFilters}
53
- manufacturers={manufacturers}
54
- excludedManufacturers={excludedManufacturers}
55
- />
56
- )}
57
- <SupportedDeviceContent
58
- resetFilterValue={() => {
59
- setFilterValue('')
60
- }}
61
- filterValue={filterValue}
62
- filters={filters}
63
- manufacturers={manufacturers}
64
- excludedManufacturers={excludedManufacturers}
65
- includeIf={includeIf}
66
- excludeIf={excludeIf}
67
- />
68
- </div>
69
- )
70
- }
@@ -1,9 +0,0 @@
1
- import type { ElementProps } from 'lib/element.js'
2
-
3
- import type { SupportedDeviceTableManufacturerKeysProps } from './SupportedDeviceTableManufacturerKeys.js'
4
-
5
- export const name = 'seam-supported-device-table-manufacturer-keys'
6
-
7
- export const props: ElementProps<SupportedDeviceTableManufacturerKeysProps> = {}
8
-
9
- export { SupportedDeviceTableManufacturerKeys as Component } from './SupportedDeviceTableManufacturerKeys.js'
@@ -1,64 +0,0 @@
1
- import type { Manufacturer } from '@seamapi/types/devicedb'
2
- import classNames from 'classnames'
3
-
4
- import { CopyIcon } from 'lib/icons/Copy.js'
5
- import {
6
- type CommonProps,
7
- withRequiredCommonProps,
8
- } from 'lib/seam/components/common-props.js'
9
- import { useComponentTelemetry } from 'lib/telemetry/index.js'
10
- import { copyToClipboard } from 'lib/ui/clipboard.js'
11
- import { MenuItem } from 'lib/ui/Menu/MenuItem.js'
12
-
13
- import { useManufacturers } from './use-manufacturers.js'
14
-
15
- export interface SupportedDeviceTableManufacturerKeysProps
16
- extends CommonProps {}
17
-
18
- export const NestedSupportedDeviceTableManufacturerKeys =
19
- withRequiredCommonProps(SupportedDeviceTableManufacturerKeys)
20
-
21
- export function SupportedDeviceTableManufacturerKeys({
22
- className,
23
- }: SupportedDeviceTableManufacturerKeysProps = {}): JSX.Element {
24
- useComponentTelemetry('SupportedDeviceTableManufacturerKeys')
25
-
26
- const { manufacturers } = useManufacturers()
27
-
28
- return (
29
- <div
30
- className={classNames(
31
- 'supported-device-table-manufacturer-keys',
32
- className
33
- )}
34
- >
35
- {manufacturers?.map((manufacturer) => (
36
- <ManufacturerKey
37
- key={manufacturer.manufacturer_id}
38
- manufacturer={manufacturer}
39
- />
40
- ))}
41
- </div>
42
- )
43
- }
44
-
45
- function ManufacturerKey({
46
- manufacturer,
47
- }: {
48
- manufacturer: Manufacturer
49
- }): JSX.Element {
50
- const key = manufacturer.display_name
51
- return (
52
- <div className='seam-manufacturer-key'>
53
- <div className='seam-manufacturer-key-value'>{key}</div>
54
- <MenuItem
55
- className='seam-copy-button'
56
- onClick={() => {
57
- void copyToClipboard(key)
58
- }}
59
- >
60
- <CopyIcon />
61
- </MenuItem>
62
- </div>
63
- )
64
- }
@@ -1,44 +0,0 @@
1
- import type { SeamHttpApiError } from '@seamapi/http/connect'
2
- import { useSeamClient } from '@seamapi/react-query'
3
- import type {
4
- DeviceModel,
5
- RouteRequestParams,
6
- RouteResponse,
7
- } from '@seamapi/types/devicedb'
8
- import { useQuery } from '@tanstack/react-query'
9
-
10
- import type { UseSeamQueryResultLegacy } from 'lib/seam/use-seam-query-result.js'
11
-
12
- export type UseDeviceModelParams = DeviceModelsGetParams
13
-
14
- export type UseDeviceModelData = DeviceModel | null
15
-
16
- export function useDeviceModel(
17
- params: UseDeviceModelParams
18
- ): UseSeamQueryResultLegacy<'deviceModel', UseDeviceModelData> {
19
- const { client: seam } = useSeamClient()
20
- const { data, ...rest } = useQuery<UseDeviceModelData, SeamHttpApiError>({
21
- enabled: seam != null,
22
- queryKey: ['internal', 'device_models', 'get', params],
23
- queryFn: async () => {
24
- if (seam == null) return null
25
- const {
26
- data: { device_model: deviceModel },
27
- } = await seam.client.get<DeviceModelsGetResponse>(
28
- '/internal/devicedb/v1/device_models/get',
29
- { params }
30
- )
31
- // UPSTREAM: Response type does not match DeviceModel.
32
- return deviceModel as DeviceModel
33
- },
34
- })
35
-
36
- return {
37
- ...rest,
38
- deviceModel: data,
39
- }
40
- }
41
-
42
- type DeviceModelsGetParams = RouteRequestParams<'/v1/device_models/get'>
43
-
44
- type DeviceModelsGetResponse = RouteResponse<'/v1/device_models/get'>
@@ -1,57 +0,0 @@
1
- import type { SeamHttpApiError } from '@seamapi/http/connect'
2
- import { useSeamClient } from '@seamapi/react-query'
3
- import type {
4
- DeviceModel,
5
- RouteRequestParams,
6
- RouteResponse,
7
- } from '@seamapi/types/devicedb'
8
- import { useQuery, useQueryClient } from '@tanstack/react-query'
9
-
10
- import type { UseSeamQueryResultLegacy } from 'lib/seam/use-seam-query-result.js'
11
-
12
- export type UseDeviceModelsParams = DeviceModelsListParams
13
-
14
- export type UseDeviceModelsData = DeviceModel[]
15
-
16
- export function useDeviceModels(
17
- params?: UseDeviceModelsParams
18
- ): UseSeamQueryResultLegacy<'deviceModels', UseDeviceModelsData> {
19
- const { client: seam } = useSeamClient()
20
- const queryClient = useQueryClient()
21
-
22
- const { data, ...rest } = useQuery<UseDeviceModelsData, SeamHttpApiError>({
23
- enabled: seam != null,
24
- queryKey: ['internal', 'device_models', 'list', params],
25
- queryFn: async () => {
26
- if (seam == null) return []
27
- const {
28
- data: { device_models: deviceModels },
29
- } = await seam.client.get<DeviceModelsListResponse>(
30
- '/internal/devicedb/v1/device_models/list',
31
- { params }
32
- )
33
- for (const deviceModel of deviceModels) {
34
- queryClient.setQueryData(
35
- [
36
- 'internal',
37
- 'device_models',
38
- 'get',
39
- { device_model_id: deviceModel.device_model_id },
40
- ],
41
- deviceModel
42
- )
43
- }
44
- // UPSTREAM: Response type does not match DeviceModel[].
45
- return deviceModels as DeviceModel[]
46
- },
47
- })
48
-
49
- return {
50
- ...rest,
51
- deviceModels: data,
52
- }
53
- }
54
-
55
- type DeviceModelsListParams = RouteRequestParams<'/v1/device_models/list'>
56
-
57
- type DeviceModelsListResponse = RouteResponse<'/v1/device_models/list'>
@@ -1,88 +0,0 @@
1
- import type { ManufacturerIntegrationSupportLevel } from '@seamapi/types/devicedb'
2
-
3
- import {
4
- useDeviceModels,
5
- type UseDeviceModelsParams,
6
- } from 'lib/seam/components/SupportedDeviceTable/use-device-models.js'
7
-
8
- import { useFilteredManufacturers } from './use-filtered-manufacturers.js'
9
-
10
- export interface DeviceModelFilters {
11
- supportedOnly: boolean
12
- manufacturer: string | null
13
- }
14
-
15
- export const supportedIntegrationSupportLevels: ManufacturerIntegrationSupportLevel[] =
16
- ['stable', 'beta']
17
-
18
- export const useFilteredDeviceModels = ({
19
- filterValue,
20
- filters,
21
- includeIf,
22
- excludeIf,
23
- ...manufacturersParams
24
- }: {
25
- filterValue: string
26
- filters: DeviceModelFilters
27
- manufacturers: string[] | null
28
- excludedManufacturers: string[]
29
- includeIf: string[] | null
30
- excludeIf: string[]
31
- }): ReturnType<typeof useDeviceModels> => {
32
- const { manufacturers } = useFilteredManufacturers({
33
- ...manufacturersParams,
34
- integrationSupportLevels: filters.supportedOnly
35
- ? supportedIntegrationSupportLevels
36
- : null,
37
- })
38
-
39
- const params: UseDeviceModelsParams = {}
40
-
41
- if (excludeIf.length > 0) {
42
- params.exclude_if = excludeIf
43
- }
44
-
45
- // UPSTREAM: API does not parse zero-length arrays correctly.
46
- if (includeIf != null && includeIf.length > 0) {
47
- params.include_if = includeIf
48
- }
49
-
50
- if (filterValue.trim() !== '') {
51
- params.text_search = filterValue.trim()
52
- }
53
-
54
- if (filters.supportedOnly) {
55
- params.integration_support_levels = supportedIntegrationSupportLevels
56
- }
57
-
58
- if (filters.manufacturer !== null) {
59
- const manufacturer = manufacturers?.find(
60
- (manufacturer) => manufacturer.display_name === filters.manufacturer
61
- )
62
-
63
- if (manufacturer != null) {
64
- params.manufacturer_id = manufacturer.manufacturer_id
65
- }
66
- }
67
-
68
- if (filters.manufacturer == null && manufacturers != null) {
69
- params.manufacturer_ids = manufacturers.map((m) => m.manufacturer_id)
70
- }
71
-
72
- const { deviceModels, ...rest } = useDeviceModels(params)
73
-
74
- return {
75
- ...rest,
76
- deviceModels:
77
- // UPSTREAM: API does not parse zero-length arrays correctly.
78
- includeIf?.length === 0
79
- ? []
80
- : deviceModels?.filter((deviceModel) =>
81
- manufacturers?.some(
82
- (manufacturer) =>
83
- deviceModel.manufacturer.manufacturer_id ===
84
- manufacturer.manufacturer_id
85
- )
86
- ),
87
- }
88
- }
@@ -1,69 +0,0 @@
1
- import type { ManufacturerIntegrationSupportLevel } from '@seamapi/types/devicedb'
2
-
3
- import { useManufacturers } from 'lib/seam/components/SupportedDeviceTable/use-manufacturers.js'
4
-
5
- interface Params {
6
- manufacturers: string[] | null
7
- excludedManufacturers: string[]
8
- integrationSupportLevels: ManufacturerIntegrationSupportLevel[] | null
9
- }
10
-
11
- export const useFilteredManufacturers = ({
12
- integrationSupportLevels,
13
- ...params
14
- }: Params): ReturnType<typeof useManufacturers> => {
15
- const { manufacturers, ...rest } = useManufacturers({
16
- integration_support_levels: integrationSupportLevels ?? undefined,
17
- liqe_query: createLiqeQuery(params),
18
- })
19
-
20
- return {
21
- ...rest,
22
- manufacturers: manufacturers?.filter(
23
- (manufacturer) => manufacturer.device_model_count > 0
24
- ),
25
- }
26
- }
27
-
28
- export const createLiqeQuery = ({
29
- manufacturers,
30
- excludedManufacturers,
31
- }: Pick<Params, 'manufacturers' | 'excludedManufacturers'>):
32
- | string
33
- | undefined => {
34
- if (
35
- (manufacturers?.some(isInvalidInput) ?? false) ||
36
- excludedManufacturers.some(isInvalidInput)
37
- ) {
38
- return undefined
39
- }
40
-
41
- const excludedManufacturersClause = `NOT (${excludedManufacturers
42
- .map(manufacturerToMatcher)
43
- .join(' OR ')})`
44
-
45
- if (manufacturers == null) {
46
- if (excludedManufacturers.length === 0) return undefined
47
- return excludedManufacturersClause
48
- }
49
-
50
- if (manufacturers.length === 0) {
51
- return 'manufacturer_id:none'
52
- }
53
-
54
- const includedManufacturersClause = `(${manufacturers
55
- .map(manufacturerToMatcher)
56
- .join(' OR ')})`
57
-
58
- if (excludedManufacturers.length === 0) return includedManufacturersClause
59
-
60
- return `${includedManufacturersClause} AND ${excludedManufacturersClause}`
61
- }
62
-
63
- const manufacturerToMatcher = (value: string): string => {
64
- const [manufacturer, uuid] = value.split('=')
65
- if (uuid != null) return `manufacturer_id:"${uuid}"`
66
- return `display_name:"${manufacturer}"`
67
- }
68
-
69
- const isInvalidInput = (value: string): boolean => value.includes('"')
@@ -1,40 +0,0 @@
1
- import type { SeamHttpApiError } from '@seamapi/http/connect'
2
- import { useSeamClient } from '@seamapi/react-query'
3
- import type {
4
- Manufacturer,
5
- RouteRequestParams,
6
- RouteResponse,
7
- } from '@seamapi/types/devicedb'
8
- import { useQuery } from '@tanstack/react-query'
9
-
10
- import type { UseSeamQueryResultLegacy } from 'lib/seam/use-seam-query-result.js'
11
-
12
- export type UseManufacturerParams = ManufacturersGetParams
13
-
14
- export type UseManufacturerData = Manufacturer | null
15
-
16
- export function useManufacturer(
17
- params: UseManufacturerParams
18
- ): UseSeamQueryResultLegacy<'manufacturer', UseManufacturerData> {
19
- const { client: seam } = useSeamClient()
20
- const { data, ...rest } = useQuery<UseManufacturerData, SeamHttpApiError>({
21
- enabled: seam != null,
22
- queryKey: ['internal', 'manufacturers', 'get', params],
23
- queryFn: async () => {
24
- if (seam == null) return null
25
- const {
26
- data: { manufacturer },
27
- } = await seam.client.get<ManufacturersGetResponse>(
28
- '/internal/devicedb/v1/manufacturers/get',
29
- { params }
30
- )
31
- return manufacturer
32
- },
33
- })
34
-
35
- return { ...rest, manufacturer: data }
36
- }
37
-
38
- type ManufacturersGetParams = RouteRequestParams<'/v1/manufacturers/get'>
39
-
40
- type ManufacturersGetResponse = RouteResponse<'/v1/manufacturers/get'>
@@ -1,53 +0,0 @@
1
- import type { SeamHttpApiError } from '@seamapi/http/connect'
2
- import { useSeamClient } from '@seamapi/react-query'
3
- import type {
4
- Manufacturer,
5
- RouteRequestParams,
6
- RouteResponse,
7
- } from '@seamapi/types/devicedb'
8
- import { useQuery, useQueryClient } from '@tanstack/react-query'
9
-
10
- import type { UseSeamQueryResultLegacy } from 'lib/seam/use-seam-query-result.js'
11
-
12
- export type UseManufacturersParams = ManufacturersListParams
13
-
14
- export type UseManufacturersData = Manufacturer[]
15
-
16
- export function useManufacturers(
17
- params?: UseManufacturersParams
18
- ): UseSeamQueryResultLegacy<'manufacturers', UseManufacturersData> {
19
- const { client: seam } = useSeamClient()
20
- const queryClient = useQueryClient()
21
-
22
- const { data, ...rest } = useQuery<UseManufacturersData, SeamHttpApiError>({
23
- enabled: seam != null,
24
- queryKey: ['internal', 'manufacturers', 'list', params],
25
- queryFn: async () => {
26
- if (seam == null) return []
27
- const {
28
- data: { manufacturers },
29
- } = await seam.client.get<ManufacturersListResponse>(
30
- '/internal/devicedb/v1/manufacturers/list',
31
- { params }
32
- )
33
- for (const manufacturer of manufacturers) {
34
- queryClient.setQueryData(
35
- [
36
- 'internal',
37
- 'manufacturers',
38
- 'get',
39
- { manufacturer_id: manufacturer.manufacturer_id },
40
- ],
41
- manufacturer
42
- )
43
- }
44
- return manufacturers
45
- },
46
- })
47
-
48
- return { ...rest, manufacturers: data }
49
- }
50
-
51
- type ManufacturersListParams = RouteRequestParams<'/v1/manufacturers/list'>
52
-
53
- type ManufacturersListResponse = RouteResponse<'/v1/manufacturers/list'>
@@ -1,20 +0,0 @@
1
- @mixin all {
2
- .supported-device-table-manufacturer-keys {
3
- font-size: 18px;
4
-
5
- .seam-manufacturer-key {
6
- display: table-row;
7
- }
8
-
9
- .seam-manufacturer-key-value {
10
- display: table-cell;
11
- }
12
-
13
- .seam-copy-button {
14
- display: table-cell;
15
- cursor: pointer;
16
- padding-left: 10px;
17
- font-size: 25px;
18
- }
19
- }
20
- }