@attraccess/plugin-shelly 0.1.0 → 0.2.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.
@@ -1,8 +1,7 @@
1
- import { r as importShared } from "./_virtual___federation_fn_import-BXODRNto.js";
2
- //#region \0rolldown/runtime.js
3
- var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
4
- //#endregion
5
- //#region ../../../libs/plugins-frontend-sdk/src/lib/frontend.api-client.ts
1
+ import { r as importShared } from "./_virtual___federation_fn_import-D2E5es2p.js";
2
+ // \0rolldown/runtime.js
3
+ var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod, mod.exports), cb = null), mod.exports);
4
+ // ../../../libs/plugins-frontend-sdk/src/lib/frontend.api-client.ts
6
5
  var BASE_URL_GLOBAL = "__ATTRACCESS_API_BASE_URL__";
7
6
  /** The API origin the host is talking to. Falls back to the current origin. */
8
7
  function getApiBaseUrl() {
@@ -61,8 +60,9 @@ function createPluginApiClient(basePath = "") {
61
60
  }
62
61
  };
63
62
  }
64
- //#endregion
65
- //#region ../../../node_modules/.pnpm/react@19.2.8/node_modules/react/cjs/react-jsx-runtime.production.js
63
+ // ../../../libs/plugins-frontend-sdk/src/lib/frontend.license.ts
64
+ var { useCallback: useCallback$7, useEffect: useEffect$5, useState: useState$6 } = await importShared("react");
65
+ // ../../../node_modules/.pnpm/react@19.3.1/node_modules/react/cjs/react-jsx-runtime.production.js
66
66
  /**
67
67
  * @license React
68
68
  * react-jsx-runtime.production.js
@@ -94,8 +94,7 @@ var require_react_jsx_runtime_production = /* @__PURE__ */ __commonJSMin(((expor
94
94
  exports.jsx = jsxProd;
95
95
  exports.jsxs = jsxProd;
96
96
  }));
97
- //#endregion
98
- //#region ../../../libs/plugins-frontend-sdk/src/lib/frontend.live-updates.tsx
97
+ // ../../../libs/plugins-frontend-sdk/src/lib/frontend.live-updates.tsx
99
98
  var import_jsx_runtime = (/* @__PURE__ */ __commonJSMin(((exports, module) => {
100
99
  module.exports = require_react_jsx_runtime_production();
101
100
  })))();
@@ -154,14 +153,11 @@ function usePluginLiveUpdates(props) {
154
153
  ]);
155
154
  return { abort: useCallback$6(() => unsubscribe.current?.(), []) };
156
155
  }
157
- //#endregion
158
- //#region ../../../libs/plugins-frontend-sdk/src/lib/frontend.standard-drawer.tsx
156
+ // ../../../libs/plugins-frontend-sdk/src/lib/frontend.standard-drawer.tsx
159
157
  var { StandardDrawer: SharedStandardDrawer } = await importShared("@attraccess/plugins-frontend-ui");
160
- //#endregion
161
- //#region ../../../libs/plugins-frontend-sdk/src/lib/frontend.standard-modal.tsx
158
+ // ../../../libs/plugins-frontend-sdk/src/lib/frontend.standard-modal.tsx
162
159
  var { StandardModal: SharedStandardModal } = await importShared("@attraccess/plugins-frontend-ui");
163
- //#endregion
164
- //#region frontend/src/api.ts
160
+ // frontend/src/api.ts
165
161
  var api = createPluginApiClient("/api/shelly");
166
162
  function listDevices() {
167
163
  return api.request("/devices");
@@ -218,8 +214,7 @@ function discoverDevices(input = {}) {
218
214
  body: input
219
215
  });
220
216
  }
221
- //#endregion
222
- //#region frontend/src/shared/drawer.tsx
217
+ // frontend/src/shared/TextFieldRow.tsx
223
218
  var { Input, Label, TextField } = await importShared("@heroui/react");
224
219
  function TextFieldRow({ label, value, onChange, placeholder, required, description, dataCy }) {
225
220
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(TextField, {
@@ -253,15 +248,12 @@ var en_default = {
253
248
  "model": "Model",
254
249
  "auth": "Auth",
255
250
  "firmware": "Firmware",
256
- "actions": "Actions",
257
251
  "unknown": "Unknown",
258
252
  "generation": "Gen {{generation}}",
259
253
  "generationPlus": "Gen {{generation}}+",
260
254
  "empty": "No devices yet. Run discovery, or add your first Shelly by its IP.",
261
255
  "probeError": "Probe failed: {{message}}",
262
256
  "info": "View device info",
263
- "more": "More actions",
264
- "deviceActions": "Device actions",
265
257
  "manageFirmware": "Manage firmware",
266
258
  "password": "Set admin password",
267
259
  "reprobe": "Re-probe device",
@@ -383,15 +375,12 @@ var de_default = {
383
375
  "model": "Modell",
384
376
  "auth": "Authentifizierung",
385
377
  "firmware": "Firmware",
386
- "actions": "Aktionen",
387
378
  "unknown": "Unbekannt",
388
379
  "generation": "Gen {{generation}}",
389
380
  "generationPlus": "Gen {{generation}}+",
390
381
  "empty": "Noch keine Geräte vorhanden. Starte die Suche oder füge dein erstes Shelly-Gerät über seine IP-Adresse hinzu.",
391
382
  "probeError": "Geräteprüfung fehlgeschlagen: {{message}}",
392
383
  "info": "Geräteinformationen anzeigen",
393
- "more": "Weitere Aktionen",
394
- "deviceActions": "Geräteaktionen",
395
384
  "manageFirmware": "Firmware verwalten",
396
385
  "password": "Admin-Passwort festlegen",
397
386
  "reprobe": "Gerät erneut prüfen",
@@ -500,19 +489,17 @@ var de_default = {
500
489
  "refresh": "Aktualisieren"
501
490
  }
502
491
  };
503
- //#endregion
504
- //#region frontend/src/i18n.ts
492
+ // frontend/src/i18n.ts
505
493
  var { useTranslations } = await importShared("@attraccess/plugins-frontend-ui");
506
494
  var useShellyTranslations = () => useTranslations({
507
495
  en: en_default,
508
496
  de: de_default
509
497
  }, { escapeValues: false });
510
- //#endregion
511
- //#region frontend/src/devices/AddDeviceDrawer.tsx
498
+ // frontend/src/devices/AddDeviceDrawer.tsx
512
499
  var { DrawerBody: DrawerBody$4, DrawerHeader: DrawerHeader$4, DrawerHeading: DrawerHeading$4, Form: Form$3 } = await importShared("@heroui/react");
513
- var { PlusIcon: PlusIcon$1, XIcon: XIcon$4 } = await importShared("lucide-react");
500
+ var { PlusIcon: PlusIcon$2, XIcon: XIcon$4 } = await importShared("lucide-react");
514
501
  var { useCallback: useCallback$5, useRef: useRef$2, useState: useState$5 } = await importShared("react");
515
- var { Button: Button$6, StandardDrawer: StandardDrawer$4, StatusAlert: StatusAlert$5 } = await importShared("@attraccess/plugins-frontend-ui");
502
+ var { Button: Button$8, StandardDrawer: StandardDrawer$4, StatusAlert: StatusAlert$5 } = await importShared("@attraccess/plugins-frontend-ui");
516
503
  function AddDeviceDrawer({ isOpen, onOpenChange, onAdded }) {
517
504
  const { t, tMessage } = useShellyTranslations();
518
505
  const [ipAddress, setIpAddress] = useState$5("");
@@ -566,7 +553,7 @@ function AddDeviceDrawer({ isOpen, onOpenChange, onAdded }) {
566
553
  className: "sh:text-sm sh:text-muted",
567
554
  children: t("add.description")
568
555
  })]
569
- }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button$6, {
556
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button$8, {
570
557
  isIconOnly: true,
571
558
  variant: "ghost",
572
559
  "aria-label": t("common.close"),
@@ -600,18 +587,18 @@ function AddDeviceDrawer({ isOpen, onOpenChange, onAdded }) {
600
587
  }),
601
588
  /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
602
589
  className: "sh:flex sh:justify-end sh:gap-2 sh:pt-2",
603
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button$6, {
590
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button$8, {
604
591
  variant: "secondary",
605
592
  onPress: close,
606
593
  children: t("common.cancel")
607
- }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Button$6, {
594
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Button$8, {
608
595
  variant: "primary",
609
596
  type: "submit",
610
597
  isPending: submitting,
611
598
  onPress: submit,
612
599
  "data-cy": "shelly-add-submit",
613
600
  children: [
614
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PlusIcon$1, { className: "sh:h-4 sh:w-4" }),
601
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PlusIcon$2, { className: "sh:h-4 sh:w-4" }),
615
602
  " ",
616
603
  t("devices.add")
617
604
  ]
@@ -625,12 +612,11 @@ function AddDeviceDrawer({ isOpen, onOpenChange, onAdded }) {
625
612
  }) })]
