@teja-app/ui 0.0.13 → 0.0.15

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 (41) hide show
  1. package/dist/index.cjs +5 -0
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/index.d.ts +1 -0
  4. package/dist/index.d.ts.map +1 -1
  5. package/dist/index.js +6 -1
  6. package/dist/index.js.map +1 -1
  7. package/dist/instrumentation/context.d.ts +9 -0
  8. package/dist/instrumentation/context.d.ts.map +1 -0
  9. package/dist/instrumentation/index.cjs +8 -0
  10. package/dist/instrumentation/index.cjs.map +1 -0
  11. package/dist/instrumentation/index.d.ts +10 -0
  12. package/dist/instrumentation/index.d.ts.map +1 -0
  13. package/dist/instrumentation/index.js +8 -0
  14. package/dist/instrumentation/index.js.map +1 -0
  15. package/dist/instrumentation/tracker.d.ts +28 -0
  16. package/dist/instrumentation/tracker.d.ts.map +1 -0
  17. package/dist/instrumentation/useInstrumentedClick.d.ts +31 -0
  18. package/dist/instrumentation/useInstrumentedClick.d.ts.map +1 -0
  19. package/dist/theme/components/AIComposeButton.d.ts +2 -0
  20. package/dist/theme/components/AIComposeButton.d.ts.map +1 -1
  21. package/dist/theme/components/Button.d.ts +2 -0
  22. package/dist/theme/components/Button.d.ts.map +1 -1
  23. package/dist/theme/components/CountdownPill.d.ts +15 -0
  24. package/dist/theme/components/CountdownPill.d.ts.map +1 -0
  25. package/dist/theme/components/IconButton.d.ts +2 -0
  26. package/dist/theme/components/IconButton.d.ts.map +1 -1
  27. package/dist/theme/components/countdown.d.ts +37 -0
  28. package/dist/theme/components/countdown.d.ts.map +1 -0
  29. package/dist/theme/components/countdown.test.d.ts +2 -0
  30. package/dist/theme/components/countdown.test.d.ts.map +1 -0
  31. package/dist/theme/components/index.d.ts +2 -0
  32. package/dist/theme/components/index.d.ts.map +1 -1
  33. package/dist/theme/index.cjs +83 -2
  34. package/dist/theme/index.cjs.map +1 -1
  35. package/dist/theme/index.js +83 -2
  36. package/dist/theme/index.js.map +1 -1
  37. package/dist/useInstrumentedClick-B7QAnoBt.js +68 -0
  38. package/dist/useInstrumentedClick-B7QAnoBt.js.map +1 -0
  39. package/dist/useInstrumentedClick-COxikkTF.cjs +67 -0
  40. package/dist/useInstrumentedClick-COxikkTF.cjs.map +1 -0
  41. package/package.json +6 -1
@@ -1,6 +1,7 @@
1
1
  import { jsx, jsxs, Fragment } from "react/jsx-runtime";
2
2
  import * as React from "react";
3
3
  import React__default, { useMemo, useState, useEffect, useRef, useCallback, useContext, createContext, forwardRef, useId as useId$1, useLayoutEffect, Fragment as Fragment$1, isValidElement, cloneElement, createElement, useSyncExternalStore } from "react";
4
+ import { useInstrumentedClick } from "@teja-app/ui/instrumentation";
4
5
  import * as ReactDOM from "react-dom";
5
6
  import { flushSync, createPortal } from "react-dom";
