@celljs/ta-initiative 4.15.0 → 4.15.2

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 +3 -3
  2. package/web/index.js +92 -50
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@celljs/ta-initiative",
3
- "version": "4.15.0",
3
+ "version": "4.15.2",
4
4
  "description": "A pi package for Ta: what Ta does on its own and how far, by kind and by the user's trust; proposals other packages offer, the user's suggestions to decide or undo, and a weekly review that keeps the scheduled tasks and learns the user",
5
5
  "keywords": [
6
6
  "pi-package"
@@ -27,8 +27,8 @@
27
27
  "watch": "tsc -b -w --preserveWatchOutput"
28
28
  },
29
29
  "devDependencies": {
30
- "@celljs/ta-protocol": "4.15.0",
31
- "@celljs/ta-web": "4.15.0",
30
+ "@celljs/ta-protocol": "4.15.2",
31
+ "@celljs/ta-web": "4.15.2",
32
32
  "@types/react": "^19.3.0"
33
33
  },
34
34
  "publishConfig": {
package/web/index.js CHANGED
@@ -711,16 +711,17 @@ function useBusy(ui) {
711
711
  function message(error) {
712
712
  return error instanceof Error ? error.message : String(error);
713
713
  }
714
- function clock(at) {
714
+ function clock(at, now = Date.now()) {
715
715
  const date = new Date(at);
716
716
  const pad = (value) => String(value).padStart(2, "0");
717
- return `${pad(date.getMonth() + 1)}-${pad(date.getDate())} ${pad(date.getHours())}:${pad(date.getMinutes())}`;
717
+ const time = `${pad(date.getHours())}:${pad(date.getMinutes())}`;
718
+ return date.toDateString() === new Date(now).toDateString() ? time : `${pad(date.getMonth() + 1)}-${pad(date.getDate())} ${time}`;
718
719
  }
719
720
  function kindTitle(kinds, id, language) {
720
721
  const kind = kinds.find((one) => one.kind.id === id)?.kind;
721
722
  return kind ? KindTitleUtil.pick(kind.title, language) : id;
722
723
  }
723
- function Act({ pi, label, primary, onClick }) {
724
+ function Act({ pi, label, primary, icon: Icon, onClick }) {
724
725
  const [busy, run] = useBusy(pi.ui);
725
726
  const words = InitiativeWords.of(pi.ui.language);
726
727
  const act = async () => {
@@ -737,8 +738,26 @@ function Act({ pi, label, primary, onClick }) {
737
738
  onClick: () => void run(act)
738
739
  }, busy && /* @__PURE__ */ React.createElement("span", {
739
740
  className: "ta-spinner ta-busy-mark"
741
+ }), Icon && /* @__PURE__ */ React.createElement(Icon, {
742
+ size: 13
740
743
  }), /* @__PURE__ */ React.createElement("span", null, label));
741
744
  }
745
+ function Head({ pi, proposal, kinds, at, words }) {
746
+ const Mark = pi.ui.icons.Sparkles;
747
+ return /* @__PURE__ */ React.createElement("div", {
748
+ className: "tin-kind"
749
+ }, Mark && /* @__PURE__ */ React.createElement("span", {
750
+ className: "tin-mark"
751
+ }, /* @__PURE__ */ React.createElement(Mark, {
752
+ size: 12
753
+ })), /* @__PURE__ */ React.createElement("span", {
754
+ className: "tin-kind-title"
755
+ }, kindTitle(kinds, proposal.kind, pi.ui.language)), proposal.state === "digest" && /* @__PURE__ */ React.createElement("span", {
756
+ className: "tin-tag"
757
+ }, words.inBrief), /* @__PURE__ */ React.createElement("span", {
758
+ className: "tin-time"
759
+ }, clock(at)));
760
+ }
742
761
  function Evidence({ pi, proposal, words }) {
743
762
  const files = proposal.evidence ?? [];
744
763
  if (files.length === 0) {
@@ -767,33 +786,25 @@ function Waiting({
767
786
  };
768
787
  const reversible = kinds.find((one) => one.kind.id === proposal.kind)?.kind.reversible ?? false;
769
788
  return /* @__PURE__ */ React.createElement("li", {
770
- className: "tin-card"
771
- }, /* @__PURE__ */ React.createElement("div", {
772
- className: "tin-kind"
773
- }, /* @__PURE__ */ React.createElement("span", null, kindTitle(kinds, proposal.kind, pi.ui.language)), proposal.state === "digest" && /* @__PURE__ */ React.createElement("span", {
774
- className: "tin-tag"
775
- }, words.inBrief), /* @__PURE__ */ React.createElement("span", {
776
- className: "tin-time"
777
- }, clock(proposal.at))), /* @__PURE__ */ React.createElement("div", {
789
+ className: "tin-card",
790
+ "data-tone": "wait"
791
+ }, /* @__PURE__ */ React.createElement(Head, {
792
+ pi,
793
+ proposal,
794
+ kinds,
795
+ at: proposal.at,
796
+ words
797
+ }), /* @__PURE__ */ React.createElement("div", {
778
798
  className: "tin-title"
779
799
  }, proposal.title), proposal.why && /* @__PURE__ */ React.createElement("div", {
780
800
  className: "tin-why"
781
- }, proposal.why), /* @__PURE__ */ React.createElement(Evidence, {
801
+ }, proposal.why), away && /* @__PURE__ */ React.createElement(Evidence, {
782
802
  pi,
783
803
  proposal,
784
804
  words
785
805
  }), /* @__PURE__ */ React.createElement("div", {
786
- className: "tin-actions"
787
- }, /* @__PURE__ */ React.createElement(Act, {
788
- pi,
789
- label: words.accept,
790
- primary: true,
791
- onClick: decide("accept")
792
- }), /* @__PURE__ */ React.createElement(Act, {
793
- pi,
794
- label: words.decline,
795
- onClick: decide("decline")
796
- })), /* @__PURE__ */ React.createElement("div", {
806
+ className: "tin-foot"
807
+ }, /* @__PURE__ */ React.createElement("div", {
797
808
  className: "tin-more"
798
809
  }, reversible && /* @__PURE__ */ React.createElement("button", {
799
810
  type: "button",
@@ -807,7 +818,18 @@ function Waiting({
807
818
  onClick: () => void decide("never")().catch(() => {
808
819
  return;
809
820
  })
810
- }, words.neverAgain)));
821
+ }, words.neverAgain)), /* @__PURE__ */ React.createElement("div", {
822
+ className: "tin-actions"
823
+ }, /* @__PURE__ */ React.createElement(Act, {
824
+ pi,
825
+ label: words.decline,
826
+ onClick: decide("decline")
827
+ }), /* @__PURE__ */ React.createElement(Act, {
828
+ pi,
829
+ label: words.accept,
830
+ primary: true,
831
+ onClick: decide("accept")
832
+ }))));
811
833
  }
812
834
  function Done({
813
835
  pi,
@@ -817,27 +839,33 @@ function Done({
817
839
  now
818
840
  }) {
819
841
  const words = InitiativeWords.of(pi.ui.language);
820
- const state = proposal.state === "undone" ? words.undoneState : proposal.state === "failed" ? InitiativeWords.format(words.failedState, { error: proposal.error ?? "" }) : "";
842
+ const tone = proposal.state === "undone" ? "undone" : proposal.state === "failed" ? "failed" : "done";
843
+ const state = tone === "undone" ? words.undoneState : tone === "failed" ? InitiativeWords.format(words.failedState, { error: proposal.error ?? "" }) : words.inboxDone;
821
844
  return /* @__PURE__ */ React.createElement("li", {
822
845
  className: "tin-card tin-done",
823
- "data-state": proposal.state
824
- }, /* @__PURE__ */ React.createElement("div", {
825
- className: "tin-kind"
826
- }, /* @__PURE__ */ React.createElement("span", null, kindTitle(kinds, proposal.kind, pi.ui.language)), /* @__PURE__ */ React.createElement("span", {
827
- className: "tin-time"
828
- }, clock(proposal.decidedAt ?? proposal.at))), /* @__PURE__ */ React.createElement("div", {
846
+ "data-tone": tone
847
+ }, /* @__PURE__ */ React.createElement(Head, {
848
+ pi,
849
+ proposal,
850
+ kinds,
851
+ at: proposal.decidedAt ?? proposal.at,
852
+ words
853
+ }), /* @__PURE__ */ React.createElement("div", {
829
854
  className: "tin-title"
830
855
  }, proposal.title), proposal.why && /* @__PURE__ */ React.createElement("div", {
831
856
  className: "tin-why"
832
- }, proposal.why), state && /* @__PURE__ */ React.createElement("div", {
857
+ }, proposal.why), /* @__PURE__ */ React.createElement("div", {
858
+ className: "tin-foot"
859
+ }, /* @__PURE__ */ React.createElement("span", {
833
860
  className: "tin-state"
834
- }, state), InboxUtil.canUndo(proposal, now) && /* @__PURE__ */ React.createElement("div", {
861
+ }, /* @__PURE__ */ React.createElement("i", null), /* @__PURE__ */ React.createElement("span", null, state)), InboxUtil.canUndo(proposal, now) && /* @__PURE__ */ React.createElement("div", {
835
862
  className: "tin-actions"
836
863
  }, /* @__PURE__ */ React.createElement(Act, {
837
864
  pi,
838
865
  label: words.undo,
866
+ icon: pi.ui.icons.Undo2,
839
867
  onClick: () => store.undo(proposal.id)
840
- })));
868
+ }))));
841
869
  }
842
870
  function Inbox({ pi, store }) {
843
871
  const state = useInitiative(React, store);
@@ -920,8 +948,9 @@ function ProposalCards({ pi, store, ids }) {
920
948
  now
921
949
  }) : /* @__PURE__ */ React.createElement("li", {
922
950
  key: proposal.id,
923
- className: "tin-decided"
924
- }, proposal.state === "done" ? words.acceptedLine : proposal.state === "declined" ? words.declinedLine : words.expiredLine, " · ", proposal.title)));
951
+ className: "tin-decided",
952
+ "data-state": proposal.state
953
+ }, /* @__PURE__ */ React.createElement("i", null), /* @__PURE__ */ React.createElement("span", null, proposal.state === "done" ? words.acceptedLine : proposal.state === "declined" ? words.declinedLine : words.expiredLine, " · ", proposal.title))));
925
954
  }