626
613
  });
627
614
  }
628
- //#endregion
629
- //#region frontend/src/AdminPasswordDrawer.tsx
615
+ // frontend/src/AdminPasswordDrawer.tsx
630
616
  var { DrawerBody: DrawerBody$3, DrawerFooter: DrawerFooter$2, DrawerHeader: DrawerHeader$3, DrawerHeading: DrawerHeading$3, Form: Form$2 } = await importShared("@heroui/react");
631
617
  var { KeyRoundIcon: KeyRoundIcon$1, XIcon: XIcon$3 } = await importShared("lucide-react");
632
618
  var { useCallback: useCallback$4, useEffect: useEffect$3, useState: useState$4 } = await importShared("react");
633
- var { Button: Button$5, PasswordInput: PasswordInput$2, StandardDrawer: StandardDrawer$3, StatusAlert: StatusAlert$4 } = await importShared("@attraccess/plugins-frontend-ui");
619
+ var { Button: Button$7, PasswordInput: PasswordInput$2, StandardDrawer: StandardDrawer$3, StatusAlert: StatusAlert$4 } = await importShared("@attraccess/plugins-frontend-ui");
634
620
  function AdminPasswordDrawer({ device, onOpenChange, onSaved }) {
635
621
  const { t, tMessage } = useShellyTranslations();
636
622
  const [currentPassword, setCurrentPassword] = useState$4("");
@@ -698,7 +684,7 @@ function AdminPasswordDrawer({ device, onOpenChange, onSaved }) {
698
684
  address: device.ipAddress
699
685
  })
700
686
  })]
701
- }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button$5, {
687
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button$7, {
702
688
  isIconOnly: true,
703
689
  variant: "ghost",
704
690
  "aria-label": t("common.close"),
@@ -739,11 +725,11 @@ function AdminPasswordDrawer({ device, onOpenChange, onSaved }) {
739
725
  })
740
726
  ]
741
727
  }) }),
742
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(DrawerFooter$2, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button$5, {
728
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(DrawerFooter$2, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button$7, {
743
729
  variant: "secondary",
744
730
  onPress: close,
745
731
  children: t("common.cancel")
746
- }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Button$5, {
732
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Button$7, {
747
733
  variant: "primary",
748
734
  isPending: submitting,
749
735
  onPress: () => void submit(),
@@ -757,12 +743,53 @@ function AdminPasswordDrawer({ device, onOpenChange, onSaved }) {
757
743
  ]
758
744
  });
759
745
  }
760
- //#endregion
761
- //#region frontend/src/devices/info/DeviceInfoDrawer.tsx
762
- var { Button: Button$4, PasswordInput: PasswordInput$1, StandardDrawer: StandardDrawer$2, StatusAlert: StatusAlert$3, useDateTimeFormatter: useDateTimeFormatter$1 } = await importShared("@attraccess/plugins-frontend-ui");
763
- var { Card, DrawerBody: DrawerBody$2, DrawerFooter: DrawerFooter$1, DrawerHeader: DrawerHeader$2, DrawerHeading: DrawerHeading$2, Form: Form$1, Skeleton } = await importShared("@heroui/react");
764
- var { InfoIcon: InfoIcon$1, RefreshCwIcon: RefreshCwIcon$2, XIcon: XIcon$2 } = await importShared("lucide-react");
765
- var { useCallback: useCallback$3, useEffect: useEffect$2, useState: useState$3 } = await importShared("react");
746
+ // frontend/src/devices/info/AuthProtectedForm.tsx
747
+ var { Button: Button$6, PasswordInput: PasswordInput$1 } = await importShared("@attraccess/plugins-frontend-ui");
748
+ var { Form: Form$1 } = await importShared("@heroui/react");
749
+ function AuthProtectedForm({ authState, currentPassword, onChange, loading, onLoad }) {
750
+ const { t } = useShellyTranslations();
751
+ if (authState !== "required") return null;
752
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
753
+ className: "sh:rounded-md sh:border-l-4 sh:border-l-warning sh:bg-warning/5 sh:p-4",
754
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Form$1, {
755
+ onSubmit: (e) => {
756
+ e.preventDefault();
757
+ onLoad();
758
+ },
759
+ className: "sh:flex sh:flex-col sh:gap-3",
760
+ children: [
761
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
762
+ className: "sh:text-sm",
763
+ children: t("info.auth")
764
+ }),
765
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PasswordInput$1, {
766
+ label: t("password.title"),
767
+ value: currentPassword,
768
+ onChange,
769
+ placeholder: t("info.passwordPlaceholder"),
770
+ autoComplete: "current-password",
771
+ "data-cy": "shelly-info-current-password"
772
+ }),
773
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
774
+ className: "sh:flex sh:justify-end",
775
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button$6, {
776
+ variant: "primary",
777
+ size: "sm",
778
+ isPending: loading,
779
+ onPress: onLoad,
780
+ "data-cy": "shelly-info-unlock",
781
+ children: t("info.load")
782
+ })
783
+ }),
784
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", {
785
+ type: "submit",
786
+ hidden: true
787
+ })
788
+ ]
789
+ })
790
+ });
791
+ }
792
+ // frontend/src/devices/info/infoValues.ts
766
793
  function formatInfoValue(value, t, language, suffix = "") {
767
794
  if (value === void 0 || value === null || value === "") return t("info.notReported");
768
795
  if (typeof value === "boolean") return t(value ? "info.on" : "info.off");
@@ -793,6 +820,8 @@ function formatUptime(seconds, t, language) {
793
820
  if (hours > 0) return `${hours}h ${minutes}m`;
794
821
  return `${minutes}m`;
795
822
  }
823
+ // frontend/src/devices/info/DeviceInfoCards.tsx
824
+ var { Card } = await importShared("@heroui/react");
796
825
  function DeviceInfoCards({ info }) {
797
826
  const { t, language } = useShellyTranslations();
798
827
  const formatValue = (value, suffix = "") => formatInfoValue(value, t, language, suffix);
@@ -907,49 +936,11 @@ function DeviceInfoCards({ info }) {
907
936
  }) })] }, card.title))
