@xsynaptic/share-kit 0.4.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -439,7 +439,7 @@ const shareKitFacebook = {
439
439
  },
440
440
  composer: ({ url }) => withQuery("https://www.facebook.com/sharer/sharer.php", { u: url }),
441
441
  count: shareKitCountLength,
442
- hint: "Facebook only takes the link. Your caption is copied, so paste it into your post.",
442
+ hint: "Facebook only takes the link. Your text is copied, so paste it into your post.",
443
443
  id: "facebook",
444
444
  images: [shareKitLandscapeFormat, shareKitPortraitFormat],
445
445
  label: "Facebook",
@@ -448,11 +448,11 @@ const shareKitFacebook = {
448
448
  };
449
449
  const shareKitInstagram = {
450
450
  actions: {
451
- desktop: [],
451
+ desktop: ["save-image"],
452
452
  mobile: ["share-image"]
453
453
  },
454
454
  count: shareKitCountLength,
455
- hint: "Links in Instagram captions aren't clickable. Point people to the link in your bio.",
455
+ hint: "Your text is copied, so paste it as the caption. Links in it aren't clickable.",
456
456
  id: "instagram",
457
457
  images: [shareKitPortraitFormat],
458
458
  label: "Instagram",
@@ -461,11 +461,11 @@ const shareKitInstagram = {
461
461
  };
462
462
  const shareKitInstagramStory = {
463
463
  actions: {
464
- desktop: [],
464
+ desktop: ["save-image"],
465
465
  mobile: ["share-image"]
466
466
  },
467
467
  count: shareKitCountLength,
468
- hint: "Add the link to your Story with a link sticker.",
468
+ hint: "The link is copied, so add it to your Story with a link sticker.",
469
469
  id: "instagram-story",
470
470
  images: [shareKitStoryFormat, shareKitPortraitFormat],
471
471
  label: "Story",
@@ -478,7 +478,7 @@ const shareKitLinkedin = {
478
478
  },
479
479
  composer: ({ url }) => withQuery("https://www.linkedin.com/sharing/share-offsite/", { url }),
480
480
  count: shareKitCountLength,
481
- hint: "LinkedIn only takes the link. Your caption is copied, so paste it into your post.",
481
+ hint: "LinkedIn only takes the link. Your text is copied, so paste it into your post.",
482
482
  id: "linkedin",
483
483
  images: [shareKitLandscapeFormat],
484
484
  label: "LinkedIn",
@@ -492,6 +492,7 @@ const shareKitLine = {
492
492
  },
493
493
  composer: ({ device, text, url }) => device === "mobile" ? `https://line.me/R/share?text=${encodeURIComponent(text)}` : `https://social-plugins.line.me/lineit/share?url=${encodeURIComponent(url)}&text=${encodeURIComponent(text)}`,
494
494
  count: shareKitCountLength,
495
+ hint: "Opens the LINE app if you have it, or LINE on the web, which asks you to sign in.",
495
496
  id: "line",
496
497
  images: [shareKitLandscapeFormat],
497
498
  label: "LINE",
@@ -499,9 +500,10 @@ const shareKitLine = {
499
500
  };
500
501
  const shareKitMastodon = {
501
502
  actions: {
502
- desktop: [],
503
- mobile: ["share-image"]
503
+ desktop: ["open-composer"],
504
+ mobile: ["share-image", "open-composer"]
504
505
  },
506
+ composer: ({ text }) => `https://share.joinmastodon.org/#text=${encodeURIComponent(text)}`,
505
507
  count: shareKitWithLinkCost(shareKitCountStringz, fixedLinkCost),
506
508
  id: "mastodon",
507
509
  images: [shareKitPortraitFormat],
@@ -591,6 +593,7 @@ function canRun(action, input) {
591
593
  switch (action) {
592
594
  case "copy-caption": return true;
593
595
  case "open-composer": return Boolean(input.composerUrl);
596
+ case "save-image": return input.hasSuggestedImage;
594
597
  case "share-image": return input.canShareFiles && input.hasSuggestedImage;
595
598
  case "share-link":
596
599
  case "share-text": return input.canShareText;
@@ -713,17 +716,12 @@ var ShareFeedback = class {
713
716
  }
714
717
  };
715
718
  // src/icons.ts
716
- const shareKitInterfaceIconNames = [
717
- "close",
718
- "more",
719
- "qr"
720
- ];
719
+ const shareKitInterfaceIconNames = ["close", "more"];
721
720
  const shareKitInterfaceIcons = {
722
721
  any: "M3.16 14.47L5.99 11.65A4.5 4.5 0 0 1 12.35 18.01L9.53 20.84A4.5 4.5 0 0 1 3.16 14.47ZM4.58 15.89A2.5 2.5 0 0 0 8.11 19.42L10.94 16.6A2.5 2.5 0 0 0 7.4 13.06ZM11.65 5.99L14.47 3.16A4.5 4.5 0 0 1 20.84 9.53L18.01 12.35A4.5 4.5 0 0 1 11.65 5.99ZM13.06 7.4A2.5 2.5 0 0 0 16.6 10.94L19.42 8.11A2.5 2.5 0 0 0 15.89 4.58ZM8.46 14.12L14.12 8.46L15.54 9.88L9.88 15.54Z",
723
722
  close: "M6 7.41 7.41 6 12 10.59 16.59 6 18 7.41 13.41 12 18 16.59 16.59 18 12 13.41 7.41 18 6 16.59 10.59 12Z",
724
723
  messages: "M5 4h14a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2ZM5 6v9h14V6ZM7 17v4l4-4Z",
725
- more: "M4 12a2 2 0 1 0 4 0a2 2 0 1 0-4 0ZM10 12a2 2 0 1 0 4 0a2 2 0 1 0-4 0ZM16 12a2 2 0 1 0 4 0a2 2 0 1 0-4 0Z",
726
- qr: "M3 3h7v7H3ZM4.5 4.5v4h4v-4ZM5.5 5.5h2v2h-2ZM14 3h7v7h-7ZM15.5 4.5v4h4v-4ZM16.5 5.5h2v2h-2ZM3 14h7v7H3ZM4.5 15.5v4h4v-4ZM5.5 16.5h2v2h-2ZM14 14h2v2h-2ZM18 14h3v2h-3ZM16 16h2v2h-2ZM14 18h2v3h-2ZM18 18h3v3h-3Z"
724
+ more: "M4 12a2 2 0 1 0 4 0a2 2 0 1 0-4 0ZM10 12a2 2 0 1 0 4 0a2 2 0 1 0-4 0ZM16 12a2 2 0 1 0 4 0a2 2 0 1 0-4 0Z"
727
725
  };
728
726
  var ShareIconSource = class {
729
727
  get icons() {
@@ -879,27 +877,32 @@ const shareKitStringDefaults = {
879
877
  assetCopy: "Copy",
880
878
  assetSave: "Save",
881
879
  assetShare: "Share",
882
- captionCopy: "Copy caption",
883
880
  captionOver: "{count} over the limit for {destination}",
884
881
  captionReset: "Reset",
885
- captionTitle: "Caption",
886
882
  close: "Close",
887
883
  copied: "Copied",
888
- copyManual: "Couldn't copy. The caption is selected, so you can copy it yourself.",
884
+ copyManual: "Couldn't copy. The text is selected, so you can copy it yourself.",
885
+ copyText: "Copy text",
886
+ copyTitle: "Copy title",
887
+ countOver: "{count} over",
889
888
  destinationsMore: "More",
890
889
  destinationsTitle: "Post to",
891
890
  error: "Something went wrong. Try saving instead.",
891
+ fieldText: "Text",
892
+ fieldTitle: "Title",
893
+ imagesHint: "Save or copy one, then add it to your post.",
894
+ imagesHintMobile: "Share one straight to an app, or save it.",
892
895
  imagesTitle: "Images",
893
896
  linkCopy: "Copy link",
894
897
  linkTitle: "Link",
895
- primaryCopy: "Copy caption",
896
898
  primaryOpen: "Open {destination}",
899
+ primarySaveImage: "Save image",
897
900
  primaryShareImage: "Share image",
898
901
  primaryShareLink: "Share link",
899
902
  primaryShareText: "Share",
900
903
  qrAlt: "QR code for this page",
901
904
  qrTitle: "Scan to continue on your phone",
902
- qrToggle: "Continue on your phone",
905
+ qrToggle: "Open on phone",
903
906
  retry: "Ready. Tap again to share.",
904
907
  saved: "Saved",
905
908
  saveError: "Couldn't save. Try again.",
@@ -950,9 +953,8 @@ function renderHeading({ classNames }, children, id) {
950
953
  id
951
954
  }, children);
952
955
  }
953
- function renderIconButton({ icons }, { action, attributes, fallback, icon, label }) {
956
+ function renderIconButton({ icons }, { action, fallback, icon, label }) {
954
957
  return createElement("button", {
955
- ...attributes,
956
958
  "aria-label": label,
957
959
  class: "share-kit-icon-button",
958
960
  "data-share-kit-action": action,
@@ -961,25 +963,19 @@ function renderIconButton({ icons }, { action, attributes, fallback, icon, label
961
963
  }, [createIconSlot(icon, icons[icon], fallback)]);
962
964
  }
963
965
  function renderHeader(context) {
964
- const { capabilities, id, strings } = context;
966
+ const { id, strings } = context;
965
967
  const heading = createElement("h2", {
966
968
  class: "share-kit-title",
967
969
  id: `${id}-title`,
968
970
  tabindex: "-1"
969
971
  }, [strings.title]);
970
972
  return {
971
- header: createElement("header", { class: "share-kit-header" }, [heading, createElement("div", { class: "share-kit-header-actions" }, [capabilities.has("mobile") ? void 0 : renderIconButton(context, {
972
- action: "qr",
973
- attributes: { "aria-haspopup": "dialog" },
974
- fallback: "QR",
975
- icon: "qr",
976
- label: strings.qrToggle
977
- }), renderIconButton(context, {
973
+ header: createElement("header", { class: "share-kit-header" }, [heading, renderIconButton(context, {
978
974
  action: "close",
979
975
  fallback: "×",
980
976
  icon: "close",
981
977
  label: strings.close
982
- })])]),
978
+ })]),
983
979
  heading
984
980
  };
985
981
  }
@@ -995,7 +991,7 @@ function renderDestination(context, destination) {
995
991
  type: "button"
996
992
  }, [renderDestinationIcon(context, destination.id), createElement("span", {}, [getDestinationLabel(strings, destination)])]);
997
993
  }
998
- function renderDestinations(context) {
994
+ function renderDestinationRow(context) {
999
995
  const { destinations, destinationsMore, id, strings } = context;
1000
996
  const headingId = `${id}-destinations`;
1001
997
  const more = destinationsMore.length > 0 ? createElement("button", {
@@ -1015,21 +1011,36 @@ function renderDestinations(context) {
1015
1011
  }, [...destinations.map((destination) => renderDestination(context, destination)), ...extra]);
1016
1012
  return {
1017
1013
  more,
1018
- section: createElement("section", { class: "share-kit-section" }, [renderHeading(context, [strings.destinationsTitle], headingId), createElement("div", { class: "share-kit-destinations-row" }, [group, more])])
1014
+ nodes: [renderHeading(context, [strings.destinationsTitle], headingId), createElement("div", { class: "share-kit-destinations-row" }, [group, more])]
1015
+ };
1016
+ }
1017
+ function renderDestinations(context) {
1018
+ const hint = createElement("p", {
1019
+ class: "share-kit-hint",
1020
+ id: `${context.id}-hint`
1021
+ });
1022
+ if (context.destinations.length + context.destinationsMore.length === 1) return {
1023
+ hint,
1024
+ more: void 0,
1025
+ section: hint
1026
+ };
1027
+ const { more, nodes } = renderDestinationRow(context);
1028
+ return {
1029
+ hint,
1030
+ more,
1031
+ section: createElement("section", { class: "share-kit-section" }, [...nodes, hint])
1019
1032
  };
1020
1033
  }
1021
1034
  function renderCaption(context) {
1022
1035
  const { classNames, id, payload, strings } = context;
1023
1036
  const captionId = `${id}-caption`;
1024
1037
  const countId = `${id}-count`;
1025
- const hintId = `${id}-hint`;
1026
1038
  const caption = createElement("textarea", {
1027
- "aria-describedby": `${countId} ${hintId}`,
1039
+ "aria-describedby": `${countId} ${id}-hint`,
1028
1040
  class: joinClasses("share-kit-caption", classNames.input),
1029
1041
  dir: "auto",
1030
1042
  id: captionId,
1031
- lang: payload.locale,
1032
- rows: "6"
1043
+ lang: payload.locale
1033
1044
  });
1034
1045
  const count = createElement("span", {
1035
1046
  class: "share-kit-count",
@@ -1037,25 +1048,30 @@ function renderCaption(context) {
1037
1048
  });
1038
1049
  const captionCopy = renderAction(context, {
1039
1050
  action: "copy-caption",
1040
- label: strings.captionCopy
1051
+ label: ""
1041
1052
  });
1042
- const hint = createElement("p", {
1043
- class: "share-kit-hint",
1044
- id: hintId
1053
+ const reset = renderAction(context, {
1054
+ action: "reset",
1055
+ label: strings.captionReset
1045
1056
  });
1057
+ const label = createElement("label", { for: captionId });
1058
+ const alert = createElement("p", {
1059
+ class: "share-kit-visually-hidden",
1060
+ role: "status"
1061
+ });
1062
+ reset.hidden = true;
1046
1063
  return {
1064
+ alert,
1047
1065
  caption,
1048
1066
  captionCopy,
1067
+ captionLabel: label,
1049
1068
  count,
1050
- hint,
1069
+ reset,
1051
1070
  section: createElement("section", { class: "share-kit-section" }, [
1052
- renderHeading(context, [createElement("label", { for: captionId }, [strings.captionTitle])]),
1071
+ renderHeading(context, [label]),
1053
1072
  caption,
1054
- createElement("div", { class: "share-kit-caption-meta" }, [count, createElement("span", { class: "share-kit-actions" }, [renderAction(context, {
1055
- action: "reset",
1056
- label: strings.captionReset
1057
- }), captionCopy])]),
1058
- hint
1073
+ createElement("div", { class: "share-kit-caption-meta" }, [count, createElement("span", { class: "share-kit-actions" }, [reset, captionCopy])]),
1074
+ alert
1059
1075
  ])
1060
1076
  };
1061
1077
  }
@@ -1067,6 +1083,7 @@ function renderTile(context, { actions, asset, index }) {
1067
1083
  class: "share-kit-tile",
1068
1084
  "data-share-kit-asset": asset.id
1069
1085
  }, [
1086
+ createElement("div", { class: "share-kit-tile-label" }, [createElement("span", { id: labelId }, [asset.label]), badge]),
1070
1087
  createElement("img", {
1071
1088
  alt: asset.alt,
1072
1089
  class: "share-kit-preview",
@@ -1076,7 +1093,6 @@ function renderTile(context, { actions, asset, index }) {
1076
1093
  src: asset.previewSrc,
1077
1094
  width: String(asset.width)
1078
1095
  }),
1079
- createElement("div", { class: "share-kit-tile-label" }, [createElement("span", { id: labelId }, [asset.label]), badge]),
1080
1096
  createElement("div", { class: "share-kit-actions" }, actions.map(([action, label]) => renderAction(context, {
1081
1097
  action,
1082
1098
  describedBy: labelId,
@@ -1086,14 +1102,14 @@ function renderTile(context, { actions, asset, index }) {
1086
1102
  }
1087
1103
  function getAssetActions({ capabilities, strings }) {
1088
1104
  const actions = [];
1089
- const canShare = capabilities.has("files");
1105
+ const canShare = capabilities.has("files") && capabilities.has("mobile");
1090
1106
  if (canShare) actions.push(["share", strings.assetShare]);
1091
- if (capabilities.has("copy-image") && !(canShare && capabilities.has("mobile"))) actions.push(["copy", strings.assetCopy]);
1107
+ if (!canShare && capabilities.has("copy-image")) actions.push(["copy", strings.assetCopy]);
1092
1108
  actions.push(["save", strings.assetSave]);
1093
1109
  return actions;
1094
1110
  }
1095
1111
  function renderImages(context) {
1096
- const { payload, strings } = context;
1112
+ const { capabilities, payload, strings } = context;
1097
1113
  const actions = getAssetActions(context);
1098
1114
  const assets = /* @__PURE__ */ new Map();
1099
1115
  for (const [index, asset] of payload.assets.entries()) assets.set(renderTile(context, {
@@ -1105,15 +1121,29 @@ function renderImages(context) {
1105
1121
  return {
1106
1122
  assets,
1107
1123
  grid,
1108
- section: createElement("section", { class: "share-kit-section" }, [renderHeading(context, [strings.imagesTitle]), grid])
1124
+ section: createElement("section", { class: "share-kit-section" }, [
1125
+ renderHeading(context, [strings.imagesTitle]),
1126
+ createElement("p", { class: "share-kit-hint" }, [capabilities.has("mobile") ? strings.imagesHintMobile : strings.imagesHint]),
1127
+ grid
1128
+ ])
1109
1129
  };
1110
1130
  }
1111
1131
  function renderLink(context) {
1112
- const { payload, strings } = context;
1113
- return createElement("section", { class: "share-kit-section" }, [renderHeading(context, [strings.linkTitle]), createElement("div", { class: "share-kit-link-row" }, [createElement("p", { class: "share-kit-link" }, [payload.url]), renderAction(context, {
1114
- action: "copy-link",
1115
- label: strings.linkCopy
1116
- })])]);
1132
+ const { capabilities, strings } = context;
1133
+ const link = createElement("p", { class: "share-kit-link" });
1134
+ const qr = capabilities.has("mobile") ? void 0 : createElement("button", {
1135
+ "aria-haspopup": "dialog",
1136
+ class: joinClasses("share-kit-action", context.classNames.action),
1137
+ "data-share-kit-action": "qr",
1138
+ type: "button"
1139
+ }, [strings.qrToggle]);
1140
+ return {
1141
+ link,
1142
+ section: createElement("section", { class: "share-kit-section" }, [renderHeading(context, [strings.linkTitle]), createElement("div", { class: "share-kit-link-row" }, [link, createElement("span", { class: "share-kit-actions" }, [renderAction(context, {
1143
+ action: "copy-link",
1144
+ label: strings.linkCopy
1145
+ }), qr])])])
1146
+ };
1117
1147
  }
1118
1148
  function renderShareKit(input) {
1119
1149
  const context = {
@@ -1124,6 +1154,7 @@ function renderShareKit(input) {
1124
1154
  const destinations = renderDestinations(context);
1125
1155
  const caption = renderCaption(context);
1126
1156
  const images = renderImages(context);
1157
+ const link = renderLink(context);
1127
1158
  const status = createElement("p", {
1128
1159
  class: "share-kit-status",
1129
1160
  role: "status"
@@ -1143,53 +1174,70 @@ function renderShareKit(input) {
1143
1174
  createElement("div", { class: "share-kit-scroll" }, [
1144
1175
  destinations.section,
1145
1176
  caption.section,
1146
- renderLink(context),
1147
- images.section
1177
+ images.section,
1178
+ link.section
1148
1179
  ]),
1149
1180
  createElement("footer", { class: "share-kit-footer" }, [status, primary])
1150
1181
  ])]);
1151
1182
  return {
1183
+ alert: caption.alert,
1152
1184
  assets: images.assets,
1153
1185
  caption: caption.caption,
1154
1186
  captionCopy: caption.captionCopy,
1187
+ captionLabel: caption.captionLabel,
1188
+ captionSection: caption.section,
1155
1189
  count: caption.count,
1156
1190
  dialog,
1157
1191
  grid: images.grid,
1158
1192
  heading,
1159
- hint: caption.hint,
1193
+ hint: destinations.hint,
1194
+ link: link.link,
1160
1195
  more: destinations.more,
1161
1196
  primary,
1197
+ reset: caption.reset,
1162
1198
  status,
1163
1199
  tiles: [...images.assets.keys()]
1164
1200
  };
1165
1201
  }
1166
1202
  // src/sync.ts
1167
1203
  const primaryLabels = {
1168
- "copy-caption": "primaryCopy",
1169
1204
  "open-composer": "primaryOpen",
1205
+ "save-image": "primarySaveImage",
1170
1206
  "share-image": "primaryShareImage",
1171
1207
  "share-link": "primaryShareLink",
1172
1208
  "share-text": "primaryShareText"
1173
1209
  };
1174
- function syncCaptionView({ destination, parts, primaryAction, strings }) {
1210
+ const copyLabels = {
1211
+ full: "copyText",
1212
+ text: "copyText",
1213
+ title: "copyTitle",
1214
+ url: "linkCopy"
1215
+ };
1216
+ function syncCaptionView({ destination, isEdited, parts, primaryAction, strings }) {
1175
1217
  const { limit } = destination;
1176
1218
  const count = destination.count(parts.caption.value);
1177
1219
  const isOver = limit !== void 0 && count > limit;
1178
1220
  const label = getDestinationLabel(strings, destination);
1179
- parts.count.textContent = limit === void 0 ? String(count) : `${String(count)} / ${String(limit)}`;
1221
+ const over = String(count - (limit ?? 0));
1222
+ const copyLabel = strings[copyLabels[destination.shape]];
1223
+ const total = limit === void 0 ? String(count) : `${String(count)} / ${String(limit)}`;
1224
+ const overNote = isOver ? ` · ${formatShareString(strings.countOver, { count: over })}` : "";
1225
+ parts.count.textContent = `${total}${overNote}`;
1180
1226
  parts.count.toggleAttribute("data-share-kit-over", isOver);
1181
1227
  parts.caption.setAttribute("aria-invalid", String(isOver));
1228
+ parts.captionCopy.textContent = copyLabel;
1182
1229
  parts.captionCopy.hidden = primaryAction === "copy-caption";
1183
- parts.primary.textContent = formatShareString(strings[primaryLabels[primaryAction]], { destination: label });
1230
+ parts.reset.hidden = !isEdited;
1231
+ parts.primary.textContent = primaryAction === "copy-caption" ? copyLabel : formatShareString(strings[primaryLabels[primaryAction]], { destination: label });
1184
1232
  return {
1185
1233
  isOver,
1186
1234
  message: formatShareString(strings.captionOver, {
1187
- count: String(count - (limit ?? 0)),
1235
+ count: over,
1188
1236
  destination: label
1189
1237
  })
1190
1238
  };
1191
1239
  }
1192
- function syncDestinationView({ assets, destination, parts, strings, suggested }) {
1240
+ function syncDestinationView({ assets, destination, parts, strings, suggested, url }) {
1193
1241
  for (const radio of parts.dialog.querySelectorAll("[role=\"radio\"]")) {
1194
1242
  const isSelected = radio.dataset.shareKitDestination === destination.id;
1195
1243
  radio.setAttribute("aria-checked", String(isSelected));
@@ -1197,6 +1245,11 @@ function syncDestinationView({ assets, destination, parts, strings, suggested })
1197
1245
  }
1198
1246
  parts.hint.textContent = getDestinationHint(strings, destination) ?? "";
1199
1247
  parts.hint.hidden = parts.hint.textContent === "";
1248
+ parts.captionSection.hidden = destination.shape === "url";
1249
+ parts.captionLabel.textContent = destination.shape === "title" ? strings.fieldTitle : strings.fieldText;
1250
+ parts.caption.rows = destination.shape === "title" ? 2 : 6;
1251
+ parts.link.textContent = url;
1252
+ parts.link.title = url;
1200
1253
  for (const asset of assets) {
1201
1254
  const badge = asset.querySelector(".share-kit-badge");
1202
1255
  if (badge) badge.hidden = asset !== suggested;
@@ -1223,7 +1276,7 @@ function isKeyOf(record, key) {
1223
1276
  return Object.hasOwn(record, key);
1224
1277
  }
1225
1278
  const BaseElement = typeof HTMLElement === "undefined" ? Object : HTMLElement;
1226
- var ShareKitElement = class extends BaseElement {
1279
+ var ShareKitElement = class ShareKitElement extends BaseElement {
1227
1280
  catalogue = /* @__PURE__ */ new Map();
1228
1281
  iconSource = new ShareIconSource({});
1229
1282
  #abortController;
@@ -1242,7 +1295,7 @@ var ShareKitElement = class extends BaseElement {
1242
1295
  },
1243
1296
  "copy-link": (button) => {
1244
1297
  this.#track("copy-link");
1245
- this.#feedback?.copyText(this.#payload?.url ?? "", button);
1298
+ this.#feedback?.copyText(this.#getUrl(), button);
1246
1299
  },
1247
1300
  destination: (button) => {
1248
1301
  const destination = this.#getRendered(button.dataset.shareKitDestination);
@@ -1250,8 +1303,8 @@ var ShareKitElement = class extends BaseElement {
1250
1303
  this.#selectDestination(destination);
1251
1304
  this.#track("destination");
1252
1305
  },
1253
- more: (button) => {
1254
- this.#showMore(button);
1306
+ more: () => {
1307
+ this.#showMore()[0]?.focus();
1255
1308
  },
1256
1309
  primary: () => {
1257
1310
  this.#primaryActions[this.#getPrimaryAction()]();
@@ -1262,6 +1315,7 @@ var ShareKitElement = class extends BaseElement {
1262
1315
  reset: () => {
1263
1316
  this.#isCaptionEdited = false;
1264
1317
  this.#syncDestination();
1318
+ this.#parts?.caption.focus();
1265
1319
  },
1266
1320
  save: (_button, tile) => {
1267
1321
  if (tile) this.#settle("save", this.#files?.save(tile), tile);
@@ -1292,6 +1346,12 @@ var ShareKitElement = class extends BaseElement {
1292
1346
  this.#copyCaption();
1293
1347
  openComposer(href);
1294
1348
  },
1349
+ "save-image": () => {
1350
+ const tile = this.#getSuggestedAsset();
1351
+ if (!tile) return;
1352
+ this.#copyCaption();
1353
+ this.#settle("save", this.#files?.save(tile), tile);
1354
+ },
1295
1355
  "share-image": () => {
1296
1356
  const tile = this.#getSuggestedAsset();
1297
1357
  if (!tile) return;
@@ -1343,9 +1403,9 @@ var ShareKitElement = class extends BaseElement {
1343
1403
  this.addEventListener("pointerover", ({ target }) => this.#files?.warm(target), { signal });
1344
1404
  for (const type of iconIntentEvents) this.addEventListener(type, this.#handleTriggerIntent, { signal });
1345
1405
  window.addEventListener("hashchange", this.#handleHashChange, { signal });
1346
- this.querySelector("[data-share-kit-trigger]")?.toggleAttribute("disabled", false);
1406
+ for (const trigger of this.querySelectorAll("[data-share-kit-trigger]")) trigger.toggleAttribute("disabled", false);
1347
1407
  queueMicrotask(() => {
1348
- if (!signal.aborted && isOpenHash(payload.settings.openHash)) this.#open();
1408
+ if (!signal.aborted && this.#ownsOpenHash()) this.#open();
1349
1409
  });
1350
1410
  }
1351
1411
  disconnectedCallback() {
@@ -1365,8 +1425,10 @@ var ShareKitElement = class extends BaseElement {
1365
1425
  this.#isOver = false;
1366
1426
  }
1367
1427
  async #copyCaption(button) {
1368
- const caption = this.#parts?.caption;
1369
- if (caption) await this.#feedback?.copyText(caption.value, button, caption);
1428
+ const parts = this.#parts;
1429
+ if (!parts) return;
1430
+ const fallback = parts.captionSection.hidden ? void 0 : parts.caption;
1431
+ await this.#feedback?.copyText(parts.caption.value, button, fallback);
1370
1432
  }
1371
1433
  #dispatch(detail) {
1372
1434
  this.dispatchEvent(new CustomEvent(shareKitActionEventName, {
@@ -1437,8 +1499,9 @@ var ShareKitElement = class extends BaseElement {
1437
1499
  }
1438
1500
  #handleClick = (event) => {
1439
1501
  if (!(event.target instanceof Element)) return;
1440
- if (event.target.closest("[data-share-kit-trigger]")) {
1441
- this.#open();
1502
+ const trigger = event.target.closest("[data-share-kit-trigger]");
1503
+ if (trigger) {
1504
+ this.#open(trigger.dataset.shareKitTrigger);
1442
1505
  return;
1443
1506
  }
1444
1507
  const button = event.target.closest("[data-share-kit-action]");
@@ -1450,7 +1513,7 @@ var ShareKitElement = class extends BaseElement {
1450
1513
  clearOpenHash(this.#payload?.settings.openHash);
1451
1514
  };
1452
1515
  #handleHashChange = () => {
1453
- if (isOpenHash(this.#payload?.settings.openHash)) this.#open();
1516
+ if (this.#ownsOpenHash()) this.#open();
1454
1517
  };
1455
1518
  #handleInput = (event) => {
1456
1519
  if (event.target === this.#parts?.caption) this.#isCaptionEdited = true;
@@ -1485,14 +1548,18 @@ var ShareKitElement = class extends BaseElement {
1485
1548
  if (!signal.aborted && this.#parts) patchIcons(this.#parts.dialog, icons);
1486
1549
  });
1487
1550
  }
1488
- #open() {
1551
+ #open(destinationId) {
1489
1552
  this.#loadIcons();
1490
1553
  const parts = this.#parts ?? this.#render();
1491
1554
  if (!parts || parts.dialog.open) return;
1555
+ const destination = this.#getRendered(destinationId);
1556
+ if (destination) this.#selectDestination(destination);
1557
+ if (destination && this.#lists?.more.includes(destination)) this.#showMore();
1492
1558
  parts.dialog.showModal();
1493
1559
  parts.heading.focus();
1494
1560
  this.#track("open");
1495
1561
  this.#isOver = false;
1562
+ parts.alert.textContent = "";
1496
1563
  this.#syncCaption();
1497
1564
  }
1498
1565
  async #openQr() {
@@ -1503,6 +1570,12 @@ var ShareKitElement = class extends BaseElement {
1503
1570
  this.#feedback?.announce(this.#strings.error);
1504
1571
  }
1505
1572
  }
1573
+ #ownsOpenHash() {
1574
+ const openHash = this.#payload?.settings.openHash;
1575
+ if (!isOpenHash(openHash)) return false;
1576
+ for (const element of document.querySelectorAll(this.localName)) if (element instanceof ShareKitElement && element.#payload?.settings.openHash === openHash) return element === this;
1577
+ return false;
1578
+ }
1506
1579
  #prefetch() {
1507
1580
  if (!this.#capabilities.has("files") || !this.#capabilities.has("mobile")) return;
1508
1581
  const tile = this.#getSuggestedAsset();
@@ -1573,11 +1646,11 @@ var ShareKitElement = class extends BaseElement {
1573
1646
  outcome: outcome === "unsaved" ? "error" : outcome
1574
1647
  });
1575
1648
  }
1576
- #showMore(button) {
1649
+ #showMore() {
1577
1650
  const hidden = [...this.querySelectorAll("[role=\"radio\"][hidden]")];
1578
1651
  for (const radio of hidden) radio.hidden = false;
1579
- button.hidden = true;
1580
- hidden[0]?.focus();
1652
+ if (this.#parts?.more) this.#parts.more.hidden = true;
1653
+ return hidden;
1581
1654
  }
1582
1655
  #syncCaption() {
1583
1656
  const parts = this.#parts;
@@ -1585,12 +1658,14 @@ var ShareKitElement = class extends BaseElement {
1585
1658
  if (!parts || !destination) return;
1586
1659
  const { isOver, message } = syncCaptionView({
1587
1660
  destination,
1661
+ isEdited: this.#isCaptionEdited,
1588
1662
  parts,
1589
1663
  primaryAction: this.#getPrimaryAction(),
1590
1664
  strings: this.#strings
1591
1665
  });
1592
- if (isOver && !this.#isOver && parts.dialog.open) this.#feedback?.announce(message);
1593
- this.#isOver = isOver;
1666
+ const isAnnounced = isOver && parts.dialog.open;
1667
+ if (isAnnounced !== this.#isOver) parts.alert.textContent = isAnnounced ? message : "";
1668
+ this.#isOver = isAnnounced;
1594
1669
  }
1595
1670
  #syncDestination() {
1596
1671
  const parts = this.#parts;
@@ -1602,7 +1677,8 @@ var ShareKitElement = class extends BaseElement {
1602
1677
  destination,
1603
1678
  parts,
1604
1679
  strings: this.#strings,
1605
- suggested: this.#getSuggestedAsset()
1680
+ suggested: this.#getSuggestedAsset(),
1681
+ url: this.#getUrl()
1606
1682
  });
1607
1683
  if (!this.#isCaptionEdited) parts.caption.value = fitCaption({
1608
1684
  description: payload.description,