@seamapi/react 1.63.1 → 1.65.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 (82) hide show
  1. package/README.md +61 -4
  2. package/dist/elements.js +6133 -6020
  3. package/dist/elements.js.map +1 -1
  4. package/dist/index.css +2 -4
  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/SeamProvider.d.ts +2 -1
  9. package/lib/seam/SeamProvider.js +10 -4
  10. package/lib/seam/SeamProvider.js.map +1 -1
  11. package/lib/seam/components/AccessCodeDetails/AccessCodeDetails.d.ts +1 -1
  12. package/lib/seam/components/AccessCodeDetails/AccessCodeDetails.js +11 -13
  13. package/lib/seam/components/AccessCodeDetails/AccessCodeDetails.js.map +1 -1
  14. package/lib/seam/components/AccessCodeTable/AccessCodeHealthBar.d.ts +4 -1
  15. package/lib/seam/components/AccessCodeTable/AccessCodeHealthBar.js +3 -2
  16. package/lib/seam/components/AccessCodeTable/AccessCodeHealthBar.js.map +1 -1
  17. package/lib/seam/components/AccessCodeTable/AccessCodeTable.d.ts +1 -1
  18. package/lib/seam/components/AccessCodeTable/AccessCodeTable.js +15 -11
  19. package/lib/seam/components/AccessCodeTable/AccessCodeTable.js.map +1 -1
  20. package/lib/seam/components/ClimateSettingScheduleDetails/ClimateSettingScheduleDetails.d.ts +1 -1
  21. package/lib/seam/components/ClimateSettingScheduleDetails/ClimateSettingScheduleDetails.js +2 -2
  22. package/lib/seam/components/ClimateSettingScheduleDetails/ClimateSettingScheduleDetails.js.map +1 -1
  23. package/lib/seam/components/ClimateSettingScheduleTable/ClimateSettingScheduleTable.d.ts +1 -1
  24. package/lib/seam/components/ClimateSettingScheduleTable/ClimateSettingScheduleTable.js +12 -7
  25. package/lib/seam/components/ClimateSettingScheduleTable/ClimateSettingScheduleTable.js.map +1 -1
  26. package/lib/seam/components/DeviceDetails/LockDeviceDetails.js +11 -4
  27. package/lib/seam/components/DeviceDetails/LockDeviceDetails.js.map +1 -1
  28. package/lib/seam/components/DeviceDetails/ThermostatDeviceDetails.d.ts +1 -1
  29. package/lib/seam/components/DeviceDetails/ThermostatDeviceDetails.js +2 -2
  30. package/lib/seam/components/DeviceDetails/ThermostatDeviceDetails.js.map +1 -1
  31. package/lib/seam/components/DeviceTable/DeviceHealthBar.d.ts +3 -1
  32. package/lib/seam/components/DeviceTable/DeviceHealthBar.js +4 -3
  33. package/lib/seam/components/DeviceTable/DeviceHealthBar.js.map +1 -1
  34. package/lib/seam/components/DeviceTable/DeviceTable.d.ts +1 -1
  35. package/lib/seam/components/DeviceTable/DeviceTable.js +14 -9
  36. package/lib/seam/components/DeviceTable/DeviceTable.js.map +1 -1
  37. package/lib/seam/components/SupportedDeviceTable/use-device-model.d.ts +7 -0
  38. package/lib/seam/components/SupportedDeviceTable/use-device-model.js +18 -0
  39. package/lib/seam/components/SupportedDeviceTable/use-device-model.js.map +1 -0
  40. package/lib/seam/components/SupportedDeviceTable/use-device-models.d.ts +7 -0
  41. package/lib/seam/components/SupportedDeviceTable/use-device-models.js +17 -0
  42. package/lib/seam/components/SupportedDeviceTable/use-device-models.js.map +1 -0
  43. package/lib/seam/components/SupportedDeviceTable/use-manufacturer.d.ts +7 -0
  44. package/lib/seam/components/SupportedDeviceTable/use-manufacturer.js +18 -0
  45. package/lib/seam/components/SupportedDeviceTable/use-manufacturer.js.map +1 -0
  46. package/lib/seam/components/SupportedDeviceTable/use-manufacturers.d.ts +7 -0
  47. package/lib/seam/components/SupportedDeviceTable/use-manufacturers.js +17 -0
  48. package/lib/seam/components/SupportedDeviceTable/use-manufacturers.js.map +1 -0
  49. package/lib/seam/components/common-props.d.ts +3 -0
  50. package/lib/seam/components/common-props.js.map +1 -1
  51. package/lib/seam/filters.d.ts +8 -0
  52. package/lib/seam/filters.js +16 -0
  53. package/lib/seam/filters.js.map +1 -0
  54. package/lib/telemetry/client.js.map +1 -1
  55. package/lib/ui/Snackbar/Snackbar.d.ts +1 -1
  56. package/lib/ui/Snackbar/Snackbar.js +1 -1
  57. package/lib/ui/Snackbar/Snackbar.js.map +1 -1
  58. package/lib/version.d.ts +1 -1
  59. package/lib/version.js +1 -1
  60. package/package.json +15 -5
  61. package/src/lib/element.tsx +6 -1
  62. package/src/lib/seam/SeamProvider.tsx +17 -2
  63. package/src/lib/seam/components/AccessCodeDetails/AccessCodeDetails.tsx +24 -30
  64. package/src/lib/seam/components/AccessCodeTable/AccessCodeHealthBar.tsx +9 -1
  65. package/src/lib/seam/components/AccessCodeTable/AccessCodeTable.tsx +32 -5
  66. package/src/lib/seam/components/ClimateSettingScheduleDetails/ClimateSettingScheduleDetails.tsx +4 -0
  67. package/src/lib/seam/components/ClimateSettingScheduleTable/ClimateSettingScheduleTable.tsx +21 -5
  68. package/src/lib/seam/components/DeviceDetails/LockDeviceDetails.tsx +19 -8
  69. package/src/lib/seam/components/DeviceDetails/ThermostatDeviceDetails.tsx +4 -0
  70. package/src/lib/seam/components/DeviceTable/DeviceHealthBar.tsx +10 -2
  71. package/src/lib/seam/components/DeviceTable/DeviceTable.tsx +29 -7
  72. package/src/lib/seam/components/SupportedDeviceTable/use-device-model.ts +45 -0
  73. package/src/lib/seam/components/SupportedDeviceTable/use-device-models.ts +43 -0
  74. package/src/lib/seam/components/SupportedDeviceTable/use-manufacturer.ts +45 -0
  75. package/src/lib/seam/components/SupportedDeviceTable/use-manufacturers.ts +43 -0
  76. package/src/lib/seam/components/common-props.tsx +10 -0
  77. package/src/lib/seam/filters.ts +32 -0
  78. package/src/lib/telemetry/client.ts +3 -3
  79. package/src/lib/ui/Snackbar/Snackbar.tsx +2 -2
  80. package/src/lib/version.ts +1 -1
  81. package/src/styles/_device-details.scss +1 -2
  82. package/src/styles/_thermostat.scss +1 -2