908
937
  });
909
938
  }
910
- function AuthProtectedForm({ authState, currentPassword, onChange, loading, onLoad }) {
911
- const { t } = useShellyTranslations();
912
- if (authState !== "required") return null;
913
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
914
- className: "sh:rounded-md sh:border-l-4 sh:border-l-warning sh:bg-warning/5 sh:p-4",
915
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Form$1, {
916
- onSubmit: (e) => {
917
- e.preventDefault();
918
- onLoad();
919
- },
920
- className: "sh:flex sh:flex-col sh:gap-3",
921
- children: [
922
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
923
- className: "sh:text-sm",
924
- children: t("info.auth")
925
- }),
926
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PasswordInput$1, {
927
- label: t("password.title"),
928
- value: currentPassword,
929
- onChange,
930
- placeholder: t("info.passwordPlaceholder"),
931
- autoComplete: "current-password",
932
- "data-cy": "shelly-info-current-password"
933
- }),
934
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
935
- className: "sh:flex sh:justify-end",
936
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button$4, {
937
- variant: "primary",
938
- size: "sm",
939
- isPending: loading,
940
- onPress: onLoad,
941
- "data-cy": "shelly-info-unlock",
942
- children: t("info.load")
943
- })
944
- }),
945
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", {
946
- type: "submit",
947
- hidden: true
948
- })
949
- ]
950
- })
951
- });
952
- }
939
+ // frontend/src/devices/info/DeviceInfoDrawer.tsx
940
+ var { Button: Button$5, StandardDrawer: StandardDrawer$2, StatusAlert: StatusAlert$3, useDateTimeFormatter: useDateTimeFormatter$1 } = await importShared("@attraccess/plugins-frontend-ui");
941
+ var { DrawerBody: DrawerBody$2, DrawerFooter: DrawerFooter$1, DrawerHeader: DrawerHeader$2, DrawerHeading: DrawerHeading$2, Skeleton } = await importShared("@heroui/react");
942
+ var { InfoIcon: InfoIcon$1, RefreshCwIcon: RefreshCwIcon$2, XIcon: XIcon$2 } = await importShared("lucide-react");
943
+ var { useCallback: useCallback$3, useEffect: useEffect$2, useState: useState$3 } = await importShared("react");
953
944
  function DeviceInfoDrawer({ device, onOpenChange }) {
954
945
  const { t } = useShellyTranslations();
955
946
  const formatDateTime = useDateTimeFormatter$1({
@@ -1001,7 +992,7 @@ function DeviceInfoDrawer({ device, onOpenChange }) {
1001
992
  className: "sh:text-sm sh:text-muted",
1002
993
  children: device.ipAddress
1003
994
  })]
1004
- }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button$4, {
995
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button$5, {
1005
996
  isIconOnly: true,
1006
997
  variant: "ghost",
1007
998
  "aria-label": t("common.close"),
@@ -1040,7 +1031,7 @@ function DeviceInfoDrawer({ device, onOpenChange }) {
1040
1031
  children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
1041
1032
  className: "sh:text-xs sh:text-default-500",
1042
1033
  children: info ? t("info.updated", { time: formatDateTime(info.fetchedAt) }) : ""
1043
- }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Button$4, {
1034
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Button$5, {
1044
1035
  variant: "secondary",
1045
1036
  onPress: () => void load(),
1046
1037
  isPending: loading,
@@ -1055,9 +1046,8 @@ function DeviceInfoDrawer({ device, onOpenChange }) {
1055
1046
  ]
1056
1047
  });
1057
1048
  }
1058
- //#endregion
1059
- //#region frontend/src/DiscoverDrawer.tsx
1060
- var { Button: Button$3, StandardDrawer: StandardDrawer$1, StatusAlert: StatusAlert$2 } = await importShared("@attraccess/plugins-frontend-ui");
1049
+ // frontend/src/DiscoverDrawer.tsx
1050
+ var { Button: Button$4, StandardDrawer: StandardDrawer$1, StatusAlert: StatusAlert$2 } = await importShared("@attraccess/plugins-frontend-ui");
1061
1051
  var { Chip: Chip$2, DrawerBody: DrawerBody$1, DrawerHeader: DrawerHeader$1, DrawerHeading: DrawerHeading$1, Form, Spinner: Spinner$1 } = await importShared("@heroui/react");
1062
1052
  var { SearchIcon: SearchIcon$1, XIcon: XIcon$1 } = await importShared("lucide-react");
1063
1053
  var { useCallback: useCallback$2, useRef: useRef$1, useState: useState$2 } = await importShared("react");
@@ -1154,7 +1144,7 @@ function DiscoverDrawer({ isOpen, onOpenChange, onDiscovered }) {
1154
1144
  className: "sh:text-sm sh:text-muted",
1155
1145
  children: t("discovery.description")
1156
1146
  })]
1157
- }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button$3, {
1147
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button$4, {
1158
1148
  isIconOnly: true,
1159
1149
  variant: "ghost",
1160
1150
  "aria-label": t("common.close"),
@@ -1189,11 +1179,11 @@ function DiscoverDrawer({ isOpen, onOpenChange, onDiscovered }) {
1189
1179
  result && !running && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ResultSummary, { result }),
1190
1180
  /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
1191
1181
  className: "sh:flex sh:justify-end sh:gap-2 sh:pt-2",
1192
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button$3, {
1182
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button$4, {
1193
1183
  variant: "secondary",
1194
1184
  onPress: close,
1195
1185
  children: t(result ? "common.done" : "common.cancel")
1196
- }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Button$3, {
1186
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Button$4, {
1197
1187
  variant: "primary",
1198
1188
  type: "submit",
1199
1189
  isPending: running,
@@ -1214,11 +1204,65 @@ function DiscoverDrawer({ isOpen, onOpenChange, onDiscovered }) {
1214
1204
  }) })]
1215
1205
  });
1216
1206
  }
