@seamapi/react 3.1.2 → 4.0.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 (145) hide show
  1. package/README.md +2 -2
  2. package/dist/elements.js +11198 -11349
  3. package/dist/elements.js.map +1 -1
  4. package/dist/index.css +8 -193
  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/components/AccessCodeDetails/AccessCodeDetails.d.ts +1 -1
  9. package/lib/seam/components/AccessCodeDetails/AccessCodeDetails.js +3 -3
  10. package/lib/seam/components/AccessCodeDetails/AccessCodeDetails.js.map +1 -1
  11. package/lib/seam/components/AccessCodeTable/AccessCodeTable.d.ts +1 -1
  12. package/lib/seam/components/AccessCodeTable/AccessCodeTable.js +4 -4
  13. package/lib/seam/components/AccessCodeTable/AccessCodeTable.js.map +1 -1
  14. package/lib/seam/components/DeviceDetails/DeviceDetails.d.ts +1 -1
  15. package/lib/seam/components/DeviceDetails/DeviceDetails.js +1 -2
  16. package/lib/seam/components/DeviceDetails/DeviceDetails.js.map +1 -1
  17. package/lib/seam/components/DeviceDetails/LockDeviceDetails.d.ts +1 -1
  18. package/lib/seam/components/DeviceDetails/LockDeviceDetails.js +2 -2
  19. package/lib/seam/components/DeviceDetails/LockDeviceDetails.js.map +1 -1
  20. package/lib/seam/components/DeviceDetails/ThermostatDeviceDetails.d.ts +1 -1
  21. package/lib/seam/components/DeviceDetails/ThermostatDeviceDetails.js +2 -46
  22. package/lib/seam/components/DeviceDetails/ThermostatDeviceDetails.js.map +1 -1
  23. package/lib/seam/components/DeviceTable/DeviceTable.d.ts +1 -1
  24. package/lib/seam/components/DeviceTable/DeviceTable.js +2 -2
  25. package/lib/seam/components/DeviceTable/DeviceTable.js.map +1 -1
  26. package/lib/seam/components/common-props.d.ts +0 -1
  27. package/lib/seam/components/common-props.js.map +1 -1
  28. package/lib/seam/components/index.d.ts +0 -2
  29. package/lib/seam/components/index.js +0 -2
  30. package/lib/seam/components/index.js.map +1 -1
  31. package/lib/seam/index.d.ts +0 -2
  32. package/lib/seam/index.js +0 -2
  33. package/lib/seam/index.js.map +1 -1
  34. package/lib/seam/thermostats/thermostat-device.d.ts +0 -1
  35. package/lib/seam/thermostats/thermostat-device.js.map +1 -1
  36. package/lib/ui/thermostat/FanModeMenu.js +1 -0
  37. package/lib/ui/thermostat/FanModeMenu.js.map +1 -1
  38. package/lib/version.d.ts +1 -1
  39. package/lib/version.js +1 -1
  40. package/package.json +8 -8
  41. package/src/lib/element.tsx +0 -1
  42. package/src/lib/seam/components/AccessCodeDetails/AccessCodeDetails.tsx +0 -3
  43. package/src/lib/seam/components/AccessCodeTable/AccessCodeTable.tsx +0 -4
  44. package/src/lib/seam/components/DeviceDetails/DeviceDetails.tsx +0 -2
  45. package/src/lib/seam/components/DeviceDetails/LockDeviceDetails.tsx +0 -2
  46. package/src/lib/seam/components/DeviceDetails/ThermostatDeviceDetails.tsx +0 -144
  47. package/src/lib/seam/components/DeviceTable/DeviceTable.tsx +0 -2
  48. package/src/lib/seam/components/common-props.tsx +0 -1
  49. package/src/lib/seam/components/elements.ts +0 -2
  50. package/src/lib/seam/components/index.ts +0 -2
  51. package/src/lib/seam/index.ts +0 -2
  52. package/src/lib/seam/thermostats/thermostat-device.ts +0 -1
  53. package/src/lib/ui/thermostat/FanModeMenu.tsx +1 -0
  54. package/src/lib/version.ts +1 -1
  55. package/src/styles/_main.scss +0 -4
  56. package/src/styles/_thermostat.scss +0 -98
  57. package/lib/seam/components/ClimateSettingScheduleDetails/ClimateSettingScheduleCard.d.ts +0 -7
  58. package/lib/seam/components/ClimateSettingScheduleDetails/ClimateSettingScheduleCard.js +0 -43
  59. package/lib/seam/components/ClimateSettingScheduleDetails/ClimateSettingScheduleCard.js.map +0 -1
  60. package/lib/seam/components/ClimateSettingScheduleDetails/ClimateSettingScheduleDetails.d.ts +0 -7
  61. package/lib/seam/components/ClimateSettingScheduleDetails/ClimateSettingScheduleDetails.js +0 -55
  62. package/lib/seam/components/ClimateSettingScheduleDetails/ClimateSettingScheduleDetails.js.map +0 -1
  63. package/lib/seam/components/ClimateSettingScheduleDetails/ClimateSettingScheduleDeviceBar.d.ts +0 -5
  64. package/lib/seam/components/ClimateSettingScheduleDetails/ClimateSettingScheduleDeviceBar.js +0 -31
  65. package/lib/seam/components/ClimateSettingScheduleDetails/ClimateSettingScheduleDeviceBar.js.map +0 -1
  66. package/lib/seam/components/ClimateSettingScheduleDetails/dates.d.ts +0 -1
  67. package/lib/seam/components/ClimateSettingScheduleDetails/dates.js +0 -9
  68. package/lib/seam/components/ClimateSettingScheduleDetails/dates.js.map +0 -1
  69. package/lib/seam/components/ClimateSettingScheduleTable/ClimateSettingScheduleRow.d.ts +0 -8
  70. package/lib/seam/components/ClimateSettingScheduleTable/ClimateSettingScheduleRow.js +0 -10
  71. package/lib/seam/components/ClimateSettingScheduleTable/ClimateSettingScheduleRow.js.map +0 -1
  72. package/lib/seam/components/ClimateSettingScheduleTable/ClimateSettingScheduleRowDetails.d.ts +0 -5
  73. package/lib/seam/components/ClimateSettingScheduleTable/ClimateSettingScheduleRowDetails.js +0 -28
  74. package/lib/seam/components/ClimateSettingScheduleTable/ClimateSettingScheduleRowDetails.js.map +0 -1
  75. package/lib/seam/components/ClimateSettingScheduleTable/ClimateSettingScheduleTable.d.ts +0 -14
  76. package/lib/seam/components/ClimateSettingScheduleTable/ClimateSettingScheduleTable.js +0 -80
  77. package/lib/seam/components/ClimateSettingScheduleTable/ClimateSettingScheduleTable.js.map +0 -1
  78. package/lib/seam/components/CreateClimateSettingScheduleForm/CreateClimateSettingScheduleForm.d.ts +0 -5
  79. package/lib/seam/components/CreateClimateSettingScheduleForm/CreateClimateSettingScheduleForm.js +0 -29
  80. package/lib/seam/components/CreateClimateSettingScheduleForm/CreateClimateSettingScheduleForm.js.map +0 -1
  81. package/lib/seam/thermostats/climate-setting-schedules/use-climate-setting-schedule.d.ts +0 -6
  82. package/lib/seam/thermostats/climate-setting-schedules/use-climate-setting-schedule.js +0 -16
  83. package/lib/seam/thermostats/climate-setting-schedules/use-climate-setting-schedule.js.map +0 -1
  84. package/lib/seam/thermostats/climate-setting-schedules/use-climate-setting-schedules.d.ts +0 -6
  85. package/lib/seam/thermostats/climate-setting-schedules/use-climate-setting-schedules.js +0 -28
  86. package/lib/seam/thermostats/climate-setting-schedules/use-climate-setting-schedules.js.map +0 -1
  87. package/lib/seam/thermostats/climate-setting-schedules/use-create-climate-setting-schedule.d.ts +0 -7
  88. package/lib/seam/thermostats/climate-setting-schedules/use-create-climate-setting-schedule.js +0 -25
  89. package/lib/seam/thermostats/climate-setting-schedules/use-create-climate-setting-schedule.js.map +0 -1
  90. package/lib/seam/thermostats/climate-setting-schedules/use-delete-climate-setting-schedule.d.ts +0 -6
  91. package/lib/seam/thermostats/climate-setting-schedules/use-delete-climate-setting-schedule.js +0 -27
  92. package/lib/seam/thermostats/climate-setting-schedules/use-delete-climate-setting-schedule.js.map +0 -1
  93. package/lib/seam/thermostats/climate-setting-schedules/use-update-climate-setting-schedule.d.ts +0 -6
  94. package/lib/seam/thermostats/climate-setting-schedules/use-update-climate-setting-schedule.js +0 -46
  95. package/lib/seam/thermostats/climate-setting-schedules/use-update-climate-setting-schedule.js.map +0 -1
  96. package/lib/seam/thermostats/use-update-thermostat.d.ts +0 -6
  97. package/lib/seam/thermostats/use-update-thermostat.js +0 -51
  98. package/lib/seam/thermostats/use-update-thermostat.js.map +0 -1
  99. package/lib/ui/ClimateSettingForm/ClimateSettingScheduleForm.d.ts +0 -32
  100. package/lib/ui/ClimateSettingForm/ClimateSettingScheduleForm.js +0 -85
  101. package/lib/ui/ClimateSettingForm/ClimateSettingScheduleForm.js.map +0 -1
  102. package/lib/ui/ClimateSettingForm/ClimateSettingScheduleFormClimateSetting.d.ts +0 -13
  103. package/lib/ui/ClimateSettingForm/ClimateSettingScheduleFormClimateSetting.js +0 -44
  104. package/lib/ui/ClimateSettingForm/ClimateSettingScheduleFormClimateSetting.js.map +0 -1
  105. package/lib/ui/ClimateSettingForm/ClimateSettingScheduleFormDefaultClimateSetting.d.ts +0 -10
  106. package/lib/ui/ClimateSettingForm/ClimateSettingScheduleFormDefaultClimateSetting.js +0 -24
  107. package/lib/ui/ClimateSettingForm/ClimateSettingScheduleFormDefaultClimateSetting.js.map +0 -1
  108. package/lib/ui/ClimateSettingForm/ClimateSettingScheduleFormDeviceSelect.d.ts +0 -10
  109. package/lib/ui/ClimateSettingForm/ClimateSettingScheduleFormDeviceSelect.js +0 -10
  110. package/lib/ui/ClimateSettingForm/ClimateSettingScheduleFormDeviceSelect.js.map +0 -1
  111. package/lib/ui/ClimateSettingForm/ClimateSettingScheduleFormNameAndSchedule.d.ts +0 -15
  112. package/lib/ui/ClimateSettingForm/ClimateSettingScheduleFormNameAndSchedule.js +0 -30
  113. package/lib/ui/ClimateSettingForm/ClimateSettingScheduleFormNameAndSchedule.js.map +0 -1
  114. package/lib/ui/ClimateSettingForm/ClimateSettingScheduleFormTimeZonePicker.d.ts +0 -9
  115. package/lib/ui/ClimateSettingForm/ClimateSettingScheduleFormTimeZonePicker.js +0 -16
  116. package/lib/ui/ClimateSettingForm/ClimateSettingScheduleFormTimeZonePicker.js.map +0 -1
  117. package/lib/ui/ClimateSettingForm/set-point-bounds.d.ts +0 -4
  118. package/lib/ui/ClimateSettingForm/set-point-bounds.js +0 -17
  119. package/lib/ui/ClimateSettingForm/set-point-bounds.js.map +0 -1
  120. package/src/lib/seam/components/ClimateSettingScheduleDetails/ClimateSettingScheduleCard.tsx +0 -107
  121. package/src/lib/seam/components/ClimateSettingScheduleDetails/ClimateSettingScheduleDetails.element.ts +0 -11
  122. package/src/lib/seam/components/ClimateSettingScheduleDetails/ClimateSettingScheduleDetails.tsx +0 -175
  123. package/src/lib/seam/components/ClimateSettingScheduleDetails/ClimateSettingScheduleDeviceBar.tsx +0 -72
  124. package/src/lib/seam/components/ClimateSettingScheduleDetails/dates.ts +0 -10
  125. package/src/lib/seam/components/ClimateSettingScheduleTable/ClimateSettingScheduleRow.tsx +0 -35
  126. package/src/lib/seam/components/ClimateSettingScheduleTable/ClimateSettingScheduleRowDetails.tsx +0 -60
  127. package/src/lib/seam/components/ClimateSettingScheduleTable/ClimateSettingScheduleTable.element.ts +0 -17
  128. package/src/lib/seam/components/ClimateSettingScheduleTable/ClimateSettingScheduleTable.tsx +0 -220
  129. package/src/lib/seam/components/CreateClimateSettingScheduleForm/CreateClimateSettingScheduleForm.element.ts +0 -9
  130. package/src/lib/seam/components/CreateClimateSettingScheduleForm/CreateClimateSettingScheduleForm.tsx +0 -56
  131. package/src/lib/seam/thermostats/climate-setting-schedules/use-climate-setting-schedule.ts +0 -34
  132. package/src/lib/seam/thermostats/climate-setting-schedules/use-climate-setting-schedules.ts +0 -53
  133. package/src/lib/seam/thermostats/climate-setting-schedules/use-create-climate-setting-schedule.ts +0 -53
  134. package/src/lib/seam/thermostats/climate-setting-schedules/use-delete-climate-setting-schedule.ts +0 -51
  135. package/src/lib/seam/thermostats/climate-setting-schedules/use-update-climate-setting-schedule.ts +0 -83
  136. package/src/lib/seam/thermostats/use-update-thermostat.ts +0 -90
  137. package/src/lib/ui/ClimateSettingForm/ClimateSettingScheduleForm.tsx +0 -189
  138. package/src/lib/ui/ClimateSettingForm/ClimateSettingScheduleFormClimateSetting.tsx +0 -118
  139. package/src/lib/ui/ClimateSettingForm/ClimateSettingScheduleFormDefaultClimateSetting.tsx +0 -79
  140. package/src/lib/ui/ClimateSettingForm/ClimateSettingScheduleFormDeviceSelect.tsx +0 -36
  141. package/src/lib/ui/ClimateSettingForm/ClimateSettingScheduleFormNameAndSchedule.tsx +0 -120
  142. package/src/lib/ui/ClimateSettingForm/ClimateSettingScheduleFormTimeZonePicker.tsx +0 -43
  143. package/src/lib/ui/ClimateSettingForm/set-point-bounds.ts +0 -31
  144. package/src/styles/_climate-setting-schedule-details.scss +0 -44
  145. package/src/styles/_climate-setting-schedule-form.scss +0 -111