6
7
  const PRIMARY_OPTIONS = {
@@ -656,9 +657,17 @@ const Button$1 = forwardRef(function Button2({
656
657
  type = "button",
657
658
  disabled,
658
659
  testId,
660
+ telemetryId,
661
+ onClick,
659
662
  ...rest
660
663
  }, ref) {
661
664
  const dims = SIZE_DIMS$2[size2];
665
+ const instrumentedClick = useInstrumentedClick(onClick, {
666
+ telemetryId,
667
+ testId,
668
+ kind: "Button",
669
+ variant
670
+ });
662
671
  return /* @__PURE__ */ jsxs(
663
672
  "button",
664
673
  {
@@ -666,6 +675,7 @@ const Button$1 = forwardRef(function Button2({
666
675
  type,
667
676
  disabled,
668
677
  "data-testid": testId,
678
+ onClick: instrumentedClick,
669
679
  style: {
670
680
  height: dims.h,
671
681
  padding: dims.pad,
@@ -767,6 +777,61 @@ function Badge({
767
777
  children
768
778
  ] });
769
779
  }
780
+ const TONE_COLORS = {
781
+ waiting: { bg: "var(--ai-soft)", fg: "var(--ai)", dot: "var(--ai)" },
782
+ soon: { bg: "var(--warning-soft)", fg: "var(--warning)", dot: "var(--warning)" },
783
+ ready: { bg: "var(--success-soft)", fg: "var(--success)", dot: "var(--success)" }
784
+ };
785
+ function CountdownPill({
786
+ tone,
787
+ label,
788
+ icon = "clock",
789
+ dot,
790
+ testId,
791
+ "data-testid": dataTestId
792
+ }) {
793
+ const showDot = dot ?? tone !== "ready";
794
+ return /* @__PURE__ */ jsxs(
795
+ Badge,
796
+ {
797
+ tone: "neutral",
798
+ colors: TONE_COLORS[tone],
799
+ dot: showDot,
800
+ testId,
801
+ "data-testid": dataTestId,
802
+ children: [
803
+ /* @__PURE__ */ jsx(Icon, { name: icon, size: 12 }),
804
+ /* @__PURE__ */ jsx("span", { style: { fontFamily: "var(--font-mono)", fontWeight: 600 }, children: label })
805
+ ]
806
+ }
807
+ );
808
+ }
809
+ const DAY_S = 86400;
810
+ const HOUR_S = 3600;
811
+ const MIN_S = 60;
812
+ function countdownParts(startMs, nowMs, soonThresholdSeconds = 120) {
813
+ const deltaMs = startMs - nowMs;
814
+ if (deltaMs <= 0) {
815
+ return {
816
+ tone: "ready",
817
+ days: 0,
818
+ hours: 0,
819
+ minutes: 0,
820
+ seconds: 0,
821
+ unit: "now",
822
+ clock: "00:00"
823
+ };
824
+ }
825
+ const total = Math.floor(deltaMs / 1e3);
826
+ const days = Math.floor(total / DAY_S);
827
+ const hours = Math.floor(total % DAY_S / HOUR_S);
828
+ const minutes = Math.floor(total % HOUR_S / MIN_S);
829
+ const seconds = total % MIN_S;
830
+ const unit = days > 0 ? "days" : hours > 0 ? "hours" : "minutes";
831
+ const clock = `${minutes.toString().padStart(2, "0")}:${seconds.toString().padStart(2, "0")}`;
832
+ const tone = total <= soonThresholdSeconds ? "soon" : "waiting";
833
+ return { tone, days, hours, minutes, seconds, unit, clock };
834
+ }
770
835
  const Card = forwardRef(function Card2({
771
836
  padding = 20,
772
837
  children,
@@ -16505,8 +16570,14 @@ const Switch = forwardRef(function Switch2({ on = false, onChange, size: size2 =
16505
16570
  });
16506
16571
  const SIZE_PX$1 = { sm: 22, md: 26, lg: 32 };
16507
16572
  const IconButton = forwardRef(
16508
- function IconButton2({ children, size: size2 = "md", tone = "default", style, testId, type = "button", ...rest }, ref) {
16573
+ function IconButton2({ children, size: size2 = "md", tone = "default", style, testId, telemetryId, onClick, type = "button", ...rest }, ref) {
16509
16574
  const dim = SIZE_PX$1[size2];
16575
+ const instrumentedClick = useInstrumentedClick(onClick, {
16576
+ telemetryId,
16577
+ testId,
16578
+ kind: "IconButton",
16579
+ variant: tone
16580
+ });
16510
16581
  const merged = {
16511
16582
  width: dim,
16512
16583
  height: dim,
@@ -16530,6 +16601,7 @@ const IconButton = forwardRef(
16530
16601
  type,
16531
16602
  "data-testid": testId,
16532
16603
  "data-tone": tone,
16604
+ onClick: instrumentedClick,
16533
16605
  style: merged,
16534
16606
  ...rest,
16535
16607
  children
@@ -17222,8 +17294,14 @@ function AIBadge({
17222
17294
  ] });
17223
17295
  }
17224
17296
  const AIComposeButton = forwardRef(
17225
- function AIComposeButton2({ size: size2 = "md", children = "Compose with AI", style, testId, type = "button", ...rest }, ref) {
17297
+ function AIComposeButton2({ size: size2 = "md", children = "Compose with AI", style, testId, telemetryId, onClick, type = "button", ...rest }, ref) {
17226
17298
  const h2 = size2 === "sm" ? 28 : 32;
17299
+ const instrumentedClick = useInstrumentedClick(onClick, {
17300
+ telemetryId,
17301
+ testId,
17302
+ kind: "AIComposeButton",
17303
+ variant: size2
17304
+ });
17227
17305
  const fz = size2 === "sm" ? 12 : 13;
17228
17306
  const merged = {
17229
17307
  height: h2,
@@ -17248,6 +17326,7 @@ const AIComposeButton = forwardRef(
17248
17326
  type,
17249
17327
  "data-testid": testId,
17250
17328
  "data-size": size2,
17329
+ onClick: instrumentedClick,
17251
17330
  style: merged,
17252
17331
  ...rest,
17253
17332
  children: [
@@ -19069,6 +19148,7 @@ export {
19069
19148
  Chip,
19070
19149
  Combobox,
19071
19150
  ConfirmDialog,
19151
+ CountdownPill,
19072
19152
  CountryPicker,
19073
19153
  DEFAULT_LANG_OPTIONS,
19074
19154
  DENSITY_OPTIONS,
@@ -19161,6 +19241,7 @@ export {
19161
19241
  ViewToggle,
19162
19242
  applyTheme,
19163
19243
  controlBoxStyle,
19244
+ countdownParts,
19164
19245
  ensureAIStyles,
19165
19246
  ensureSidebarNavStyles,
19166
19247
  ensureSkeletonStyles,