1217
- //#endregion
1218
- //#region frontend/src/devices/firmware/useFirmwareDrawerState.tsx
1207
+ // frontend/src/devices/firmware/FirmwareDetails.tsx
1208
+ var { EmptyState: EmptyState$1, useDateTimeFormatter } = await importShared("@attraccess/plugins-frontend-ui");
1209
+ function VersionRow({ label, value }) {
1210
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
1211
+ className: "sh:flex sh:items-baseline sh:justify-between sh:gap-3 sh:border-b sh:border-default-200 sh:py-2 sh:last:border-b-0",
1212
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
1213
+ className: "sh:text-xs sh:font-medium sh:uppercase sh:tracking-wide sh:text-default-500",
1214
+ children: label
1215
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
1216
+ className: "sh:min-w-0 sh:truncate sh:text-sm sh:text-default-800",
1217
+ title: value,
1218
+ children: value
1219
+ })]
1220
+ });
1221
+ }
1222
+ function FirmwareDetails({ status }) {
1223
+ const { t } = useShellyTranslations();
1224
+ const formatDateTime = useDateTimeFormatter({ showSeconds: true });
1225
+ if (!status) return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(EmptyState$1, { message: t("firmware.empty") });
1226
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("section", {
1227
+ className: "sh:rounded-xl sh:border sh:border-default-200 sh:bg-surface sh:p-4",
1228
+ "data-cy": "shelly-firmware-details",
1229
+ children: [
1230
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(VersionRow, {
1231
+ label: t("firmware.installed"),
1232
+ value: status.currentVersion ?? t("devices.unknown")
1233
+ }),
1234
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(VersionRow, {
1235
+ label: t("firmware.stable"),
1236
+ value: status.available.stable ?? t("firmware.upToDate")
1237
+ }),
1238
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(VersionRow, {
1239
+ label: t("firmware.beta"),
1240
+ value: status.available.beta ?? t("firmware.nothingNewer")
1241
+ }),
1242
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(VersionRow, {
1243
+ label: t("firmware.checked"),
1244
+ value: String(formatDateTime(status.fetchedAt))
1245
+ })
1246
+ ]
1247
+ });
1248
+ }
1249
+ // frontend/src/devices/firmware/shortVersion.ts
1250
+ /**
1251
+ * Gen1 reports versions as `20230913-114150/v1.14.0` — only the tail is useful
1252
+ * at a glance, the full string stays in the tooltip.
1253
+ */
1254
+ function shortVersion(version) {
1255
+ const tail = version.split("/").pop();
1256
+ return tail && tail.length > 0 ? tail : version;
1257
+ }
1258
+ // frontend/src/devices/firmware/FirmwareDrawer.tsx
1259
+ var { Button: Button$3, PasswordInput, StandardDrawer, StatusAlert: StatusAlert$1, TableDataLoadingIndicator: TableDataLoadingIndicator$1 } = await importShared("@attraccess/plugins-frontend-ui");
1260
+ var { DrawerBody, DrawerFooter, DrawerHeader, DrawerHeading, Spinner } = await importShared("@heroui/react");
1261
+ var { CpuIcon: CpuIcon$1, DownloadIcon, RefreshCwIcon: RefreshCwIcon$1, XIcon } = await importShared("lucide-react");
1219
1262
  var { useCallback: useCallback$1, useEffect: useEffect$1, useRef, useState: useState$1 } = await importShared("react");
1220
1263
  var UPDATE_TIMEOUT_MS = 3e5;
1221
- function useFirmwareDrawerState({ device, onOpenChange, onUpdated }) {
1264
+ var STAGES = ["stable", "beta"];
1265
+ function FirmwareDrawer({ device, onOpenChange, onUpdated }) {
1222
1266
  const { t, tMessage } = useShellyTranslations();
1223
1267
  const [status, setStatus] = useState$1(null);
1224
1268
  const [currentPassword, setCurrentPassword] = useState$1("");
@@ -1297,126 +1341,6 @@ function useFirmwareDrawerState({ device, onOpenChange, onUpdated }) {
1297
1341
  }, Math.max(0, deadline.current - Date.now()));
1298
1342
  return () => clearTimeout(timeout);
1299
1343
  }, [installing, device]);
1300
- return {
1301
- t,
1302
- tMessage,
1303
- status,
1304
- currentPassword,
1305
- setCurrentPassword,
1306
- loading,
1307
- error,
1308
- installing,
1309
- installedVersion,
1310
- targetVersion,
1311
- close,
1312
- load,
1313
- install,
1314
- stages: ["stable", "beta"],
1315
- device,
1316
- onOpenChange
1317
- };
1318
- }
1319
- //#endregion
1320
- //#region frontend/src/devices/firmware/FirmwareDrawer.tsx
1321
- var { Button: Button$2, EmptyState: EmptyState$1, PasswordInput, StandardDrawer, StatusAlert: StatusAlert$1, TableDataLoadingIndicator: TableDataLoadingIndicator$1, useDateTimeFormatter } = await importShared("@attraccess/plugins-frontend-ui");
1322
- var { DrawerBody, DrawerFooter, DrawerHeader, DrawerHeading, Spinner, Tooltip: Tooltip$1 } = await importShared("@heroui/react");
1323
- var { ArrowUpCircleIcon, CpuIcon: CpuIcon$1, DownloadIcon, RefreshCwIcon: RefreshCwIcon$1, XIcon } = await importShared("lucide-react");
1324
- function shortVersion(version) {
1325
- const tail = version.split("/").pop();
1326
- return tail && tail.length > 0 ? tail : version;
1327
- }
1328
- /** Table cell summarising a device's firmware state from the bulk overview. */
1329
- function FirmwareCell({ entry }) {
1330
- const { t } = useShellyTranslations();
1331
- if (!entry) return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
1332
- className: "sh:text-sm sh:text-default-400",
1333
- children: t("firmware.checking")
1334
- });
1335
- if (entry.error || !entry.status) return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
1336
- className: "sh:block sh:max-w-40 sh:truncate sh:text-sm sh:text-default-400",
1337
- title: entry.error ?? void 0,
1338
- children: t("firmware.unavailable")
1339
- });
1340
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
1341
- className: "sh:flex sh:flex-col sh:gap-1",
1342
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
1343
- className: "sh:block sh:max-w-40 sh:truncate sh:text-sm sh:text-default-700",
1344
- title: entry.status.currentVersion ?? void 0,
1345
- children: entry.status.currentVersion ? shortVersion(entry.status.currentVersion) : t("devices.unknown")
1346
- }), entry.status.hasUpdate && entry.status.available.stable && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
1347
- className: "sh:max-w-40 sh:truncate sh:text-xs sh:text-warning-600",
1348
- title: entry.status.available.stable,
1349
- children: t("firmware.available", { version: shortVersion(entry.status.available.stable) })
1350
- })]
1351
- });
1352
- }
1353
- /**
1354
- * "Update available" marker next to the device name, so the signal survives the
1355
- * breakpoints where the Firmware column is hidden. Icon-only on purpose: a text
1356
- * chip here widens the Device column enough to push the row actions out of the
1357
- * table's visible width on tablets.
1358
- */
1359
- function UpdateAvailableIndicator({ entry }) {
1360
- const { t } = useShellyTranslations();
1361
- const version = entry?.status?.hasUpdate ? entry.status.available.stable : null;
1362
- if (!version) return null;
1363
- const label = t("firmware.updateAvailable", { version: shortVersion(version) });
1364
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Tooltip$1, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Tooltip$1.Trigger, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button$2, {
1365
- variant: "ghost",
1366
- size: "sm",
1367
- isIconOnly: true,
1368
- "aria-label": label,
1369
- className: "sh:h-6 sh:w-6 sh:min-w-6 sh:text-warning",
1370
- "data-cy": "shelly-update-available",
1371
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ArrowUpCircleIcon, { className: "sh:h-4 sh:w-4" })
1372
- }) }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Tooltip$1.Content, { children: label })] });
1373
- }
1374
- function VersionRow({ label, value }) {
1375
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
1376
- className: "sh:flex sh:items-baseline sh:justify-between sh:gap-3 sh:border-b sh:border-default-200 sh:py-2 sh:last:border-b-0",
1377
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
1378
- className: "sh:text-xs sh:font-medium sh:uppercase sh:tracking-wide sh:text-default-500",
1379
- children: label
1380
- }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
1381
- className: "sh:min-w-0 sh:truncate sh:text-sm sh:text-default-800",
1382
- title: value,
1383
- children: value
1384
- })]
1385
- });
1386
- }
1387
- function FirmwareDetails({ status }) {
1388
- const { t } = useShellyTranslations();
1389
- const formatDateTime = useDateTimeFormatter({ showSeconds: true });
1390
- if (!status) return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(EmptyState$1, { message: t("firmware.empty") });
1391
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("section", {
1392
- className: "sh:rounded-xl sh:border sh:border-default-200 sh:bg-surface sh:p-4",
1393
- "data-cy": "shelly-firmware-details",
1394
- children: [
1395
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(VersionRow, {
1396
- label: t("firmware.installed"),
1397
- value: status.currentVersion ?? t("devices.unknown")
1398
- }),
1399
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(VersionRow, {
1400
- label: t("firmware.stable"),
1401
- value: status.available.stable ?? t("firmware.upToDate")
1402
- }),
1403
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(VersionRow, {
1404
- label: t("firmware.beta"),
1405
- value: status.available.beta ?? t("firmware.nothingNewer")
1406
- }),
1407
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(VersionRow, {
1408
- label: t("firmware.checked"),
1409
- value: String(formatDateTime(status.fetchedAt))
1410
- })
1411
- ]
1412
- });
1413
- }
1414
- function FirmwareDrawer({ device, onOpenChange, onUpdated }) {
1415
- const { t, tMessage, status, currentPassword, setCurrentPassword, loading, error, installing, installedVersion, targetVersion, close, load, install, stages } = useFirmwareDrawerState({
1416
- device,
1417
- onOpenChange,
1418
- onUpdated
1419
- });
1420
1344
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(StandardDrawer, {
1421
1345
  isOpen: !!device,
1422
1346
  onOpenChange,
@@ -1438,7 +1362,7 @@ function FirmwareDrawer({ device, onOpenChange, onUpdated }) {
1438
1362
  address: device.ipAddress
1439
1363
  })
1440
1364
  })]
