@processdynamics/components 0.1.7 → 0.1.9

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/README.md CHANGED
@@ -201,6 +201,7 @@ The packages the components import are declared as `peerDependencies` in `packag
201
201
  - `class-variance-authority` for button variants
202
202
  - `cn` for class merging
203
203
  - `sonner` for the toaster
204
+ - `next` for the footer navigation's links and current path
204
205
 
205
206
  They are also dev dependencies here so Storybook and the tests can run.
206
207
 
package/dist/index.cjs CHANGED
@@ -33,7 +33,9 @@ var index_exports = {};
33
33
  __export(index_exports, {
34
34
  DatePicker: () => DatePicker,
35
35
  DebouncedInput: () => DebouncedInput,
36
+ FooterNavigation: () => FooterNavigation,
36
37
  JobCard: () => JobCard,
38
+ PullToRefreshArea: () => PullToRefreshArea,
37
39
  Toaster: () => Toaster2,
38
40
  toast: () => import_sonner2.toast,
39
41
  toastColors: () => toastColors
@@ -430,7 +432,7 @@ var DatePicker = ({
430
432
  // src/components/debounceInput/DebouncedInput.tsx
431
433
  var import_react2 = require("react");
432
434
 
433
- // src/lib/debounce.ts
435
+ // src/components/debounceInput/debounce.ts
434
436
  function debounce(fn, delayMs) {
435
437
  let timeout = null;
436
438
  let latestArgs = null;
@@ -758,11 +760,213 @@ function toastColors({
758
760
  function Toaster2({ position = "top-center", ...props }) {
759
761
  return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Toaster, { position, ...props });
760
762
  }
763
+
764
+ // src/components/pullToRefreshArea/PullToRefreshArea.tsx
765
+ var import_react4 = require("react");
766
+
767
+ // src/components/pullToRefreshArea/usePullToRefresh.ts
768
+ var import_react3 = require("react");
769
+
770
+ // src/components/pullToRefreshArea/pullToRefresh.ts
771
+ var DEAD_ZONE_PX = 8;
772
+ var RESISTANCE = 0.5;
773
+ var MAX_PULL_PX = 120;
774
+ var REFRESH_THRESHOLD_PX = 64;
775
+ var REFRESHING_HEIGHT_PX = 48;
776
+ function getPullDistance(fingerDeltaY) {
777
+ if (fingerDeltaY <= DEAD_ZONE_PX) return 0;
778
+ return Math.min((fingerDeltaY - DEAD_ZONE_PX) * RESISTANCE, MAX_PULL_PX);
779
+ }
780
+ function isPastThreshold(pullDistance) {
781
+ return pullDistance >= REFRESH_THRESHOLD_PX;
782
+ }
783
+ var IGNORED_SELECTOR = "input, textarea, select, [contenteditable='true'], [data-no-pull-refresh]";
784
+ function isScrolledVertically(element) {
785
+ const { overflowY } = getComputedStyle(element);
786
+ const canScroll = overflowY === "auto" || overflowY === "scroll";
787
+ return canScroll && element.scrollHeight > element.clientHeight && element.scrollTop > 0;
788
+ }
789
+ function shouldIgnoreTouchTarget(target, container) {
790
+ for (let element = target; element && element !== container; element = element.parentElement) {
791
+ if (element.matches(IGNORED_SELECTOR)) return true;
792
+ if (element instanceof HTMLElement && isScrolledVertically(element)) return true;
793
+ }
794
+ return false;
795
+ }
796
+
797
+ // src/components/pullToRefreshArea/usePullToRefresh.ts
798
+ var RELOAD_MESSAGE_DELAY_MS = 700;
799
+ var MIN_REFRESH_DISPLAY_MS = 500;
800
+ function wait(milliseconds) {
801
+ return new Promise((resolve) => setTimeout(resolve, milliseconds));
802
+ }
803
+ function usePullToRefresh({ containerRef, isEnabled, onRefresh, onReload }) {
804
+ const [pullDistance, setPullDistance] = (0, import_react3.useState)(0);
805
+ const [phase, setPhase] = (0, import_react3.useState)("idle");
806
+ const onRefreshRef = (0, import_react3.useRef)(onRefresh);
807
+ const onReloadRef = (0, import_react3.useRef)(onReload);
808
+ (0, import_react3.useEffect)(() => {
809
+ onRefreshRef.current = onRefresh;
810
+ onReloadRef.current = onReload;
811
+ });
812
+ (0, import_react3.useEffect)(() => {
813
+ const container = containerRef.current;
814
+ if (!container || !isEnabled) return;
815
+ let startY = 0;
816
+ let distance = 0;
817
+ let isTracking = false;
818
+ let isBusy = false;
819
+ function reset() {
820
+ distance = 0;
821
+ setPullDistance(0);
822
+ setPhase("idle");
823
+ }
824
+ function handleTouchStart(event) {
825
+ if (isBusy || event.touches.length !== 1 || !container || container.scrollTop > 0) return;
826
+ if (shouldIgnoreTouchTarget(event.target, container)) return;
827
+ startY = event.touches[0].clientY;
828
+ distance = 0;
829
+ isTracking = true;
830
+ }
831
+ function handleTouchMove(event) {
832
+ if (!isTracking || !container) return;
833
+ if (container.scrollTop > 0) {
834
+ isTracking = false;
835
+ reset();
836
+ return;
837
+ }
838
+ distance = getPullDistance(event.touches[0].clientY - startY);
839
+ if (distance > 0) event.preventDefault();
840
+ setPullDistance(distance);
841
+ setPhase(distance === 0 ? "idle" : isPastThreshold(distance) ? "ready" : "pulling");
842
+ }
843
+ async function handleTouchEnd() {
844
+ if (!isTracking) return;
845
+ isTracking = false;
846
+ if (!isPastThreshold(distance)) {
847
+ reset();
848
+ return;
849
+ }
850
+ isBusy = true;
851
+ setPhase("refreshing");
852
+ setPullDistance(REFRESHING_HEIGHT_PX);
853
+ const startedAt = Date.now();
854
+ let outcome = "refreshed";
855
+ try {
856
+ outcome = await onRefreshRef.current();
857
+ } catch (error) {
858
+ console.error("Pull-down refresh failed:", error);
859
+ }
860
+ if (outcome === "reloading") {
861
+ setPhase("reloading");
862
+ await wait(RELOAD_MESSAGE_DELAY_MS);
863
+ (onReloadRef.current ?? (() => window.location.reload()))();
864
+ return;
865
+ }
866
+ await wait(Math.max(0, MIN_REFRESH_DISPLAY_MS - (Date.now() - startedAt)));
867
+ isBusy = false;
868
+ reset();
869
+ }
870
+ function handleTouchCancel() {
871
+ if (!isTracking) return;
872
+ isTracking = false;
873
+ reset();
874
+ }
875
+ container.addEventListener("touchstart", handleTouchStart, { passive: true });
876
+ container.addEventListener("touchmove", handleTouchMove, { passive: false });
877
+ container.addEventListener("touchend", handleTouchEnd, { passive: true });
878
+ container.addEventListener("touchcancel", handleTouchCancel, { passive: true });
879
+ return () => {
880
+ container.removeEventListener("touchstart", handleTouchStart);
881
+ container.removeEventListener("touchmove", handleTouchMove);
882
+ container.removeEventListener("touchend", handleTouchEnd);
883
+ container.removeEventListener("touchcancel", handleTouchCancel);
884
+ };
885
+ }, [containerRef, isEnabled]);
886
+ return { pullDistance, phase };
887
+ }
888
+
889
+ // src/components/pullToRefreshArea/PullToRefreshArea.tsx
890
+ var import_jsx_runtime14 = require("react/jsx-runtime");
891
+ var LABELS = {
892
+ idle: "",
893
+ pulling: "Pull down to refresh",
894
+ ready: "Release to refresh",
895
+ refreshing: "Refreshing\u2026",
896
+ reloading: "Updating to the new version\u2026"
897
+ };
898
+ function PullToRefreshArea({
899
+ isEnabled,
900
+ onRefresh,
901
+ onReload,
902
+ className,
903
+ children
904
+ }) {
905
+ const containerRef = (0, import_react4.useRef)(null);
906
+ const { pullDistance, phase } = usePullToRefresh({
907
+ containerRef,
908
+ isEnabled,
909
+ onRefresh,
910
+ onReload
911
+ });
912
+ const isDragging = phase === "pulling" || phase === "ready";
913
+ const isWorking = phase === "refreshing" || phase === "reloading";
914
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { ref: containerRef, className: (0, import_cn6.cn)(className, isEnabled && "overscroll-y-contain"), children: [
915
+ isEnabled && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
916
+ "div",
917
+ {
918
+ role: "status",
919
+ "aria-live": "polite",
920
+ className: "flex items-end justify-center overflow-hidden text-sm text-muted-foreground",
921
+ style: { height: pullDistance, transition: isDragging ? "none" : "height 200ms ease" },
922
+ children: phase !== "idle" && /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("span", { className: "flex items-center gap-2 pb-2", children: [
923
+ isWorking ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { className: "h-4 w-4 animate-spin rounded-full border-2 border-muted border-t-primary" }) : /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
924
+ "span",
925
+ {
926
+ "aria-hidden": "true",
927
+ className: "inline-block transition-transform",
928
+ style: { transform: phase === "ready" ? "rotate(180deg)" : "none" },
929
+ children: "\u2193"
930
+ }
931
+ ),
932
+ LABELS[phase]
933
+ ] })
934
+ }
935
+ ),
936
+ children
937
+ ] });
938
+ }
939
+
940
+ // src/components/footerNavigation/FooterNavigation.tsx
941
+ var import_link = __toESM(require("next/link"), 1);
942
+ var import_navigation = require("next/navigation");
943
+ var import_jsx_runtime15 = require("react/jsx-runtime");
944
+ function FooterNavigation({ onClick, navItems }) {
945
+ const pathname = (0, import_navigation.usePathname)();
946
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("nav", { className: "flex border-t border-gray-200 bg-white shrink-0", children: navItems.map(({ href, icon, label }) => {
947
+ const isActive = pathname === href;
948
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
949
+ import_link.default,
950
+ {
951
+ href,
952
+ onClick,
953
+ className: `flex-1 px-1 py-2.5 flex flex-col items-center gap-0.5 border-none bg-transparent cursor-pointer text-[10px] font-medium border-t-2 transition-colors ${isActive ? "text-primary border-t-primary" : "text-gray-500 border-t-transparent"}`,
954
+ children: [
955
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: "text-xl leading-none", children: icon }),
956
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { children: label })
957
+ ]
958
+ },
959
+ href
960
+ );
961
+ }) });
962
+ }
761
963
  // Annotate the CommonJS export names for ESM import in node:
762
964
  0 && (module.exports = {
763
965
  DatePicker,
764
966
  DebouncedInput,
967
+ FooterNavigation,
765
968
  JobCard,
969
+ PullToRefreshArea,
766
970
  Toaster,
767
971
  toast,
768
972
  toastColors
package/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as react from 'react';
2
- import { ComponentProps, FocusEventHandler, ReactNode, CSSProperties } from 'react';
2
+ import { ComponentProps, FocusEventHandler, ReactNode, CSSProperties, MouseEventHandler } from 'react';
3
3
  import { ToasterProps as ToasterProps$1 } from 'sonner';
4
4
  export { toast } from 'sonner';
5
5
 
@@ -268,5 +268,64 @@ declare function toastColors({ background, text, border, }: ToastColors): CSSPro
268
268
  */
269
269
  declare function Toaster({ position, ...props }: ToasterProps): react.JSX.Element;
270
270
 
271
- export { DatePicker, DebouncedInput, JobCard, Toaster, toastColors };
272
- export type { DebouncedInputProps, JobCardAction, JobCardBadge, JobCardBanner, JobCardColor, JobCardData, JobCardPill, JobCardPillTone, JobCardProps, JobCardStage, JobCardTone, ToastColors, ToasterProps };
271
+ /** What a refresh reports back: the data was refreshed, or a new version of the app is about to replace the page. */
272
+ type RefreshOutcome = "refreshed" | "reloading";
273
+ type PullPhase = "idle" | "pulling" | "ready" | "refreshing" | "reloading";
274
+
275
+ interface PullToRefreshAreaProps {
276
+ /**
277
+ * Turns the pull gesture on or off. Turn it off where a refresh can't work,
278
+ * for example when the app can't reach its version check. When off, the area
279
+ * renders its children and nothing else. Not controlled by the area.
280
+ */
281
+ isEnabled: boolean;
282
+ /**
283
+ * Runs when the user pulls past the threshold and lets go. Resolve with
284
+ * `"refreshed"` once the data is up to date, or `"reloading"` when a newer
285
+ * version of the app is live: the area then shows its updating message and
286
+ * calls `onReload`. If it rejects, the error is logged and the area resets.
287
+ */
288
+ onRefresh: () => Promise<RefreshOutcome>;
289
+ /**
290
+ * Called after the updating message has been shown, when `onRefresh`
291
+ * resolved with `"reloading"`. Defaults to reloading the browser page.
292
+ */
293
+ onReload?: () => void;
294
+ /** Classes for the scrolling container. Give it a fixed height or a flex size, because the area itself is what scrolls. */
295
+ className?: string;
296
+ /** The page content. */
297
+ children: ReactNode;
298
+ }
299
+ /**
300
+ * The scrolling page area, with a quiet strip that opens at the top while you
301
+ * pull down. The pull only starts when the area is scrolled to the top, and it
302
+ * ignores touches that begin on fields, inside lists that are scrolled down, or
303
+ * inside anything marked `data-no-pull-refresh`. What a refresh does is up to
304
+ * the app, through `onRefresh`.
305
+ */
306
+ declare function PullToRefreshArea({ isEnabled, onRefresh, onReload, className, children, }: PullToRefreshAreaProps): react.JSX.Element;
307
+
308
+ /** One tab in the footer navigation. */
309
+ type FooterNavigationItem = {
310
+ /** Where the tab links to. The tab is active when this matches the current path exactly. */
311
+ href: string;
312
+ /** What shows above the label: an emoji or text, or any element such as an icon. */
313
+ icon: string | ReactNode;
314
+ /** The tab's text, shown under the icon. */
315
+ label: string;
316
+ };
317
+ interface FooterNavigationProps {
318
+ /** The tabs, in the order they show. Each `href` should be unique, because it is the React key. */
319
+ navItems: FooterNavigationItem[];
320
+ /** Called when any tab is clicked, before the navigation happens. Not controlled: the link still navigates. */
321
+ onClick: MouseEventHandler<HTMLAnchorElement>;
322
+ }
323
+ /**
324
+ * A row of equal-width tabs for the foot of a phone-sized screen. The tab whose
325
+ * `href` matches the current path is highlighted with the primary colour.
326
+ * It reads the path from the Next router, so it must render inside a Next app.
327
+ */
328
+ declare function FooterNavigation({ onClick, navItems }: FooterNavigationProps): react.JSX.Element;
329
+
330
+ export { DatePicker, DebouncedInput, FooterNavigation, JobCard, PullToRefreshArea, Toaster, toastColors };
331
+ export type { DebouncedInputProps, FooterNavigationItem, FooterNavigationProps, JobCardAction, JobCardBadge, JobCardBanner, JobCardColor, JobCardData, JobCardPill, JobCardPillTone, JobCardProps, JobCardStage, JobCardTone, PullPhase, PullToRefreshAreaProps, RefreshOutcome, ToastColors, ToasterProps };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as react from 'react';
2
- import { ComponentProps, FocusEventHandler, ReactNode, CSSProperties } from 'react';
2
+ import { ComponentProps, FocusEventHandler, ReactNode, CSSProperties, MouseEventHandler } from 'react';
3
3
  import { ToasterProps as ToasterProps$1 } from 'sonner';
4
4
  export { toast } from 'sonner';
5
5
 
@@ -268,5 +268,64 @@ declare function toastColors({ background, text, border, }: ToastColors): CSSPro
268
268
  */
269
269
  declare function Toaster({ position, ...props }: ToasterProps): react.JSX.Element;
270
270
 
271
- export { DatePicker, DebouncedInput, JobCard, Toaster, toastColors };
272
- export type { DebouncedInputProps, JobCardAction, JobCardBadge, JobCardBanner, JobCardColor, JobCardData, JobCardPill, JobCardPillTone, JobCardProps, JobCardStage, JobCardTone, ToastColors, ToasterProps };
271
+ /** What a refresh reports back: the data was refreshed, or a new version of the app is about to replace the page. */
272
+ type RefreshOutcome = "refreshed" | "reloading";
273
+ type PullPhase = "idle" | "pulling" | "ready" | "refreshing" | "reloading";
274
+
275
+ interface PullToRefreshAreaProps {
276
+ /**
277
+ * Turns the pull gesture on or off. Turn it off where a refresh can't work,
278
+ * for example when the app can't reach its version check. When off, the area
279
+ * renders its children and nothing else. Not controlled by the area.
280
+ */
281
+ isEnabled: boolean;
282
+ /**
283
+ * Runs when the user pulls past the threshold and lets go. Resolve with
284
+ * `"refreshed"` once the data is up to date, or `"reloading"` when a newer
285
+ * version of the app is live: the area then shows its updating message and
286
+ * calls `onReload`. If it rejects, the error is logged and the area resets.
287
+ */
288
+ onRefresh: () => Promise<RefreshOutcome>;
289
+ /**
290
+ * Called after the updating message has been shown, when `onRefresh`
291
+ * resolved with `"reloading"`. Defaults to reloading the browser page.
292
+ */
293
+ onReload?: () => void;
294
+ /** Classes for the scrolling container. Give it a fixed height or a flex size, because the area itself is what scrolls. */
295
+ className?: string;
296
+ /** The page content. */
297
+ children: ReactNode;
298
+ }
299
+ /**
300
+ * The scrolling page area, with a quiet strip that opens at the top while you
301
+ * pull down. The pull only starts when the area is scrolled to the top, and it
302
+ * ignores touches that begin on fields, inside lists that are scrolled down, or
303
+ * inside anything marked `data-no-pull-refresh`. What a refresh does is up to
304
+ * the app, through `onRefresh`.
305
+ */
306
+ declare function PullToRefreshArea({ isEnabled, onRefresh, onReload, className, children, }: PullToRefreshAreaProps): react.JSX.Element;
307
+
308
+ /** One tab in the footer navigation. */
309
+ type FooterNavigationItem = {
310
+ /** Where the tab links to. The tab is active when this matches the current path exactly. */
311
+ href: string;
312
+ /** What shows above the label: an emoji or text, or any element such as an icon. */
313
+ icon: string | ReactNode;
314
+ /** The tab's text, shown under the icon. */
315
+ label: string;
316
+ };
317
+ interface FooterNavigationProps {
318
+ /** The tabs, in the order they show. Each `href` should be unique, because it is the React key. */
319
+ navItems: FooterNavigationItem[];
320
+ /** Called when any tab is clicked, before the navigation happens. Not controlled: the link still navigates. */
321
+ onClick: MouseEventHandler<HTMLAnchorElement>;
322
+ }
323
+ /**
324
+ * A row of equal-width tabs for the foot of a phone-sized screen. The tab whose
325
+ * `href` matches the current path is highlighted with the primary colour.
326
+ * It reads the path from the Next router, so it must render inside a Next app.
327
+ */
328
+ declare function FooterNavigation({ onClick, navItems }: FooterNavigationProps): react.JSX.Element;
329
+
330
+ export { DatePicker, DebouncedInput, FooterNavigation, JobCard, PullToRefreshArea, Toaster, toastColors };
331
+ export type { DebouncedInputProps, FooterNavigationItem, FooterNavigationProps, JobCardAction, JobCardBadge, JobCardBanner, JobCardColor, JobCardData, JobCardPill, JobCardPillTone, JobCardProps, JobCardStage, JobCardTone, PullPhase, PullToRefreshAreaProps, RefreshOutcome, ToastColors, ToasterProps };
package/dist/index.js CHANGED
@@ -397,7 +397,7 @@ import {
397
397
  useState as useState2
398
398
  } from "react";
399
399
 
400
- // src/lib/debounce.ts
400
+ // src/components/debounceInput/debounce.ts
401
401
  function debounce(fn, delayMs) {
402
402
  let timeout = null;
403
403
  let latestArgs = null;
@@ -725,10 +725,212 @@ function toastColors({
725
725
  function Toaster2({ position = "top-center", ...props }) {
726
726
  return /* @__PURE__ */ jsx12(Toaster, { position, ...props });
727
727
  }
728
+
729
+ // src/components/pullToRefreshArea/PullToRefreshArea.tsx
730
+ import { useRef as useRef4 } from "react";
731
+
732
+ // src/components/pullToRefreshArea/usePullToRefresh.ts
733
+ import { useEffect as useEffect3, useRef as useRef3, useState as useState3 } from "react";
734
+
735
+ // src/components/pullToRefreshArea/pullToRefresh.ts
736
+ var DEAD_ZONE_PX = 8;
737
+ var RESISTANCE = 0.5;
738
+ var MAX_PULL_PX = 120;
739
+ var REFRESH_THRESHOLD_PX = 64;
740
+ var REFRESHING_HEIGHT_PX = 48;
741
+ function getPullDistance(fingerDeltaY) {
742
+ if (fingerDeltaY <= DEAD_ZONE_PX) return 0;
743
+ return Math.min((fingerDeltaY - DEAD_ZONE_PX) * RESISTANCE, MAX_PULL_PX);
744
+ }
745
+ function isPastThreshold(pullDistance) {
746
+ return pullDistance >= REFRESH_THRESHOLD_PX;
747
+ }
748
+ var IGNORED_SELECTOR = "input, textarea, select, [contenteditable='true'], [data-no-pull-refresh]";
749
+ function isScrolledVertically(element) {
750
+ const { overflowY } = getComputedStyle(element);
751
+ const canScroll = overflowY === "auto" || overflowY === "scroll";
752
+ return canScroll && element.scrollHeight > element.clientHeight && element.scrollTop > 0;
753
+ }
754
+ function shouldIgnoreTouchTarget(target, container) {
755
+ for (let element = target; element && element !== container; element = element.parentElement) {
756
+ if (element.matches(IGNORED_SELECTOR)) return true;
757
+ if (element instanceof HTMLElement && isScrolledVertically(element)) return true;
758
+ }
759
+ return false;
760
+ }
761
+
762
+ // src/components/pullToRefreshArea/usePullToRefresh.ts
763
+ var RELOAD_MESSAGE_DELAY_MS = 700;
764
+ var MIN_REFRESH_DISPLAY_MS = 500;
765
+ function wait(milliseconds) {
766
+ return new Promise((resolve) => setTimeout(resolve, milliseconds));
767
+ }
768
+ function usePullToRefresh({ containerRef, isEnabled, onRefresh, onReload }) {
769
+ const [pullDistance, setPullDistance] = useState3(0);
770
+ const [phase, setPhase] = useState3("idle");
771
+ const onRefreshRef = useRef3(onRefresh);
772
+ const onReloadRef = useRef3(onReload);
773
+ useEffect3(() => {
774
+ onRefreshRef.current = onRefresh;
775
+ onReloadRef.current = onReload;
776
+ });
777
+ useEffect3(() => {
778
+ const container = containerRef.current;
779
+ if (!container || !isEnabled) return;
780
+ let startY = 0;
781
+ let distance = 0;
782
+ let isTracking = false;
783
+ let isBusy = false;
784
+ function reset() {
785
+ distance = 0;
786
+ setPullDistance(0);
787
+ setPhase("idle");
788
+ }
789
+ function handleTouchStart(event) {
790
+ if (isBusy || event.touches.length !== 1 || !container || container.scrollTop > 0) return;
791
+ if (shouldIgnoreTouchTarget(event.target, container)) return;
792
+ startY = event.touches[0].clientY;
793
+ distance = 0;
794
+ isTracking = true;
795
+ }
796
+ function handleTouchMove(event) {
797
+ if (!isTracking || !container) return;
798
+ if (container.scrollTop > 0) {
799
+ isTracking = false;
800
+ reset();
801
+ return;
802
+ }
803
+ distance = getPullDistance(event.touches[0].clientY - startY);
804
+ if (distance > 0) event.preventDefault();
805
+ setPullDistance(distance);
806
+ setPhase(distance === 0 ? "idle" : isPastThreshold(distance) ? "ready" : "pulling");
807
+ }
808
+ async function handleTouchEnd() {
809
+ if (!isTracking) return;
810
+ isTracking = false;
811
+ if (!isPastThreshold(distance)) {
812
+ reset();
813
+ return;
814
+ }
815
+ isBusy = true;
816
+ setPhase("refreshing");
817
+ setPullDistance(REFRESHING_HEIGHT_PX);
818
+ const startedAt = Date.now();
819
+ let outcome = "refreshed";
820
+ try {
821
+ outcome = await onRefreshRef.current();
822
+ } catch (error) {
823
+ console.error("Pull-down refresh failed:", error);
824
+ }
825
+ if (outcome === "reloading") {
826
+ setPhase("reloading");
827
+ await wait(RELOAD_MESSAGE_DELAY_MS);
828
+ (onReloadRef.current ?? (() => window.location.reload()))();
829
+ return;
830
+ }
831
+ await wait(Math.max(0, MIN_REFRESH_DISPLAY_MS - (Date.now() - startedAt)));
832
+ isBusy = false;
833
+ reset();
834
+ }
835
+ function handleTouchCancel() {
836
+ if (!isTracking) return;
837
+ isTracking = false;
838
+ reset();
839
+ }
840
+ container.addEventListener("touchstart", handleTouchStart, { passive: true });
841
+ container.addEventListener("touchmove", handleTouchMove, { passive: false });
842
+ container.addEventListener("touchend", handleTouchEnd, { passive: true });
843
+ container.addEventListener("touchcancel", handleTouchCancel, { passive: true });
844
+ return () => {
845
+ container.removeEventListener("touchstart", handleTouchStart);
846
+ container.removeEventListener("touchmove", handleTouchMove);
847
+ container.removeEventListener("touchend", handleTouchEnd);
848
+ container.removeEventListener("touchcancel", handleTouchCancel);
849
+ };
850
+ }, [containerRef, isEnabled]);
851
+ return { pullDistance, phase };
852
+ }
853
+
854
+ // src/components/pullToRefreshArea/PullToRefreshArea.tsx
855
+ import { jsx as jsx13, jsxs as jsxs6 } from "react/jsx-runtime";
856
+ var LABELS = {
857
+ idle: "",
858
+ pulling: "Pull down to refresh",
859
+ ready: "Release to refresh",
860
+ refreshing: "Refreshing\u2026",
861
+ reloading: "Updating to the new version\u2026"
862
+ };
863
+ function PullToRefreshArea({
864
+ isEnabled,
865
+ onRefresh,
866
+ onReload,
867
+ className,
868
+ children
869
+ }) {
870
+ const containerRef = useRef4(null);
871
+ const { pullDistance, phase } = usePullToRefresh({
872
+ containerRef,
873
+ isEnabled,
874
+ onRefresh,
875
+ onReload
876
+ });
877
+ const isDragging = phase === "pulling" || phase === "ready";
878
+ const isWorking = phase === "refreshing" || phase === "reloading";
879
+ return /* @__PURE__ */ jsxs6("div", { ref: containerRef, className: cn6(className, isEnabled && "overscroll-y-contain"), children: [
880
+ isEnabled && /* @__PURE__ */ jsx13(
881
+ "div",
882
+ {
883
+ role: "status",
884
+ "aria-live": "polite",
885
+ className: "flex items-end justify-center overflow-hidden text-sm text-muted-foreground",
886
+ style: { height: pullDistance, transition: isDragging ? "none" : "height 200ms ease" },
887
+ children: phase !== "idle" && /* @__PURE__ */ jsxs6("span", { className: "flex items-center gap-2 pb-2", children: [
888
+ isWorking ? /* @__PURE__ */ jsx13("span", { className: "h-4 w-4 animate-spin rounded-full border-2 border-muted border-t-primary" }) : /* @__PURE__ */ jsx13(
889
+ "span",
890
+ {
891
+ "aria-hidden": "true",
892
+ className: "inline-block transition-transform",
893
+ style: { transform: phase === "ready" ? "rotate(180deg)" : "none" },
894
+ children: "\u2193"
895
+ }
896
+ ),
897
+ LABELS[phase]
898
+ ] })
899
+ }
900
+ ),
901
+ children
902
+ ] });
903
+ }
904
+
905
+ // src/components/footerNavigation/FooterNavigation.tsx
906
+ import Link from "next/link";
907
+ import { usePathname } from "next/navigation";
908
+ import { jsx as jsx14, jsxs as jsxs7 } from "react/jsx-runtime";
909
+ function FooterNavigation({ onClick, navItems }) {
910
+ const pathname = usePathname();
911
+ return /* @__PURE__ */ jsx14("nav", { className: "flex border-t border-gray-200 bg-white shrink-0", children: navItems.map(({ href, icon, label }) => {
912
+ const isActive = pathname === href;
913
+ return /* @__PURE__ */ jsxs7(
914
+ Link,
915
+ {
916
+ href,
917
+ onClick,
918
+ className: `flex-1 px-1 py-2.5 flex flex-col items-center gap-0.5 border-none bg-transparent cursor-pointer text-[10px] font-medium border-t-2 transition-colors ${isActive ? "text-primary border-t-primary" : "text-gray-500 border-t-transparent"}`,
919
+ children: [
920
+ /* @__PURE__ */ jsx14("span", { className: "text-xl leading-none", children: icon }),
921
+ /* @__PURE__ */ jsx14("span", { children: label })
922
+ ]
923
+ },
924
+ href
925
+ );
926
+ }) });
927
+ }
728
928
  export {
729
929
  DatePicker,
730
930
  DebouncedInput,
931
+ FooterNavigation,
731
932
  JobCard,
933
+ PullToRefreshArea,
732
934
  Toaster2 as Toaster,
733
935
  toast,
734
936
  toastColors
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@processdynamics/components",
3
- "version": "0.1.7",
3
+ "version": "0.1.9",
4
4
  "description": "Process Dynamics React component library, built on shadcn (Radix) and Tailwind CSS v4.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -99,6 +99,7 @@
99
99
  "cn": "^0.5.2",
100
100
  "date-fns": "^4.4.0",
101
101
  "lucide-react": "^1.66.0",
102
+ "next": "^16.0.0",
102
103
  "radix-ui": "^1.8.1",
103
104
  "react": "^19.0.0",
104
105
  "react-day-picker": "^10.0.2",