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