1441
- }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button$2, {
1365
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button$3, {
1442
1366
  isIconOnly: true,
1443
1367
  variant: "ghost",
1444
1368
  "aria-label": t("common.close"),
@@ -1489,7 +1413,7 @@ function FirmwareDrawer({ device, onOpenChange, onUpdated }) {
1489
1413
  }) }),
1490
1414
  /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(DrawerFooter, {
1491
1415
  className: "sh:flex-wrap",
1492
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Button$2, {
1416
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Button$3, {
1493
1417
  variant: "secondary",
1494
1418
  onPress: load,
1495
1419
  isPending: loading,
@@ -1500,10 +1424,10 @@ function FirmwareDrawer({ device, onOpenChange, onUpdated }) {
1500
1424
  " ",
1501
1425
  t("firmware.recheck")
1502
1426
  ]
1503
- }), stages.map((stage) => {
1427
+ }), STAGES.map((stage) => {
1504
1428
  const version = status?.available[stage];
1505
1429
  if (!version) return null;
1506
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Button$2, {
1430
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Button$3, {
1507
1431
  variant: stage === "stable" ? "primary" : "secondary",
1508
1432
  onPress: () => install(stage),
1509
1433
  isPending: installing === stage,
@@ -1527,11 +1451,8 @@ function FirmwareDrawer({ device, onOpenChange, onUpdated }) {
1527
1451
  ]
1528
1452
  });
1529
1453
  }
1530
- //#endregion
1531
- //#region frontend/src/devices/DeviceRowParts.tsx
1532
- var { Button: Button$1 } = await importShared("@attraccess/plugins-frontend-ui");
1533
- var { Chip: Chip$1, Dropdown, DropdownItem, DropdownMenu, DropdownPopover, DropdownTrigger, Tooltip } = await importShared("@heroui/react");
1534
- var { CpuIcon, InfoIcon, KeyRoundIcon, MoreVerticalIcon, RefreshCwIcon, Trash2Icon, TriangleAlertIcon } = await importShared("lucide-react");
1454
+ // frontend/src/devices/AuthChip.tsx
1455
+ var { Chip: Chip$1 } = await importShared("@heroui/react");
1535
1456
  function AuthChip({ state }) {
1536
1457
  const { t } = useShellyTranslations();
1537
1458
  const { color } = {
@@ -1547,9 +1468,84 @@ function AuthChip({ state }) {
1547
1468
  children: t(`auth.${state}`)
1548
1469
  });
1549
1470
  }
1471
+ // frontend/src/devices/EmptyDevices.tsx
1472
+ var { Button: Button$2, EmptyState } = await importShared("@attraccess/plugins-frontend-ui");
1473
+ var { PlusIcon: PlusIcon$1 } = await importShared("lucide-react");
1474
+ function EmptyDevices({ onAdd }) {
1475
+ const { t } = useShellyTranslations();
1476
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
1477
+ className: "sh:flex sh:flex-col sh:items-center sh:justify-center sh:gap-3 sh:pb-6",
1478
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(EmptyState, { message: t("devices.empty") }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Button$2, {
1479
+ variant: "secondary",
1480
+ size: "sm",
1481
+ onPress: onAdd,
1482
+ "data-cy": "shelly-add-open-empty",
1483
+ children: [
1484
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PlusIcon$1, { className: "sh:h-4 sh:w-4" }),
1485
+ " ",
1486
+ t("devices.add")
1487
+ ]
1488
+ })]
1489
+ });
1490
+ }
1491
+ // frontend/src/devices/firmware/FirmwareCell.tsx
1492
+ /** Table cell summarising a device's firmware state from the bulk overview. */
1493
+ function FirmwareCell({ entry }) {
1494
+ const { t } = useShellyTranslations();
1495
+ if (!entry) return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
1496
+ className: "sh:text-sm sh:text-default-400",
1497
+ children: t("firmware.checking")
1498
+ });
1499
+ if (entry.error || !entry.status) return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
1500
+ className: "sh:block sh:max-w-40 sh:truncate sh:text-sm sh:text-default-400",
1501
+ title: entry.error ?? void 0,
1502
+ children: t("firmware.unavailable")
1503
+ });
1504
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
1505
+ className: "sh:flex sh:flex-col sh:gap-1",
1506
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
1507
+ className: "sh:block sh:max-w-40 sh:truncate sh:text-sm sh:text-default-700",
1508
+ title: entry.status.currentVersion ?? void 0,
1509
+ children: entry.status.currentVersion ? shortVersion(entry.status.currentVersion) : t("devices.unknown")
1510
+ }), entry.status.hasUpdate && entry.status.available.stable && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
1511
+ className: "sh:max-w-40 sh:truncate sh:text-xs sh:text-warning-600",
1512
+ title: entry.status.available.stable,
1513
+ children: t("firmware.available", { version: shortVersion(entry.status.available.stable) })
1514
+ })]
1515
+ });
1516
+ }
1517
+ // frontend/src/devices/firmware/UpdateAvailableIndicator.tsx
1518
+ var { Button: Button$1 } = await importShared("@attraccess/plugins-frontend-ui");
1519
+ var { Tooltip: Tooltip$1 } = await importShared("@heroui/react");
1520
+ var { ArrowUpCircleIcon } = await importShared("lucide-react");
1521
+ /**
1522
+ * "Update available" marker next to the device name, so the signal survives the
1523
+ * breakpoints where the Firmware column is hidden. Icon-only on purpose: a text
1524
+ * chip here widens the Device column enough to push the row actions out of the
1525
+ * table's visible width on tablets.
1526
+ */
1527
+ function UpdateAvailableIndicator({ entry }) {
1528
+ const { t } = useShellyTranslations();
1529
+ const version = entry?.status?.hasUpdate ? entry.status.available.stable : null;
1530
+ if (!version) return null;
1531
+ const label = t("firmware.updateAvailable", { version: shortVersion(version) });
1532
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Tooltip$1, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Tooltip$1.Trigger, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button$1, {
1533
+ variant: "ghost",
1534
+ size: "sm",
1535
+ isIconOnly: true,
1536
+ "aria-label": label,
1537
+ className: "sh:h-6 sh:w-6 sh:min-w-6 sh:text-warning",
1538
+ "data-cy": "shelly-update-available",
1539
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ArrowUpCircleIcon, { className: "sh:h-4 sh:w-4" })
1540
+ }) }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Tooltip$1.Content, { children: label })] });
1541
+ }
1542
+ // frontend/src/devices/ProbeErrorIndicator.tsx
1543
+ var { Button } = await importShared("@attraccess/plugins-frontend-ui");
1544
+ var { Tooltip } = await importShared("@heroui/react");
1545
+ var { TriangleAlertIcon } = await importShared("lucide-react");
1550
1546
  function ProbeErrorIndicator({ message }) {
1551
1547
  const { t } = useShellyTranslations();
1552
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Tooltip, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Tooltip.Trigger, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button$1, {
1548
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Tooltip, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Tooltip.Trigger, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, {
1553
1549
  variant: "ghost",
1554
1550
  size: "sm",
1555
1551
  isIconOnly: true,
@@ -1559,79 +1555,72 @@ function ProbeErrorIndicator({ message }) {
1559
1555
  children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TriangleAlertIcon, { className: "sh:h-4 sh:w-4" })
1560
1556
  }) }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Tooltip.Content, { children: t("devices.probeError", { message }) })] });
