@tensor_1/react 2.14.2 → 2.16.0

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 (58) hide show
  1. package/README.md +5 -0
  2. package/dist/ChartCore-Do6gRBN3.d.cts +44 -0
  3. package/dist/chart-preset.cjs +41 -9
  4. package/dist/chart-preset.d.cts +2 -2
  5. package/dist/chart-preset.d.ts +1 -1
  6. package/dist/chart-preset.js +4 -1
  7. package/dist/chart.cjs +41 -9
  8. package/dist/chart.d.cts +2 -2
  9. package/dist/chart.d.ts +1 -1
  10. package/dist/chart.js +4 -1
  11. package/dist/combobox-model.d.ts +9 -0
  12. package/dist/combobox-model.js +10 -0
  13. package/dist/components/AsyncOperationStatus.d.ts +16 -0
  14. package/dist/components/AsyncOperationStatus.js +24 -0
  15. package/dist/components/Breadcrumbs.d.ts +18 -0
  16. package/dist/components/Breadcrumbs.js +14 -0
  17. package/dist/components/Card.d.ts +11 -2
  18. package/dist/components/Card.js +16 -1
  19. package/dist/components/Chart.d.ts +1 -1
  20. package/dist/components/Chart.js +4 -1
  21. package/dist/components/ChartCore.d.ts +24 -3
  22. package/dist/components/ChartCore.js +38 -9
  23. package/dist/components/CollapsibleSection.d.ts +11 -0
  24. package/dist/components/CollapsibleSection.js +17 -0
  25. package/dist/components/Combobox.d.ts +19 -0
  26. package/dist/components/Combobox.js +120 -0
  27. package/dist/components/DetailPage.d.ts +33 -0
  28. package/dist/components/DetailPage.js +19 -0
  29. package/dist/components/Dialogs.d.ts +35 -0
  30. package/dist/components/Dialogs.js +55 -0
  31. package/dist/components/Flow.d.ts +26 -0
  32. package/dist/components/Flow.js +48 -0
  33. package/dist/components/Modal.d.ts +3 -1
  34. package/dist/components/Modal.js +6 -4
  35. package/dist/components/Pipeline.d.ts +25 -0
  36. package/dist/components/Pipeline.js +65 -0
  37. package/dist/components/RelatedLinks.d.ts +16 -0
  38. package/dist/components/RelatedLinks.js +14 -0
  39. package/dist/components/RelativeTime.d.ts +23 -0
  40. package/dist/components/RelativeTime.js +40 -0
  41. package/dist/components/Sidebar.d.ts +7 -2
  42. package/dist/components/Sidebar.js +27 -9
  43. package/dist/components/States.d.ts +23 -4
  44. package/dist/components/States.js +28 -6
  45. package/dist/components/TableControls.d.ts +77 -0
  46. package/dist/components/TableControls.js +61 -0
  47. package/dist/components/ToggleRow.d.ts +14 -0
  48. package/dist/components/ToggleRow.js +16 -0
  49. package/dist/index.cjs +1392 -786
  50. package/dist/index.d.cts +323 -8
  51. package/dist/index.d.ts +16 -2
  52. package/dist/index.js +40 -2
  53. package/dist/relative-time-clock.d.ts +4 -0
  54. package/dist/relative-time-clock.js +33 -0
  55. package/dist/relative-time-model.d.ts +9 -0
  56. package/dist/relative-time-model.js +16 -0
  57. package/package.json +1 -1
  58. package/dist/ChartCore-Bt1C84ty.d.cts +0 -22
@@ -0,0 +1,33 @@
1
+ const clocks = /* @__PURE__ */ new Map();
2
+ const getClock = (interval) => {
3
+ let clock = clocks.get(interval);
4
+ if (!clock) {
5
+ clock = { now: Date.now(), listeners: /* @__PURE__ */ new Set() };
6
+ clocks.set(interval, clock);
7
+ }
8
+ return clock;
9
+ };
10
+ const readRelativeClock = (interval) => getClock(interval).now;
11
+ function subscribeRelativeClock(interval, listener) {
12
+ if (interval <= 0 || typeof window === "undefined") return () => {
13
+ };
14
+ const clock = getClock(interval);
15
+ clock.listeners.add(listener);
16
+ if (!clock.timer) {
17
+ clock.timer = window.setInterval(() => {
18
+ clock.now = Date.now();
19
+ clock.listeners.forEach((notify) => notify());
20
+ }, interval);
21
+ }
22
+ return () => {
23
+ clock.listeners.delete(listener);
24
+ if (clock.listeners.size === 0 && clock.timer) {
25
+ window.clearInterval(clock.timer);
26
+ clock.timer = void 0;
27
+ }
28
+ };
29
+ }
30
+ export {
31
+ readRelativeClock,
32
+ subscribeRelativeClock
33
+ };
@@ -0,0 +1,9 @@
1
+ type RelativeTimeUnit = 'second' | 'minute' | 'hour' | 'day';
2
+ interface RelativeTimeValue {
3
+ value: number;
4
+ unit: RelativeTimeUnit;
5
+ }
6
+ declare function parseDateValue(value: Date | number | string): Date | null;
7
+ declare function relativeTimeValue(date: Date, now: Date): RelativeTimeValue;
8
+
9
+ export { type RelativeTimeUnit, type RelativeTimeValue, parseDateValue, relativeTimeValue };
@@ -0,0 +1,16 @@
1
+ function parseDateValue(value) {
2
+ const date = value instanceof Date ? new Date(value.getTime()) : new Date(value);
3
+ return Number.isNaN(date.getTime()) ? null : date;
4
+ }
5
+ function relativeTimeValue(date, now) {
6
+ const seconds = (date.getTime() - now.getTime()) / 1e3;
7
+ const absolute = Math.abs(seconds);
8
+ if (absolute < 60) return { value: Math.round(seconds), unit: "second" };
9
+ if (absolute < 3600) return { value: Math.round(seconds / 60), unit: "minute" };
10
+ if (absolute < 86400) return { value: Math.round(seconds / 3600), unit: "hour" };
11
+ return { value: Math.round(seconds / 86400), unit: "day" };
12
+ }
13
+ export {
14
+ parseDateValue,
15
+ relativeTimeValue
16
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tensor_1/react",
3
- "version": "2.14.2",
3
+ "version": "2.16.0",
4
4
  "description": "Thin React wrappers over the UIx v2 CSS component library.",
5
5
  "license": "UNLICENSED",
6
6
  "type": "module",
@@ -1,22 +0,0 @@
1
- import { CSSProperties, ReactNode } from 'react';
2
- import { EChartsOption, ECharts } from 'echarts';
3
-
4
- declare function uixChartPalette(): string[];
5
- interface ChartTableRow {
6
- [key: string]: string | number;
7
- }
8
- interface ChartProps {
9
- option: EChartsOption;
10
- title?: string;
11
- subtitle?: string;
12
- height?: string | number;
13
- className?: string;
14
- style?: CSSProperties;
15
- ariaLabel?: string;
16
- tableData?: ChartTableRow[];
17
- tableHeaders?: string[];
18
- onReady?: (chart: ECharts) => void;
19
- header?: ReactNode;
20
- }
21
-
22
- export { type ChartProps as C, type ChartTableRow as a, uixChartPalette as u };