@thesquad-components/sqd-module-template 0.1.1 → 0.1.3

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
@@ -1,8 +1,41 @@
1
1
  import { ResponsiveContainer, RadialBarChart, PolarAngleAxis, Tooltip, RadialBar } from 'recharts';
2
2
  import { extendTailwindMerge } from 'tailwind-merge';
3
- import { jsx, jsxs } from 'react/jsx-runtime';
4
- import { useState, useMemo, useEffect } from 'react';
3
+ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
4
+ import { createContext, useState, useMemo, useCallback, useEffect, isValidElement, useContext } from 'react';
5
+ import { Link, Button as Button$1, TextField as TextField$1, Label as Label$1, Group, Input as Input$1, Text, TooltipTrigger as TooltipTrigger$1, Tooltip as Tooltip$1, OverlayArrow } from 'react-aria-components';
6
+ import { HelpCircle, InfoCircle } from '@untitledui/icons';
5
7
 
8
+ var __defProp = Object.defineProperty;
9
+ var __defProps = Object.defineProperties;
10
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
11
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
12
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
13
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
14
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
15
+ var __spreadValues = (a, b) => {
16
+ for (var prop in b || (b = {}))
17
+ if (__hasOwnProp.call(b, prop))
18
+ __defNormalProp(a, prop, b[prop]);
19
+ if (__getOwnPropSymbols)
20
+ for (var prop of __getOwnPropSymbols(b)) {
21
+ if (__propIsEnum.call(b, prop))
22
+ __defNormalProp(a, prop, b[prop]);
23
+ }
24
+ return a;
25
+ };
26
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
27
+ var __objRest = (source, exclude) => {
28
+ var target = {};
29
+ for (var prop in source)
30
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
31
+ target[prop] = source[prop];
32
+ if (source != null && __getOwnPropSymbols)
33
+ for (var prop of __getOwnPropSymbols(source)) {
34
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
35
+ target[prop] = source[prop];
36
+ }
37
+ return target;
38
+ };
6
39
  var twMerge = extendTailwindMerge({
7
40
  extend: {
8
41
  theme: {
@@ -11,6 +44,9 @@ var twMerge = extendTailwindMerge({
11
44
  }
12
45
  });
13
46
  var cx = twMerge;
47
+ function sortCx(classes) {
48
+ return classes;
49
+ }
14
50
  var ChartTooltipContent = ({ active, payload, label, isRadialChart }) => {
15
51
  if (!active || !payload || payload.length === 0) {
16
52
  return null;
@@ -48,6 +84,8 @@ var ActivityGaugeLg = ({
48
84
  data = radialData,
49
85
  maxValue = 1e3
50
86
  }) => {
87
+ var _a, _b;
88
+ const ringClassName = (_b = (_a = data[0]) == null ? void 0 : _a.className) != null ? _b : "text-utility-brand-700";
51
89
  return /* @__PURE__ */ jsx(ResponsiveContainer, { height: 356, children: /* @__PURE__ */ jsxs(
52
90
  RadialBarChart,
53
91
  {
@@ -74,6 +112,7 @@ var ActivityGaugeLg = ({
74
112
  dataKey: "value",
75
113
  cornerRadius: 99,
76
114
  fill: "currentColor",
115
+ className: ringClassName,
77
116
  background: {
78
117
  className: "fill-utility-gray-100"
79
118
  }
@@ -129,15 +168,592 @@ var getTasksCount = async (daysBack, options = {}) => {
129
168
  const payload = await response.json();
130
169
  return (_e = payload.count) != null ? _e : 0;
131
170
  };
132
- var TasksActivityGauge = ({ daysBack = 7 }) => {
171
+
172
+ // src/utils/is-react-component.ts
173
+ var isFunctionComponent = (component) => {
174
+ return typeof component === "function";
175
+ };
176
+ var isClassComponent = (component) => {
177
+ return typeof component === "function" && component.prototype && (!!component.prototype.isReactComponent || !!component.prototype.render);
178
+ };
179
+ var isForwardRefComponent = (component) => {
180
+ return typeof component === "object" && component !== null && component.$$typeof.toString() === "Symbol(react.forward_ref)";
181
+ };
182
+ var isReactComponent = (component) => {
183
+ return isFunctionComponent(component) || isForwardRefComponent(component) || isClassComponent(component);
184
+ };
185
+ var styles = sortCx({
186
+ common: {
187
+ root: [
188
+ "group relative inline-flex h-max cursor-pointer items-center justify-center whitespace-nowrap outline-brand transition duration-100 ease-linear before:absolute focus-visible:outline-2 focus-visible:outline-offset-2",
189
+ // When button is used within `InputGroup`
190
+ "in-data-input-wrapper:shadow-xs in-data-input-wrapper:focus:!z-50 in-data-input-wrapper:in-data-leading:-mr-px in-data-input-wrapper:in-data-leading:rounded-r-none in-data-input-wrapper:in-data-leading:before:rounded-r-none in-data-input-wrapper:in-data-trailing:-ml-px in-data-input-wrapper:in-data-trailing:rounded-l-none in-data-input-wrapper:in-data-trailing:before:rounded-l-none",
191
+ // Disabled styles
192
+ "disabled:cursor-not-allowed disabled:text-fg-disabled",
193
+ // Icon styles
194
+ "disabled:*:data-icon:text-fg-disabled_subtle",
195
+ // Same as `icon` but for SSR icons that cannot be passed to the client as functions.
196
+ "*:data-icon:pointer-events-none *:data-icon:size-5 *:data-icon:shrink-0 *:data-icon:transition-inherit-all"
197
+ ].join(" "),
198
+ icon: "pointer-events-none size-5 shrink-0 transition-inherit-all"
199
+ },
200
+ sizes: {
201
+ sm: {
202
+ root: [
203
+ "gap-1 rounded-lg px-3 py-2 text-sm font-semibold before:rounded-[7px] data-icon-only:p-2",
204
+ "in-data-input-wrapper:px-3.5 in-data-input-wrapper:py-2.5 in-data-input-wrapper:data-icon-only:p-2.5"
205
+ ].join(" "),
206
+ linkRoot: "gap-1"
207
+ },
208
+ md: {
209
+ root: [
210
+ "gap-1 rounded-lg px-3.5 py-2.5 text-sm font-semibold before:rounded-[7px] data-icon-only:p-2.5",
211
+ "in-data-input-wrapper:gap-1.5 in-data-input-wrapper:px-4 in-data-input-wrapper:text-md in-data-input-wrapper:data-icon-only:p-3"
212
+ ].join(" "),
213
+ linkRoot: "gap-1"
214
+ },
215
+ lg: {
216
+ root: "gap-1.5 rounded-lg px-4 py-2.5 text-md font-semibold before:rounded-[7px] data-icon-only:p-3",
217
+ linkRoot: "gap-1.5"
218
+ },
219
+ xl: {
220
+ root: "gap-1.5 rounded-lg px-4.5 py-3 text-md font-semibold before:rounded-[7px] data-icon-only:p-3.5",
221
+ linkRoot: "gap-1.5"
222
+ }
223
+ },
224
+ colors: {
225
+ primary: {
226
+ root: [
227
+ "bg-brand-solid text-white shadow-xs-skeumorphic ring-1 ring-transparent ring-inset hover:bg-brand-solid_hover data-loading:bg-brand-solid_hover",
228
+ // Inner border gradient
229
+ "before:absolute before:inset-px before:border before:border-white/12 before:mask-b-from-0%",
230
+ // Disabled styles
231
+ "disabled:bg-disabled disabled:shadow-xs disabled:ring-disabled_subtle",
232
+ // Icon styles
233
+ "*:data-icon:text-button-primary-icon hover:*:data-icon:text-button-primary-icon_hover"
234
+ ].join(" ")
235
+ },
236
+ secondary: {
237
+ root: [
238
+ "bg-primary text-secondary shadow-xs-skeumorphic ring-1 ring-primary ring-inset hover:bg-primary_hover hover:text-secondary_hover data-loading:bg-primary_hover",
239
+ // Disabled styles
240
+ "disabled:shadow-xs disabled:ring-disabled_subtle",
241
+ // Icon styles
242
+ "*:data-icon:text-fg-quaternary hover:*:data-icon:text-fg-quaternary_hover"
243
+ ].join(" ")
244
+ },
245
+ tertiary: {
246
+ root: [
247
+ "text-tertiary hover:bg-primary_hover hover:text-tertiary_hover data-loading:bg-primary_hover",
248
+ // Icon styles
249
+ "*:data-icon:text-fg-quaternary hover:*:data-icon:text-fg-quaternary_hover"
250
+ ].join(" ")
251
+ },
252
+ "link-gray": {
253
+ root: [
254
+ "justify-normal rounded p-0! text-tertiary hover:text-tertiary_hover",
255
+ // Inner text underline
256
+ "*:data-text:underline *:data-text:decoration-transparent *:data-text:underline-offset-2 hover:*:data-text:decoration-current",
257
+ // Icon styles
258
+ "*:data-icon:text-fg-quaternary hover:*:data-icon:text-fg-quaternary_hover"
259
+ ].join(" ")
260
+ },
261
+ "link-color": {
262
+ root: [
263
+ "justify-normal rounded p-0! text-brand-secondary hover:text-brand-secondary_hover",
264
+ // Inner text underline
265
+ "*:data-text:underline *:data-text:decoration-transparent *:data-text:underline-offset-2 hover:*:data-text:decoration-current",
266
+ // Icon styles
267
+ "*:data-icon:text-fg-brand-secondary_alt hover:*:data-icon:text-fg-brand-secondary_hover"
268
+ ].join(" ")
269
+ },
270
+ "primary-destructive": {
271
+ root: [
272
+ "bg-error-solid text-white shadow-xs-skeumorphic ring-1 ring-transparent outline-error ring-inset hover:bg-error-solid_hover data-loading:bg-error-solid_hover",
273
+ // Inner border gradient
274
+ "before:absolute before:inset-px before:border before:border-white/12 before:mask-b-from-0%",
275
+ // Disabled styles
276
+ "disabled:bg-disabled disabled:shadow-xs disabled:ring-disabled_subtle",
277
+ // Icon styles
278
+ "*:data-icon:text-button-destructive-primary-icon hover:*:data-icon:text-button-destructive-primary-icon_hover"
279
+ ].join(" ")
280
+ },
281
+ "secondary-destructive": {
282
+ root: [
283
+ "bg-primary text-error-primary shadow-xs-skeumorphic ring-1 ring-error_subtle outline-error ring-inset hover:bg-error-primary hover:text-error-primary_hover data-loading:bg-error-primary",
284
+ // Disabled styles
285
+ "disabled:bg-primary disabled:shadow-xs disabled:ring-disabled_subtle",
286
+ // Icon styles
287
+ "*:data-icon:text-fg-error-secondary hover:*:data-icon:text-fg-error-primary"
288
+ ].join(" ")
289
+ },
290
+ "tertiary-destructive": {
291
+ root: [
292
+ "text-error-primary outline-error hover:bg-error-primary hover:text-error-primary_hover data-loading:bg-error-primary",
293
+ // Icon styles
294
+ "*:data-icon:text-fg-error-secondary hover:*:data-icon:text-fg-error-primary"
295
+ ].join(" ")
296
+ },
297
+ "link-destructive": {
298
+ root: [
299
+ "justify-normal rounded p-0! text-error-primary outline-error hover:text-error-primary_hover",
300
+ // Inner text underline
301
+ "*:data-text:underline *:data-text:decoration-transparent *:data-text:underline-offset-2 hover:*:data-text:decoration-current",
302
+ // Icon styles
303
+ "*:data-icon:text-fg-error-secondary hover:*:data-icon:text-fg-error-primary"
304
+ ].join(" ")
305
+ }
306
+ }
307
+ });
308
+ var Button = (_a) => {
309
+ var _b = _a, {
310
+ size = "sm",
311
+ color = "primary",
312
+ children,
313
+ className,
314
+ noTextPadding,
315
+ iconLeading: IconLeading,
316
+ iconTrailing: IconTrailing,
317
+ isDisabled: disabled,
318
+ isLoading: loading,
319
+ showTextWhileLoading
320
+ } = _b, otherProps = __objRest(_b, [
321
+ "size",
322
+ "color",
323
+ "children",
324
+ "className",
325
+ "noTextPadding",
326
+ "iconLeading",
327
+ "iconTrailing",
328
+ "isDisabled",
329
+ "isLoading",
330
+ "showTextWhileLoading"
331
+ ]);
332
+ const href = "href" in otherProps ? otherProps.href : void 0;
333
+ const Component = href ? Link : Button$1;
334
+ const isIcon = (IconLeading || IconTrailing) && !children;
335
+ const isLinkType = ["link-gray", "link-color", "link-destructive"].includes(color);
336
+ noTextPadding = isLinkType || noTextPadding;
337
+ let props = {};
338
+ if (href) {
339
+ props = __spreadProps(__spreadValues({}, otherProps), {
340
+ href: disabled ? void 0 : href
341
+ });
342
+ } else {
343
+ props = __spreadProps(__spreadValues({}, otherProps), {
344
+ type: otherProps.type || "button",
345
+ isPending: loading
346
+ });
347
+ }
348
+ return /* @__PURE__ */ jsxs(
349
+ Component,
350
+ __spreadProps(__spreadValues({
351
+ "data-loading": loading ? true : void 0,
352
+ "data-icon-only": isIcon ? true : void 0
353
+ }, props), {
354
+ isDisabled: disabled,
355
+ className: cx(
356
+ styles.common.root,
357
+ styles.sizes[size].root,
358
+ styles.colors[color].root,
359
+ isLinkType && styles.sizes[size].linkRoot,
360
+ (loading || href && (disabled || loading)) && "pointer-events-none",
361
+ // If in `loading` state, hide everything except the loading icon (and text if `showTextWhileLoading` is true).
362
+ loading && (showTextWhileLoading ? "[&>*:not([data-icon=loading]):not([data-text])]:hidden" : "[&>*:not([data-icon=loading])]:invisible"),
363
+ className
364
+ ),
365
+ children: [
366
+ isValidElement(IconLeading) && IconLeading,
367
+ isReactComponent(IconLeading) && /* @__PURE__ */ jsx(IconLeading, { "data-icon": "leading", className: styles.common.icon }),
368
+ loading && /* @__PURE__ */ jsxs(
369
+ "svg",
370
+ {
371
+ fill: "none",
372
+ "data-icon": "loading",
373
+ viewBox: "0 0 20 20",
374
+ className: cx(styles.common.icon, !showTextWhileLoading && "absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2"),
375
+ children: [
376
+ /* @__PURE__ */ jsx("circle", { className: "stroke-current opacity-30", cx: "10", cy: "10", r: "8", fill: "none", strokeWidth: "2" }),
377
+ /* @__PURE__ */ jsx(
378
+ "circle",
379
+ {
380
+ className: "origin-center animate-spin stroke-current",
381
+ cx: "10",
382
+ cy: "10",
383
+ r: "8",
384
+ fill: "none",
385
+ strokeWidth: "2",
386
+ strokeDasharray: "12.5 50",
387
+ strokeLinecap: "round"
388
+ }
389
+ )
390
+ ]
391
+ }
392
+ ),
393
+ children && /* @__PURE__ */ jsx("span", { "data-text": true, className: cx("transition-inherit-all", !noTextPadding && "px-0.5"), children }),
394
+ isValidElement(IconTrailing) && IconTrailing,
395
+ isReactComponent(IconTrailing) && /* @__PURE__ */ jsx(IconTrailing, { "data-icon": "trailing", className: styles.common.icon })
396
+ ]
397
+ })
398
+ );
399
+ };
400
+ var HintText = (_a) => {
401
+ var _b = _a, { isInvalid, className } = _b, props = __objRest(_b, ["isInvalid", "className"]);
402
+ return /* @__PURE__ */ jsx(
403
+ Text,
404
+ __spreadProps(__spreadValues({}, props), {
405
+ slot: isInvalid ? "errorMessage" : "description",
406
+ className: cx(
407
+ "text-sm text-tertiary",
408
+ // Invalid state
409
+ isInvalid && "text-error-primary",
410
+ "group-invalid:text-error-primary",
411
+ className
412
+ )
413
+ })
414
+ );
415
+ };
416
+ HintText.displayName = "HintText";
417
+ var Tooltip2 = (_a) => {
418
+ var _b = _a, {
419
+ title,
420
+ description,
421
+ children,
422
+ arrow = false,
423
+ delay = 300,
424
+ closeDelay = 0,
425
+ trigger,
426
+ isDisabled,
427
+ isOpen,
428
+ defaultOpen,
429
+ offset = 6,
430
+ crossOffset,
431
+ placement = "top",
432
+ onOpenChange
433
+ } = _b, tooltipProps = __objRest(_b, [
434
+ "title",
435
+ "description",
436
+ "children",
437
+ "arrow",
438
+ "delay",
439
+ "closeDelay",
440
+ "trigger",
441
+ "isDisabled",
442
+ "isOpen",
443
+ "defaultOpen",
444
+ "offset",
445
+ "crossOffset",
446
+ "placement",
447
+ "onOpenChange"
448
+ ]);
449
+ const isTopOrBottomLeft = ["top left", "top end", "bottom left", "bottom end"].includes(placement);
450
+ const isTopOrBottomRight = ["top right", "top start", "bottom right", "bottom start"].includes(placement);
451
+ const calculatedCrossOffset = isTopOrBottomLeft ? -12 : isTopOrBottomRight ? 12 : 0;
452
+ return /* @__PURE__ */ jsxs(TooltipTrigger$1, __spreadProps(__spreadValues({}, { trigger, delay, closeDelay, isDisabled, isOpen, defaultOpen, onOpenChange }), { children: [
453
+ children,
454
+ /* @__PURE__ */ jsx(
455
+ Tooltip$1,
456
+ __spreadProps(__spreadValues({}, tooltipProps), {
457
+ offset,
458
+ placement,
459
+ crossOffset: crossOffset != null ? crossOffset : calculatedCrossOffset,
460
+ className: ({ isEntering, isExiting }) => cx(isEntering && "ease-out animate-in", isExiting && "ease-in animate-out"),
461
+ children: ({ isEntering, isExiting }) => /* @__PURE__ */ jsxs(
462
+ "div",
463
+ {
464
+ className: cx(
465
+ "z-50 flex max-w-xs origin-(--trigger-anchor-point) flex-col items-start gap-1 rounded-lg bg-primary-solid px-3 shadow-lg will-change-transform",
466
+ description ? "py-3" : "py-2",
467
+ isEntering && "ease-out animate-in fade-in zoom-in-95 in-placement-left:slide-in-from-right-0.5 in-placement-right:slide-in-from-left-0.5 in-placement-top:slide-in-from-bottom-0.5 in-placement-bottom:slide-in-from-top-0.5",
468
+ isExiting && "ease-in animate-out fade-out zoom-out-95 in-placement-left:slide-out-to-right-0.5 in-placement-right:slide-out-to-left-0.5 in-placement-top:slide-out-to-bottom-0.5 in-placement-bottom:slide-out-to-top-0.5"
469
+ ),
470
+ children: [
471
+ /* @__PURE__ */ jsx("span", { className: "text-xs font-semibold text-white", children: title }),
472
+ description && /* @__PURE__ */ jsx("span", { className: "text-xs font-medium text-tooltip-supporting-text", children: description }),
473
+ arrow && /* @__PURE__ */ jsx(OverlayArrow, { children: /* @__PURE__ */ jsx(
474
+ "svg",
475
+ {
476
+ viewBox: "0 0 100 100",
477
+ className: "size-2.5 fill-bg-primary-solid in-placement-left:-rotate-90 in-placement-right:rotate-90 in-placement-top:rotate-0 in-placement-bottom:rotate-180",
478
+ children: /* @__PURE__ */ jsx("path", { d: "M0,0 L35.858,35.858 Q50,50 64.142,35.858 L100,0 Z" })
479
+ }
480
+ ) })
481
+ ]
482
+ }
483
+ )
484
+ })
485
+ )
486
+ ] }));
487
+ };
488
+ var TooltipTrigger = (_a) => {
489
+ var _b = _a, { children, className } = _b, buttonProps = __objRest(_b, ["children", "className"]);
490
+ return /* @__PURE__ */ jsx(Button$1, __spreadProps(__spreadValues({}, buttonProps), { className: (values) => cx("h-max w-max outline-hidden", typeof className === "function" ? className(values) : className), children }));
491
+ };
492
+ var Label = (_a) => {
493
+ var _b = _a, { isRequired, tooltip, tooltipDescription, className } = _b, props = __objRest(_b, ["isRequired", "tooltip", "tooltipDescription", "className"]);
494
+ return /* @__PURE__ */ jsxs(
495
+ Label$1,
496
+ __spreadProps(__spreadValues({
497
+ "data-label": "true"
498
+ }, props), {
499
+ className: cx("flex cursor-default items-center gap-0.5 text-sm font-medium text-secondary", className),
500
+ children: [
501
+ props.children,
502
+ /* @__PURE__ */ jsx("span", { className: cx("hidden text-brand-tertiary", isRequired && "block", typeof isRequired === "undefined" && "group-required:block"), children: "*" }),
503
+ tooltip && /* @__PURE__ */ jsx(Tooltip2, { title: tooltip, description: tooltipDescription, placement: "top", children: /* @__PURE__ */ jsx(
504
+ TooltipTrigger,
505
+ {
506
+ isDisabled: false,
507
+ className: "cursor-pointer text-fg-quaternary transition duration-200 hover:text-fg-quaternary_hover focus:text-fg-quaternary_hover",
508
+ children: /* @__PURE__ */ jsx(HelpCircle, { className: "size-4" })
509
+ }
510
+ ) })
511
+ ]
512
+ })
513
+ );
514
+ };
515
+ Label.displayName = "Label";
516
+ var InputBase = (_a) => {
517
+ var _b = _a, {
518
+ ref,
519
+ tooltip,
520
+ shortcut,
521
+ groupRef,
522
+ size = "sm",
523
+ isInvalid,
524
+ isDisabled,
525
+ icon: Icon,
526
+ placeholder,
527
+ wrapperClassName,
528
+ tooltipClassName,
529
+ inputClassName,
530
+ iconClassName,
531
+ isRequired: _isRequired
532
+ } = _b, inputProps = __objRest(_b, [
533
+ "ref",
534
+ "tooltip",
535
+ "shortcut",
536
+ "groupRef",
537
+ "size",
538
+ "isInvalid",
539
+ "isDisabled",
540
+ "icon",
541
+ "placeholder",
542
+ "wrapperClassName",
543
+ "tooltipClassName",
544
+ "inputClassName",
545
+ "iconClassName",
546
+ // Omit this prop to avoid invalid HTML attribute warning
547
+ "isRequired"
548
+ ]);
549
+ const hasTrailingIcon = tooltip || isInvalid;
550
+ const hasLeadingIcon = Icon;
551
+ const context = useContext(TextFieldContext);
552
+ const inputSize = (context == null ? void 0 : context.size) || size;
553
+ const sizes = sortCx({
554
+ sm: {
555
+ root: cx("px-3 py-2", hasTrailingIcon && "pr-9", hasLeadingIcon && "pl-10"),
556
+ iconLeading: "left-3",
557
+ iconTrailing: "right-3",
558
+ shortcut: "pr-2.5"
559
+ },
560
+ md: {
561
+ root: cx("px-3.5 py-2.5", hasTrailingIcon && "pr-9.5", hasLeadingIcon && "pl-10.5"),
562
+ iconLeading: "left-3.5",
563
+ iconTrailing: "right-3.5",
564
+ shortcut: "pr-3"
565
+ }
566
+ });
567
+ return /* @__PURE__ */ jsxs(
568
+ Group,
569
+ __spreadProps(__spreadValues({}, { isDisabled, isInvalid }), {
570
+ ref: groupRef,
571
+ className: ({ isFocusWithin, isDisabled: isDisabled2, isInvalid: isInvalid2 }) => cx(
572
+ "relative flex w-full flex-row place-content-center place-items-center rounded-lg bg-primary shadow-xs ring-1 ring-primary transition-shadow duration-100 ease-linear ring-inset",
573
+ isFocusWithin && !isDisabled2 && "ring-2 ring-brand",
574
+ // Disabled state styles
575
+ isDisabled2 && "cursor-not-allowed bg-disabled_subtle ring-disabled",
576
+ "group-disabled:cursor-not-allowed group-disabled:bg-disabled_subtle group-disabled:ring-disabled",
577
+ // Invalid state styles
578
+ isInvalid2 && "ring-error_subtle",
579
+ "group-invalid:ring-error_subtle",
580
+ // Invalid state with focus-within styles
581
+ isInvalid2 && isFocusWithin && "ring-2 ring-error",
582
+ isFocusWithin && "group-invalid:ring-2 group-invalid:ring-error",
583
+ context == null ? void 0 : context.wrapperClassName,
584
+ wrapperClassName
585
+ ),
586
+ children: [
587
+ Icon && /* @__PURE__ */ jsx(
588
+ Icon,
589
+ {
590
+ className: cx(
591
+ "pointer-events-none absolute size-5 text-fg-quaternary",
592
+ isDisabled && "text-fg-disabled",
593
+ sizes[inputSize].iconLeading,
594
+ context == null ? void 0 : context.iconClassName,
595
+ iconClassName
596
+ )
597
+ }
598
+ ),
599
+ /* @__PURE__ */ jsx(
600
+ Input$1,
601
+ __spreadProps(__spreadValues({}, inputProps), {
602
+ ref,
603
+ placeholder,
604
+ className: cx(
605
+ "m-0 w-full bg-transparent text-md text-primary ring-0 outline-hidden placeholder:text-placeholder autofill:rounded-lg autofill:text-primary",
606
+ isDisabled && "cursor-not-allowed text-disabled",
607
+ sizes[inputSize].root,
608
+ context == null ? void 0 : context.inputClassName,
609
+ inputClassName
610
+ )
611
+ })
612
+ ),
613
+ tooltip && !isInvalid && /* @__PURE__ */ jsx(Tooltip2, { title: tooltip, placement: "top", children: /* @__PURE__ */ jsx(
614
+ TooltipTrigger,
615
+ {
616
+ className: cx(
617
+ "absolute cursor-pointer text-fg-quaternary transition duration-200 hover:text-fg-quaternary_hover focus:text-fg-quaternary_hover",
618
+ sizes[inputSize].iconTrailing,
619
+ context == null ? void 0 : context.tooltipClassName,
620
+ tooltipClassName
621
+ ),
622
+ children: /* @__PURE__ */ jsx(HelpCircle, { className: "size-4" })
623
+ }
624
+ ) }),
625
+ isInvalid && /* @__PURE__ */ jsx(
626
+ InfoCircle,
627
+ {
628
+ className: cx(
629
+ "pointer-events-none absolute size-4 text-fg-error-secondary",
630
+ sizes[inputSize].iconTrailing,
631
+ context == null ? void 0 : context.tooltipClassName,
632
+ tooltipClassName
633
+ )
634
+ }
635
+ ),
636
+ shortcut && /* @__PURE__ */ jsx(
637
+ "div",
638
+ {
639
+ className: cx(
640
+ "pointer-events-none absolute inset-y-0.5 right-0.5 z-10 flex items-center rounded-r-[inherit] bg-linear-to-r from-transparent to-bg-primary to-40% pl-8",
641
+ sizes[inputSize].shortcut
642
+ ),
643
+ children: /* @__PURE__ */ jsx(
644
+ "span",
645
+ {
646
+ className: cx(
647
+ "pointer-events-none rounded px-1 py-px text-xs font-medium text-quaternary ring-1 ring-secondary select-none ring-inset",
648
+ isDisabled && "bg-transparent text-disabled"
649
+ ),
650
+ "aria-hidden": "true",
651
+ children: typeof shortcut === "string" ? shortcut : "\u2318K"
652
+ }
653
+ )
654
+ }
655
+ )
656
+ ]
657
+ })
658
+ );
659
+ };
660
+ InputBase.displayName = "InputBase";
661
+ var TextFieldContext = createContext({});
662
+ var TextField = (_a) => {
663
+ var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
664
+ return /* @__PURE__ */ jsx(TextFieldContext.Provider, { value: props, children: /* @__PURE__ */ jsx(
665
+ TextField$1,
666
+ __spreadProps(__spreadValues({}, props), {
667
+ "data-input-wrapper": true,
668
+ className: (state) => cx("group flex h-max w-full flex-col items-start justify-start gap-1.5", typeof className === "function" ? className(state) : className)
669
+ })
670
+ ) });
671
+ };
672
+ TextField.displayName = "TextField";
673
+ var Input = (_a) => {
674
+ var _b = _a, {
675
+ size = "sm",
676
+ placeholder,
677
+ icon: Icon,
678
+ label,
679
+ hint,
680
+ shortcut,
681
+ hideRequiredIndicator,
682
+ className,
683
+ ref,
684
+ groupRef,
685
+ tooltip,
686
+ iconClassName,
687
+ inputClassName,
688
+ wrapperClassName,
689
+ tooltipClassName
690
+ } = _b, props = __objRest(_b, [
691
+ "size",
692
+ "placeholder",
693
+ "icon",
694
+ "label",
695
+ "hint",
696
+ "shortcut",
697
+ "hideRequiredIndicator",
698
+ "className",
699
+ "ref",
700
+ "groupRef",
701
+ "tooltip",
702
+ "iconClassName",
703
+ "inputClassName",
704
+ "wrapperClassName",
705
+ "tooltipClassName"
706
+ ]);
707
+ return /* @__PURE__ */ jsx(TextField, __spreadProps(__spreadValues({ "aria-label": !label ? placeholder : void 0 }, props), { className, children: ({ isRequired, isInvalid }) => /* @__PURE__ */ jsxs(Fragment, { children: [
708
+ label && /* @__PURE__ */ jsx(Label, { isRequired: hideRequiredIndicator ? !hideRequiredIndicator : isRequired, children: label }),
709
+ /* @__PURE__ */ jsx(
710
+ InputBase,
711
+ __spreadValues({}, {
712
+ ref,
713
+ groupRef,
714
+ size,
715
+ placeholder,
716
+ icon: Icon,
717
+ shortcut,
718
+ iconClassName,
719
+ inputClassName,
720
+ wrapperClassName,
721
+ tooltipClassName,
722
+ tooltip
723
+ })
724
+ ),
725
+ hint && /* @__PURE__ */ jsx(HintText, { isInvalid, children: hint })
726
+ ] }) }));
727
+ };
728
+ Input.displayName = "Input";
729
+ var TasksActivityGauge = ({ daysBack = 14, maxValue = 1e3 }) => {
133
730
  const [count, setCount] = useState(null);
134
731
  const [error, setError] = useState(null);
135
- const subtitle = useMemo(() => `Tasks last ${daysBack} days`, [daysBack]);
732
+ const [isLoading, setIsLoading] = useState(false);
733
+ const [daysBackValue, setDaysBackValue] = useState(daysBack.toString());
734
+ const [activeDaysBack, setActiveDaysBack] = useState(daysBack);
735
+ const subtitle = useMemo(() => `Tasks last ${activeDaysBack} days`, [activeDaysBack]);
736
+ const fetchCount = useCallback(
737
+ async (value) => {
738
+ setIsLoading(true);
739
+ setError(null);
740
+ try {
741
+ const total = await getTasksCount(value);
742
+ setCount(total);
743
+ } catch (err) {
744
+ setError(err instanceof Error ? err.message : "Failed to load tasks count");
745
+ } finally {
746
+ setIsLoading(false);
747
+ }
748
+ },
749
+ []
750
+ );
136
751
  useEffect(() => {
137
752
  let isActive = true;
753
+ setIsLoading(true);
138
754
  setError(null);
139
755
  setCount(null);
140
- getTasksCount(daysBack).then((total) => {
756
+ getTasksCount(activeDaysBack).then((total) => {
141
757
  if (isActive) {
142
758
  setCount(total);
143
759
  }
@@ -145,13 +761,59 @@ var TasksActivityGauge = ({ daysBack = 7 }) => {
145
761
  if (isActive) {
146
762
  setError(err instanceof Error ? err.message : "Failed to load tasks count");
147
763
  }
764
+ }).finally(() => {
765
+ if (isActive) {
766
+ setIsLoading(false);
767
+ }
148
768
  });
149
769
  return () => {
150
770
  isActive = false;
151
771
  };
152
- }, [daysBack]);
772
+ }, [activeDaysBack]);
153
773
  const title = error ? "\u2014" : count === null ? "\u2026" : count.toLocaleString();
154
- return /* @__PURE__ */ jsx(ActivityGaugeLg, { title, subtitle });
774
+ const gaugeValue = count != null ? count : 0;
775
+ const computedMax = Math.max(maxValue, gaugeValue, 1);
776
+ const gaugeData = [
777
+ {
778
+ name: "Tasks",
779
+ value: gaugeValue,
780
+ className: "text-utility-brand-700"
781
+ }
782
+ ];
783
+ const handleDaysBackChange = (value) => {
784
+ setDaysBackValue(value);
785
+ const parsed = Number(value);
786
+ if (Number.isFinite(parsed) && parsed > 0) {
787
+ setActiveDaysBack(Math.floor(parsed));
788
+ }
789
+ };
790
+ return /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-4", children: [
791
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-end justify-between gap-3", children: [
792
+ /* @__PURE__ */ jsx("div", { className: "min-w-[180px]", children: /* @__PURE__ */ jsx(
793
+ Input,
794
+ {
795
+ label: "Days back",
796
+ type: "number",
797
+ value: daysBackValue,
798
+ onChange: handleDaysBackChange,
799
+ size: "sm",
800
+ placeholder: "14"
801
+ }
802
+ ) }),
803
+ /* @__PURE__ */ jsx(
804
+ Button,
805
+ {
806
+ color: "primary",
807
+ size: "sm",
808
+ isLoading,
809
+ showTextWhileLoading: true,
810
+ onClick: () => fetchCount(activeDaysBack),
811
+ children: "Refresh"
812
+ }
813
+ )
814
+ ] }),
815
+ /* @__PURE__ */ jsx(ActivityGaugeLg, { title, subtitle, data: gaugeData, maxValue: computedMax })
816
+ ] });
155
817
  };
156
818
 
157
819
  export { ActivityGaugeLg, TasksActivityGauge, getTasksCount };