@seamapi/react 1.17.0 → 1.18.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 (57) hide show
  1. package/README.md +2 -4
  2. package/dist/elements.js +3220 -3200
  3. package/dist/elements.js.map +1 -1
  4. package/lib/seam/components/AccessCodeDetails/AccessCodeDevice.js +11 -7
  5. package/lib/seam/components/AccessCodeDetails/AccessCodeDevice.js.map +1 -1
  6. package/lib/seam/components/AccessCodeTable/AccessCodeTable.js +2 -2
  7. package/lib/seam/components/AccessCodeTable/AccessCodeTable.js.map +1 -1
  8. package/lib/seam/components/DeviceDetails/DeviceDetails.js +6 -69
  9. package/lib/seam/components/DeviceDetails/DeviceDetails.js.map +1 -1
  10. package/lib/seam/components/DeviceDetails/DeviceModel.d.ts +2 -3
  11. package/lib/seam/components/DeviceDetails/DeviceModel.js +1 -11
  12. package/lib/seam/components/DeviceDetails/DeviceModel.js.map +1 -1
  13. package/lib/seam/components/DeviceDetails/LockDeviceDetails.d.ts +7 -0
  14. package/lib/seam/components/DeviceDetails/LockDeviceDetails.js +68 -0
  15. package/lib/seam/components/DeviceDetails/LockDeviceDetails.js.map +1 -0
  16. package/lib/seam/components/DeviceTable/DeviceRow.js +1 -12
  17. package/lib/seam/components/DeviceTable/DeviceRow.js.map +1 -1
  18. package/lib/seam/components/DeviceTable/DeviceTable.js +4 -3
  19. package/lib/seam/components/DeviceTable/DeviceTable.js.map +1 -1
  20. package/lib/seam/devices/use-device.d.ts +2 -2
  21. package/lib/seam/devices/use-device.js.map +1 -1
  22. package/lib/seam/devices/use-devices.d.ts +2 -2
  23. package/lib/seam/devices/use-devices.js.map +1 -1
  24. package/lib/seam/devices/use-toggle-lock.d.ts +1 -1
  25. package/lib/seam/devices/use-toggle-lock.js +1 -1
  26. package/lib/seam/devices/use-toggle-lock.js.map +1 -1
  27. package/lib/ui/device/BatteryStatus.d.ts +2 -2
  28. package/lib/ui/device/BatteryStatus.js +9 -15
  29. package/lib/ui/device/BatteryStatus.js.map +1 -1
  30. package/lib/ui/device/DeviceImage.d.ts +2 -2
  31. package/lib/ui/device/DeviceImage.js.map +1 -1
  32. package/lib/ui/device/LockStatus.d.ts +3 -3
  33. package/lib/ui/device/LockStatus.js +4 -0
  34. package/lib/ui/device/LockStatus.js.map +1 -1
  35. package/lib/ui/device/OnlineStatus.d.ts +2 -2
  36. package/lib/version.d.ts +1 -1
  37. package/lib/version.js +1 -1
  38. package/package.json +3 -3
  39. package/src/lib/seam/components/AccessCodeDetails/AccessCodeDevice.tsx +13 -8
  40. package/src/lib/seam/components/AccessCodeTable/AccessCodeTable.tsx +2 -2
  41. package/src/lib/seam/components/DeviceDetails/DeviceDetails.tsx +7 -153
  42. package/src/lib/seam/components/DeviceDetails/DeviceModel.tsx +5 -19
  43. package/src/lib/seam/components/DeviceDetails/LockDeviceDetails.tsx +158 -0
  44. package/src/lib/seam/components/DeviceTable/DeviceRow.tsx +3 -15
  45. package/src/lib/seam/components/DeviceTable/DeviceTable.tsx +4 -3
  46. package/src/lib/seam/devices/use-device.ts +2 -3
  47. package/src/lib/seam/devices/use-devices.ts +2 -3
  48. package/src/lib/seam/devices/use-toggle-lock.ts +7 -8
  49. package/src/lib/ui/device/BatteryStatus.tsx +19 -29
  50. package/src/lib/ui/device/DeviceImage.tsx +4 -2
  51. package/src/lib/ui/device/LockStatus.tsx +7 -3
  52. package/src/lib/ui/device/OnlineStatus.tsx +2 -2
  53. package/src/lib/version.ts +1 -1
  54. package/lib/seam/devices/types.d.ts +0 -2
  55. package/lib/seam/devices/types.js +0 -2
  56. package/lib/seam/devices/types.js.map +0 -1
  57. package/src/lib/seam/devices/types.ts +0 -5
@@ -1,4 +1,4 @@
1
- import type { LockDevice } from 'seamapi'
1
+ import type { BatteryStatus as SeamBatteryStatus, CommonDevice } from 'seamapi'
2
2
 
3
3
  import { BatteryLevelCriticalIcon } from 'lib/icons/BatteryLevelCritical.js'
4
4
  import { BatteryLevelFullIcon } from 'lib/icons/BatteryLevelFull.js'
@@ -6,31 +6,23 @@ import { BatteryLevelHighIcon } from 'lib/icons/BatteryLevelHigh.js'
6
6
  import { BatteryLevelLowIcon } from 'lib/icons/BatteryLevelLow.js'
7
7
 
8
8
  interface BatteryStatusProps {
9
- device: LockDevice
9
+ device: CommonDevice
10
10
  }
11
11
 
