@seamapi/react 5.2.2 → 5.2.4

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 +11 -11
  3. package/dist/ecosystem.js.map +1 -1
  4. package/dist/elements.js +6767 -6629
  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 +48 -2
  18. package/lib/seam/components/SupportedDevices/device-models.js.map +1 -1
  19. package/lib/seam/ecosystem/types.d.ts +10 -1
  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 +79 -2
  30. package/src/lib/seam/ecosystem/types.ts +12 -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 {
@@ -42,7 +43,8 @@ export const capabilityLabels: Partial<Record<CapabilityName, string>> = {
42
43
  can_program_offline_access_codes: 'Offline access codes',
43
44
  can_provision_mobile_keys: 'Mobile keys',
44
45
  can_provision_wallet_keys: 'Wallet keys',
45
- can_encode_plastic_cards: 'Key cards',
46
+ can_encode_plastic_cards: 'Encode key cards',
47
+ can_assign_plastic_cards: 'Assign key cards',
46
48
  can_hvac_heat: 'Heat',
47
49
  can_hvac_cool: 'Cool',
48
50
  can_hvac_auto: 'Heat and cool',
@@ -192,14 +194,89 @@ const genericSupportDetails = new Set([
192
194
  const isGenericSupportDetail = (details: string): boolean =>
193
195
  genericSupportDetails.has(details.trim())
194
196
 
197
+ const isMissingMessage = (message: unknown): boolean =>
198
+ typeof message !== 'string' ||
199
+ message.trim().length === 0 ||
200
+ message.trim() === 'Requirement message not found' ||
201
+ message.trim() === 'Report details not found'
202
+
203
+ export const getProvidersWithMissingRequirements = (
204
+ models: DeviceModelSummary[]
205
+ ): string[] =>
206
+ [
207
+ ...new Set(
208
+ models.flatMap((model) =>
209
+ model.capabilities_by_provider
210
+ .filter((entry) =>
211
+ entry.capabilities.some(
212
+ (capability) =>
213
+ capability.report?.requirements?.['provider'] != null &&
214
+ isMissingMessage(
215
+ capability.report.requirements['provider'].message
216
+ )
217
+ )
218
+ )
219
+ .map((entry) => entry.provider.slug)
220
+ )
221
+ ),
222
+ ].sort()
223
+
224
+ /** Legacy translation treats provider prose as a dictionary key; the public provider retains the prose. */
225
+ export const resolveProviderRequirements = (
226
+ models: DeviceModelSummary[],
227
+ providers: ProviderRequirements[]
228
+ ): DeviceModelSummary[] => {
229
+ const bySlug = new Map(
230
+ providers.map((provider) => [provider.slug, provider.requirements_md])
231
+ )
232
+ return models.map((model) => ({
233
+ ...model,
234
+ capabilities_by_provider: model.capabilities_by_provider.map((entry) => ({
235
+ ...entry,
236
+ capabilities: entry.capabilities.map((capability) => {
237
+ const report = capability.report
238
+ const requirement = report?.requirements?.['provider']
239
+ if (
240
+ report == null ||
241
+ requirement == null ||
242
+ !isMissingMessage(requirement.message)
243
+ )
244
+ return capability
245
+ const message = bySlug.get(entry.provider.slug)
246
+ return {
247
+ ...capability,
248
+ report: {
249
+ ...report,
250
+ requirements: {
251
+ ...report.requirements,
252
+ provider: {
253
+ ...requirement,
254
+ message:
255
+ typeof message === 'string' && !isMissingMessage(message)
256
+ ? message.trim()
257
+ : 'Additional integration requirements apply. Check with your integration provider.',
258
+ },
259
+ },
260
+ },
261
+ }
262
+ }),
263
+ })),
264
+ }))
265
+ }
266
+
195
267
  /** Keep specific constraints; replace boilerplate with an actionable setup note. */
196
268
  export const getCapabilityRequirementMessages = (
197
269
  capability: SupportedCapability
198
270
  ): string[] => {
199
- const messages = new Set(capability.requirements)
271
+ const messages = new Set(
272
+ capability.requirements.map((message) =>
273
+ isMissingMessage(message) ? 'Additional setup is required.' : message
274
+ )
275
+ )
200
276
  if (capability.supported === 'conditionally') {
201
277
  if (
202
278
  capability.details != null &&
279
+ !isMissingMessage(capability.details) &&
203
280
  !isGenericSupportDetail(capability.details)
204
281
  )
205
282
  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'
@@ -189,6 +195,7 @@ export type CapabilityName =
189
195
  | 'can_remotely_unlock'
190
196
  | 'can_remotely_lock'
191
197
  | 'can_encode_plastic_cards'
198
+ | 'can_assign_plastic_cards'
192
199
  | 'can_provision_mobile_keys'
193
200
  | 'can_provision_wallet_keys'
194
201
  | 'can_hvac_cool'
@@ -391,6 +398,11 @@ export interface ManufacturersListResponse {
391
398
  pagination: Pagination
392
399
  }
393
400
 
401
+ export interface ProvidersListResponse {
402
+ providers: ProviderRequirements[]
403
+ pagination: Pagination
404
+ }
405
+
394
406
  export interface EcosystemErrorResponse {
395
407
  ok: false
396
408
  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.4'
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);