@seamapi/react 5.2.2 → 5.2.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.
Files changed (33) hide show
  1. package/README.md +3 -3
  2. package/dist/ecosystem.js +10 -10
  3. package/dist/ecosystem.js.map +1 -1
  4. package/dist/elements.js +6765 -6628
  5. package/dist/elements.js.map +1 -1
  6. package/dist/index.css +31 -2
  7. package/dist/index.css.map +1 -1
  8. package/dist/index.min.css +1 -1
  9. package/dist/index.min.css.map +1 -1
  10. package/lib/seam/components/SupportedDevices/DeviceModelRow.js +15 -5
  11. package/lib/seam/components/SupportedDevices/DeviceModelRow.js.map +1 -1
  12. package/lib/seam/components/SupportedDevices/RequirementIcon.js +1 -1
  13. package/lib/seam/components/SupportedDevices/RequirementIcon.js.map +1 -1
  14. package/lib/seam/components/SupportedDevices/SupportedDevices.js +7 -3
  15. package/lib/seam/components/SupportedDevices/SupportedDevices.js.map +1 -1
  16. package/lib/seam/components/SupportedDevices/device-models.d.ts +4 -1
  17. package/lib/seam/components/SupportedDevices/device-models.js +46 -1
  18. package/lib/seam/components/SupportedDevices/device-models.js.map +1 -1
  19. package/lib/seam/ecosystem/types.d.ts +9 -0
  20. package/lib/seam/ecosystem/use-ecosystem-provider-requirements.d.ts +4 -0
  21. package/lib/seam/ecosystem/use-ecosystem-provider-requirements.js +49 -0
  22. package/lib/seam/ecosystem/use-ecosystem-provider-requirements.js.map +1 -0
  23. package/lib/version.d.ts +1 -1
  24. package/lib/version.js +1 -1
  25. package/package.json +1 -1
  26. package/src/lib/seam/components/SupportedDevices/DeviceModelRow.tsx +97 -58
  27. package/src/lib/seam/components/SupportedDevices/RequirementIcon.tsx +6 -1
  28. package/src/lib/seam/components/SupportedDevices/SupportedDevices.tsx +15 -2
  29. package/src/lib/seam/components/SupportedDevices/device-models.ts +77 -1
  30. package/src/lib/seam/ecosystem/types.ts +11 -0
  31. package/src/lib/seam/ecosystem/use-ecosystem-provider-requirements.ts +62 -0
  32. package/src/lib/version.ts +1 -1
  33. package/src/styles/_supported-devices.scss +36 -2
@@ -1,3 +1,5 @@
1
+ import { useId, useState } from 'react'
2
+
1
3
  import { CheckIcon } from 'lib/icons/Check.js'
2
4
  import { TriangleWarningOutlineIcon } from 'lib/icons/TriangleWarningOutline.js'
