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