@@ -1,90 +0,0 @@
1
- import type {
2
- SeamHttpApiError,
3
- ThermostatsUpdateBody,
4
- } from '@seamapi/http/connect'
5
- import type { Device } from '@seamapi/types/connect'
6
- import {
7
- useMutation,
8
- type UseMutationResult,
9
- useQueryClient,
10
- } from '@tanstack/react-query'
11
-
12
- import { shake } from 'lib/object.js'
13
- import { NullSeamClientError, useSeamClient } from 'lib/seam/use-seam-client.js'
14
-
15
- export type UseUpdateThermostatParams = never
16
-
17
- export type UseUpdateThermostatData = undefined
18
-
19
- export type UseUpdateThermostatMutationVariables = ThermostatsUpdateBody
20
-
21
- export function useUpdateThermostat(): UseMutationResult<
22
- UseUpdateThermostatData,
23
- SeamHttpApiError,
24
- UseUpdateThermostatMutationVariables
25
- > {
26
- const { client } = useSeamClient()
27
- const queryClient = useQueryClient()
28
-
29
- return useMutation<
30
- UseUpdateThermostatData,
31
- SeamHttpApiError,
32
- UseUpdateThermostatMutationVariables
33
- >({
34
- mutationFn: async (variables) => {
35
- if (client === null) throw new NullSeamClientError()
36
- await client.thermostats.update(variables)
37
- },
38
- onSuccess: (_data, variables) => {
39
- queryClient.setQueryData<Device | null>(
40
- ['devices', 'get', { device_id: variables.device_id }],
41
- (device) => {
42
- if (device == null) {
43
- return
44
- }
45
- return getUpdatedDevice(device, variables)
46
- }
47
- )
48
-
49
- queryClient.setQueryData<Device[]>(
50
- ['devices', 'list', { device_id: variables.device_id }],
51
- (devices): Device[] => {
52
- if (devices == null) {
53
- return []
54
- }
55
-
56
- return devices.map((device) => {
57
- if (device.device_id === variables.device_id) {
58
- return getUpdatedDevice(device, variables)
59
- }
60
-
61
- return device
62
- })
63
- }
64
- )
65
- },
66
- })
67
- }
68
-
69
- const getUpdatedDevice = (
70
- device: Device,
71
- variables: UseUpdateThermostatMutationVariables
72
- ): Device => {
73
- const { properties } = device
74
- if (
75
- 'default_climate_setting' in properties &&
76
- properties.default_climate_setting != null
77
- ) {
78
- return {
79
- ...device,
80
- properties: {
81
- ...properties,
82
- default_climate_setting: {
83
- ...properties.default_climate_setting,
84
- ...shake(variables.default_climate_setting),
85
- },
86
- },
87
- }
88
- }
89
- return device
90
- }
@@ -1,189 +0,0 @@
1
- import classNames from 'classnames'
2
- import { useEffect, useState } from 'react'
3
- import { useForm } from 'react-hook-form'
4
-
5
- import { getSystemTimeZone } from 'lib/dates.js'
6
- import { useSeamClient } from 'lib/index.js'
7
- import {
8
- type ClimateSetting,
9
- type HvacModeSetting,
10
- isThermostatDevice,
11
- } from 'lib/seam/thermostats/thermostat-device.js'
12
- import { ClimateSettingScheduleFormClimateSetting } from 'lib/ui/ClimateSettingForm/ClimateSettingScheduleFormClimateSetting.js'
13
- import { ClimateSettingScheduleFormDefaultClimateSetting } from 'lib/ui/ClimateSettingForm/ClimateSettingScheduleFormDefaultClimateSetting.js'
14
- import { ClimateSettingScheduleFormDeviceSelect } from 'lib/ui/ClimateSettingForm/ClimateSettingScheduleFormDeviceSelect.js'
15
- import { ClimateSettingScheduleFormNameAndSchedule } from 'lib/ui/ClimateSettingForm/ClimateSettingScheduleFormNameAndSchedule.js'
16
- import { ClimateSettingScheduleFormTimeZonePicker } from 'lib/ui/ClimateSettingForm/ClimateSettingScheduleFormTimeZonePicker.js'
17
-
18
- export interface ClimateSettingScheduleFormSubmitData {
19
- name: string
20
- deviceId: string
21
- startDate: string
22
- endDate: string
23
- timeZone: string
24
- climateSetting: ClimateSetting
25
- }
26
-
27
- export interface ClimateSettingScheduleFormProps {
28
- className?: string
29
- onBack?: () => void
30
- isSubmitting: boolean
31
- onSubmit: (data: ClimateSettingScheduleFormSubmitData) => void
32
- }
33
-
34
- export interface ClimateSettingScheduleFormFields {
35
- name: string
36
- deviceId: string
37
- startDate: string
38
- endDate: string
39
- timeZone: string
40
- climateSetting: {
41
- hvacModeSetting: HvacModeSetting
42
- // may have to ignore one or the other fields here on submit
43
- heatingSetPoint: number
44
- coolingSetPoint: number
45
- }
46
- }
47
-
48
- export function ClimateSettingScheduleForm({
49
- className,
50
- ...props
51
- }: ClimateSettingScheduleFormProps): JSX.Element | null {
52
- return (
53
- <div
54
- className={classNames('seam-climate-setting-schedule-form', className)}
55
- >
56
- <Content {...props} />
57
- </div>
58
- )
59
- }
60
-
61
- function Content({
62
- onBack,
63
- }: Omit<ClimateSettingScheduleFormProps, 'className'>): JSX.Element {
64
- const { client } = useSeamClient()
65
- const { control, watch, resetField } =
66
- useForm<ClimateSettingScheduleFormFields>({
67
- defaultValues: {
68
- deviceId: '',
69
- name: '',
70
- startDate: '',
71
- endDate: '',
72
- timeZone: getSystemTimeZone(),
73
- climateSetting: {
74
- hvacModeSetting: 'heat_cool',
75
- heatingSetPoint: 70,
76
- coolingSetPoint: 75,
77
- },
78
- },
79
- })
80
-
81
- const deviceId = watch('deviceId')
82
- const timeZone = watch('timeZone')
83
-
84
- const [page, setPage] = useState<
85
- | 'device_select'
86
- | 'default_setting'
87
- | 'name_and_schedule'
88
- | 'time_zone_select'
89
- | 'climate_setting'
90
- >('device_select')
91
-
92
- const returnToDeviceSelect = (): void => {
93
- resetField('deviceId')
94
- setPage('device_select')
95
- }
96
-
97
- useEffect(() => {
98
- if (page === 'device_select' && deviceId !== '' && client != null) {
99
- client.devices
100
- .get({ device_id: deviceId })
101
- .then((device) => {
102
- if (!isThermostatDevice(device)) return
103
-
104
- if (device.properties.default_climate_setting != null) {
105
- setPage('name_and_schedule')
106
- return
107
- }
108
-
109
- setPage('default_setting')
110
- })
111
- .catch(() => {})
112
- }
113
- }, [client, deviceId, page, setPage])
114
-
115
- if (page === 'device_select') {
116
- return (
117
- <ClimateSettingScheduleFormDeviceSelect
118
- title={t.addNewClimateSettingSchedule}
119
- control={control}
120
- onBack={onBack}
121
- />
122
- )
123
- }
124
-
125
- if (page === 'default_setting') {
126
- return (
127
- <ClimateSettingScheduleFormDefaultClimateSetting
128
- title={t.addNewClimateSettingSchedule}
129
- deviceId={deviceId}
130
- onBack={returnToDeviceSelect}
131
- onCancel={onBack}
132
- onSave={() => {
133
- setPage('name_and_schedule')
134
- }}
135
- />
136
- )
137
- }
138
-
139
- if (page === 'name_and_schedule') {
140
- return (
141
- <ClimateSettingScheduleFormNameAndSchedule
142
- title={t.addNewClimateSettingSchedule}
143
- control={control}
144
- deviceId={deviceId}
145
- onBack={returnToDeviceSelect}
146
- onCancel={onBack}
147
- onNext={() => {
148
- setPage('climate_setting')
149
- }}
150
- onChangeTimeZone={() => {
151
- setPage('time_zone_select')
152
- }}
153
- timeZone={timeZone}
154
- />
155
- )
156
- }
157
-
158
- if (page === 'time_zone_select') {
159
- return (
160
- <ClimateSettingScheduleFormTimeZonePicker
161
- control={control}
162
- onClose={() => {
163
- setPage('name_and_schedule')
164
- }}
165
- />
166
- )
167
- }
168
-
169
- if (page === 'climate_setting') {
170
- return (
171
- <ClimateSettingScheduleFormClimateSetting
172
- title={t.addNewClimateSettingSchedule}
173
- control={control}
174
- deviceId={deviceId}
175
- onBack={() => {
176
- setPage('name_and_schedule')
177
- }}
178
- onCancel={onBack}
179
- onSave={() => {}}
180
- />
181
- )
182
- }
183
-
184
- return <></>
185
- }
186
-
187
- export const t = {
188
- addNewClimateSettingSchedule: 'Add a climate setting schedule',
189
- }
@@ -1,118 +0,0 @@
1
- import { type Control, Controller } from 'react-hook-form'
2
-
3
- import { useDevice } from 'lib/seam/devices/use-device.js'
4
- import { isThermostatDevice } from 'lib/seam/thermostats/thermostat-device.js'
5
- import { Button } from 'lib/ui/Button.js'
6
- import type { ClimateSettingScheduleFormFields } from 'lib/ui/ClimateSettingForm/ClimateSettingScheduleForm.js'
7
- import {
8
- getSetPointBounds,
9
- type SetPointBounds,
10
- } from 'lib/ui/ClimateSettingForm/set-point-bounds.js'
11
- import { FormField } from 'lib/ui/FormField.js'
12
- import { InputLabel } from 'lib/ui/InputLabel.js'
13
- import { ContentHeader } from 'lib/ui/layout/ContentHeader.js'
14
- import { ClimateSettingControlGroup } from 'lib/ui/thermostat/ClimateSettingControlGroup.js'
15
-
16
- interface ClimateSettingScheduleFormClimateSettingProps {
17
- title: string
18
- control: Control<ClimateSettingScheduleFormFields>
19
- deviceId: string
20
- onBack: () => void
21
- onCancel: (() => void) | undefined
22
- onSave: () => void
23
- }
24
-
25
- export function ClimateSettingScheduleFormClimateSetting({
26
- title,
27
- control,
28
- deviceId,
29
- onBack,
30
- onCancel,
31
- onSave,
32
- }: ClimateSettingScheduleFormClimateSettingProps): JSX.Element {
33
- const { device } = useDevice({
34
- device_id: deviceId,
35
- })
36
-
37
- if (device == null) return <></>
38
- if (!isThermostatDevice(device)) return <></>
39
-
40
- const setPointBounds = getSetPointBounds(device)
41
-
42
- return (
43
- <>
44
- <ContentHeader
45
- title={title}
46
- onBack={onBack}
47
- subheading={device?.properties.name}
48
- />
49
- <div className='seam-main'>
50
- <div className='seam-climate-setting-schedule-form-climate-setting'>
51
- <div className='seam-content'>
52
- <div>
53
- <InputLabel>{t.climateSetting}</InputLabel>
54
- <span className='seam-label'>{t.climateSettingSubHeading}</span>
55
- </div>
56
- <FormContent control={control} setPointBounds={setPointBounds} />
57
- </div>
58
- </div>
59
- <div className='seam-actions'>
60
- <Button onClick={onCancel}>{t.cancel}</Button>
61
- <Button variant='solid' onClick={onSave}>
62
- {t.save}
63
- </Button>
64
- </div>
65
- </div>
66
- </>
67
- )
68
- }
69
-
70
- interface FormContentProps {
71
- control: Control<ClimateSettingScheduleFormFields>
72
- setPointBounds: SetPointBounds
73
- }
74
-
75
- function FormContent({
76
- control,
77
- setPointBounds,
78
- }: FormContentProps): JSX.Element {
79
- return (
80
- <FormField>
81
- <Controller
82
- name='climateSetting'
83
- control={control}
84
- render={({ field: { value, onChange } }) => (
85
- <ClimateSettingControlGroup
86
- mode={value.hvacModeSetting}
87
- onModeChange={(mode) => {
88
- onChange({ ...value, hvacModeSetting: mode })
89
- }}
90
- coolValue={value.coolingSetPoint}
91
- heatValue={value.heatingSetPoint}
92
- {...setPointBounds}
93
- onCoolValueChange={(coolingSetPoint) => {
94
- onChange({
95
- ...value,
96
- coolingSetPoint,
97
- })
98
- }}
99
- onHeatValueChange={(heatingSetPoint) => {
100
- onChange({
101
- ...value,
102
- heatingSetPoint,
103
- })
104
- }}
105
- />
106
- )}
107
- />
108
- </FormField>
109
- )
110
- }
111
-
112
- const t = {
113
- climateSetting: 'Climate setting',
114
- climateSettingSubHeading: 'Choose mode and adjust the climate',
115
- cancel: 'Cancel',
116
- save: 'Save',
117
- next: 'Next',
118
- }
@@ -1,79 +0,0 @@
1
- import { useState } from 'react'
2
-
3
- import { useDevice } from 'lib/seam/devices/use-device.js'
4
- import type { HvacModeSetting } from 'lib/seam/thermostats/thermostat-device.js'
5
- import { Button } from 'lib/ui/Button.js'
6
- import { InputLabel } from 'lib/ui/InputLabel.js'
7
- import { ContentHeader } from 'lib/ui/layout/ContentHeader.js'
8
- import { ClimateSettingControlGroup } from 'lib/ui/thermostat/ClimateSettingControlGroup.js'
9
-
10
- interface ClimateSettingScheduleFormDefaultClimateSettingProps {
11
- title: string
12
- deviceId: string
13
- onBack: () => void
14
- onCancel: (() => void) | undefined
15
- onSave: () => void
16
- }
17
-
18
- export function ClimateSettingScheduleFormDefaultClimateSetting({
19
- title,
20
- deviceId,
21
- onBack,
22
- onCancel,
23
- onSave,
24
- }: ClimateSettingScheduleFormDefaultClimateSettingProps): JSX.Element {
25
- const { device } = useDevice({
26
- device_id: deviceId,
27
- })
28
-
29
- const [mode, setMode] = useState<HvacModeSetting>('heat_cool')
30
- const [heatValue, setHeatValue] = useState(70)
31
- const [coolValue, setCoolValue] = useState(75)
32
-
33
- return (
34
- <>
35
- <ContentHeader
36
- title={title}
37
- onBack={onBack}
38
- subheading={device?.properties.name}
39
- />
40
- <div className='seam-main'>
41
- <div className='seam-climate-setting-schedule-form-default-climate-setting'>
42
- <div className='seam-content'>
43
- <div className='seam-default-climate-setting-message'>
44
- <p>{t.defaultClimateMessage}</p>
45
- </div>
46
- <div className='seam-control-group-title'>
47
- <InputLabel>{t.defaultClimate}</InputLabel>
48
- <span className='seam-label'>{t.defautClimateSubHeading}</span>
49
- </div>
50
- <ClimateSettingControlGroup
51
- mode={mode}
52
- onModeChange={setMode}
53
- heatValue={heatValue}
54
- onHeatValueChange={setHeatValue}
55
- coolValue={coolValue}
56
- onCoolValueChange={setCoolValue}
57
- />
58
- </div>
59
- </div>
60
- <div className='seam-actions'>
61
- <Button onClick={onCancel}>{t.cancel}</Button>
62
- <Button variant='solid' onClick={onSave}>
63
- {t.save}
64
- </Button>
65
- </div>
66
- </div>
67
- </>
68
- )
69
- }
70
-
71
- const t = {
72
- defaultClimate: 'Default Climate',
73
- defautClimateSubHeading:
74
- 'Choose the default mode and climate for this device',
75
- defaultClimateMessage:
76
- 'This device doesn’t have a default climate set up yet. Choose the climate you’d like the device to fall back to after scheduled climates reach their ends.',
77
- cancel: 'Cancel',
78
- save: 'Save',
79
- }
@@ -1,36 +0,0 @@
1
- import { type Control, Controller } from 'react-hook-form'
2
-
3
- import type { ClimateSettingScheduleFormFields } from 'lib/ui/ClimateSettingForm/ClimateSettingScheduleForm.js'
4
- import { ContentHeader } from 'lib/ui/layout/ContentHeader.js'
5
- import { ThermostatSelect } from 'lib/ui/thermostat/ThermostatSelect.js'
6
-
7
- interface ClimateSettingScheduleFormDeviceSelectProps {
8
- title: string
9
- control: Control<ClimateSettingScheduleFormFields>
10
- onBack: (() => void) | undefined
11
- }
12
-
13
- export function ClimateSettingScheduleFormDeviceSelect({
14
- title,
15
- control,
16
- onBack,
17
- }: ClimateSettingScheduleFormDeviceSelectProps): JSX.Element {
18
- return (
19
- <>
20
- <ContentHeader title={title} onBack={onBack} />
21
- <div className='seam-main'>
22
- <Controller
23
- name='deviceId'
24
- control={control}
25
- render={({ field: { onChange } }) => (
26
- <ThermostatSelect
27
- onSelect={(deviceId) => {
28
- onChange(deviceId)
29
- }}
30
- />
31
- )}
32
- />
33
- </div>
34
- </>
35
- )
36
- }
@@ -1,120 +0,0 @@
1
- import { type Control, Controller } from 'react-hook-form'
2
-
3
- import { formatTimeZone } from 'lib/dates.js'
4
- import { ChevronRightIcon } from 'lib/icons/ChevronRight.js'
5
- import { useDevice } from 'lib/seam/devices/use-device.js'
6
- import { Button } from 'lib/ui/Button.js'
7
- import type { ClimateSettingScheduleFormFields } from 'lib/ui/ClimateSettingForm/ClimateSettingScheduleForm.js'
8
- import { DateTimePicker } from 'lib/ui/DateTimePicker/DateTimePicker.js'
9
- import { FormField } from 'lib/ui/FormField.js'
10
- import { InputLabel } from 'lib/ui/InputLabel.js'
11
- import { ContentHeader } from 'lib/ui/layout/ContentHeader.js'
12
- import { TextField } from 'lib/ui/TextField/TextField.js'
13
-
14
- interface ClimateSettingScheduleFormNameAndScheduleProps {
15
- title: string
16
- control: Control<ClimateSettingScheduleFormFields>
17
- deviceId: string
18
- timeZone: string
19
- onBack: () => void
20
- onCancel: (() => void) | undefined
21
- onNext: () => void
22
- onChangeTimeZone: () => void
23
- }
24
-
25
- export function ClimateSettingScheduleFormNameAndSchedule({
26
- title,
27
- control,
28
- deviceId,
29
- timeZone,
30
- onBack,
31
- onCancel,
32
- onNext,
33
- onChangeTimeZone,
34
- }: ClimateSettingScheduleFormNameAndScheduleProps): JSX.Element {
35
- const { device } = useDevice({
36
- device_id: deviceId,
37
- })
38
-
39
- return (
40
- <>
41
- <ContentHeader
42
- title={title}
43
- onBack={onBack}
44
- subheading={device?.properties.name}
45
- />
46
- <div className='seam-main'>
47
- <div className='seam-climate-setting-schedule-form-name-and-schedule'>
48
- <div className='seam-content'>
49
- <FormField>
50
- <InputLabel>{t.nameInputLabel}</InputLabel>
51
- <Controller
52
- name='name'
53
- control={control}
54
- defaultValue=''
55
- render={({ field, fieldState: { invalid, error } }) => {
56
- return (
57
- <TextField
58
- {...field}
59
- size='large'
60
- clearable
61
- hasError={invalid}
62
- helperText={error?.message}
63
- />
64
- )
65
- }}
66
- />
67
- </FormField>
68
-
69
- <FormField>
70
- <InputLabel>{t.startTimeLabel}</InputLabel>
71
- <div className='seam-time-zone'>
72
- <span className='seam-label'>{t.selectedTimeZoneLabel}</span>
73
- <span className='seam-selected' onClick={onChangeTimeZone}>
74
- {formatTimeZone(timeZone)}
75
- <ChevronRightIcon />
76
- </span>
77
- </div>
78
- <Controller
79
- name='startDate'
80
- control={control}
81
- defaultValue=''
82
- render={({ field }) => (
83
- <DateTimePicker {...field} size='large' />
84
- )}
85
- />
86
- </FormField>
87
- <FormField>
88
- <InputLabel>{t.endTimeLabel}</InputLabel>
89
- <Controller
90
- name='endDate'
91
- control={control}
92
- defaultValue=''
93
- render={({ field }) => (
94
- <DateTimePicker {...field} size='large' />
95
- )}
96
- />
97
- </FormField>
98
- </div>
99
- </div>
100
- <div className='seam-actions'>
101
- <Button onClick={onCancel}>{t.cancel}</Button>
102
- <Button variant='solid' onClick={onNext}>
103
- {t.next}
104
- </Button>
105
- </div>
106
- </div>
107
- </>
108
- )
109
- }
110
-
111
- const t = {
112
- nameInputLabel: 'Name the climate setting schedule',
113
- startTimeLabel: 'Start time',
114
- endTimeLabel: 'End time',
115
- addNewClimateSettingSchedule: 'Add a climate setting schedule',
116
- cancel: 'Cancel',
117
- save: 'Save',
118
- next: 'Next',
119
- selectedTimeZoneLabel: 'All times in',
120
- }
@@ -1,43 +0,0 @@
1
- import { useState } from 'react'
2
- import { type Control, Controller } from 'react-hook-form'
3
-
4
- import type { ClimateSettingScheduleFormFields } from 'lib/ui/ClimateSettingForm/ClimateSettingScheduleForm.js'
5
- import { ContentHeader } from 'lib/ui/layout/ContentHeader.js'
6
- import { TimeZonePicker } from 'lib/ui/TimeZonePicker/TimeZonePicker.js'
7
-
8
- interface ClimateSettingScheduleFormTimeZonePickerProps {
9
- control: Control<ClimateSettingScheduleFormFields>
10
- onClose: () => void
11
- }
12
-
13
- export function ClimateSettingScheduleFormTimeZonePicker({
14
- control,
15
- onClose,
16
- }: ClimateSettingScheduleFormTimeZonePickerProps): JSX.Element {
17
- const [title, setTitle] = useState(t.titleAuto)
18
-
19
- return (
20
- <>
21
- <ContentHeader title={title} onBack={onClose} />
22
- <div className='seam-main'>
23
- <Controller
24
- name='timeZone'
25
- control={control}
26
- render={({ field }) => (
27
- <TimeZonePicker
28
- {...field}
29
- onManualTimeZoneSelected={(manualTimeZoneSelected) => {
30
- setTitle(manualTimeZoneSelected ? t.titleManual : t.titleAuto)
31
- }}
32
- />
33
- )}
34
- />
35
- </div>
36
- </>
37
- )
38
- }
39
-
40
- const t = {
41
- titleAuto: 'Time Zone (automatic)',
42
- titleManual: 'Time Zone (manual)',
43
- }