@processdynamics/components 0.1.4 → 0.1.6

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
@@ -57,7 +57,7 @@ The story tests don't check styling. For visual changes, open the story in a bro
57
57
 
58
58
  ### DatePicker
59
59
 
60
- A single date picker. A button shows the chosen date, or "Pick a date", and opens a calendar in a popover.
60
+ A single date picker. A text field takes a typed date, and a calendar button beside it opens a calendar in a popover. Both change the same date.
61
61
 
62
62
  ```tsx
63
63
  "use client";
@@ -73,15 +73,18 @@ export function Example() {
73
73
 
74
74
  | Prop | Type | Description |
75
75
  | --- | --- | --- |
76
- | `date` | `Date \| null` | The selected date. Optional. The component is controlled, so update it from `onSelect` or the button won't change. |
77
- | `onSelect` | `(date: Date) => void` | Required. Called with the chosen day, and the popover closes straight after. |
76
+ | `date` | `Date \| null` | The selected date. Optional. The component is controlled, so update it from `onSelect` or the date won't change. |
77
+ | `onSelect` | `(date: Date) => void` | Required. Called with the chosen day, from the calendar or from a typed date. |
78
+ | `dateFormat` | `string` | A date-fns format string for showing and typing the date. Optional, defaults to `dd/MM/yyyy`. The placeholder is this in lower case. |
78
79
 
79
80
  Behaviour to know about:
80
81
 
81
- - The button and popover fill the width of their container, so size it with a wrapper.
82
- - The date shows in long format, for example "March 15th, 2026".
83
- - The calendar opens on the month of `date`, or the current month when there is none. With no date, today is highlighted as the selection while the button still says "Pick a date".
84
- - A date can be changed but not cleared.
82
+ - The field and the calendar button fill the width of their container, so size it with a wrapper.
83
+ - A typed date is read when the user presses Enter or leaves the field. Text that is not a real date, or a year under 1000 such as `2/11/26`, is ignored and the field goes back to the last good date. Enter doesn't submit a surrounding form.
84
+ - Picking a day in the calendar fills the field and closes the popover.
85
+ - The calendar opens on the month of `date`, or the current month when there is none. With no date, today is highlighted as the selection while the field stays empty.
86
+ - A date can be changed but not cleared. Emptying the field puts the last date back.
87
+ - The field's accessible name is "Date" and the button's is "Open calendar". With two pickers on one page, wrap each in a labelled group.
85
88
  - The popover is modal on purpose, so it works inside a vaul drawer.
86
89
 
87
90
  The full docs page, with live controls and stories, is in Storybook under Components, then DatePicker.
package/dist/index.cjs CHANGED
@@ -32,6 +32,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
32
32
  var index_exports = {};
33
33
  __export(index_exports, {
34
34
  DatePicker: () => DatePicker,
35
+ DebouncedInput: () => DebouncedInput,
35
36
  JobCard: () => JobCard
36
37
  });
37
38
  module.exports = __toCommonJS(index_exports);
@@ -313,71 +314,218 @@ function PopoverContent({
313
314
  }
314
315
  ) });
315
316
  }
317
+ function PopoverAnchor({
318
+ ...props
319
+ }) {
320
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_radix_ui2.Popover.Anchor, { "data-slot": "popover-anchor", ...props });
321
+ }
322
+
323
+ // src/components/ui/input.tsx
324
+ var import_cn4 = require("cn");
325
+ var import_jsx_runtime4 = require("react/jsx-runtime");
326
+ function Input({ className, type, ...props }) {
327
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
328
+ "input",
329
+ {
330
+ type,
331
+ "data-slot": "input",
332
+ className: (0, import_cn4.cn)(
333
+ "h-8 w-full min-w-0 rounded-lg border border-input bg-transparent px-2.5 py-1 text-base transition-colors outline-none file:inline-flex file:h-6 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40",
334
+ className
335
+ ),
336
+ ...props
337
+ }
338
+ );
339
+ }
316
340
 
317
341
  // src/components/datePicker/DatePicker.tsx
318
342
  var import_date_fns = require("date-fns");
319
343
  var import_react = require("react");
320
- var import_jsx_runtime4 = require("react/jsx-runtime");
321
- var DatePicker = ({ onSelect, date }) => {
344
+ var import_jsx_runtime5 = require("react/jsx-runtime");
345
+ var DEFAULT_DATE_FORMAT = "dd/MM/yyyy";
346
+ var MIN_TYPED_YEAR = 1e3;
347
+ var parseTypedDate = (text, dateFormat) => {
348
+ const parsed = (0, import_date_fns.parse)(text.trim(), dateFormat, /* @__PURE__ */ new Date());
349
+ if (!(0, import_date_fns.isValid)(parsed) || parsed.getFullYear() < MIN_TYPED_YEAR) return null;
350
+ return parsed;
351
+ };
352
+ var formatDate = (date, dateFormat) => date ? (0, import_date_fns.format)(date, dateFormat) : "";
353
+ var DatePicker = ({
354
+ onSelect,
355
+ date,
356
+ dateFormat = DEFAULT_DATE_FORMAT
357
+ }) => {
322
358
  const [isOpen, setIsOpen] = (0, import_react.useState)(false);
323
- const handleSelect = (selectedDate) => {
359
+ const [typedText, setTypedText] = (0, import_react.useState)(formatDate(date, dateFormat));
360
+ const [shownDate, setShownDate] = (0, import_react.useState)(date);
361
+ if (date?.getTime() !== shownDate?.getTime()) {
362
+ setShownDate(date);
363
+ setTypedText(formatDate(date, dateFormat));
364
+ }
365
+ const handleCalendarSelect = (selectedDate) => {
366
+ setTypedText(formatDate(selectedDate, dateFormat));
324
367
  onSelect(selectedDate);
325
368
  setIsOpen(false);
326
369
  };
370
+ const commitTypedText = () => {
371
+ const parsedDate = parseTypedDate(typedText, dateFormat);
372
+ if (!parsedDate) {
373
+ setTypedText(formatDate(date, dateFormat));
374
+ return;
375
+ }
376
+ setTypedText(formatDate(parsedDate, dateFormat));
377
+ if (!date || !(0, import_date_fns.isSameDay)(parsedDate, date)) onSelect(parsedDate);
378
+ };
327
379
  return (
328
380
  // Modal so the calendar re-enables pointer events for itself. Inside a vaul
329
381
  // drawer the popover is portaled outside the drawer, and vaul bundles its
330
382
  // own copy of Radix's layer package, so a non-modal popover inherits the
331
383
  // drawer's pointer-events: none and its day buttons never receive clicks.
332
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(Popover, { modal: true, open: isOpen, onOpenChange: setIsOpen, children: [
333
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
334
- Button,
335
- {
336
- variant: "outline",
337
- "data-empty": !date,
338
- className: "w-full justify-between text-left font-normal data-[empty=true]:text-muted-foreground",
339
- children: [
340
- date ? (0, import_date_fns.format)(date, "PPP") : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { children: "Pick a date" }),
341
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_lucide_react2.ChevronDownIcon, { "data-icon": "inline-end" })
342
- ]
343
- }
344
- ) }),
345
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
346
- PopoverContent,
384
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(Popover, { modal: true, open: isOpen, onOpenChange: setIsOpen, children: [
385
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(PopoverAnchor, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex w-full gap-2", children: [
386
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
387
+ Input,
388
+ {
389
+ value: typedText,
390
+ onChange: (event) => setTypedText(event.target.value),
391
+ onBlur: commitTypedText,
392
+ onKeyDown: (event) => {
393
+ if (event.key !== "Enter") return;
394
+ event.preventDefault();
395
+ commitTypedText();
396
+ },
397
+ placeholder: dateFormat.toLowerCase(),
398
+ autoComplete: "off",
399
+ "aria-label": "Date"
400
+ }
401
+ ),
402
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
403
+ Button,
404
+ {
405
+ type: "button",
406
+ variant: "outline",
407
+ size: "icon",
408
+ "aria-label": "Open calendar",
409
+ children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.CalendarIcon, {})
410
+ }
411
+ ) })
412
+ ] }) }),
413
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(PopoverContent, { className: "w-auto p-0", align: "start", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
414
+ Calendar,
347
415
  {
348
- className: "w-[--radix-popover-trigger-width] p-0",
349
- align: "start",
350
- children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
351
- Calendar,
352
- {
353
- classNames: { root: "w-full" },
354
- mode: "single",
355
- required: true,
356
- selected: date ?? /* @__PURE__ */ new Date(),
357
- onSelect: handleSelect,
358
- defaultMonth: date ?? /* @__PURE__ */ new Date()
359
- }
360
- )
416
+ mode: "single",
417
+ required: true,
418
+ selected: date ?? /* @__PURE__ */ new Date(),
419
+ onSelect: handleCalendarSelect,
420
+ defaultMonth: date ?? /* @__PURE__ */ new Date()
361
421
  }
362
- )
422
+ ) })
363
423
  ] })
364
424
  );
365
425
  };
366
426
 
427
+ // src/components/debounceInput/DebouncedInput.tsx
428
+ var import_react2 = require("react");
429
+
430
+ // src/lib/debounce.ts
431
+ function debounce(fn, delayMs) {
432
+ let timeout = null;
433
+ let latestArgs = null;
434
+ const run = () => {
435
+ const args = latestArgs;
436
+ timeout = null;
437
+ latestArgs = null;
438
+ if (args) fn(...args);
439
+ };
440
+ const debounced = (...args) => {
441
+ latestArgs = args;
442
+ if (timeout) clearTimeout(timeout);
443
+ timeout = setTimeout(run, delayMs);
444
+ };
445
+ debounced.cancel = () => {
446
+ if (timeout) clearTimeout(timeout);
447
+ timeout = null;
448
+ latestArgs = null;
449
+ };
450
+ debounced.flush = () => {
451
+ if (!timeout) return;
452
+ clearTimeout(timeout);
453
+ run();
454
+ };
455
+ return debounced;
456
+ }
457
+
458
+ // src/components/debounceInput/DebouncedInput.tsx
459
+ var import_jsx_runtime6 = require("react/jsx-runtime");
460
+ function DebouncedInput({
461
+ value,
462
+ onValueChange,
463
+ delay = 250,
464
+ onFocus,
465
+ onBlur,
466
+ ...inputProps
467
+ }) {
468
+ const [text, setText] = (0, import_react2.useState)(value);
469
+ const [isFocused, setIsFocused] = (0, import_react2.useState)(false);
470
+ const onValueChangeRef = (0, import_react2.useRef)(onValueChange);
471
+ (0, import_react2.useEffect)(() => {
472
+ onValueChangeRef.current = onValueChange;
473
+ });
474
+ const commitTextRef = (0, import_react2.useRef)(null);
475
+ (0, import_react2.useEffect)(() => {
476
+ const commitText = debounce(
477
+ (next) => onValueChangeRef.current(next),
478
+ delay
479
+ );
480
+ commitTextRef.current = commitText;
481
+ const flushWaitingText = () => commitText.flush();
482
+ document.addEventListener("pointerdown", flushWaitingText, true);
483
+ return () => {
484
+ document.removeEventListener("pointerdown", flushWaitingText, true);
485
+ commitText.flush();
486
+ commitTextRef.current = null;
487
+ };
488
+ }, [delay]);
489
+ if (!isFocused && text !== value) {
490
+ setText(value);
491
+ }
492
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
493
+ Input,
494
+ {
495
+ ...inputProps,
496
+ type: "text",
497
+ value: text,
498
+ onChange: (e) => {
499
+ setText(e.target.value);
500
+ commitTextRef.current?.(e.target.value);
501
+ },
502
+ onFocus: (e) => {
503
+ setIsFocused(true);
504
+ onFocus?.(e);
505
+ },
506
+ onBlur: (e) => {
507
+ commitTextRef.current?.flush();
508
+ setIsFocused(false);
509
+ onBlur?.(e);
510
+ }
511
+ }
512
+ );
513
+ }
514
+
367
515
  // src/components/ui/card.tsx
368
- var import_cn4 = require("cn");
369
- var import_jsx_runtime5 = require("react/jsx-runtime");
516
+ var import_cn5 = require("cn");
517
+ var import_jsx_runtime7 = require("react/jsx-runtime");
370
518
  function Card({
371
519
  className,
372
520
  size = "default",
373
521
  ...props
374
522
  }) {
375
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
523
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
376
524
  "div",
377
525
  {
378
526
  "data-slot": "card",
379
527
  "data-size": size,
380
- className: (0, import_cn4.cn)(
528
+ className: (0, import_cn5.cn)(
381
529
  "group/card flex flex-col gap-(--card-spacing) overflow-hidden rounded-xl bg-card py-(--card-spacing) text-sm text-card-foreground ring-1 ring-foreground/10 [--card-spacing:--spacing(4)] has-data-[slot=card-footer]:pb-0 has-[>img:first-child]:pt-0 data-[size=sm]:[--card-spacing:--spacing(3)] data-[size=sm]:has-data-[slot=card-footer]:pb-0 *:[img:first-child]:rounded-t-xl *:[img:last-child]:rounded-b-xl",
382
530
  className
383
531
  ),
@@ -386,28 +534,28 @@ function Card({
386
534
  );
387
535
  }
388
536
  function CardContent({ className, ...props }) {
389
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
537
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
390
538
  "div",
391
539
  {
392
540
  "data-slot": "card-content",
393
- className: (0, import_cn4.cn)("px-(--card-spacing)", className),
541
+ className: (0, import_cn5.cn)("px-(--card-spacing)", className),
394
542
  ...props
395
543
  }
396
544
  );
397
545
  }
398
546
 
399
547
  // src/lib/utils.ts
400
- var import_cn5 = require("cn");
548
+ var import_cn6 = require("cn");
401
549
 
402
550
  // src/components/jobCard/JobCardBannerBar.tsx
403
- var import_jsx_runtime6 = require("react/jsx-runtime");
404
- var JobCardBannerBar = ({ banner }) => /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "mt-3 flex items-center gap-2 rounded border border-blue-300 bg-blue-50 px-3 py-1.5 text-xs text-gray-600 shadow [&>svg]:h-4 [&>svg]:w-4", children: [
551
+ var import_jsx_runtime8 = require("react/jsx-runtime");
552
+ var JobCardBannerBar = ({ banner }) => /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "mt-3 flex items-center gap-2 rounded border border-blue-300 bg-blue-50 px-3 py-1.5 text-xs text-gray-600 shadow [&>svg]:h-4 [&>svg]:w-4", children: [
405
553
  banner.icon,
406
554
  banner.label
407
555
  ] });
408
556
 
409
557
  // src/components/jobCard/JobCardParts.tsx
410
- var import_jsx_runtime7 = require("react/jsx-runtime");
558
+ var import_jsx_runtime9 = require("react/jsx-runtime");
411
559
  var DEFAULT_STAGE_COLOR = "#6b7280";
412
560
  var BADGE_COLOR_CLASSES = {
413
561
  gray: "bg-gray-300",
@@ -418,45 +566,45 @@ var BADGE_COLOR_CLASSES = {
418
566
  blue: "bg-blue-300",
419
567
  purple: "bg-purple-300"
420
568
  };
421
- var JobCardHeading = ({ title, stage, leadingContent }) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "flex items-center gap-2 mb-1", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "flex justify-between w-full", children: [
422
- /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("span", { className: "flex items-center gap-2 font-bold text-base", children: [
569
+ var JobCardHeading = ({ title, stage, leadingContent }) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "flex items-center gap-2 mb-1", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "flex justify-between w-full", children: [
570
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { className: "flex items-center gap-2 font-bold text-base", children: [
423
571
  leadingContent,
424
572
  title
425
573
  ] }),
426
- stage && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "flex items-center gap-2 text-xs", children: [
427
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
574
+ stage && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "flex items-center gap-2 text-xs", children: [
575
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
428
576
  "span",
429
577
  {
430
578
  className: "w-2 h-2 rounded-full",
431
579
  style: { backgroundColor: stage.color ?? DEFAULT_STAGE_COLOR }
432
580
  }
433
581
  ),
434
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "text-gray-900", children: stage.label })
582
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "text-gray-900", children: stage.label })
435
583
  ] })
436
584
  ] }) });
437
- var JobCardDetails = ({ details }) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "flex flex-col gap-1", children: details.map((detail, index) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "text-xs text-gray-500", children: detail }, `${index}-${detail}`)) });
438
- var JobCardCallouts = ({ callouts }) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "flex justify-between w-full", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "text-xs my-1 w-full space-y-1", children: callouts.map((callout, index) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
585
+ var JobCardDetails = ({ details }) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "flex flex-col gap-1", children: details.map((detail, index) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "text-xs text-gray-500", children: detail }, `${index}-${detail}`)) });
586
+ var JobCardCallouts = ({ callouts }) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "flex justify-between w-full", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "text-xs my-1 w-full space-y-1", children: callouts.map((callout, index) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
439
587
  "div",
440
588
  {
441
589
  className: "flex gap-2 items-center border p-2 rounded bg-white shadow",
442
- children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { children: callout })
590
+ children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { children: callout })
443
591
  },
444
592
  `${index}-${callout}`
445
593
  )) }) });
446
594
  var JobCardSummary = ({
447
595
  job,
448
596
  leadingContent
449
- }) => /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "w-full", children: [
450
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(JobCardHeading, { title: job.title, stage: job.stage, leadingContent }),
451
- job.subtitle && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "text-[13px] text-gray-600 mb-1", children: job.subtitle }),
452
- job.details && job.details.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(JobCardDetails, { details: job.details }),
453
- job.description && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "text-sm text-gray-700 italic mt-1", children: job.description }),
454
- job.callouts && job.callouts.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(JobCardCallouts, { callouts: job.callouts })
597
+ }) => /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "w-full", children: [
598
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(JobCardHeading, { title: job.title, stage: job.stage, leadingContent }),
599
+ job.subtitle && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "text-[13px] text-gray-600 mb-1", children: job.subtitle }),
600
+ job.details && job.details.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(JobCardDetails, { details: job.details }),
601
+ job.description && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "text-sm text-gray-700 italic mt-1", children: job.description }),
602
+ job.callouts && job.callouts.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(JobCardCallouts, { callouts: job.callouts })
455
603
  ] });
456
604
  var JobCardBadgeBlock = ({
457
605
  badge,
458
606
  hasPills
459
- }) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: `flex pr-4 w-20 ${hasPills ? "border-r" : ""}`, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
607
+ }) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: `flex pr-4 w-20 ${hasPills ? "border-r" : ""}`, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
460
608
  "span",
461
609
  {
462
610
  className: `flex items-center shadow border rounded px-4 py-1 text-center text-wrap ${BADGE_COLOR_CLASSES[badge.color]} ${hasPills ? "border-r" : ""}`,
@@ -465,7 +613,7 @@ var JobCardBadgeBlock = ({
465
613
  ) });
466
614
 
467
615
  // src/components/jobCard/JobCardPills.tsx
468
- var import_jsx_runtime8 = require("react/jsx-runtime");
616
+ var import_jsx_runtime10 = require("react/jsx-runtime");
469
617
  var PILL_BASE = "flex items-center gap-1 h-5 rounded-full text-center text-[10px] md:text-xs [&>svg]:w-3 [&>svg]:h-3";
470
618
  var PILL_TONE_CLASSES = {
471
619
  critical: "px-3 bg-red-500 text-white font-bold shadow-md shadow-red-900/70",
@@ -479,27 +627,27 @@ var PILL_TONE_CLASSES = {
479
627
  outline: "px-3 border border-gray-300 bg-white text-gray-600",
480
628
  dashed: "px-3 border border-dashed border-gray-400 bg-white text-gray-600"
481
629
  };
482
- var JobCardPillItem = ({ pill }) => /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("span", { className: `${PILL_BASE} ${PILL_TONE_CLASSES[pill.tone]}`, children: [
630
+ var JobCardPillItem = ({ pill }) => /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("span", { className: `${PILL_BASE} ${PILL_TONE_CLASSES[pill.tone]}`, children: [
483
631
  pill.icon,
484
632
  pill.label
485
633
  ] });
486
634
  var JobCardPillList = ({ pills }) => {
487
635
  const priorityPills = pills.filter((pill) => pill.priority);
488
636
  const otherPills = pills.filter((pill) => !pill.priority);
489
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "flex gap-2 flex-wrap", children: [
490
- priorityPills.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
637
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "flex gap-2 flex-wrap", children: [
638
+ priorityPills.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
491
639
  "div",
492
640
  {
493
641
  className: `flex gap-2 w-full ${otherPills.length > 0 ? "pb-2 border-b" : ""}`,
494
- children: priorityPills.map((pill) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(JobCardPillItem, { pill }, pill.label))
642
+ children: priorityPills.map((pill) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(JobCardPillItem, { pill }, pill.label))
495
643
  }
496
644
  ),
497
- otherPills.map((pill) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(JobCardPillItem, { pill }, pill.label))
645
+ otherPills.map((pill) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(JobCardPillItem, { pill }, pill.label))
498
646
  ] });
499
647
  };
500
648
 
501
649
  // src/components/jobCard/JobCard.tsx
502
- var import_jsx_runtime9 = require("react/jsx-runtime");
650
+ var import_jsx_runtime11 = require("react/jsx-runtime");
503
651
  var CARD_TONE_CLASSES = {
504
652
  success: "border-green-400 bg-green-50",
505
653
  warning: "border-orange-400 bg-orange-50",
@@ -515,11 +663,11 @@ var JobCard = ({
515
663
  className
516
664
  }) => {
517
665
  const hasPills = Boolean(job.pills && job.pills.length > 0);
518
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
666
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
519
667
  Card,
520
668
  {
521
669
  onClick,
522
- className: (0, import_cn5.cn)(
670
+ className: (0, import_cn6.cn)(
523
671
  // The shadcn Card adds vertical padding, a gap, bigger corners and a
524
672
  // ring. The card's own padding is set on CardContent below, so those
525
673
  // are cancelled here to keep the original, tighter layout.
@@ -529,14 +677,14 @@ var JobCard = ({
529
677
  CARD_TONE_CLASSES[job.tone ?? "neutral"],
530
678
  className
531
679
  ),
532
- children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(CardContent, { className: "p-3.5", children: [
533
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "flex justify-between items-start mb-2", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(JobCardSummary, { job, leadingContent }) }),
534
- (job.badge || hasPills) && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "flex gap-2 text-xs", children: [
535
- job.badge && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(JobCardBadgeBlock, { badge: job.badge, hasPills }),
536
- hasPills && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(JobCardPillList, { pills: job.pills ?? [] })
680
+ children: /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(CardContent, { className: "p-3.5", children: [
681
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "flex justify-between items-start mb-2", children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(JobCardSummary, { job, leadingContent }) }),
682
+ (job.badge || hasPills) && /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "flex gap-2 text-xs", children: [
683
+ job.badge && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(JobCardBadgeBlock, { badge: job.badge, hasPills }),
684
+ hasPills && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(JobCardPillList, { pills: job.pills ?? [] })
537
685
  ] }),
538
- job.banner && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(JobCardBannerBar, { banner: job.banner }),
539
- action && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
686
+ job.banner && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(JobCardBannerBar, { banner: job.banner }),
687
+ action && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
540
688
  Button,
541
689
  {
542
690
  onClick: (event) => {
@@ -549,7 +697,7 @@ var JobCard = ({
549
697
  children: action.label
550
698
  }
551
699
  ),
552
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { children: expandedContent })
700
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { children: expandedContent })
553
701
  ] })
554
702
  }
555
703
  );
@@ -557,5 +705,6 @@ var JobCard = ({
557
705
  // Annotate the CommonJS export names for ESM import in node:
558
706
  0 && (module.exports = {
559
707
  DatePicker,
708
+ DebouncedInput,
560
709
  JobCard
561
710
  });
package/dist/index.d.cts CHANGED
@@ -1,35 +1,85 @@
1
1
  import * as react from 'react';
2
- import { ReactNode } from 'react';
2
+ import { ComponentProps, FocusEventHandler, ReactNode } from 'react';
3
3
 
4
4
  interface IDatePicker {
5
5
  /**
6
- * Called with the chosen day when the user picks one. The popover closes
7
- * straight afterwards. It is not called when the popover is dismissed
8
- * without a pick.
6
+ * Called with the chosen day when the user picks one in the calendar, or
7
+ * types a real date and presses Enter or leaves the field. It is not called
8
+ * when the popover is dismissed without a pick, or for text that is not a
9
+ * real date.
9
10
  */
10
11
  onSelect: (date: Date) => void;
11
12
  /**
12
- * The selected date. The component is controlled: it never stores the
13
- * date itself, so update this from `onSelect` or the button text will not
14
- * change. Leave it empty (`undefined` or `null`) to show the placeholder.
13
+ * The selected date. The component is controlled: it never decides the date
14
+ * itself, so update this from `onSelect` or the date will not change. Leave
15
+ * it empty (`undefined` or `null`) to show the placeholder.
15
16
  */
16
17
  date?: Date | null;
18
+ /**
19
+ * How the date is shown and typed, as a date-fns format string. Defaults to
20
+ * `dd/MM/yyyy`. The placeholder is this in lower case.
21
+ */
22
+ dateFormat?: string;
17
23
  }
18
24
  /**
19
- * A single date picker. A button shows the chosen date (or "Pick a date")
20
- * and opens a calendar in a popover.
25
+ * A single date picker. A text field takes a typed date, and a calendar button
26
+ * beside it opens a calendar in a popover. Both change the same date.
21
27
  *
22
- * - The button and the popover both fill the width of their container, so
23
- * size it by wrapping it in an element with a width.
24
- * - The date is shown in the long format from date-fns, for example
25
- * "March 15th, 2026".
28
+ * - The field and the button fill the width of their container, so size it by
29
+ * wrapping it in an element with a width.
30
+ * - The date is shown as `dd/MM/yyyy` unless `dateFormat` says otherwise.
31
+ * - A typed date is read when the user presses Enter or leaves the field. If it
32
+ * is not a real date, the field goes back to the last good date.
26
33
  * - The calendar opens on the month of `date`, or on the current month when
27
34
  * there is no date. With no date, today is highlighted as the selection.
28
35
  * - A date can be changed but not cleared, because the calendar is in
29
- * required single mode.
36
+ * required single mode and an emptied field goes back to the last date.
30
37
  * - The popover is modal on purpose, so it still works inside a vaul drawer.
31
38
  */
32
- declare const DatePicker: ({ onSelect, date }: IDatePicker) => react.JSX.Element;
39
+ declare const DatePicker: ({ onSelect, date, dateFormat, }: IDatePicker) => react.JSX.Element;
40
+
41
+ declare function Input({ className, type, ...props }: react.ComponentProps<"input">): react.JSX.Element;
42
+
43
+ interface DebouncedInputProps extends Omit<ComponentProps<typeof Input>, "type" | "value" | "defaultValue" | "onChange"> {
44
+ /**
45
+ * The text the owner holds. Controlled: the box shows what is typed at once,
46
+ * and follows this value when it changes from elsewhere (opening a saved job,
47
+ * resetting the form). While the box has focus, outside changes are ignored
48
+ * so they cannot overwrite characters typed since.
49
+ */
50
+ value: string;
51
+ /**
52
+ * Called with the latest text once typing has paused for `delay`, and not on
53
+ * every keystroke. The waiting text is also passed through at once when the
54
+ * box loses focus, when it unmounts, and on the next press anywhere on the
55
+ * page. The owner should store it and pass it back as `value`.
56
+ */
57
+ onValueChange: (value: string) => void;
58
+ /** How long typing must pause before `onValueChange` is called. */
59
+ delay?: number;
60
+ /**
61
+ * Called when the box gains focus. Typing is not reported by this: it only
62
+ * says the box was entered, and the value is unchanged.
63
+ */
64
+ onFocus?: FocusEventHandler<HTMLInputElement>;
65
+ /**
66
+ * Called when the box loses focus. Any text still waiting for the pause is
67
+ * passed to `onValueChange` first, so by the time this runs the owner already
68
+ * holds what was typed.
69
+ */
70
+ onBlur?: FocusEventHandler<HTMLInputElement>;
71
+ }
72
+ /**
73
+ * Text input that tells its owner about a change only after typing pauses.
74
+ *
75
+ * The typed text lives locally so every keystroke shows at once, while the
76
+ * owner (a store that re-renders a whole form) is written to once per pause.
77
+ * The waiting text is pushed through straight away on blur, on unmount, and on
78
+ * the next press anywhere on the page. The press covers a Save tapped soon
79
+ * after typing: iOS Safari does not blur a focused input when a button is
80
+ * tapped, so blur alone could let Save read the old value.
81
+ */
82
+ declare function DebouncedInput({ value, onValueChange, delay, onFocus, onBlur, ...inputProps }: DebouncedInputProps): react.JSX.Element;
33
83
 
34
84
  /**
35
85
  * How the whole card is coloured. `success` is green, `warning` orange,
@@ -159,5 +209,5 @@ interface JobCardProps {
159
209
  */
160
210
  declare const JobCard: ({ job, onClick, action, leadingContent, expandedContent, className, }: JobCardProps) => react.JSX.Element;
161
211
 
162
- export { DatePicker, JobCard };
163
- export type { JobCardAction, JobCardBadge, JobCardBanner, JobCardColor, JobCardData, JobCardPill, JobCardPillTone, JobCardProps, JobCardStage, JobCardTone };
212
+ export { DatePicker, DebouncedInput, JobCard };
213
+ export type { DebouncedInputProps, JobCardAction, JobCardBadge, JobCardBanner, JobCardColor, JobCardData, JobCardPill, JobCardPillTone, JobCardProps, JobCardStage, JobCardTone };
package/dist/index.d.ts CHANGED
@@ -1,35 +1,85 @@
1
1
  import * as react from 'react';
2
- import { ReactNode } from 'react';
2
+ import { ComponentProps, FocusEventHandler, ReactNode } from 'react';
3
3
 
4
4
  interface IDatePicker {
5
5
  /**
6
- * Called with the chosen day when the user picks one. The popover closes
7
- * straight afterwards. It is not called when the popover is dismissed
8
- * without a pick.
6
+ * Called with the chosen day when the user picks one in the calendar, or
7
+ * types a real date and presses Enter or leaves the field. It is not called
8
+ * when the popover is dismissed without a pick, or for text that is not a
9
+ * real date.
9
10
  */
10
11
  onSelect: (date: Date) => void;
11
12
  /**
12
- * The selected date. The component is controlled: it never stores the
13
- * date itself, so update this from `onSelect` or the button text will not
14
- * change. Leave it empty (`undefined` or `null`) to show the placeholder.
13
+ * The selected date. The component is controlled: it never decides the date
14
+ * itself, so update this from `onSelect` or the date will not change. Leave
15
+ * it empty (`undefined` or `null`) to show the placeholder.
15
16
  */
16
17
  date?: Date | null;
18
+ /**
19
+ * How the date is shown and typed, as a date-fns format string. Defaults to
20
+ * `dd/MM/yyyy`. The placeholder is this in lower case.
21
+ */
22
+ dateFormat?: string;
17
23
  }
18
24
  /**
19
- * A single date picker. A button shows the chosen date (or "Pick a date")
20
- * and opens a calendar in a popover.
25
+ * A single date picker. A text field takes a typed date, and a calendar button
26
+ * beside it opens a calendar in a popover. Both change the same date.
21
27
  *
22
- * - The button and the popover both fill the width of their container, so
23
- * size it by wrapping it in an element with a width.
24
- * - The date is shown in the long format from date-fns, for example
25
- * "March 15th, 2026".
28
+ * - The field and the button fill the width of their container, so size it by
29
+ * wrapping it in an element with a width.
30
+ * - The date is shown as `dd/MM/yyyy` unless `dateFormat` says otherwise.
31
+ * - A typed date is read when the user presses Enter or leaves the field. If it
32
+ * is not a real date, the field goes back to the last good date.
26
33
  * - The calendar opens on the month of `date`, or on the current month when
27
34
  * there is no date. With no date, today is highlighted as the selection.
28
35
  * - A date can be changed but not cleared, because the calendar is in
29
- * required single mode.
36
+ * required single mode and an emptied field goes back to the last date.
30
37
  * - The popover is modal on purpose, so it still works inside a vaul drawer.
31
38
  */
32
- declare const DatePicker: ({ onSelect, date }: IDatePicker) => react.JSX.Element;
39
+ declare const DatePicker: ({ onSelect, date, dateFormat, }: IDatePicker) => react.JSX.Element;
40
+
41
+ declare function Input({ className, type, ...props }: react.ComponentProps<"input">): react.JSX.Element;
42
+
43
+ interface DebouncedInputProps extends Omit<ComponentProps<typeof Input>, "type" | "value" | "defaultValue" | "onChange"> {
44
+ /**
45
+ * The text the owner holds. Controlled: the box shows what is typed at once,
46
+ * and follows this value when it changes from elsewhere (opening a saved job,
47
+ * resetting the form). While the box has focus, outside changes are ignored
48
+ * so they cannot overwrite characters typed since.
49
+ */
50
+ value: string;
51
+ /**
52
+ * Called with the latest text once typing has paused for `delay`, and not on
53
+ * every keystroke. The waiting text is also passed through at once when the
54
+ * box loses focus, when it unmounts, and on the next press anywhere on the
55
+ * page. The owner should store it and pass it back as `value`.
56
+ */
57
+ onValueChange: (value: string) => void;
58
+ /** How long typing must pause before `onValueChange` is called. */
59
+ delay?: number;
60
+ /**
61
+ * Called when the box gains focus. Typing is not reported by this: it only
62
+ * says the box was entered, and the value is unchanged.
63
+ */
64
+ onFocus?: FocusEventHandler<HTMLInputElement>;
65
+ /**
66
+ * Called when the box loses focus. Any text still waiting for the pause is
67
+ * passed to `onValueChange` first, so by the time this runs the owner already
68
+ * holds what was typed.
69
+ */
70
+ onBlur?: FocusEventHandler<HTMLInputElement>;
71
+ }
72
+ /**
73
+ * Text input that tells its owner about a change only after typing pauses.
74
+ *
75
+ * The typed text lives locally so every keystroke shows at once, while the
76
+ * owner (a store that re-renders a whole form) is written to once per pause.
77
+ * The waiting text is pushed through straight away on blur, on unmount, and on
78
+ * the next press anywhere on the page. The press covers a Save tapped soon
79
+ * after typing: iOS Safari does not blur a focused input when a button is
80
+ * tapped, so blur alone could let Save read the old value.
81
+ */
82
+ declare function DebouncedInput({ value, onValueChange, delay, onFocus, onBlur, ...inputProps }: DebouncedInputProps): react.JSX.Element;
33
83
 
34
84
  /**
35
85
  * How the whole card is coloured. `success` is green, `warning` orange,
@@ -159,5 +209,5 @@ interface JobCardProps {
159
209
  */
160
210
  declare const JobCard: ({ job, onClick, action, leadingContent, expandedContent, className, }: JobCardProps) => react.JSX.Element;
161
211
 
162
- export { DatePicker, JobCard };
163
- export type { JobCardAction, JobCardBadge, JobCardBanner, JobCardColor, JobCardData, JobCardPill, JobCardPillTone, JobCardProps, JobCardStage, JobCardTone };
212
+ export { DatePicker, DebouncedInput, JobCard };
213
+ export type { DebouncedInputProps, JobCardAction, JobCardBadge, JobCardBanner, JobCardColor, JobCardData, JobCardPill, JobCardPillTone, JobCardProps, JobCardStage, JobCardTone };
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
 
3
3
  // src/components/datePicker/DatePicker.tsx
4
- import { ChevronDownIcon as ChevronDownIcon2 } from "lucide-react";
4
+ import { CalendarIcon } from "lucide-react";
5
5
 
6
6
  // src/components/ui/calendar.tsx
7
7
  import * as React from "react";
@@ -280,71 +280,222 @@ function PopoverContent({
280
280
  }
281
281
  ) });
282
282
  }
283
+ function PopoverAnchor({
284
+ ...props
285
+ }) {
286
+ return /* @__PURE__ */ jsx3(PopoverPrimitive.Anchor, { "data-slot": "popover-anchor", ...props });
287
+ }
288
+
289
+ // src/components/ui/input.tsx
290
+ import { cn as cn4 } from "cn";
291
+ import { jsx as jsx4 } from "react/jsx-runtime";
292
+ function Input({ className, type, ...props }) {
293
+ return /* @__PURE__ */ jsx4(
294
+ "input",
295
+ {
296
+ type,
297
+ "data-slot": "input",
298
+ className: cn4(
299
+ "h-8 w-full min-w-0 rounded-lg border border-input bg-transparent px-2.5 py-1 text-base transition-colors outline-none file:inline-flex file:h-6 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40",
300
+ className
301
+ ),
302
+ ...props
303
+ }
304
+ );
305
+ }
283
306
 
284
307
  // src/components/datePicker/DatePicker.tsx
285
- import { format } from "date-fns";
308
+ import { format, isSameDay, isValid, parse } from "date-fns";
286
309
  import { useState } from "react";
287
- import { jsx as jsx4, jsxs } from "react/jsx-runtime";
288
- var DatePicker = ({ onSelect, date }) => {
310
+ import { jsx as jsx5, jsxs } from "react/jsx-runtime";
311
+ var DEFAULT_DATE_FORMAT = "dd/MM/yyyy";
312
+ var MIN_TYPED_YEAR = 1e3;
313
+ var parseTypedDate = (text, dateFormat) => {
314
+ const parsed = parse(text.trim(), dateFormat, /* @__PURE__ */ new Date());
315
+ if (!isValid(parsed) || parsed.getFullYear() < MIN_TYPED_YEAR) return null;
316
+ return parsed;
317
+ };
318
+ var formatDate = (date, dateFormat) => date ? format(date, dateFormat) : "";
319
+ var DatePicker = ({
320
+ onSelect,
321
+ date,
322
+ dateFormat = DEFAULT_DATE_FORMAT
323
+ }) => {
289
324
  const [isOpen, setIsOpen] = useState(false);
290
- const handleSelect = (selectedDate) => {
325
+ const [typedText, setTypedText] = useState(formatDate(date, dateFormat));
326
+ const [shownDate, setShownDate] = useState(date);
327
+ if (date?.getTime() !== shownDate?.getTime()) {
328
+ setShownDate(date);
329
+ setTypedText(formatDate(date, dateFormat));
330
+ }
331
+ const handleCalendarSelect = (selectedDate) => {
332
+ setTypedText(formatDate(selectedDate, dateFormat));
291
333
  onSelect(selectedDate);
292
334
  setIsOpen(false);
293
335
  };
336
+ const commitTypedText = () => {
337
+ const parsedDate = parseTypedDate(typedText, dateFormat);
338
+ if (!parsedDate) {
339
+ setTypedText(formatDate(date, dateFormat));
340
+ return;
341
+ }
342
+ setTypedText(formatDate(parsedDate, dateFormat));
343
+ if (!date || !isSameDay(parsedDate, date)) onSelect(parsedDate);
344
+ };
294
345
  return (
295
346
  // Modal so the calendar re-enables pointer events for itself. Inside a vaul
296
347
  // drawer the popover is portaled outside the drawer, and vaul bundles its
297
348
  // own copy of Radix's layer package, so a non-modal popover inherits the
298
349
  // drawer's pointer-events: none and its day buttons never receive clicks.
299
350
  /* @__PURE__ */ jsxs(Popover, { modal: true, open: isOpen, onOpenChange: setIsOpen, children: [
300
- /* @__PURE__ */ jsx4(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxs(
301
- Button,
302
- {
303
- variant: "outline",
304
- "data-empty": !date,
305
- className: "w-full justify-between text-left font-normal data-[empty=true]:text-muted-foreground",
306
- children: [
307
- date ? format(date, "PPP") : /* @__PURE__ */ jsx4("span", { children: "Pick a date" }),
308
- /* @__PURE__ */ jsx4(ChevronDownIcon2, { "data-icon": "inline-end" })
309
- ]
310
- }
311
- ) }),
312
- /* @__PURE__ */ jsx4(
313
- PopoverContent,
351
+ /* @__PURE__ */ jsx5(PopoverAnchor, { asChild: true, children: /* @__PURE__ */ jsxs("div", { className: "flex w-full gap-2", children: [
352
+ /* @__PURE__ */ jsx5(
353
+ Input,
354
+ {
355
+ value: typedText,
356
+ onChange: (event) => setTypedText(event.target.value),
357
+ onBlur: commitTypedText,
358
+ onKeyDown: (event) => {
359
+ if (event.key !== "Enter") return;
360
+ event.preventDefault();
361
+ commitTypedText();
362
+ },
363
+ placeholder: dateFormat.toLowerCase(),
364
+ autoComplete: "off",
365
+ "aria-label": "Date"
366
+ }
367
+ ),
368
+ /* @__PURE__ */ jsx5(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsx5(
369
+ Button,
370
+ {
371
+ type: "button",
372
+ variant: "outline",
373
+ size: "icon",
374
+ "aria-label": "Open calendar",
375
+ children: /* @__PURE__ */ jsx5(CalendarIcon, {})
376
+ }
377
+ ) })
378
+ ] }) }),
379
+ /* @__PURE__ */ jsx5(PopoverContent, { className: "w-auto p-0", align: "start", children: /* @__PURE__ */ jsx5(
380
+ Calendar,
314
381
  {
315
- className: "w-[--radix-popover-trigger-width] p-0",
316
- align: "start",
317
- children: /* @__PURE__ */ jsx4(
318
- Calendar,
319
- {
320
- classNames: { root: "w-full" },
321
- mode: "single",
322
- required: true,
323
- selected: date ?? /* @__PURE__ */ new Date(),
324
- onSelect: handleSelect,
325
- defaultMonth: date ?? /* @__PURE__ */ new Date()
326
- }
327
- )
382
+ mode: "single",
383
+ required: true,
384
+ selected: date ?? /* @__PURE__ */ new Date(),
385
+ onSelect: handleCalendarSelect,
386
+ defaultMonth: date ?? /* @__PURE__ */ new Date()
328
387
  }
329
- )
388
+ ) })
330
389
  ] })
331
390
  );
332
391
  };
333
392
 
393
+ // src/components/debounceInput/DebouncedInput.tsx
394
+ import {
395
+ useEffect as useEffect2,
396
+ useRef as useRef2,
397
+ useState as useState2
398
+ } from "react";
399
+
400
+ // src/lib/debounce.ts
401
+ function debounce(fn, delayMs) {
402
+ let timeout = null;
403
+ let latestArgs = null;
404
+ const run = () => {
405
+ const args = latestArgs;
406
+ timeout = null;
407
+ latestArgs = null;
408
+ if (args) fn(...args);
409
+ };
410
+ const debounced = (...args) => {
411
+ latestArgs = args;
412
+ if (timeout) clearTimeout(timeout);
413
+ timeout = setTimeout(run, delayMs);
414
+ };
415
+ debounced.cancel = () => {
416
+ if (timeout) clearTimeout(timeout);
417
+ timeout = null;
418
+ latestArgs = null;
419
+ };
420
+ debounced.flush = () => {
421
+ if (!timeout) return;
422
+ clearTimeout(timeout);
423
+ run();
424
+ };
425
+ return debounced;
426
+ }
427
+
428
+ // src/components/debounceInput/DebouncedInput.tsx
429
+ import { jsx as jsx6 } from "react/jsx-runtime";
430
+ function DebouncedInput({
431
+ value,
432
+ onValueChange,
433
+ delay = 250,
434
+ onFocus,
435
+ onBlur,
436
+ ...inputProps
437
+ }) {
438
+ const [text, setText] = useState2(value);
439
+ const [isFocused, setIsFocused] = useState2(false);
440
+ const onValueChangeRef = useRef2(onValueChange);
441
+ useEffect2(() => {
442
+ onValueChangeRef.current = onValueChange;
443
+ });
444
+ const commitTextRef = useRef2(null);
445
+ useEffect2(() => {
446
+ const commitText = debounce(
447
+ (next) => onValueChangeRef.current(next),
448
+ delay
449
+ );
450
+ commitTextRef.current = commitText;
451
+ const flushWaitingText = () => commitText.flush();
452
+ document.addEventListener("pointerdown", flushWaitingText, true);
453
+ return () => {
454
+ document.removeEventListener("pointerdown", flushWaitingText, true);
455
+ commitText.flush();
456
+ commitTextRef.current = null;
457
+ };
458
+ }, [delay]);
459
+ if (!isFocused && text !== value) {
460
+ setText(value);
461
+ }
462
+ return /* @__PURE__ */ jsx6(
463
+ Input,
464
+ {
465
+ ...inputProps,
466
+ type: "text",
467
+ value: text,
468
+ onChange: (e) => {
469
+ setText(e.target.value);
470
+ commitTextRef.current?.(e.target.value);
471
+ },
472
+ onFocus: (e) => {
473
+ setIsFocused(true);
474
+ onFocus?.(e);
475
+ },
476
+ onBlur: (e) => {
477
+ commitTextRef.current?.flush();
478
+ setIsFocused(false);
479
+ onBlur?.(e);
480
+ }
481
+ }
482
+ );
483
+ }
484
+
334
485
  // src/components/ui/card.tsx
335
- import { cn as cn4 } from "cn";
336
- import { jsx as jsx5 } from "react/jsx-runtime";
486
+ import { cn as cn5 } from "cn";
487
+ import { jsx as jsx7 } from "react/jsx-runtime";
337
488
  function Card({
338
489
  className,
339
490
  size = "default",
340
491
  ...props
341
492
  }) {
342
- return /* @__PURE__ */ jsx5(
493
+ return /* @__PURE__ */ jsx7(
343
494
  "div",
344
495
  {
345
496
  "data-slot": "card",
346
497
  "data-size": size,
347
- className: cn4(
498
+ className: cn5(
348
499
  "group/card flex flex-col gap-(--card-spacing) overflow-hidden rounded-xl bg-card py-(--card-spacing) text-sm text-card-foreground ring-1 ring-foreground/10 [--card-spacing:--spacing(4)] has-data-[slot=card-footer]:pb-0 has-[>img:first-child]:pt-0 data-[size=sm]:[--card-spacing:--spacing(3)] data-[size=sm]:has-data-[slot=card-footer]:pb-0 *:[img:first-child]:rounded-t-xl *:[img:last-child]:rounded-b-xl",
349
500
  className
350
501
  ),
@@ -353,18 +504,18 @@ function Card({
353
504
  );
354
505
  }
355
506
  function CardContent({ className, ...props }) {
356
- return /* @__PURE__ */ jsx5(
507
+ return /* @__PURE__ */ jsx7(
357
508
  "div",
358
509
  {
359
510
  "data-slot": "card-content",
360
- className: cn4("px-(--card-spacing)", className),
511
+ className: cn5("px-(--card-spacing)", className),
361
512
  ...props
362
513
  }
363
514
  );
364
515
  }
365
516
 
366
517
  // src/lib/utils.ts
367
- import { cn as cn5 } from "cn";
518
+ import { cn as cn6 } from "cn";
368
519
 
369
520
  // src/components/jobCard/JobCardBannerBar.tsx
370
521
  import { jsxs as jsxs2 } from "react/jsx-runtime";
@@ -374,7 +525,7 @@ var JobCardBannerBar = ({ banner }) => /* @__PURE__ */ jsxs2("div", { className:
374
525
  ] });
375
526
 
376
527
  // src/components/jobCard/JobCardParts.tsx
377
- import { jsx as jsx6, jsxs as jsxs3 } from "react/jsx-runtime";
528
+ import { jsx as jsx8, jsxs as jsxs3 } from "react/jsx-runtime";
378
529
  var DEFAULT_STAGE_COLOR = "#6b7280";
379
530
  var BADGE_COLOR_CLASSES = {
380
531
  gray: "bg-gray-300",
@@ -385,28 +536,28 @@ var BADGE_COLOR_CLASSES = {
385
536
  blue: "bg-blue-300",
386
537
  purple: "bg-purple-300"
387
538
  };
388
- var JobCardHeading = ({ title, stage, leadingContent }) => /* @__PURE__ */ jsx6("div", { className: "flex items-center gap-2 mb-1", children: /* @__PURE__ */ jsxs3("div", { className: "flex justify-between w-full", children: [
539
+ var JobCardHeading = ({ title, stage, leadingContent }) => /* @__PURE__ */ jsx8("div", { className: "flex items-center gap-2 mb-1", children: /* @__PURE__ */ jsxs3("div", { className: "flex justify-between w-full", children: [
389
540
  /* @__PURE__ */ jsxs3("span", { className: "flex items-center gap-2 font-bold text-base", children: [
390
541
  leadingContent,
391
542
  title
392
543
  ] }),
393
544
  stage && /* @__PURE__ */ jsxs3("div", { className: "flex items-center gap-2 text-xs", children: [
394
- /* @__PURE__ */ jsx6(
545
+ /* @__PURE__ */ jsx8(
395
546
  "span",
396
547
  {
397
548
  className: "w-2 h-2 rounded-full",
398
549
  style: { backgroundColor: stage.color ?? DEFAULT_STAGE_COLOR }
399
550
  }
400
551
  ),
401
- /* @__PURE__ */ jsx6("span", { className: "text-gray-900", children: stage.label })
552
+ /* @__PURE__ */ jsx8("span", { className: "text-gray-900", children: stage.label })
402
553
  ] })
403
554
  ] }) });
404
- var JobCardDetails = ({ details }) => /* @__PURE__ */ jsx6("div", { className: "flex flex-col gap-1", children: details.map((detail, index) => /* @__PURE__ */ jsx6("div", { className: "text-xs text-gray-500", children: detail }, `${index}-${detail}`)) });
405
- var JobCardCallouts = ({ callouts }) => /* @__PURE__ */ jsx6("div", { className: "flex justify-between w-full", children: /* @__PURE__ */ jsx6("div", { className: "text-xs my-1 w-full space-y-1", children: callouts.map((callout, index) => /* @__PURE__ */ jsx6(
555
+ var JobCardDetails = ({ details }) => /* @__PURE__ */ jsx8("div", { className: "flex flex-col gap-1", children: details.map((detail, index) => /* @__PURE__ */ jsx8("div", { className: "text-xs text-gray-500", children: detail }, `${index}-${detail}`)) });
556
+ var JobCardCallouts = ({ callouts }) => /* @__PURE__ */ jsx8("div", { className: "flex justify-between w-full", children: /* @__PURE__ */ jsx8("div", { className: "text-xs my-1 w-full space-y-1", children: callouts.map((callout, index) => /* @__PURE__ */ jsx8(
406
557
  "div",
407
558
  {
408
559
  className: "flex gap-2 items-center border p-2 rounded bg-white shadow",
409
- children: /* @__PURE__ */ jsx6("span", { children: callout })
560
+ children: /* @__PURE__ */ jsx8("span", { children: callout })
410
561
  },
411
562
  `${index}-${callout}`
412
563
  )) }) });
@@ -414,16 +565,16 @@ var JobCardSummary = ({
414
565
  job,
415
566
  leadingContent
416
567
  }) => /* @__PURE__ */ jsxs3("div", { className: "w-full", children: [
417
- /* @__PURE__ */ jsx6(JobCardHeading, { title: job.title, stage: job.stage, leadingContent }),
418
- job.subtitle && /* @__PURE__ */ jsx6("div", { className: "text-[13px] text-gray-600 mb-1", children: job.subtitle }),
419
- job.details && job.details.length > 0 && /* @__PURE__ */ jsx6(JobCardDetails, { details: job.details }),
420
- job.description && /* @__PURE__ */ jsx6("div", { className: "text-sm text-gray-700 italic mt-1", children: job.description }),
421
- job.callouts && job.callouts.length > 0 && /* @__PURE__ */ jsx6(JobCardCallouts, { callouts: job.callouts })
568
+ /* @__PURE__ */ jsx8(JobCardHeading, { title: job.title, stage: job.stage, leadingContent }),
569
+ job.subtitle && /* @__PURE__ */ jsx8("div", { className: "text-[13px] text-gray-600 mb-1", children: job.subtitle }),
570
+ job.details && job.details.length > 0 && /* @__PURE__ */ jsx8(JobCardDetails, { details: job.details }),
571
+ job.description && /* @__PURE__ */ jsx8("div", { className: "text-sm text-gray-700 italic mt-1", children: job.description }),
572
+ job.callouts && job.callouts.length > 0 && /* @__PURE__ */ jsx8(JobCardCallouts, { callouts: job.callouts })
422
573
  ] });
423
574
  var JobCardBadgeBlock = ({
424
575
  badge,
425
576
  hasPills
426
- }) => /* @__PURE__ */ jsx6("div", { className: `flex pr-4 w-20 ${hasPills ? "border-r" : ""}`, children: /* @__PURE__ */ jsx6(
577
+ }) => /* @__PURE__ */ jsx8("div", { className: `flex pr-4 w-20 ${hasPills ? "border-r" : ""}`, children: /* @__PURE__ */ jsx8(
427
578
  "span",
428
579
  {
429
580
  className: `flex items-center shadow border rounded px-4 py-1 text-center text-wrap ${BADGE_COLOR_CLASSES[badge.color]} ${hasPills ? "border-r" : ""}`,
@@ -432,7 +583,7 @@ var JobCardBadgeBlock = ({
432
583
  ) });
433
584
 
434
585
  // src/components/jobCard/JobCardPills.tsx
435
- import { jsx as jsx7, jsxs as jsxs4 } from "react/jsx-runtime";
586
+ import { jsx as jsx9, jsxs as jsxs4 } from "react/jsx-runtime";
436
587
  var PILL_BASE = "flex items-center gap-1 h-5 rounded-full text-center text-[10px] md:text-xs [&>svg]:w-3 [&>svg]:h-3";
437
588
  var PILL_TONE_CLASSES = {
438
589
  critical: "px-3 bg-red-500 text-white font-bold shadow-md shadow-red-900/70",
@@ -454,19 +605,19 @@ var JobCardPillList = ({ pills }) => {
454
605
  const priorityPills = pills.filter((pill) => pill.priority);
455
606
  const otherPills = pills.filter((pill) => !pill.priority);
456
607
  return /* @__PURE__ */ jsxs4("div", { className: "flex gap-2 flex-wrap", children: [
457
- priorityPills.length > 0 && /* @__PURE__ */ jsx7(
608
+ priorityPills.length > 0 && /* @__PURE__ */ jsx9(
458
609
  "div",
459
610
  {
460
611
  className: `flex gap-2 w-full ${otherPills.length > 0 ? "pb-2 border-b" : ""}`,
461
- children: priorityPills.map((pill) => /* @__PURE__ */ jsx7(JobCardPillItem, { pill }, pill.label))
612
+ children: priorityPills.map((pill) => /* @__PURE__ */ jsx9(JobCardPillItem, { pill }, pill.label))
462
613
  }
463
614
  ),
464
- otherPills.map((pill) => /* @__PURE__ */ jsx7(JobCardPillItem, { pill }, pill.label))
615
+ otherPills.map((pill) => /* @__PURE__ */ jsx9(JobCardPillItem, { pill }, pill.label))
465
616
  ] });
466
617
  };
467
618
 
468
619
  // src/components/jobCard/JobCard.tsx
469
- import { jsx as jsx8, jsxs as jsxs5 } from "react/jsx-runtime";
620
+ import { jsx as jsx10, jsxs as jsxs5 } from "react/jsx-runtime";
470
621
  var CARD_TONE_CLASSES = {
471
622
  success: "border-green-400 bg-green-50",
472
623
  warning: "border-orange-400 bg-orange-50",
@@ -482,11 +633,11 @@ var JobCard = ({
482
633
  className
483
634
  }) => {
484
635
  const hasPills = Boolean(job.pills && job.pills.length > 0);
485
- return /* @__PURE__ */ jsx8(
636
+ return /* @__PURE__ */ jsx10(
486
637
  Card,
487
638
  {
488
639
  onClick,
489
- className: cn5(
640
+ className: cn6(
490
641
  // The shadcn Card adds vertical padding, a gap, bigger corners and a
491
642
  // ring. The card's own padding is set on CardContent below, so those
492
643
  // are cancelled here to keep the original, tighter layout.
@@ -497,13 +648,13 @@ var JobCard = ({
497
648
  className
498
649
  ),
499
650
  children: /* @__PURE__ */ jsxs5(CardContent, { className: "p-3.5", children: [
500
- /* @__PURE__ */ jsx8("div", { className: "flex justify-between items-start mb-2", children: /* @__PURE__ */ jsx8(JobCardSummary, { job, leadingContent }) }),
651
+ /* @__PURE__ */ jsx10("div", { className: "flex justify-between items-start mb-2", children: /* @__PURE__ */ jsx10(JobCardSummary, { job, leadingContent }) }),
501
652
  (job.badge || hasPills) && /* @__PURE__ */ jsxs5("div", { className: "flex gap-2 text-xs", children: [
502
- job.badge && /* @__PURE__ */ jsx8(JobCardBadgeBlock, { badge: job.badge, hasPills }),
503
- hasPills && /* @__PURE__ */ jsx8(JobCardPillList, { pills: job.pills ?? [] })
653
+ job.badge && /* @__PURE__ */ jsx10(JobCardBadgeBlock, { badge: job.badge, hasPills }),
654
+ hasPills && /* @__PURE__ */ jsx10(JobCardPillList, { pills: job.pills ?? [] })
504
655
  ] }),
505
- job.banner && /* @__PURE__ */ jsx8(JobCardBannerBar, { banner: job.banner }),
506
- action && /* @__PURE__ */ jsx8(
656
+ job.banner && /* @__PURE__ */ jsx10(JobCardBannerBar, { banner: job.banner }),
657
+ action && /* @__PURE__ */ jsx10(
507
658
  Button,
508
659
  {
509
660
  onClick: (event) => {
@@ -516,12 +667,13 @@ var JobCard = ({
516
667
  children: action.label
517
668
  }
518
669
  ),
519
- /* @__PURE__ */ jsx8("div", { children: expandedContent })
670
+ /* @__PURE__ */ jsx10("div", { children: expandedContent })
520
671
  ] })
521
672
  }
522
673
  );
523
674
  };
524
675
  export {
525
676
  DatePicker,
677
+ DebouncedInput,
526
678
  JobCard
527
679
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@processdynamics/components",
3
- "version": "0.1.4",
3
+ "version": "0.1.6",
4
4
  "description": "Process Dynamics React component library, built on shadcn (Radix) and Tailwind CSS v4.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -59,6 +59,10 @@
59
59
  "@storybook/nextjs-vite": "^10.6.5",
60
60
  "@tailwindcss/turbopack": "^4",
61
61
  "@tailwindcss/vite": "^4.3.3",
62
+ "@testing-library/dom": "^10.4.2",
63
+ "@testing-library/jest-dom": "^7.0.1",
64
+ "@testing-library/react": "^16.3.3",
65
+ "@testing-library/user-event": "^14.6.8",
62
66
  "@types/node": "^20",
63
67
  "@types/react": "^19",
64
68
  "@types/react-dom": "^19",
@@ -71,6 +75,7 @@
71
75
  "eslint-config-next": "16.4.3",
72
76
  "eslint-plugin-storybook": "^10.6.5",
73
77
  "husky": "^9.1.7",
78
+ "jsdom": "^30.1.3",
74
79
  "lucide-react": "^1.66.0",
75
80
  "next": "16.4.3",
76
81
  "playwright": "latest",