926
955
 
927
956
  // web-src/page-initiative.ts
@@ -1287,27 +1316,40 @@ var STYLE = `
1287
1316
  .tin-inbox { display: flex; flex-direction: column; min-height: 100%; max-width: 680px; margin: 0 auto; padding: 12px 16px 32px; box-sizing: border-box; }
1288
1317
  .tin-head { margin: 16px 2px 8px; color: var(--ta-muted); font-size: calc(12.5px * var(--ta-font-scale)); font-weight: 500; }
1289
1318
  .tin-list { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 10px; }
1290
- .tin-card { padding: 12px 14px; border: 1px solid var(--ta-border-muted); border-radius: 12px; background: var(--ta-card); }
1291
- .tin-kind { display: flex; align-items: center; gap: 8px; color: var(--ta-muted); font-size: calc(12px * var(--ta-font-scale)); }
1292
- .tin-kind > span:first-child { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
1293
- .tin-tag { flex: none; padding: 0 6px; border-radius: 6px; background: var(--ta-hover); }
1319
+ /*
1320
+ * A card: its head (a mark in the tone of where it stands, the kind, the time), what and why, and a foot under a
1321
+ * hairline with what the user may do. Tones: blue waits for the user, green done, red failed, grey undone.
1322
+ */
1323
+ .tin-card { --tin-tone: var(--ta-blue); padding: 12px 14px; border: 1px solid var(--ta-border-muted); border-radius: 12px; background: var(--ta-card); }
1324
+ .tin-card[data-tone='done'] { --tin-tone: var(--ta-green); }
1325
+ .tin-card[data-tone='failed'] { --tin-tone: var(--ta-red); }
1326
+ .tin-card[data-tone='undone'] { --tin-tone: var(--ta-muted); }
1327
+ .tin-kind { display: flex; align-items: center; gap: 8px; color: var(--ta-muted); font-size: calc(12px * var(--ta-font-scale)); line-height: calc(20px * var(--ta-font-scale)); }
1328
+ .tin-mark { flex: none; display: inline-flex; align-items: center; justify-content: center; width: calc(20px * var(--ta-font-scale)); height: calc(20px * var(--ta-font-scale)); border-radius: 50%; color: var(--tin-tone); background: color-mix(in srgb, var(--tin-tone) 14%, transparent); }
1329
+ .tin-kind-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
1330
+ .tin-tag { flex: none; padding: 0 6px; border-radius: 6px; background: var(--ta-hover); line-height: 1.6; }
1294
1331
  .tin-time { flex: none; font-variant-numeric: tabular-nums; }
1295
- .tin-title { margin-top: 6px; color: var(--ta-text); font-size: calc(15px * var(--ta-font-scale)); font-weight: 600; line-height: 1.45; overflow-wrap: anywhere; }
1296
- .tin-why { margin-top: 4px; color: var(--ta-text); font-size: calc(13.5px * var(--ta-font-scale)); line-height: 1.55; opacity: 0.85; overflow-wrap: anywhere; }
1297
- .tin-state { margin-top: 6px; color: var(--ta-muted); font-size: calc(12.5px * var(--ta-font-scale)); }
1298
- .tin-card[data-state='failed'] .tin-state { color: var(--ta-red, #d33); }
1299
- .tin-done .tin-title { font-weight: 500; }
1300
- .tin-actions { display: flex; gap: 8px; margin-top: 10px; }
1301
- .tin-actions .ta-button { min-width: 64px; justify-content: center; }
1302
- [data-touch] .tin-actions .ta-button { min-height: 38px; flex: 1; }
1303
- .tin-more { display: flex; gap: 14px; margin-top: 8px; }
1332
+ .tin-title { margin-top: 8px; color: var(--ta-text); font-size: calc(14.5px * var(--ta-font-scale)); font-weight: 600; line-height: 1.45; overflow-wrap: anywhere; }
1333
+ .tin-why { margin-top: 3px; color: var(--ta-secondary); font-size: calc(13px * var(--ta-font-scale)); line-height: 1.55; overflow-wrap: anywhere; }
1334
+ .tin-card[data-tone='undone'] .tin-title { color: var(--ta-muted); font-weight: 500; }
1335
+ .tin-foot { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--ta-border-muted); }
1336
+ .tin-state { flex: 1; min-width: 0; display: inline-flex; align-items: baseline; gap: 7px; color: var(--tin-tone); font-size: calc(12.5px * var(--ta-font-scale)); font-weight: 500; line-height: 1.5; overflow-wrap: anywhere; }
1337
+ .tin-state > i, .tin-decided > i { flex: none; width: 6px; height: 6px; border-radius: 50%; background: currentColor; transform: translateY(-1px); }
1338
+ .tin-actions { display: flex; gap: 8px; margin-left: auto; }
1339
+ .tin-actions .ta-button { height: calc(28px * var(--ta-font-scale)); min-width: 56px; padding: 0 12px; justify-content: center; gap: 5px; }
1340
+ .tin-actions .ta-button:not(.ta-primary) { color: var(--ta-secondary); }
1341
+ .tin-actions .ta-button:not(.ta-primary):hover:not(:disabled) { color: var(--ta-text); }
1342
+ [data-touch] .tin-actions .ta-button { height: 34px; min-width: 64px; }
1343
+ .tin-more { flex: 1 1 auto; min-width: 0; display: flex; flex-wrap: wrap; gap: 4px 14px; }
1304
1344
  .tin-link { padding: 0; border: 0; background: none; color: var(--ta-muted); font: inherit; font-size: calc(12.5px * var(--ta-font-scale)); cursor: pointer; text-align: left; }
1305
1345
  .tin-link:hover { color: var(--ta-text); }
1306
1346
  .tin-card > .tin-link { margin-top: 6px; display: block; }
1307
1347
  .tin-above { margin: 0 0 8px; }
1308
1348
  .tin-above .tin-card { padding: 10px 12px; }
1349
+ .tin-above .tin-foot { margin-top: 10px; padding-top: 8px; }
1309
1350
  .tin-in-chat { margin: 4px 0; max-width: 620px; }
1310
- .tin-decided { color: var(--ta-muted); font-size: calc(12.5px * var(--ta-font-scale)); overflow-wrap: anywhere; }
1351
+ .tin-decided { display: flex; align-items: baseline; gap: 7px; color: var(--ta-muted); font-size: calc(12.5px * var(--ta-font-scale)); line-height: 1.5; overflow-wrap: anywhere; }
1352
+ .tin-decided[data-state='done'] > i { color: var(--ta-green); }
1311
1353
  .tin-empty { padding: 48px 12px; color: var(--ta-muted); text-align: center; font-size: calc(13.5px * var(--ta-font-scale)); line-height: 1.6; }
1312
1354
  .tin-quiet { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
1313
1355
  /* The kinds, in the settings */