package/README.md CHANGED
@@ -87,13 +87,58 @@ export function App() {
87
87
  <seam-device-table publishable-key="your_publishable_key"></seam-device-table>
88
88
  <script
89
89
  type="module"
90
- src="https://react.seam.co/v/1.63.1/dist/elements.js"
90
+ src="https://react.seam.co/v/1.65.0/dist/elements.js"
91
91
  ></script>
92
92
  </body>
93
93
  ```
94
94
 
95
95
  > Update the version in the script tag above with the exact version of this package you would like to use.
96
96
 
97
+ #### Web component attributes and properties
98
+
99
+ Each React component is defined as a custom element:
100
+
101
+ - The element name is in in kebab-case,
102
+ e.g., `<DeviceTable>` becomes `<seam-device-table>`.
103
+ - Each element is wrapped in a `<SeamProvider />`.
104
+ - An attribute and custom property is defined for each `<SeamProvider />` prop and component prop.
105
+ - Attributes are in kebab-case and properties are in snakeCase.
106
+
107
+ Attributes map directly to component props.
108
+ All attributes are passed as strings, thus non-string props have some limitations:
109
+
110
+ - Number props will be parsed using `parseFloat`.
111
+ - Boolean props should be passed as `true` or `false`, e.g., `disable-css-injection="true"` or `disable-css-injection="false"`.
112
+ - Array props may be passed as JSON, e.g., `device-ids="["foo", "bar"]"`,
113
+ or CSV, e.g., `device-ids="foo,bar"`.
114
+ - Function and object props should not be passed as attributes.
115
+ Set them as properties instead.
116
+
117
+ Use custom properties to work directly with JavaScript objects and primitives.
118
+
119
+ - This will avoid any issues with string parsing and serialization.
120
+ - Use the `onSessionUpdate` prop to maintain a reference to the internal Seam client.
121
+
122
+ For example,
123
+
124
+ ```js
125
+ globalThis.customElements.whenDefined('seam-device-table').then(() => {
126
+ const elements = globalThis.document.getElementsByTagName('seam-device-table')
127
+ const element = elements[0]
128
+ if (element == null) {
129
+ throw new Error('Cannot find seam-device-table in document')
130
+ }
131
+ let seam
132
+ element.onSessionUpdate = (client) => {
133
+ seam = client
134
+ }
135
+ element.onDeviceClick = (deviceId) => {
136
+ if (seam == null) return
137
+ seam.devices.get({ device_id: deviceId }).then(console.log)
138
+ }
139
+ })
140
+ ```
141
+
97
142
  [Seam Console]: https://console.seam.co/
98
143
 
99
144
  ### React Hooks
@@ -433,10 +478,22 @@ This is the same storybook published on [react.seam.co](https://react.seam.co).
433
478
  This project uses a [fake version of Seam Connect](https://github.com/seamapi/fake-seam-connect)
434
479
  to have deterministic responses for rendering views and running tests.
435
480
 
436
- Edit the seed data for the fake or find relevant ids for testing components here:
481
+ The tests use the [default seed](https://github.com/seamapi/fake-seam-connect/blob/main/src/lib/database/seed.ts).
482
+
483
+ Edit the Storybook seed data for the fake or find relevant ids for testing components here:
484
+ [Storybook fake seed](./.storybook/seed-fake.js).
485
+
486
+ ### Fake Devicedb
437
487
 
438
- - [Storybook fake seed](./.storybook/seed-fake.js).
439
- - [Vitest fake seed](./test/fixtures/seed-fake.ts).
488
+ Fake Seam Connect optionally depends on a [fake version of the Seam Devicedb](https://github.com/seamapi/fake-devicedb).
489
+ This is required by some components and hooks in this project.
490
+
491
+ The seed data for the fake is generated by pulling data from the real API.
492
+ Update this seed data with
493
+
494
+ ```
495
+ $ npm run storybook:update-devicedb-seed
496
+ ```
440
497
 
441
498
  ### Tests
442
499