diff --git a/src/lib/seam/components/DeviceDetails/LockDeviceDetails.tsx b/src/lib/seam/components/DeviceDetails/LockDeviceDetails.tsx index c8ff12aa4..9e19e47d0 100644 --- a/src/lib/seam/components/DeviceDetails/LockDeviceDetails.tsx +++ b/src/lib/seam/components/DeviceDetails/LockDeviceDetails.tsx @@ -6,7 +6,6 @@ import { NestedAccessCodeTable } from 'lib/seam/components/AccessCodeTable/Acces import type { NestedSpecificDeviceDetailsProps } from 'lib/seam/components/DeviceDetails/DeviceDetails.js' import { DeviceInfo } from 'lib/seam/components/DeviceDetails/DeviceInfo.js' import { DeviceModel } from 'lib/seam/components/DeviceDetails/DeviceModel.js' -import { SeamEditableDeviceName } from 'lib/seam/components/SeamEditableDeviceName/SeamEditableDeviceName.js' import { deviceErrorFilter, deviceWarningFilter } from 'lib/seam/filters.js' import type { LockDevice } from 'lib/seam/locks/lock-device.js' import { useToggleLock } from 'lib/seam/locks/use-toggle-lock.js' @@ -14,6 +13,7 @@ import { Alerts } from 'lib/ui/Alert/Alerts.js' import { Button } from 'lib/ui/Button.js' import { BatteryStatusIndicator } from 'lib/ui/device/BatteryStatusIndicator.js' import { DeviceImage } from 'lib/ui/device/DeviceImage.js' +import { EditableDeviceName } from 'lib/ui/device/EditableDeviceName.js' import { OnlineStatus } from 'lib/ui/device/OnlineStatus.js' import { ContentHeader } from 'lib/ui/layout/ContentHeader.js' import { useToggle } from 'lib/ui/use-toggle.js' @@ -98,7 +98,7 @@ export function LockDeviceDetails({
{t.device} -
{t.noiseSensor} - void editable?: boolean tagName?: string value: string } & HTMLAttributes -function IconButton( - props: PropsWithChildren> -): JSX.Element { - return ( - - ) -} - -const fixName = (name: string): string => { - return name.replace(/\s+/g, ' ').trim() -} - -type Result = { type: 'success' } | { type: 'error'; message: string } - -const isValidName = (name: string): Result => { - if (name.length < 2) { - return { - type: 'error', - message: 'Name must be at least 2 characters long', - } - } - - if (name.length > 64) { - return { - type: 'error', - message: 'Name must be at most 64 characters long', - } - } - - return { - type: 'success', - } as const -} - -export function SeamEditableDeviceName({ +export function EditableDeviceName({ onEdit, editable = true, tagName, value, ...props -}: SeamDeviceNameProps): JSX.Element { +}: EditableDeviceNameProps): JSX.Element { const [editing, setEditing] = useState(false) const [errorText, setErrorText] = useState(null) const [currentValue, setCurrentValue] = useState(value) @@ -206,3 +164,50 @@ function ActionButtons(props: ActionButtonsProps): JSX.Element { ) } + +function IconButton( + props: PropsWithChildren> +): JSX.Element { + return ( + + ) +} + +const fixName = (name: string): string => { + return name.replace(/\s+/g, ' ').trim() +} + +type Result = + | { type: 'success' } + | { + type: 'error' + message: string + } + +const isValidName = (name: string): Result => { + if (name.length < 2) { + return { + type: 'error', + message: 'Name must be at least 2 characters long', + } + } + + if (name.length > 64) { + return { + type: 'error', + message: 'Name must be at most 64 characters long', + } + } + + return { + type: 'success', + } as const +} diff --git a/src/lib/ui/thermostat/ThermostatCard.tsx b/src/lib/ui/thermostat/ThermostatCard.tsx index a03f4ce3b..e16a1ae38 100644 --- a/src/lib/ui/thermostat/ThermostatCard.tsx +++ b/src/lib/ui/thermostat/ThermostatCard.tsx @@ -3,9 +3,9 @@ import { useState } from 'react' import { FanIcon } from 'lib/icons/Fan.js' import { OffIcon } from 'lib/icons/Off.js' -import { SeamEditableDeviceName } from 'lib/seam/components/SeamEditableDeviceName/SeamEditableDeviceName.js' import type { ThermostatDevice } from 'lib/seam/thermostats/thermostat-device.js' import { DeviceImage } from 'lib/ui/device/DeviceImage.js' +import { EditableDeviceName } from 'lib/ui/device/EditableDeviceName.js' import { ClimateSettingStatus } from 'lib/ui/thermostat/ClimateSettingStatus.js' import { Temperature } from 'lib/ui/thermostat/Temperature.js' @@ -52,7 +52,7 @@ function Content(props: ThermostatCardProps): JSX.Element | null {
-