12
12
  export function BatteryStatus(props: BatteryStatusProps): JSX.Element {
13
- const {
14
- device: {
15
- properties: { battery_level: batteryLevel },
16
- },
17
- } = props
18
-
19
13
  return (
20
14
  <div className='seam-battery-status'>
21
- <Content batteryLevel={batteryLevel} />
15
+ <Content status={props.device.properties.battery?.status} />
22
16
  </div>
23
17
  )
24
18
  }
25
19
 
26
- function Content(props: { batteryLevel?: number }): JSX.Element | null {
27
- const { batteryLevel } = props
28
-
29
- if (batteryLevel == null) {
30
- return null
31
- }
20
+ function Content(props: {
21
+ status: SeamBatteryStatus | null | undefined
22
+ }): JSX.Element | null {
23
+ const { status } = props
32
24
 
33
- if (batteryLevel > batteryThreshold.full) {
25
+ if (status === 'full') {
34
26
  return (
35
27
  <>
36
28
  <BatteryLevelFullIcon />
@@ -39,7 +31,7 @@ function Content(props: { batteryLevel?: number }): JSX.Element | null {
39
31
  )
40
32
  }
41
33
 
42
- if (batteryLevel > batteryThreshold.high) {
34
+ if (status === 'good') {
43
35
  return (
44
36
  <>
45
37
  <BatteryLevelHighIcon />
@@ -48,7 +40,7 @@ function Content(props: { batteryLevel?: number }): JSX.Element | null {
48
40
  )
49
41
  }
50
42
 
51
- if (batteryLevel > batteryThreshold.low) {
43
+ if (status === 'low') {
52
44
  return (
53
45
  <>
54
46
  <BatteryLevelLowIcon />
@@ -57,18 +49,16 @@ function Content(props: { batteryLevel?: number }): JSX.Element | null {
57
49
  )
58
50
  }
59
51
 
60
- return (
61
- <>
62
- <BatteryLevelCriticalIcon />
63
- <span className='seam-text-danger'>{t.critical}</span>
64
- </>
65
- )
66
- }
52
+ if (status === 'critical') {
53
+ return (
54
+ <>
55
+ <BatteryLevelCriticalIcon />
56
+ <span className='seam-text-danger'>{t.critical}</span>
57
+ </>
58
+ )
59
+ }
67
60
 
68
- const batteryThreshold = {
69
- full: 0.85,
70
- high: 0.6,
71
- low: 0.3,
61
+ return null
72
62
  }
73
63
 
74
64
  const t = {
@@ -1,8 +1,10 @@
1
1
  import type { HTMLAttributes } from 'react'
2
- import type { LockDevice } from 'seamapi'
2
+ import type { CommonDevice } from 'seamapi'
3
3
 
4
4
  export function DeviceImage(
5
- props: { device: LockDevice } & HTMLAttributes<HTMLImageElement>
5
+ props: {
6
+ device: CommonDevice
7
+ } & HTMLAttributes<HTMLImageElement>
6
8
  ): JSX.Element {
7
9
  const { device, ...imageProps } = props
8
10
 
@@ -1,13 +1,17 @@
1
- import type { LockDevice } from 'seamapi'
1
+ import { type CommonDevice, isLockDevice } from 'seamapi'
2
2
 
3
3
  import { LockLockedIcon } from 'lib/icons/LockLocked.js'
4
4
  import { LockUnlockedIcon } from 'lib/icons/LockUnlocked.js'
5
5
 
6
6
  interface LockStatusProps {
7
- device: LockDevice
7
+ device: CommonDevice
8
8
  }
9
9
 
10
- export function LockStatus(props: LockStatusProps): JSX.Element {
10
+ export function LockStatus(props: LockStatusProps): JSX.Element | null {
11
+ if (!isLockDevice(props.device)) {
12
+ return null
13
+ }
14
+
11
15
  const {
12
16
  device: {
13
17
  properties: { locked },
@@ -1,10 +1,10 @@
1
- import type { LockDevice } from 'seamapi'
1
+ import type { CommonDevice } from 'seamapi'
2
2
 
3
3
  import { OnlineStatusDeviceOfflineIcon } from 'lib/icons/OnlineStatusDeviceOffline.js'
4
4
  import { OnlineStatusOnlineIcon } from 'lib/icons/OnlineStatusOnline.js'
5
5
 
6
6
  interface OnlineStatusProps {
7
- device: LockDevice
7
+ device: CommonDevice
8
8
  }
9
9
 
10
10
  export function OnlineStatus(props: OnlineStatusProps): JSX.Element {
@@ -1,3 +1,3 @@
1
- const seamapiReactVersion = '1.17.0'
1
+ const seamapiReactVersion = '1.18.0'
2
2
 
3
3
  export default seamapiReactVersion
@@ -1,2 +0,0 @@
1
- import type { CommonDeviceProperties, Device, LockDevice } from 'seamapi';
2
- export declare const isLockDevice: (device: Device<CommonDeviceProperties, string> | LockDevice) => device is LockDevice;
@@ -1,2 +0,0 @@
1
- export const isLockDevice = (device) => 'locked' in device.properties;
2
- //# sourceMappingURL=types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/lib/seam/devices/types.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,YAAY,GAAG,CAC1B,MAA2D,EACrC,EAAE,CAAC,QAAQ,IAAI,MAAM,CAAC,UAAU,CAAA"}
@@ -1,5 +0,0 @@
1
- import type { CommonDeviceProperties, Device, LockDevice } from 'seamapi'
2
-
3
- export const isLockDevice = (
4
- device: Device<CommonDeviceProperties, string> | LockDevice
5
- ): device is LockDevice => 'locked' in device.properties