@celljs/ta-share 4.11.0 → 4.12.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 (2) hide show
  1. package/package.json +4 -4
  2. package/web/index.js +45 -18
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@celljs/ta-share",
3
- "version": "4.11.0",
3
+ "version": "4.12.0",
4
4
  "description": "A pi package for Ta: share a conversation, a page or a file by a link, public, with a password or for yourself, end to end through the relay; open and import what others share",
5
5
  "keywords": [
6
6
  "pi-package"
@@ -27,9 +27,9 @@
27
27
  "watch": "tsc -b -w --preserveWatchOutput"
28
28
  },
29
29
  "devDependencies": {
30
- "@celljs/ta-protocol": "4.11.0",
31
- "@celljs/ta-relay": "4.11.0",
32
- "@celljs/ta-web": "4.11.0",
30
+ "@celljs/ta-protocol": "4.12.0",
31
+ "@celljs/ta-relay": "4.12.0",
32
+ "@celljs/ta-web": "4.12.0",
33
33
  "@types/react": "^19.3.0"
34
34
  },
35
35
  "publishConfig": {
package/web/index.js CHANGED
@@ -959,10 +959,19 @@ function kindIcon(share) {
959
959
  function ShareRow({ share }) {
960
960
  const [copied, setCopied] = React.useState(false);
961
961
  const [stopping, setStopping] = React.useState(false);
962
+ const touch = pi.ui.useDevice().touch;
963
+ const [menu, openMenu] = pi.ui.useContextMenu();
962
964
  const Kind = icon(kindIcon(share));
963
965
  const Copy = icon("Copy");
964
966
  const Qr = icon("QrCode");
965
967
  const Stop = icon("Trash2");
968
+ const show = () => openShareDialog({ kind: "made", share });
969
+ const copy = () => void navigator.clipboard?.writeText(share.link).then(() => {
970
+ setCopied(true);
971
+ if (touch) {
972
+ pi.ui.notify(t("copied"));
973
+ }
974
+ }).catch((error) => pi.ui.notify(message(error), "error"));
966
975
  const stop = async () => {
967
976
  if (await pi.ui.confirm(t("stopTitle", { title: share.title }), t("stopHint"), { confirmLabel: t("stop"), danger: true })) {
968
977
  setStopping(true);
@@ -972,37 +981,43 @@ function ShareRow({ share }) {
972
981
  });
973
982
  }
974
983
  };
975
- return /* @__PURE__ */ React.createElement("li", {
976
- className: `tsh-row${stopping ? " ta-pending" : ""}`
984
+ const items = [
985
+ [
986
+ { key: "qr", label: t("qr"), icon: Qr, run: show },
987
+ { key: "copy", label: t("copy"), icon: Copy, run: copy }
988
+ ],
989
+ [{ key: "stop", label: t("stop"), icon: Stop, danger: true, disabled: stopping, run: () => void stop() }]
990
+ ];
991
+ const content = /* @__PURE__ */ React.createElement("div", {
992
+ className: `tsh-row${stopping ? " ta-pending" : ""}`,
993
+ "aria-busy": stopping || undefined,
994
+ onContextMenu: (event) => openMenu(event, items)
995
+ }, /* @__PURE__ */ React.createElement("button", {
996
+ type: "button",
997
+ className: "tsh-row-main",
998
+ title: t("qr"),
999
+ onClick: show
977
1000
  }, /* @__PURE__ */ React.createElement("span", {
978
1001
  className: `tsh-tile tsh-tile-${share.access}`,
979
1002
  "aria-hidden": "true"
980
1003
  }, /* @__PURE__ */ React.createElement(Kind, {
981
1004
  size: 18
982
- })), /* @__PURE__ */ React.createElement("div", {
1005
+ })), /* @__PURE__ */ React.createElement("span", {
983
1006
  className: "tsh-row-text"
984
1007
  }, /* @__PURE__ */ React.createElement("span", {
985
1008
  className: "tsh-row-title"
986
1009
  }, share.title), /* @__PURE__ */ React.createElement("span", {
987
1010
  className: "tsh-row-line"
988
- }, shareLine(share))), /* @__PURE__ */ React.createElement("div", {
1011
+ }, shareLine(share)))), !touch && /* @__PURE__ */ React.createElement("div", {
989
1012
  className: "tsh-row-actions"
990
1013
  }, /* @__PURE__ */ React.createElement("button", {
991
1014
  type: "button",
992
1015
  className: "tsh-icon",
993
1016
  title: copied ? t("copied") : t("copy"),
994
1017
  "aria-label": t("copy"),
995
- onClick: () => void navigator.clipboard?.writeText(share.link).then(() => setCopied(true))
1018
+ onClick: copy
996
1019
  }, /* @__PURE__ */ React.createElement(Copy, {
997
1020
  size: 15
998
- })), /* @__PURE__ */ React.createElement("button", {
999
- type: "button",
1000
- className: "tsh-icon",
1001
- title: t("qr"),
1002
- "aria-label": t("qr"),
1003
- onClick: () => openShareDialog({ kind: "made", share })
1004
- }, /* @__PURE__ */ React.createElement(Qr, {
1005
- size: 15
1006
1021
  })), /* @__PURE__ */ React.createElement("button", {
1007
1022
  type: "button",
1008
1023
  className: "tsh-icon tsh-danger",
@@ -1013,6 +1028,12 @@ function ShareRow({ share }) {
1013
1028
  }, /* @__PURE__ */ React.createElement(Stop, {
1014
1029
  size: 15
1015
1030
  }))));
1031
+ const SwipeRow = pi.ui.SwipeRow;
1032
+ return /* @__PURE__ */ React.createElement("li", {
1033
+ className: "tsh-item"
1034
+ }, SwipeRow ? /* @__PURE__ */ React.createElement(SwipeRow, {
1035
+ actions: [{ key: "stop", label: t("stop"), danger: true, run: () => void stop() }]
1036
+ }, content) : content, menu);
1016
1037
  }
1017
1038
  function SharesPage() {
1018
1039
  const list = useShares();
@@ -1080,11 +1101,13 @@ var STYLE = `
1080
1101
  .tsh-stop { align-self: center; border: 0; background: none; color: var(--ta-muted); font: inherit; font-size: calc(12.5px * var(--ta-font-scale)); cursor: pointer; padding: 4px 8px; border-radius: 6px; }
1081
1102
  .tsh-stop:hover { color: var(--ta-red); background: var(--ta-hover); }
1082
1103
 
1083
- /* My shares. */
1084
- .tsh-page { max-width: 720px; margin: 0 auto; padding: 12px 16px 32px; }
1085
- .tsh-rows { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; }
1086
- .tsh-row { display: flex; align-items: center; gap: 12px; padding: 10px 8px; border-radius: 10px; transition: background 120ms, opacity 200ms; }
1104
+ /* My shares: the page fills its place and scrolls, its rows never wider than it. */
1105
+ .tsh-page { flex: 1; min-width: 0; min-height: 0; width: 100%; height: 100%; overflow-y: auto; box-sizing: border-box; padding: 12px 16px 32px; }
1106
+ .tsh-rows { max-width: 720px; margin: 0 auto; padding: 0; list-style: none; display: flex; flex-direction: column; }
1107
+ .tsh-item { --ta-swipe-bg: var(--ta-main); min-width: 0; border-radius: 10px; overflow: hidden; }
1108
+ .tsh-row { display: flex; align-items: center; gap: 4px; min-width: 0; padding-right: 6px; border-radius: 10px; transition: background 120ms, opacity 200ms; }
1087
1109
  .tsh-row:hover { background: var(--ta-hover); }
1110
+ .tsh-row-main { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; padding: 10px 8px; border: 0; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; }
1088
1111
  .tsh-tile { flex: none; display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; border-radius: 11px; color: #fff; background: var(--ta-green); }
1089
1112
  .tsh-tile-password { background: var(--ta-yellow); }
1090
1113
  .tsh-tile-self { background: var(--ta-blue); }
@@ -1092,7 +1115,11 @@ var STYLE = `
1092
1115
  .tsh-row-title { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
1093
1116
  .tsh-row-line { color: var(--ta-muted); font-size: calc(12px * var(--ta-font-scale)); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
1094
1117
  .tsh-row-actions { flex: none; display: flex; gap: 2px; opacity: .75; }
1095
- .tsh-row:hover .tsh-row-actions { opacity: 1; }
1118
+ .tsh-row:hover .tsh-row-actions, .tsh-row:focus-within .tsh-row-actions { opacity: 1; }
1119
+ :root[data-touch] .tsh-row:hover { background: none; }
1120
+ :root[data-handheld] .tsh-item { border-radius: 0; }
1121
+ :root[data-touch] .tsh-row-main { padding: 12px 8px; }
1122
+ :root[data-touch] .tsh-row-main:active { background: var(--ta-hover); }
1096
1123
  .tsh-icon { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; border: 0; border-radius: 8px; background: none; color: var(--ta-secondary); cursor: pointer; }
1097
1124
  .tsh-icon:hover:not(:disabled) { background: var(--ta-hover-strong); color: var(--ta-text); }
1098
1125
  .tsh-icon.tsh-danger:hover:not(:disabled) { color: var(--ta-red); }