@trackunit/react-components 0.1.159 → 0.1.161

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/index.cjs.js CHANGED
@@ -19167,7 +19167,7 @@ const cvaIndicatorIconBackground = cssClassVarianceUtilities.cvaMerge(["rounded-
19167
19167
  */
19168
19168
  const Indicator = (_a) => {
19169
19169
  var { dataTestId, icon, label, color = "unknown", withBackground = true, withLabel = true, ping = false, className } = _a, rest = __rest$1(_a, ["dataTestId", "icon", "label", "color", "withBackground", "withLabel", "ping", "className"]);
19170
- return (jsxRuntime.jsx(Tooltip, { disabled: withLabel, label: label, children: jsxRuntime.jsxs("div", Object.assign({ className: cvaIndicator({ className }), "data-testid": dataTestId, "aria-label": label }, rest, { children: [jsxRuntime.jsxs("div", { className: cvaIndicatorIconBackground({ color, background: withBackground ? "visible" : "hidden" }), "data-testid": dataTestId ? `${dataTestId}-background` : "indicator-background", children: [ping && (jsxRuntime.jsx("div", { className: cvaIndicatorPing({ color }), "data-testid": dataTestId ? `${dataTestId}-ping` : "indicator-ping" })), icon] }), label !== undefined && withLabel && (jsxRuntime.jsx("div", { className: cvaIndicatorLabel(), "data-testid": dataTestId ? `${dataTestId}-label` : "indicator-label", children: label }))] })) }));
19170
+ return (jsxRuntime.jsx(Tooltip, { className: className, disabled: withLabel, label: label, children: jsxRuntime.jsxs("div", Object.assign({ className: cvaIndicator(), "data-testid": dataTestId, "aria-label": label }, rest, { children: [jsxRuntime.jsxs("div", { className: cvaIndicatorIconBackground({ color, background: withBackground ? "visible" : "hidden" }), "data-testid": dataTestId ? `${dataTestId}-background` : "indicator-background", children: [ping && (jsxRuntime.jsx("div", { className: cvaIndicatorPing({ color }), "data-testid": dataTestId ? `${dataTestId}-ping` : "indicator-ping" })), icon] }), label !== undefined && withLabel && (jsxRuntime.jsx("div", { className: cvaIndicatorLabel(), "data-testid": dataTestId ? `${dataTestId}-label` : "indicator-label", children: label }))] })) }));
19171
19171
  };
19172
19172
 
19173
19173
  const cvaMenuItem = cssClassVarianceUtilities.cvaMerge([
@@ -36680,6 +36680,7 @@ const useTimeout = ({ onTimeout, duration }) => {
36680
36680
  timeout.current && clearTimeout(timeout.current);
36681
36681
  }, []);
36682
36682
  React.useEffect(() => {
36683
+ // Use the latest callback function provided by the parent component.
36683
36684
  callback.current = onTimeout;
36684
36685
  }, [onTimeout]);
36685
36686
  React.useEffect(() => {
@@ -36696,26 +36697,44 @@ const useTimeout = ({ onTimeout, duration }) => {
36696
36697
  *
36697
36698
  * @param {object} options - Options for the useContinuousTimeout hook.
36698
36699
  * @param {Function} options.onTimeout - Callback function to execute on each timeout.
36700
+ * @param {Function} options.onMaxRetries - Callback function to execute when the maximum number of retries is reached.
36699
36701
  * @param {number} options.duration - Duration of the timeout in milliseconds.
36700
36702
  * @param {number} options.maxRetries - Maximum number of retry attempts.
36701
- * @returns {object} An object containing functions to start and stop the timeout.
36703
+ * @returns {object} An object containing functions to start and stop the timeout, current retry count, and the timeout status.
36702
36704
  */
36703
- const useContinuousTimeout = ({ onTimeout, duration, maxRetries }) => {
36705
+ const useContinuousTimeout = ({ onTimeout, onMaxRetries, duration, maxRetries }) => {
36704
36706
  const retries = React.useRef(0);
36707
+ const [isRunning, setIsRunning] = React.useState(false); // Track the timeout status
36708
+ const stopTimeouts = () => {
36709
+ stopTimeout();
36710
+ setIsRunning(false); // Update the status when stopped
36711
+ };
36712
+ const startTimeouts = () => {
36713
+ startTimeout();
36714
+ setIsRunning(true); // Update the status when started
36715
+ };
36705
36716
  const { startTimeout, stopTimeout } = useTimeout({
36706
36717
  duration,
36707
36718
  onTimeout: () => {
36708
- onTimeout();
36709
- if (retries.current < maxRetries) {
36710
- startTimeout();
36711
- retries.current++;
36712
- }
36713
- else {
36714
- retries.current = 0;
36719
+ if (isRunning) {
36720
+ onTimeout();
36721
+ if (retries.current < maxRetries) {
36722
+ retries.current++;
36723
+ }
36724
+ else {
36725
+ onMaxRetries === null || onMaxRetries === void 0 ? void 0 : onMaxRetries();
36726
+ retries.current = 0;
36727
+ }
36728
+ startTimeout(); // Restart the timeout if it's still running
36715
36729
  }
36716
36730
  },
36717
36731
  });
36718
- return { startTimeout, stopTimeout, retries: retries.current };
36732
+ return {
36733
+ startTimeouts,
36734
+ stopTimeouts,
36735
+ retries: retries.current,
36736
+ isRunning,
36737
+ };
36719
36738
  };
36720
36739
 
36721
36740
  /**
package/index.esm.js CHANGED
@@ -19138,7 +19138,7 @@ const cvaIndicatorIconBackground = cvaMerge(["rounded-full", "items-center", "ju
19138
19138
  */
19139
19139
  const Indicator = (_a) => {
19140
19140
  var { dataTestId, icon, label, color = "unknown", withBackground = true, withLabel = true, ping = false, className } = _a, rest = __rest$1(_a, ["dataTestId", "icon", "label", "color", "withBackground", "withLabel", "ping", "className"]);
19141
- return (jsx(Tooltip, { disabled: withLabel, label: label, children: jsxs("div", Object.assign({ className: cvaIndicator({ className }), "data-testid": dataTestId, "aria-label": label }, rest, { children: [jsxs("div", { className: cvaIndicatorIconBackground({ color, background: withBackground ? "visible" : "hidden" }), "data-testid": dataTestId ? `${dataTestId}-background` : "indicator-background", children: [ping && (jsx("div", { className: cvaIndicatorPing({ color }), "data-testid": dataTestId ? `${dataTestId}-ping` : "indicator-ping" })), icon] }), label !== undefined && withLabel && (jsx("div", { className: cvaIndicatorLabel(), "data-testid": dataTestId ? `${dataTestId}-label` : "indicator-label", children: label }))] })) }));
19141
+ return (jsx(Tooltip, { className: className, disabled: withLabel, label: label, children: jsxs("div", Object.assign({ className: cvaIndicator(), "data-testid": dataTestId, "aria-label": label }, rest, { children: [jsxs("div", { className: cvaIndicatorIconBackground({ color, background: withBackground ? "visible" : "hidden" }), "data-testid": dataTestId ? `${dataTestId}-background` : "indicator-background", children: [ping && (jsx("div", { className: cvaIndicatorPing({ color }), "data-testid": dataTestId ? `${dataTestId}-ping` : "indicator-ping" })), icon] }), label !== undefined && withLabel && (jsx("div", { className: cvaIndicatorLabel(), "data-testid": dataTestId ? `${dataTestId}-label` : "indicator-label", children: label }))] })) }));
19142
19142
  };
19143
19143
 
19144
19144
  const cvaMenuItem = cvaMerge([
@@ -36651,6 +36651,7 @@ const useTimeout = ({ onTimeout, duration }) => {
36651
36651
  timeout.current && clearTimeout(timeout.current);
36652
36652
  }, []);
36653
36653
  useEffect(() => {
36654
+ // Use the latest callback function provided by the parent component.
36654
36655
  callback.current = onTimeout;
36655
36656
  }, [onTimeout]);
36656
36657
  useEffect(() => {
@@ -36667,26 +36668,44 @@ const useTimeout = ({ onTimeout, duration }) => {
36667
36668
  *
36668
36669
  * @param {object} options - Options for the useContinuousTimeout hook.
36669
36670
  * @param {Function} options.onTimeout - Callback function to execute on each timeout.
36671
+ * @param {Function} options.onMaxRetries - Callback function to execute when the maximum number of retries is reached.
36670
36672
  * @param {number} options.duration - Duration of the timeout in milliseconds.
36671
36673
  * @param {number} options.maxRetries - Maximum number of retry attempts.
36672
- * @returns {object} An object containing functions to start and stop the timeout.
36674
+ * @returns {object} An object containing functions to start and stop the timeout, current retry count, and the timeout status.
36673
36675
  */
36674
- const useContinuousTimeout = ({ onTimeout, duration, maxRetries }) => {
36676
+ const useContinuousTimeout = ({ onTimeout, onMaxRetries, duration, maxRetries }) => {
36675
36677
  const retries = useRef(0);
36678
+ const [isRunning, setIsRunning] = useState(false); // Track the timeout status
36679
+ const stopTimeouts = () => {
36680
+ stopTimeout();
36681
+ setIsRunning(false); // Update the status when stopped
36682
+ };
36683
+ const startTimeouts = () => {
36684
+ startTimeout();
36685
+ setIsRunning(true); // Update the status when started
36686
+ };
36676
36687
  const { startTimeout, stopTimeout } = useTimeout({
36677
36688
  duration,
36678
36689
  onTimeout: () => {
36679
- onTimeout();
36680
- if (retries.current < maxRetries) {
36681
- startTimeout();
36682
- retries.current++;
36683
- }
36684
- else {
36685
- retries.current = 0;
36690
+ if (isRunning) {
36691
+ onTimeout();
36692
+ if (retries.current < maxRetries) {
36693
+ retries.current++;
36694
+ }
36695
+ else {
36696
+ onMaxRetries === null || onMaxRetries === void 0 ? void 0 : onMaxRetries();
36697
+ retries.current = 0;
36698
+ }
36699
+ startTimeout(); // Restart the timeout if it's still running
36686
36700
  }
36687
36701
  },
36688
36702
  });
36689
- return { startTimeout, stopTimeout, retries: retries.current };
36703
+ return {
36704
+ startTimeouts,
36705
+ stopTimeouts,
36706
+ retries: retries.current,
36707
+ isRunning,
36708
+ };
36690
36709
  };
36691
36710
 
36692
36711
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trackunit/react-components",
3
- "version": "0.1.159",
3
+ "version": "0.1.161",
4
4
  "repository": "https://github.com/Trackunit/manager",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "engines": {
@@ -14,7 +14,7 @@ export interface DayRangePickerProps extends CommonProps {
14
14
  /**
15
15
  * Set any days which are selected
16
16
  */
17
- selectedDays: IDateRange;
17
+ selectedDays?: IDateRange;
18
18
  /**
19
19
  * Set the language
20
20
  */
@@ -8,7 +8,7 @@ export interface ExternalLinkProps extends CommonProps {
8
8
  /**
9
9
  * Child elements.
10
10
  */
11
- children: React.ReactNode;
11
+ children?: React.ReactNode;
12
12
  /**
13
13
  * The text to display on the URL. Defaults to the url itself.
14
14
  */
@@ -1,19 +1,22 @@
1
1
  import { UseTimeoutProps } from "./useTimeout";
2
2
  interface UseContinuousTimeoutProps extends UseTimeoutProps {
3
3
  maxRetries: number;
4
+ onMaxRetries?: () => void;
4
5
  }
5
6
  /**
6
7
  * Hook for continuous retries with a timeout mechanism.
7
8
  *
8
9
  * @param {object} options - Options for the useContinuousTimeout hook.
9
10
  * @param {Function} options.onTimeout - Callback function to execute on each timeout.
11
+ * @param {Function} options.onMaxRetries - Callback function to execute when the maximum number of retries is reached.
10
12
  * @param {number} options.duration - Duration of the timeout in milliseconds.
11
13
  * @param {number} options.maxRetries - Maximum number of retry attempts.
12
- * @returns {object} An object containing functions to start and stop the timeout.
14
+ * @returns {object} An object containing functions to start and stop the timeout, current retry count, and the timeout status.
13
15
  */
14
- export declare const useContinuousTimeout: ({ onTimeout, duration, maxRetries }: UseContinuousTimeoutProps) => {
15
- startTimeout: () => void;
16
- stopTimeout: () => void;
16
+ export declare const useContinuousTimeout: ({ onTimeout, onMaxRetries, duration, maxRetries }: UseContinuousTimeoutProps) => {
17
+ startTimeouts: () => void;
18
+ stopTimeouts: () => void;
17
19
  retries: number;
20
+ isRunning: boolean;
18
21
  };
19
22
  export {};