3
5
  import {
@@ -22,6 +24,8 @@ export function DeviceModelRow({
22
24
  deviceModel,
23
25
  manufacturer,
24
26
  }: DeviceModelRowProps): JSX.Element {
27
+ const detailsId = useId()
28
+ const [expanded, setExpanded] = useState(false)
25
29
  const name = getDeviceModelName(deviceModel)
26
30
  const imageUrl = getDeviceModelImageUrl(deviceModel, manufacturer)
27
31
  const modelIds = [
@@ -74,29 +78,51 @@ export function DeviceModelRow({
74
78
  )}
75
79
  </div>
76
80
  {capabilities.length > 0 && (
77
- <ul className='seam-supported-devices-features' aria-label={t.features}>
78
- {capabilities.map((capability) => (
79
- <li key={capability.name}>
80
- {capability.supported === 'conditionally' ? (
81
- <TriangleWarningOutlineIcon
82
- aria-hidden
83
- className='seam-supported-devices-conditional-icon'
84
- />
85
- ) : (
86
- <CheckIcon aria-hidden />
87
- )}
88
- <span>
89
- {getCapabilityLabel(capability.name)}
90
- {capability.integrationSupportLevel === 'beta' && ' (beta)'}
91
- {capability.supported === 'conditionally' && (
92
- <span className='seam-ecosystem-visually-hidden'>
93
- {` (${t.requirementsBelow})`}
94
- </span>
81
+ <div className='seam-supported-devices-capabilities'>
82
+ <span className='seam-supported-devices-capabilities-label'>
83
+ {t.features}
84
+ </span>
85
+ <ul
86
+ className='seam-supported-devices-features'
87
+ aria-label={t.features}
88
+ >
89
+ {capabilities.map((capability) => (
90
+ <li key={capability.name}>
91
+ {capability.supported === 'conditionally' ? (
92
+ <button
93
+ type='button'
94
+ className='seam-supported-devices-requirement-toggle'
95
+ aria-label={t.toggleRequirements(
96
+ getCapabilityLabel(capability.name),
97
+ name
98
+ )}
99
+ aria-controls={detailsId}
100
+ aria-expanded={expanded}
101
+ onClick={() => {
102
+ setExpanded((open) => !open)
103
+ }}
104
+ >
105
+ <TriangleWarningOutlineIcon
106
+ aria-hidden
107
+ className='seam-supported-devices-conditional-icon'
108
+ />
109
+ </button>
110
+ ) : (
111
+ <CheckIcon aria-hidden />
95
112
  )}
96
- </span>
97
- </li>
98
- ))}
99
- </ul>
113
+ <span>
114
+ {getCapabilityLabel(capability.name)}
115
+ {capability.integrationSupportLevel === 'beta' && ' (beta)'}
116
+ {capability.supported === 'conditionally' && (
117
+ <span className='seam-ecosystem-visually-hidden'>
118
+ {` (${t.requirementsDetails})`}
119
+ </span>
120
+ )}
121
+ </span>
122
+ </li>
123
+ ))}
124
+ </ul>
125
+ </div>
100
126
  )}
101
127
  {deviceModel.capabilities_stale ? (
102
128
  <span className='seam-supported-devices-status'>{t.refreshing}</span>
@@ -104,41 +130,52 @@ export function DeviceModelRow({
104
130
  deviceModel.device_type?.is_accessory !== true ? (
105
131
  <span className='seam-supported-devices-status'>{t.unconfirmed}</span>
106
132
  ) : null}
107
- {requirements.size > 0 && (
108
- <ul
109
- className='seam-supported-devices-requirements'
110
- aria-label={t.requirements}
133
+ {(requirements.size > 0 ||
134
+ modelIds.length > 0 ||
135
+ providers.length > 0) && (
136
+ <details
137
+ id={detailsId}
138
+ className='seam-supported-devices-details'
139
+ open={expanded}
140
+ onToggle={(event) => {
141
+ setExpanded(event.currentTarget.open)
142
+ }}
111
143
  >
112
- {[...requirements].map(([message, features]) => (
113
- <li key={message}>
114
- <RequirementIcon message={message} />
115
- <div>
116
- <span>{message}</span>
117
- <span className='seam-supported-devices-requirement-features'>
118
- {t.requiredFor([...features].join(', '))}
119
- </span>
120
- </div>
121
- </li>
122
- ))}
123
- </ul>
124
- )}
125
- {(modelIds.length > 0 || providers.length > 0) && (
126
- <details className='seam-supported-devices-details'>
127
144
  <summary>{t.modelDetails}</summary>
128
- <dl>
129
- {modelIds.length > 0 && (
130
- <div>
131
- <dt>{t.modelNumbers}</dt>
132
- <dd>{modelIds.join(', ')}</dd>
133
- </div>
134
- )}
135
- {providers.length > 0 && (
136
- <div>
137
- <dt>{t.integration}</dt>
138
- <dd>{providers.join(', ')}</dd>
139
- </div>
140
- )}
141
- </dl>
145
+ {requirements.size > 0 && (
146
+ <ul
147
+ className='seam-supported-devices-requirements'
148
+ aria-label={t.requirements}
149
+ >
150
+ {[...requirements].map(([message, features]) => (
151
+ <li key={message}>
152
+ <RequirementIcon message={message} />
153
+ <div>
154
+ <span>{message}</span>
155
+ <span className='seam-supported-devices-requirement-features'>
156
+ {t.requiredFor([...features].join(', '))}
157
+ </span>
158
+ </div>
159
+ </li>
160
+ ))}
161
+ </ul>
162
+ )}
163
+ {(modelIds.length > 0 || providers.length > 0) && (
164
+ <dl>
165
+ {modelIds.length > 0 && (
166
+ <div>
167
+ <dt>{t.modelNumbers}</dt>
168
+ <dd>{modelIds.join(', ')}</dd>
169
+ </div>
170
+ )}
171
+ {providers.length > 0 && (
172
+ <div>
173
+ <dt>{t.integration}</dt>
174
+ <dd>{providers.join(', ')}</dd>
175
+ </div>
176
+ )}
177
+ </dl>
178
+ )}
142
179
  </details>
143
180
  )}
144
181
  </li>
@@ -146,11 +183,13 @@ export function DeviceModelRow({
146
183
  }
147
184
 
148
185
  const t = {
149
- features: 'Supported features',
186
+ features: 'Supported capabilities',
150
187
  requirements: 'Requirements',
151
- requirementsBelow: 'see requirements below',
188
+ requirementsDetails: 'expand model and requirements details',
189
+ toggleRequirements: (capability: string, device: string) =>
190
+ `${capability} requirements for ${device}`,
152
191
  requiredFor: (features: string) => `For ${features}`,
153
- modelDetails: 'Model details',
192
+ modelDetails: 'Model and requirements details',
154
193
  modelNumbers: 'Model numbers',
155
194
  integration: 'Integration',
156
195
  refreshing: 'Compatibility is being refreshed.',
@@ -13,7 +13,12 @@ export function RequirementIcon({ message }: { message: string }): JSX.Element {
13
13
  strokeLinecap='round'
14
14
  strokeLinejoin='round'
15
15
  >
16
- {/keypad/i.test(message) ? (
16
+ {/subscription|licen[sc]e|paying|paid|fees?/i.test(message) ? (
17
+ <>
18
+ <rect x='2' y='4' width='20' height='16' rx='3' />
19
+ <path d='M2 9h20M6 15h4m4 0h4' />
20
+ </>
21
+ ) : /keypad/i.test(message) ? (
17
22
  <>
18
23
  <rect x='5' y='2' width='14' height='20' rx='3' />
19
24
  <path d='M9 6h6M9 10h.01M12 10h.01M15 10h.01M9 14h.01M12 14h.01M15 14h.01M12 18h.01' />
@@ -11,7 +11,9 @@ import {
11
11
  getDeviceTypeOptions,
12
12
  getManufacturerName,
13
13
  getManufacturerOptions,
14
+ getProvidersWithMissingRequirements,
14
15
  groupDeviceModelsByManufacturer,
16
+ resolveProviderRequirements,
15
17
  scopeDeviceModelsToProvider,
16
18
  } from 'lib/seam/components/SupportedDevices/device-models.js'
17
19
  import { FilterSelect } from 'lib/seam/components/SupportedDevices/FilterSelect.js'
@@ -20,6 +22,7 @@ import { useEcosystemContext } from 'lib/seam/ecosystem/EcosystemProvider.js'
20
22
  import type { Manufacturer } from 'lib/seam/ecosystem/types.js'
21
23
  import { useEcosystemDeviceModelSummaries } from 'lib/seam/ecosystem/use-ecosystem-device-model-summaries.js'
22
24
  import { useEcosystemManufacturers } from 'lib/seam/ecosystem/use-ecosystem-manufacturers.js'
25
+ import { useEcosystemProviderRequirements } from 'lib/seam/ecosystem/use-ecosystem-provider-requirements.js'
23
26
  import {
24
27
  getEmbedKeyManufacturer,
25
28
  useEmbedKeyResolution,
@@ -100,7 +103,7 @@ export function SupportedDevices({
100
103
  enabled: (explicitManufacturer != null || isResolved) && !isResolutionError,
101
104
  })
102
105
 
103
- const availableDeviceModels = useMemo(
106
+ const scopedDeviceModels = useMemo(
104
107
  () =>
105
108
  scopeDeviceModelsToProvider(
106
109
  applyEmbedExclusions(deviceModels ?? [], embedResolution?.exclusions),
@@ -109,6 +112,16 @@ export function SupportedDevices({
109
112
  [deviceModels, embedResolution, fixedProvider]
110
113
  )
111
114
 
115
+ const missingProviderSlugs = useMemo(
116
+ () => getProvidersWithMissingRequirements(scopedDeviceModels),
117
+ [scopedDeviceModels]
118
+ )
119
+ const { providers } = useEcosystemProviderRequirements(missingProviderSlugs)
120
+ const availableDeviceModels = useMemo(
121
+ () => resolveProviderRequirements(scopedDeviceModels, providers ?? []),
122
+ [scopedDeviceModels, providers]
123
+ )
124
+
112
125
  const manufacturerSlugs = useMemo(
113
126
  () =>
114
127
  availableDeviceModels
@@ -403,7 +416,7 @@ const t = {
403
416
  allCapabilities: 'All features',
404
417
  featureStatus: 'Feature status',
405
418
  supported: 'Supported',
406
- requiresSetup: 'Requires setup · see requirements below',
419
+ requiresSetup: 'Requires setup · expand details',
407
420
  error: 'An error occurred while loading supported devices.',
408
421
  retry: 'Retry',
409
422
  noDevices: 'No supported devices found.',
@@ -6,6 +6,7 @@ import type {
6
6
  IntegrationSupportLevel,
7
7
  Manufacturer,
8
8
  ManufacturerRef,
9
+ ProviderRequirements,
9
10
  } from 'lib/seam/ecosystem/types.js'
10
11
 
11
12
  export interface DeviceModelFilters {
@@ -192,14 +193,89 @@ const genericSupportDetails = new Set([
192
193
  const isGenericSupportDetail = (details: string): boolean =>
193
194
  genericSupportDetails.has(details.trim())
194
195
 
196
+ const isMissingMessage = (message: unknown): boolean =>
197
+ typeof message !== 'string' ||
198
+ message.trim().length === 0 ||
199
+ message.trim() === 'Requirement message not found' ||
200
+ message.trim() === 'Report details not found'
201
+
202
+ export const getProvidersWithMissingRequirements = (
203
+ models: DeviceModelSummary[]
204
+ ): string[] =>
205
+ [
206
+ ...new Set(
207
+ models.flatMap((model) =>
208
+ model.capabilities_by_provider
209
+ .filter((entry) =>
210
+ entry.capabilities.some(
211
+ (capability) =>
212
+ capability.report?.requirements?.['provider'] != null &&
213
+ isMissingMessage(
214
+ capability.report.requirements['provider'].message
215
+ )
216
+ )
217
+ )
218
+ .map((entry) => entry.provider.slug)
219
+ )
220
+ ),
221
+ ].sort()
222
+
223
+ /** Legacy translation treats provider prose as a dictionary key; the public provider retains the prose. */
224
+ export const resolveProviderRequirements = (
225
+ models: DeviceModelSummary[],
226
+ providers: ProviderRequirements[]
227
+ ): DeviceModelSummary[] => {
228
+ const bySlug = new Map(
229
+ providers.map((provider) => [provider.slug, provider.requirements_md])
230
+ )
231
+ return models.map((model) => ({
232
+ ...model,
233
+ capabilities_by_provider: model.capabilities_by_provider.map((entry) => ({
234
+ ...entry,
235
+ capabilities: entry.capabilities.map((capability) => {
236
+ const report = capability.report
237
+ const requirement = report?.requirements?.['provider']
238
+ if (
239
+ report == null ||
240
+ requirement == null ||
241
+ !isMissingMessage(requirement.message)
242
+ )
243
+ return capability
244
+ const message = bySlug.get(entry.provider.slug)
245
+ return {
246
+ ...capability,
247
+ report: {
248
+ ...report,
249
+ requirements: {
250
+ ...report.requirements,
251
+ provider: {
252
+ ...requirement,
253
+ message:
254
+ typeof message === 'string' && !isMissingMessage(message)
255
+ ? message.trim()
256
+ : 'Additional integration requirements apply. Check with your integration provider.',
257
+ },
258
+ },
259
+ },
260
+ }
261
+ }),
262
+ })),
263
+ }))
264
+ }
265
+
195
266
  /** Keep specific constraints; replace boilerplate with an actionable setup note. */
196
267
  export const getCapabilityRequirementMessages = (
197
268
  capability: SupportedCapability
198
269
  ): string[] => {
199
- const messages = new Set(capability.requirements)
270
+ const messages = new Set(
271
+ capability.requirements.map((message) =>
272
+ isMissingMessage(message) ? 'Additional setup is required.' : message
273
+ )
274
+ )
200
275
  if (capability.supported === 'conditionally') {
201
276
  if (
202
277
  capability.details != null &&
278
+ !isMissingMessage(capability.details) &&
203
279
  !isGenericSupportDetail(capability.details)
204
280
  )
205
281
  messages.add(capability.details)
@@ -182,6 +182,12 @@ export interface ProviderRef {
182
182
  display_name: string | null
183
183
  }
184
184
 
185
+ /** Fields used from the public `providers/list` response to recover legacy report text. */
186
+ export interface ProviderRequirements extends ProviderRef {
187
+ has_requirements: boolean | null
188
+ requirements_md: string | null
189
+ }
190
+
185
191
  export type CapabilityName =
186
192
  | 'device_connectivity'
187
193
  | 'can_program_online_access_codes'
@@ -391,6 +397,11 @@ export interface ManufacturersListResponse {
391
397
  pagination: Pagination
392
398
  }
393
399
 
400
+ export interface ProvidersListResponse {
401
+ providers: ProviderRequirements[]
402
+ pagination: Pagination
403
+ }
404
+
394
405
  export interface EcosystemErrorResponse {
395
406
  ok: false
396
407
  error: {
@@ -0,0 +1,62 @@
1
+ import { useQuery } from '@tanstack/react-query'
2
+
3
+ import { EcosystemApiError, fetchEcosystem } from 'lib/seam/ecosystem/client.js'
4
+ import { useEcosystemContext } from 'lib/seam/ecosystem/EcosystemProvider.js'
5
+ import type {
6
+ ProviderRequirements,
7
+ ProvidersListResponse,
8
+ } from 'lib/seam/ecosystem/types.js'
9
+ import {
10
+ retryEcosystemQuery,
11
+ type UseEcosystemQueryResult,
12
+ } from 'lib/seam/ecosystem/use-ecosystem-query-result.js'
13
+
14
+ /** Only fetch providers whose legacy capability reports lost their free-text requirement. */
15
+ export function useEcosystemProviderRequirements(
16
+ slugs: string[]
17
+ ): UseEcosystemQueryResult<'providers', ProviderRequirements[]> {
18
+ const { endpoint, embedKey } = useEcosystemContext()
19
+ const sortedSlugs = [...new Set(slugs)].sort()
20
+ const { data, ...rest } = useQuery<ProviderRequirements[], EcosystemApiError>(
21
+ {
22
+ enabled: sortedSlugs.length > 0,
23
+ queryKey: [
24
+ 'ecosystem',
25
+ endpoint,
26
+ embedKey ?? null,
27
+ 'providers',
28
+ 'list',
29
+ { slugs: sortedSlugs },
30
+ ],
31
+ queryFn: async ({ signal }) => {
32
+ const providers: ProviderRequirements[] = []
33
+ const seen = new Set<string>()
34
+ let cursor: string | undefined
35
+ for (let page = 0; page < 10; page++) {
36
+ const res = await fetchEcosystem<ProvidersListResponse>(
37
+ 'providers/list',
38
+ {
39
+ endpoint,
40
+ embedKey,
41
+ signal,
42
+ params: { slugs: sortedSlugs, limit: 500, page_cursor: cursor },
43
+ }
44
+ )
45
+ providers.push(...res.providers)
46
+ if (!res.pagination.has_next_page) return providers
47
+ const next = res.pagination.next_page_cursor
48
+ if (next == null || seen.has(next)) break
49
+ seen.add(next)
50
+ cursor = next
51
+ }
52
+ throw new EcosystemApiError({
53
+ status: 502,
54
+ type: 'pagination_incomplete',
55
+ message: 'The provider catalog returned incomplete requirements.',
56
+ })
57
+ },
58
+ retry: retryEcosystemQuery,
59
+ }
60
+ )
61
+ return { ...rest, providers: data }
62
+ }
@@ -1,3 +1,3 @@
1
- const seamapiReactVersion = '5.2.2'
1
+ const seamapiReactVersion = '5.2.3'
2
2
 
3
3
  export default seamapiReactVersion
@@ -152,10 +152,21 @@
152
152
  font-size: 13px;
153
153
  }
154
154
 
155
+ .seam-supported-devices-capabilities {
156
+ display: grid;
157
+ grid-column: 2;
158
+ gap: 4px;
159
+ }
160
+
161
+ .seam-supported-devices-capabilities-label {
162
+ color: var(--seam-ecosystem-fg-2);
163
+ font-size: 12px;
164
+ font-weight: 600;
165
+ }
166
+
155
167
  .seam-supported-devices-features {
156
168
  display: flex;
157
169
  flex-wrap: wrap;
158
- grid-column: 2;
159
170
  gap: 6px 16px;
160
171
  margin: 0;
161
172
  padding: 0;
@@ -179,6 +190,29 @@
179
190
  }
180
191
  }
181
192
 
193
+ .seam-supported-devices-requirement-toggle {
194
+ display: inline-flex;
195
+ align-items: center;
196
+ justify-content: center;
197
+ width: 24px;
198
+ height: 24px;
199
+ margin: -4px 0 -4px -4px;
200
+ padding: 4px;
201
+ border: 0;
202
+ border-radius: 4px;
203
+ background: transparent;
204
+ cursor: pointer;
205
+
206
+ &:hover {
207
+ background: var(--seam-ecosystem-surface-2);
208
+ }
209
+
210
+ &:focus-visible {
211
+ outline: 2px solid var(--seam-ecosystem-accent);
212
+ outline-offset: 2px;
213
+ }
214
+ }
215
+
182
216
  .seam-supported-devices-section-footer {
183
217
  display: flex;
184
218
  justify-content: center;
@@ -197,7 +231,7 @@
197
231
  .seam-supported-devices-requirements {
198
232
  display: grid;
199
233
  gap: 12px;
200
- margin: 4px 0;
234
+ margin: 12px 0;
201
235
  padding: 12px;
202
236
  border-radius: 8px;
203
237
  background: var(--seam-ecosystem-surface-2);