1561
1557
  }
1562
- function RowActions({ deviceId, isBusy, onInfo, onFirmware, onAuth, onReprobe, onDelete }) {
1558
+ // frontend/src/devices/RowActions.tsx
1559
+ var { TableRowActions } = await importShared("@attraccess/plugins-frontend-ui");
1560
+ var { CpuIcon, InfoIcon, KeyRoundIcon, RefreshCwIcon, Trash2Icon } = await importShared("lucide-react");
1561
+ function RowActions({ device, isBusy, onInfo, onFirmware, onAuth, onReprobe, onDelete }) {
1563
1562
  const { t } = useShellyTranslations();
1564
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
1565
- className: "sh:flex sh:flex-row sh:items-center sh:justify-end sh:gap-1 sh:whitespace-nowrap",
1566
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Tooltip, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Tooltip.Trigger, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button$1, {
1567
- variant: "ghost",
1568
- size: "sm",
1569
- isIconOnly: true,
1570
- "aria-label": t("devices.info"),
1571
- isDisabled: isBusy,
1572
- onPress: onInfo,
1573
- "data-cy": `shelly-device-info-${deviceId}`,
1574
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(InfoIcon, { className: "sh:h-4 sh:w-4" })
1575
- }) }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Tooltip.Content, { children: t("devices.info") })] }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Dropdown, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(DropdownTrigger, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button$1, {
1576
- variant: "ghost",
1577
- size: "sm",
1578
- isIconOnly: true,
1579
- "aria-label": t("devices.more"),
1580
- isPending: isBusy,
1581
- "data-cy": `shelly-device-menu-${deviceId}`,
1582
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MoreVerticalIcon, { className: "sh:h-4 sh:w-4" })
1583
- }) }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DropdownPopover, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(DropdownMenu, {
1584
- "aria-label": t("devices.deviceActions"),
1585
- children: [
1586
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(DropdownItem, {
1587
- id: "firmware",
1588
- onPress: onFirmware,
1589
- "data-cy": `shelly-device-firmware-${deviceId}`,
1590
- children: [
1591
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CpuIcon, { className: "sh:mr-2 sh:inline sh:h-4 sh:w-4" }),
1592
- " ",
1593
- t("devices.manageFirmware")
1594
- ]
1595
- }),
1596
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(DropdownItem, {
1597
- id: "auth",
1598
- onPress: onAuth,
1599
- "data-cy": `shelly-device-auth-${deviceId}`,
1600
- children: [
1601
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(KeyRoundIcon, { className: "sh:mr-2 sh:inline sh:h-4 sh:w-4" }),
1602
- " ",
1603
- t("devices.password")
1604
- ]
1605
- }),
1606
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(DropdownItem, {
1607
- id: "reprobe",
1608
- onPress: onReprobe,
1609
- "data-cy": `shelly-device-reprobe-${deviceId}`,
1610
- children: [
1611
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RefreshCwIcon, { className: "sh:mr-2 sh:inline sh:h-4 sh:w-4" }),
1612
- " ",
1613
- t("devices.reprobe")
1614
- ]
1615
- }),
1616
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(DropdownItem, {
1617
- id: "delete",
1618
- onPress: onDelete,
1619
- className: "sh:text-danger",
1620
- "data-cy": `shelly-device-delete-${deviceId}`,
1621
- children: [
1622
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trash2Icon, { className: "sh:mr-2 sh:inline sh:h-4 sh:w-4" }),
1623
- " ",
1624
- t("devices.delete")
1625
- ]
1626
- })
1627
- ]
1628
- }) })] })]
1563
+ const deviceId = device.id;
1564
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TableRowActions, {
1565
+ itemName: device.name,
1566
+ isPending: isBusy,
1567
+ "data-cy": `shelly-device-menu-${deviceId}`,
1568
+ actions: [
1569
+ {
1570
+ key: "info",
1571
+ label: t("devices.info"),
1572
+ icon: InfoIcon,
1573
+ onPress: onInfo,
1574
+ "data-cy": `shelly-device-info-${deviceId}`
1575
+ },
1576
+ {
1577
+ key: "firmware",
1578
+ label: t("devices.manageFirmware"),
1579
+ icon: CpuIcon,
1580
+ onPress: onFirmware,
1581
+ "data-cy": `shelly-device-firmware-${deviceId}`
1582
+ },
1583
+ {
1584
+ key: "auth",
1585
+ label: t("devices.password"),
1586
+ icon: KeyRoundIcon,
1587
+ onPress: onAuth,
1588
+ "data-cy": `shelly-device-auth-${deviceId}`
1589
+ },
1590
+ {
1591
+ key: "reprobe",
1592
+ label: t("devices.reprobe"),
1593
+ icon: RefreshCwIcon,
1594
+ onPress: onReprobe,
1595
+ "data-cy": `shelly-device-reprobe-${deviceId}`
1596
+ },
1597
+ {
1598
+ key: "delete",
1599
+ label: t("devices.delete"),
1600
+ icon: Trash2Icon,
1601
+ tone: "danger",
1602
+ onPress: onDelete,
1603
+ "data-cy": `shelly-device-delete-${deviceId}`,
1604
+ confirm: {
1605
+ title: t("devices.delete"),
1606
+ message: t("devices.deleteDescription", {
1607
+ name: device.name,
1608
+ address: device.ipAddress
1609
+ }),
1610
+ confirmLabel: t("common.delete"),
1611
+ cancelLabel: t("common.cancel"),
1612
+ "data-cy": "shelly-delete-confirmation-modal",
1613
+ confirmDataCy: "shelly-delete-confirm",
1614
+ cancelDataCy: "shelly-delete-cancel"
1615
+ }
1616
+ }
1617
+ ]
1629
1618
  });
