@seamapi/react 1.63.1 → 1.64.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.
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.64.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