@solhun/feedback-kit-web 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.js CHANGED
@@ -815,7 +815,7 @@ import {
815
815
  } from "react";
816
816
 
817
817
  // src/version.ts
818
- var VERSION = true ? "0.4.0" : "dev";
818
+ var VERSION = true ? "0.5.0" : "dev";
819
819
 
820
820
  // src/feedback-kit.tsx
821
821
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
@@ -973,6 +973,96 @@ var inputStyle = {
973
973
  padding: "10px 11px",
974
974
  font: "inherit"
975
975
  };
976
+ function PickToggle({
977
+ active,
978
+ disabled,
979
+ variant,
980
+ focusId,
981
+ onToggle
982
+ }) {
983
+ const floating = variant === "floating";
984
+ return /* @__PURE__ */ jsxs(
985
+ "button",
986
+ {
987
+ type: "button",
988
+ role: "switch",
989
+ "aria-checked": active,
990
+ "aria-label": "\uC694\uC18C \uC9C0\uBAA9 \uBAA8\uB4DC",
991
+ "data-fk-pick-toggle": active ? "on" : "off",
992
+ "data-fk-focus-id": focusId,
993
+ disabled,
994
+ onClick: onToggle,
995
+ style: {
996
+ ...baseButton,
997
+ display: "flex",
998
+ alignItems: "center",
999
+ gap: 10,
1000
+ opacity: disabled ? 0.5 : 1,
1001
+ cursor: disabled ? "not-allowed" : "pointer",
1002
+ // 항상 값을 준다. 조건부로 빼면 리렌더 때 shorthand(border)와 충돌한다고 React 가 경고한다.
1003
+ borderColor: active ? TOKENS.accent : TOKENS.line,
1004
+ ...floating ? {
1005
+ position: "fixed",
1006
+ top: 16,
1007
+ left: "50%",
1008
+ transform: "translateX(-50%)",
1009
+ // 오버레이 자체는 클릭을 통과시킨다(pointerEvents:none) — 이 토글만 되살린다.
1010
+ pointerEvents: "auto",
1011
+ background: TOKENS.surface,
1012
+ boxShadow: TOKENS.shadow
1013
+ } : {
1014
+ width: "100%",
1015
+ justifyContent: "space-between",
1016
+ marginBottom: 16,
1017
+ background: active ? "rgba(49, 93, 115, 0.06)" : TOKENS.surface
1018
+ }
1019
+ },
1020
+ children: [
1021
+ /* @__PURE__ */ jsxs("span", { style: { display: "inline-flex", alignItems: "center", gap: 7 }, children: [
1022
+ /* @__PURE__ */ jsx("span", { "aria-hidden": "true", style: { color: active ? TOKENS.accent : TOKENS.muted }, children: "\u25CE" }),
1023
+ "\uC694\uC18C \uC9C0\uBAA9 \uBAA8\uB4DC"
1024
+ ] }),
1025
+ /* @__PURE__ */ jsxs("span", { "aria-hidden": "true", style: { display: "inline-flex", alignItems: "center", gap: 8 }, children: [
1026
+ /* @__PURE__ */ jsx(
1027
+ "span",
1028
+ {
1029
+ style: { fontSize: 12, fontWeight: 600, color: active ? TOKENS.accent : TOKENS.muted },
1030
+ children: active ? "\uCF1C\uC9D0" : "\uAEBC\uC9D0"
1031
+ }
1032
+ ),
1033
+ /* @__PURE__ */ jsx(
1034
+ "span",
1035
+ {
1036
+ style: {
1037
+ position: "relative",
1038
+ display: "inline-block",
1039
+ width: 38,
1040
+ height: 22,
1041
+ borderRadius: 11,
1042
+ background: active ? TOKENS.accent : TOKENS.line
1043
+ },
1044
+ children: /* @__PURE__ */ jsx(
1045
+ "span",
1046
+ {
1047
+ style: {
1048
+ position: "absolute",
1049
+ top: 3,
1050
+ left: active ? 19 : 3,
1051
+ width: 16,
1052
+ height: 16,
1053
+ borderRadius: "50%",
1054
+ background: TOKENS.surface,
1055
+ boxShadow: "0 1px 3px rgba(23, 32, 42, 0.35)"
1056
+ }
1057
+ }
1058
+ )
1059
+ }
1060
+ )
1061
+ ] })
1062
+ ]
1063
+ }
1064
+ );
1065
+ }
976
1066
  function MarkerStatus({ status }) {
977
1067
  const presentation = status === "sending" ? { icon: "\u21BB", text: "\uC804\uC1A1 \uC911", color: TOKENS.accent } : status === "done" ? { icon: "\u2713", text: "\uC644\uB8CC", color: TOKENS.success } : { icon: "\u25F7", text: "\uB300\uAE30", color: TOKENS.warning };
978
1068
  return /* @__PURE__ */ jsxs("span", { style: { display: "inline-flex", gap: 4, alignItems: "center", color: presentation.color }, children: [
@@ -1081,8 +1171,12 @@ function FeedbackKit(props) {
1081
1171
  return /* @__PURE__ */ jsx("div", { ...OWN_UI_PROPS, "data-feedback-kit-loading": "true" });
1082
1172
  }
1083
1173
  const activeKit = kit;
1084
- const { modal, screen } = widgetState;
1174
+ const { modal, screen, pickingActive } = widgetState;
1085
1175
  const draftLocked = modal.submitStatus === "sending" || modal.submitStatus === "pending";
1176
+ function togglePicking() {
1177
+ if (pickingActive) activeKit.widget.stopPicking();
1178
+ else activeKit.widget.startPicking();
1179
+ }
1086
1180
  async function withOwnUiHidden(action) {
1087
1181
  const root = rootRef.current;
1088
1182
  const previousVisibility = root?.style.visibility ?? "";
@@ -1154,8 +1248,7 @@ function FeedbackKit(props) {
1154
1248
  ref: floatingButtonRef,
1155
1249
  id: FLOATING_BUTTON_ID,
1156
1250
  type: "button",
1157
- disabled: screen === "picking",
1158
- "aria-label": screen === "picking" ? "\uC694\uC18C \uC9C0\uBAA9 \uC911" : "\uD53C\uB4DC\uBC31 \uBCF4\uB0B4\uAE30",
1251
+ "aria-label": "\uD53C\uB4DC\uBC31 \uBCF4\uB0B4\uAE30",
1159
1252
  onClick: () => void openReport(),
1160
1253
  style: {
1161
1254
  ...primaryButton,
@@ -1166,11 +1259,9 @@ function FeedbackKit(props) {
1166
1259
  minWidth: 112,
1167
1260
  minHeight: 46,
1168
1261
  borderRadius: 24,
1169
- boxShadow: TOKENS.shadow,
1170
- opacity: screen === "picking" ? 0.76 : 1,
1171
- cursor: screen === "picking" ? "default" : "pointer"
1262
+ boxShadow: TOKENS.shadow
1172
1263
  },
1173
- children: screen === "picking" ? "\uC9C0\uBAA9 \uC911" : "\uD53C\uB4DC\uBC31"
1264
+ children: "\uD53C\uB4DC\uBC31"
1174
1265
  }
1175
1266
  ) : null,
1176
1267
  announcement && !modal.open ? /* @__PURE__ */ jsx(
@@ -1254,7 +1345,17 @@ function FeedbackKit(props) {
1254
1345
  ]
1255
1346
  }
1256
1347
  ),
1257
- /* @__PURE__ */ jsx("p", { style: { margin: "0 0 18px", color: TOKENS.muted }, children: "\uD604\uC7AC \uD654\uBA74\uC758 \uBB38\uC81C\uB098 \uC758\uACAC\uC744 \uB0A8\uACA8\uC8FC\uC138\uC694." }),
1348
+ /* @__PURE__ */ jsx("p", { style: { margin: "0 0 14px", color: TOKENS.muted }, children: "\uD604\uC7AC \uD654\uBA74\uC758 \uBB38\uC81C\uB098 \uC758\uACAC\uC744 \uB0A8\uACA8\uC8FC\uC138\uC694." }),
1349
+ /* @__PURE__ */ jsx(
1350
+ PickToggle,
1351
+ {
1352
+ variant: "inline",
1353
+ active: pickingActive,
1354
+ disabled: draftLocked,
1355
+ focusId: MODAL_ACTION_PICK,
1356
+ onToggle: togglePicking
1357
+ }
1358
+ ),
1258
1359
  /* @__PURE__ */ jsxs("section", { "aria-labelledby": "feedback-kit-screenshot-label", style: { marginBottom: 16 }, children: [
1259
1360
  /* @__PURE__ */ jsx("strong", { id: "feedback-kit-screenshot-label", children: "\uC2A4\uD06C\uB9B0\uC0F7" }),
1260
1361
  /* @__PURE__ */ jsx(
@@ -1368,19 +1469,6 @@ function FeedbackKit(props) {
1368
1469
  ]
1369
1470
  }
1370
1471
  ),
1371
- /* @__PURE__ */ jsx(
1372
- "button",
1373
- {
1374
- type: "button",
1375
- role: "switch",
1376
- "aria-checked": "false",
1377
- disabled: draftLocked,
1378
- "data-fk-focus-id": MODAL_ACTION_PICK,
1379
- onClick: () => kit.widget.startPicking(),
1380
- style: { ...baseButton, width: "100%", marginTop: 16 },
1381
- children: "\uC694\uC18C \uC9C0\uBAA9"
1382
- }
1383
- ),
1384
1472
  modal.submitStatus !== "idle" || modal.pending > 0 ? /* @__PURE__ */ jsxs(
1385
1473
  "div",
1386
1474
  {
@@ -1503,22 +1591,7 @@ function FeedbackKit(props) {
1503
1591
  }
1504
1592
  }
1505
1593
  ) : null,
1506
- /* @__PURE__ */ jsx(
1507
- "button",
1508
- {
1509
- type: "button",
1510
- onClick: () => kit.widget.stopPicking(),
1511
- style: {
1512
- ...primaryButton,
1513
- position: "fixed",
1514
- top: 18,
1515
- right: 18,
1516
- pointerEvents: "auto",
1517
- boxShadow: TOKENS.shadow
1518
- },
1519
- children: "\uC9C0\uBAA9 \uC885\uB8CC"
1520
- }
1521
- ),
1594
+ /* @__PURE__ */ jsx(PickToggle, { variant: "floating", active: true, onToggle: togglePicking }),
1522
1595
  pickingState.markers.map((marker, index) => /* @__PURE__ */ jsx(
1523
1596
  "div",
1524
1597
  {