1630
1619
  }
1631
- //#endregion
1632
- //#region frontend/src/renderDevicesPageDevicesRows.tsx
1633
- var { Chip, TableCell, TableRow } = await importShared("@heroui/react");
1634
- function renderDevicesPageDevicesRows(device, { firmware, t, rowBusyId, setInfoDevice, setFirmwareDevice, setAuthDevice, withRowBusy, setDeleteTarget }) {
1620
+ // frontend/src/devices/DevicesTable.tsx
1621
+ var { TableActionsColumnHeader } = await importShared("@attraccess/plugins-frontend-ui");
1622
+ var { Chip, Table, TableBody, TableCell, TableColumn, TableContent, TableHeader, TableRow, TableScrollContainer } = await importShared("@heroui/react");
1623
+ function renderDeviceRow(device, { firmware, rowBusyId, setInfoDevice, setFirmwareDevice, setAuthDevice, withRowBusy, onDelete }, t) {
1635
1624
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(TableRow, {
1636
1625
  id: device.id,
1637
1626
  "data-cy": `shelly-device-row-${device.id}`,
@@ -1685,24 +1674,70 @@ function renderDevicesPageDevicesRows(device, { firmware, t, rowBusyId, setInfoD
1685
1674
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TableCell, {
1686
1675
  className: "sh:whitespace-nowrap",
1687
1676
  children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RowActions, {
1688
- deviceId: device.id,
1677
+ device,
1689
1678
  isBusy: rowBusyId === device.id,
1690
1679
  onInfo: () => setInfoDevice(device),
1691
1680
  onFirmware: () => setFirmwareDevice(device),
1692
1681
  onAuth: () => setAuthDevice(device),
1693
1682
  onReprobe: () => withRowBusy(device.id, () => reprobeDevice(device.id)),
1694
- onDelete: () => setDeleteTarget(device)
1683
+ onDelete: () => onDelete(device)
1695
1684
  })
1696
1685
  })
1697
1686
  ]
1698
1687
  }, device.id);
1699
1688
  }
1700
- //#endregion
1701
- //#region frontend/src/useDevicesPageState.tsx
1689
+ function DevicesTable({ devices, onAdd, ...rowProps }) {
1690
+ const { t, language } = useShellyTranslations();
1691
+ const { firmware, rowBusyId } = rowProps;
1692
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Table, {
1693
+ "data-cy": "shelly-device-table",
1694
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TableScrollContainer, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(TableContent, {
1695
+ "aria-label": t("devices.table"),
1696
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(TableHeader, { children: [
1697
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TableColumn, {
1698
+ isRowHeader: true,
1699
+ children: t("devices.device")
1700
+ }),
1701
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TableColumn, {
1702
+ className: "sh:hidden sh:sm:table-cell sh:md:hidden sh:lg:table-cell",
1703
+ children: t("devices.address")
1704
+ }),
1705
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TableColumn, {
1706
+ className: "sh:hidden sh:lg:table-cell",
1707
+ children: t("devices.model")
1708
+ }),
1709
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TableColumn, {
1710
+ className: "sh:hidden sh:sm:table-cell",
1711
+ children: t("devices.auth")
1712
+ }),
1713
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TableColumn, {
1714
+ className: "sh:hidden sh:xl:table-cell",
1715
+ children: t("devices.firmware")
1716
+ }),
1717
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TableColumn, {
1718
+ id: "actions",
1719
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TableActionsColumnHeader, {})
1720
+ })
1721
+ ] }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TableBody, {
1722
+ items: devices,
1723
+ dependencies: [
1724
+ firmware,
1725
+ rowBusyId,
1726
+ language
1727
+ ],
1728
+ renderEmptyState: () => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(EmptyDevices, { onAdd }),
1729
+ children: (device) => renderDeviceRow(device, rowProps, t)
1730
+ })]
1731
+ }) })
1732
+ });
1733
+ }
1734
+ // frontend/src/devices/DevicesPage.tsx
1735
+ var { PageHeader, StatusAlert, TableDataLoadingIndicator } = await importShared("@attraccess/plugins-frontend-ui");
1702
1736
  var { useOverlayState } = await importShared("@heroui/react");
1737
+ var { PlusIcon, SearchIcon, WifiIcon: WifiIcon$1 } = await importShared("lucide-react");
1703
1738
  var { useCallback, useEffect, useState } = await importShared("react");
1704
- function useDevicesPageState() {
1705
- const { t, language } = useShellyTranslations();
1739
+ function DevicesPage() {
1740
+ const { t } = useShellyTranslations();
1706
1741
  const [devices, setDevices] = useState([]);
1707
1742
  const [loading, setLoading] = useState(true);
1708
1743
  const [pageError, setPageError] = useState(null);
@@ -1711,8 +1746,6 @@ function useDevicesPageState() {
1711
1746
  const [authDevice, setAuthDevice] = useState(null);
1712
1747
  const [firmwareDevice, setFirmwareDevice] = useState(null);
1713
1748
  const [firmware, setFirmware] = useState({});
1714
- const [deleteTarget, setDeleteTarget] = useState(null);
1715
- const [deleting, setDeleting] = useState(false);
1716
1749
  const addDrawer = useOverlayState();
1717
1750
  const discoverDrawer = useOverlayState();
1718
1751
  const refreshFirmware = useCallback(async (known = []) => {
@@ -1743,78 +1776,25 @@ function useDevicesPageState() {
1743
1776
  useEffect(() => {
1744
1777
  refresh();
1745
1778
  }, [refresh]);
1746
- return {
1747
- t,
1748
- language,
1749
- devices,
1750
- loading,
1751
- pageError,
1752
- rowBusyId,
1753
- infoDevice,
1754
- setInfoDevice,
1755
- authDevice,
1756
- setAuthDevice,
1757
- firmwareDevice,
1758
- setFirmwareDevice,
1759
- firmware,
1760
- deleteTarget,
1761
- setDeleteTarget,
1762
- deleting,
1763
- addDrawer,
1764
- discoverDrawer,
1765
- refreshFirmware,
1766
- refresh,
1767
- withRowBusy: useCallback(async (id, action) => {
1768
- setRowBusyId(id);
1769
- try {
1770
- await action();
1771
- await refresh();
1772
- } catch (err) {
1773
- setPageError(err instanceof Error ? err.message : String(err));
1774
- } finally {
1775
- setRowBusyId(null);
1776
- }
1777
- }, [refresh]),
1778
- confirmDelete: useCallback(async () => {
1779
- if (!deleteTarget) return;
1780
- setDeleting(true);
1781
- try {
1782
- await deleteDevice(deleteTarget.id);
1783
- await refresh();
1784
- setDeleteTarget(null);
1785
- } catch (err) {
1786
- setPageError(err instanceof Error ? err.message : String(err));
1787
- setDeleteTarget(null);
1788
- } finally {
1789
- setDeleting(false);
1790
- }
1791
- }, [deleteTarget, refresh])
1792
- };
1793
- }
1794
- //#endregion
1795
- //#region frontend/src/devices/DevicesPage.tsx
1796
- var { Button, EmptyState, PageHeader, StatusAlert, StatusDialog, TableDataLoadingIndicator } = await importShared("@attraccess/plugins-frontend-ui");
1797
- var { Table, TableBody, TableColumn, TableContent, TableHeader, TableScrollContainer } = await importShared("@heroui/react");
1798
- var { PlusIcon, SearchIcon, WifiIcon: WifiIcon$1 } = await importShared("lucide-react");
1799
- function EmptyDevices({ onAdd }) {
1800
- const { t } = useShellyTranslations();
1801
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
1802
- className: "sh:flex sh:flex-col sh:items-center sh:justify-center sh:gap-3 sh:pb-6",
1803
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(EmptyState, { message: t("devices.empty") }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Button, {
1804
- variant: "secondary",
1805
- size: "sm",
1806
- onPress: onAdd,
1807
- "data-cy": "shelly-add-open-empty",
1808
- children: [
1809
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PlusIcon, { className: "sh:h-4 sh:w-4" }),
1810
- " ",
1811
- t("devices.add")
1812
- ]
1813
- })]
1814
- });
1815
- }
1816
- function DevicesPage() {
1817
- const { t, language, devices, loading, pageError, rowBusyId, infoDevice, setInfoDevice, authDevice, setAuthDevice, firmwareDevice, setFirmwareDevice, firmware, deleteTarget, setDeleteTarget, deleting, addDrawer, discoverDrawer, refreshFirmware, refresh, withRowBusy, confirmDelete } = useDevicesPageState();
1779
+ const withRowBusy = useCallback(async (id, action) => {
1780
+ setRowBusyId(id);
1781
+ try {
1782
+ await action();
1783
+ await refresh();
1784
+ } catch (err) {
1785
+ setPageError(err instanceof Error ? err.message : String(err));
1786
+ } finally {
1787
+ setRowBusyId(null);
1788
+ }
1789
+ }, [refresh]);
1790
+ const removeDevice = useCallback(async (device) => {
1791
+ try {
1792
+ await deleteDevice(device.id);
1793
+ await refresh();
1794
+ } catch (err) {
1795
+ setPageError(err instanceof Error ? err.message : String(err));
1796
+ }
1797
+ }, [refresh]);
1818
1798
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
1819
1799
  className: "sh:mx-auto sh:flex sh:w-full sh:max-w-5xl sh:flex-col sh:gap-6 sh:p-4 sh:md:p-6",
1820
1800
  children: [
@@ -1844,55 +1824,16 @@ function DevicesPage() {
1844
1824
  title: t("devices.loadError"),
1845
1825
  children: pageError
1846
1826
  }),
1847
- loading ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TableDataLoadingIndicator, {}) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Table, {
1848
- "data-cy": "shelly-device-table",
1849
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TableScrollContainer, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(TableContent, {
1850
- "aria-label": t("devices.table"),
1851
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(TableHeader, { children: [
1852
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TableColumn, {
1853
- isRowHeader: true,
1854
- children: t("devices.device")
1855
- }),
1856
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TableColumn, {
1857
- className: "sh:hidden sh:sm:table-cell sh:md:hidden sh:lg:table-cell",
1858
- children: t("devices.address")
1859
- }),
1860
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TableColumn, {
1861
- className: "sh:hidden sh:lg:table-cell",
1862
- children: t("devices.model")
1863
- }),
1864
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TableColumn, {
1865
- className: "sh:hidden sh:sm:table-cell",
1866
- children: t("devices.auth")
1867
- }),
1868
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TableColumn, {
1869
- className: "sh:hidden sh:xl:table-cell",
1870
- children: t("devices.firmware")
1871
- }),
1872
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TableColumn, {
1873
- className: "sh:text-end",
1874
- children: t("devices.actions")
1875
- })
1876
- ] }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TableBody, {
1877
- items: devices,
1878
- dependencies: [
1879
- firmware,
1880
- rowBusyId,
1881
- language
1882
- ],
1883
- renderEmptyState: () => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(EmptyDevices, { onAdd: addDrawer.open }),
1884
- children: (device) => renderDevicesPageDevicesRows(device, {
1885
- firmware,
1886
- t,
1887
- rowBusyId,
1888
- setInfoDevice,
1889
- setFirmwareDevice,
1890
- setAuthDevice,
1891
- withRowBusy,
1892
- setDeleteTarget
1893
- })
1894
- })]
1895
- }) })
1827
+ loading ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TableDataLoadingIndicator, {}) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DevicesTable, {
1828
+ devices,
1829
+ firmware,
1830
+ rowBusyId,
1831
+ onAdd: addDrawer.open,
1832
+ setInfoDevice,
1833
+ setFirmwareDevice,
1834
+ setAuthDevice,
1835
+ onDelete: removeDevice,
1836
+ withRowBusy
1896
1837
  }),
1897
1838
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AddDeviceDrawer, {
1898
1839
  isOpen: addDrawer.isOpen,
@@ -1917,35 +1858,15 @@ function DevicesPage() {
1917
1858
  device: firmwareDevice,
1918
1859
  onOpenChange: (open) => !open && setFirmwareDevice(null),
1919
1860
  onUpdated: () => void refreshFirmware(devices)
1920
- }),
1921
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StatusDialog, {
1922
- isOpen: !!deleteTarget,
1923
- onClose: () => setDeleteTarget(null),
1924
- status: "error",
1925
- title: t("devices.delete"),
1926
- action: {
1927
- label: t("common.delete"),
1928
- onPress: confirmDelete,
1929
- isPending: deleting,
1930
- "data-cy": "shelly-delete-confirm"
1931
- },
1932
- closeLabel: t("common.cancel"),
1933
- closeDataCy: "shelly-delete-cancel",
1934
- "data-cy": "shelly-delete-confirmation-modal",
1935
- children: t("devices.deleteDescription", {
1936
- name: deleteTarget?.name,
1937
- address: deleteTarget?.ipAddress
1938
- })
1939
1861
  })
1940
1862
  ]
1941
1863
  });
1942
1864
  }
1943
- //#endregion
1944
- //#region frontend/src/plugin.tsx
1865
+ // frontend/src/plugin.tsx
1945
1866
  var { WifiIcon } = await importShared("lucide-react");
1946
1867
  var ShellyPlugin = class {
1947
1868
  getPluginName() {
1948
- return "shelly-plugin@0.1.0";
1869
+ return "shelly-plugin@0.2.0";
1949
1870
  }
1950
1871
  getDependencies() {
1951
1872
  return [];
@@ -1970,5 +1891,4 @@ var ShellyPlugin = class {
1970
1891
  }];
1971
1892
  }
1972
1893
  };
1973
- //#endregion
1974
1894
  export { ShellyPlugin as default };