@scripso-homepad/ui 0.4.10 → 0.4.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/dist/index.cjs +122 -43
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/index.d.cts +2 -2
  4. package/dist/index.d.ts +2 -2
  5. package/dist/index.js +124 -45
  6. package/dist/index.js.map +1 -1
  7. package/dist/web/index.cjs +45 -33
  8. package/dist/web/index.cjs.map +1 -1
  9. package/dist/web/index.d.cts +2 -1
  10. package/dist/web/index.d.ts +2 -1
  11. package/dist/web/index.js +45 -33
  12. package/dist/web/index.js.map +1 -1
  13. package/package.json +3 -2
  14. package/src/components/Calendar.tsx +10 -2
  15. package/src/components/DatePicker.tsx +3 -3
  16. package/src/components/Select.tsx +133 -38
  17. package/src/theme/select.ts +1 -1
  18. package/src/utils/calendarDays.ts +15 -6
  19. package/src/web/components/Badge.tsx +1 -1
  20. package/src/web/components/ConfirmModal.tsx +2 -2
  21. package/src/web/components/Drawer.stories.tsx +7 -7
  22. package/src/web/components/Drawer.tsx +2 -2
  23. package/src/web/components/HistoryTimeline.tsx +2 -2
  24. package/src/web/components/Modal.stories.tsx +1 -1
  25. package/src/web/components/Modal.tsx +27 -10
  26. package/src/web/components/Pagination.tsx +2 -2
  27. package/src/web/components/TableActionButton.tsx +1 -1
  28. package/src/web/components/TableActionsMenu.tsx +1 -1
  29. package/src/web/components/TableIconText.tsx +1 -1
  30. package/src/web/components/Toaster.stories.tsx +7 -7
  31. package/src/web/components/table/constants.ts +2 -2
  32. package/src/web/layout/AppHeader.tsx +1 -1
  33. package/src/web/layout/BuildingSelect.tsx +2 -2
  34. package/src/web/layout/DashboardLayout.stories.tsx +1 -1
  35. package/src/web/layout/SidebarNavItem.tsx +1 -1
  36. package/src/web/layout/SidebarUserCard.tsx +3 -3
  37. package/src/web/styles/typography.css +99 -0
@@ -427,11 +427,12 @@ type ModalProps = {
427
427
  cancelDisabled?: boolean;
428
428
  confirmDisabled?: boolean;
429
429
  closeOnBackdrop?: boolean;
430
+ closeOnEscape?: boolean;
430
431
  containerClassName?: string;
431
432
  contentClassName?: string;
432
433
  buttonClassName?: string;
433
434
  };
434
- declare function Modal({ open, title, subtitle, icon, iconContainerClassName, children, cancelText, confirmText, onCancel, onConfirm, footerAlign, footerLayout, cancelDisabled, confirmDisabled, closeOnBackdrop, containerClassName, contentClassName, buttonClassName, }: ModalProps): react.JSX.Element | null;
435
+ declare function Modal({ open, title, subtitle, icon, iconContainerClassName, children, cancelText, confirmText, onCancel, onConfirm, footerAlign, footerLayout, cancelDisabled, confirmDisabled, closeOnBackdrop, closeOnEscape, containerClassName, contentClassName, buttonClassName, }: ModalProps): react.JSX.Element | null;
435
436
 
436
437
  type DrawerProps = {
437
438
  open: boolean;
@@ -427,11 +427,12 @@ type ModalProps = {
427
427
  cancelDisabled?: boolean;
428
428
  confirmDisabled?: boolean;
429
429
  closeOnBackdrop?: boolean;
430
+ closeOnEscape?: boolean;
430
431
  containerClassName?: string;
431
432
  contentClassName?: string;
432
433
  buttonClassName?: string;
433
434
  };
434
- declare function Modal({ open, title, subtitle, icon, iconContainerClassName, children, cancelText, confirmText, onCancel, onConfirm, footerAlign, footerLayout, cancelDisabled, confirmDisabled, closeOnBackdrop, containerClassName, contentClassName, buttonClassName, }: ModalProps): react.JSX.Element | null;
435
+ declare function Modal({ open, title, subtitle, icon, iconContainerClassName, children, cancelText, confirmText, onCancel, onConfirm, footerAlign, footerLayout, cancelDisabled, confirmDisabled, closeOnBackdrop, closeOnEscape, containerClassName, contentClassName, buttonClassName, }: ModalProps): react.JSX.Element | null;
435
436
 
436
437
  type DrawerProps = {
437
438
  open: boolean;
package/dist/web/index.js CHANGED
@@ -27529,7 +27529,7 @@ var require_react_dom_development = __commonJS({
27529
27529
  return root2;
27530
27530
  }
27531
27531
  var ReactVersion = "18.3.1";
27532
- function createPortal2(children, containerInfo, implementation) {
27532
+ function createPortal3(children, containerInfo, implementation) {
27533
27533
  var key = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : null;
27534
27534
  {
27535
27535
  checkKeyStringCoercion(key);
@@ -28385,7 +28385,7 @@ var require_react_dom_development = __commonJS({
28385
28385
  if (!isValidContainer(container)) {
28386
28386
  throw new Error("Target container is not a DOM element.");
28387
28387
  }
28388
- return createPortal2(children, container, null, key);
28388
+ return createPortal3(children, container, null, key);
28389
28389
  }
28390
28390
  function renderSubtreeIntoContainer(parentComponent, element, containerNode, callback) {
28391
28391
  return unstable_renderSubtreeIntoContainer(parentComponent, element, containerNode, callback);
@@ -28708,7 +28708,7 @@ function BuildingSelect({
28708
28708
  ),
28709
28709
  children: [
28710
28710
  buildingIcon ?? /* @__PURE__ */ jsx(BuildingIcon, { className: "shrink-0 text-navy" }),
28711
- /* @__PURE__ */ jsx("span", { className: "min-w-0 flex-1 truncate text-sm font-medium text-slate-blue", children: displayLabel }),
28711
+ /* @__PURE__ */ jsx("span", { className: "min-w-0 flex-1 truncate typography-14 font-medium text-slate-blue", children: displayLabel }),
28712
28712
  chevronIcon ?? /* @__PURE__ */ jsx(
28713
28713
  ChevronsUpDown,
28714
28714
  {
@@ -28756,7 +28756,7 @@ function BuildingSelect({
28756
28756
  },
28757
28757
  onClick: () => selectOption(option),
28758
28758
  className: cn(
28759
- "flex w-full rounded-lg px-3 py-2.5 text-left text-sm font-medium text-slate-blue transition-colors",
28759
+ "flex w-full rounded-lg px-3 py-2.5 text-left typography-14 font-medium text-slate-blue transition-colors",
28760
28760
  !option.disabled && "cursor-pointer hover:bg-storm-gray-50",
28761
28761
  (isSelected || isHighlighted) && !option.disabled && "bg-storm-gray-50",
28762
28762
  option.disabled && "cursor-not-allowed opacity-50"
@@ -28809,7 +28809,7 @@ function AppHeader({
28809
28809
  className
28810
28810
  ),
28811
28811
  children: [
28812
- /* @__PURE__ */ jsx("h1", { className: "truncate text-xl font-bold text-slate-blue", children: title }),
28812
+ /* @__PURE__ */ jsx("h1", { className: "truncate typography-title text-slate-blue", children: title }),
28813
28813
  /* @__PURE__ */ jsxs("div", { className: "flex shrink-0 items-center gap-3", children: [
28814
28814
  hasBuildingSelect ? /* @__PURE__ */ jsx(
28815
28815
  BuildingSelect,
@@ -28912,7 +28912,7 @@ function SidebarNavItem({ item, isOpen, onNavigate }) {
28912
28912
  "span",
28913
28913
  {
28914
28914
  className: cn(
28915
- "overflow-hidden text-sm font-semibold whitespace-nowrap transition-[max-width,opacity] duration-300 ease-in-out",
28915
+ "overflow-hidden typography-14 font-semibold whitespace-nowrap transition-[max-width,opacity] duration-300 ease-in-out",
28916
28916
  isOpen ? "max-w-[180px] opacity-100" : "max-w-0 opacity-0"
28917
28917
  ),
28918
28918
  children: item.label
@@ -28949,15 +28949,15 @@ function SidebarUserCard({
28949
28949
  /* @__PURE__ */ jsx(
28950
28950
  "div",
28951
28951
  {
28952
- className: "flex size-11 shrink-0 items-center justify-center rounded-full bg-white/5 text-sm font-bold text-white",
28952
+ className: "flex size-11 shrink-0 items-center justify-center rounded-full bg-white/5 typography-14 font-bold text-white",
28953
28953
  "aria-hidden": true,
28954
28954
  children: initials
28955
28955
  }
28956
28956
  ),
28957
28957
  isOpen ? /* @__PURE__ */ jsxs(Fragment, { children: [
28958
28958
  /* @__PURE__ */ jsxs("div", { className: "flex min-w-0 flex-1 flex-col overflow-hidden", children: [
28959
- /* @__PURE__ */ jsx("p", { className: "truncate text-sm font-bold text-white", children: user.fullName }),
28960
- /* @__PURE__ */ jsx("p", { className: "truncate text-xs text-storm-gray-100", children: user.email })
28959
+ /* @__PURE__ */ jsx("p", { className: "truncate typography-14 font-bold text-white", children: user.fullName }),
28960
+ /* @__PURE__ */ jsx("p", { className: "truncate typography-12 text-storm-gray-100", children: user.email })
28961
28961
  ] }),
28962
28962
  /* @__PURE__ */ jsx(
28963
28963
  "button",
@@ -29538,7 +29538,7 @@ var defaultLabels = {
29538
29538
  page: (pageNumber) => `Page ${pageNumber}`,
29539
29539
  showing: ({ start, end, total }) => `Showing ${start}-${end} of ${total}`
29540
29540
  };
29541
- var paginationControlClassName = "inline-flex size-7 items-center justify-center rounded-lg border border-storm-gray-50 p-1 text-xs font-medium leading-none text-storm-gray-500 transition-colors";
29541
+ var paginationControlClassName = "inline-flex size-7 items-center justify-center rounded-lg border border-storm-gray-50 p-1 typography-12 font-medium text-storm-gray-500 transition-colors";
29542
29542
  var paginationHoverClassName = "cursor-pointer hover:bg-storm-gray-0";
29543
29543
  function Pagination({
29544
29544
  page,
@@ -29572,7 +29572,7 @@ function Pagination({
29572
29572
  className
29573
29573
  ),
29574
29574
  children: [
29575
- /* @__PURE__ */ jsx("p", { className: "text-xs font-medium leading-none text-storm-gray-200", children: mergedLabels.showing({ start, end, total }) }),
29575
+ /* @__PURE__ */ jsx("p", { className: "typography-12 font-medium text-storm-gray-200", children: mergedLabels.showing({ start, end, total }) }),
29576
29576
  /* @__PURE__ */ jsxs(
29577
29577
  "nav",
29578
29578
  {
@@ -29659,8 +29659,8 @@ var tableCellPaddingClassName = "px-3 py-3";
29659
29659
  var tableHeadPaddingClassName = "px-3 py-4";
29660
29660
  var tableShellClassName = "flex flex-col overflow-hidden border bg-storm-gray-0";
29661
29661
  var tableFooterShellClassName = "overflow-hidden rounded-b-xl border bg-storm-gray-0";
29662
- var tableHeaderClassName = "bg-storm-gray-0 font-sans text-xs font-normal leading-none tracking-normal text-storm-gray-400";
29663
- var tableBodyClassName = "bg-white font-sans text-sm font-medium leading-none tracking-normal text-storm-gray-900";
29662
+ var tableHeaderClassName = "bg-storm-gray-0 typography-12 font-normal tracking-normal text-storm-gray-400";
29663
+ var tableBodyClassName = "bg-white typography-14 font-medium tracking-normal text-storm-gray-900";
29664
29664
  var tableAlignClasses = {
29665
29665
  left: "",
29666
29666
  right: "text-right",
@@ -29838,7 +29838,7 @@ function TableActionsCell({ className, children, ...props }) {
29838
29838
 
29839
29839
  // src/web/components/TableActionsMenu.tsx
29840
29840
  var import_react_dom = __toESM(require_react_dom(), 1);
29841
- var inlineActionClassName = "inline-flex cursor-pointer items-center gap-1 rounded-lg border border-storm-gray-50 bg-white px-3 py-2 font-sans text-xs font-medium leading-none text-storm-gray-900 transition-colors hover:bg-storm-gray-0";
29841
+ var inlineActionClassName = "inline-flex cursor-pointer items-center gap-1 rounded-lg border border-storm-gray-50 bg-white px-3 py-2 typography-12 font-medium text-storm-gray-900 transition-colors hover:bg-storm-gray-0";
29842
29842
  var variantClasses = {
29843
29843
  approve: inlineActionClassName,
29844
29844
  reject: inlineActionClassName,
@@ -29997,7 +29997,7 @@ function TableActionsMenu({
29997
29997
  item.onSelect();
29998
29998
  },
29999
29999
  className: cn(
30000
- "flex h-[51px] w-full cursor-pointer items-center gap-2.5 px-3 text-left font-sans text-sm font-medium leading-none text-storm-gray-900 transition-colors hover:bg-storm-gray-0",
30000
+ "flex h-[51px] w-full cursor-pointer items-center gap-2.5 px-3 text-left typography-14 font-medium text-storm-gray-900 transition-colors hover:bg-storm-gray-0",
30001
30001
  index > 0 && "border-t border-storm-gray-50",
30002
30002
  item.disabled && "cursor-not-allowed opacity-50"
30003
30003
  ),
@@ -30228,7 +30228,7 @@ function Badge({ children, variant = "neutral", icon, className }) {
30228
30228
  "span",
30229
30229
  {
30230
30230
  className: cn(
30231
- "inline-flex items-center gap-2 rounded-[28px] px-3 py-1.5 font-sans text-xs font-semibold leading-none whitespace-nowrap",
30231
+ "inline-flex items-center gap-2 rounded-[28px] px-3 py-1.5 typography-12 font-semibold whitespace-nowrap",
30232
30232
  badgeVariantClasses[variant],
30233
30233
  className
30234
30234
  ),
@@ -30247,7 +30247,7 @@ function TableIconText({ icon, children, className }) {
30247
30247
  "span",
30248
30248
  {
30249
30249
  className: cn(
30250
- "inline-flex items-center gap-2 font-sans text-sm font-medium leading-none tracking-normal text-storm-gray-900",
30250
+ "inline-flex items-center gap-2 typography-14 font-medium tracking-normal text-storm-gray-900",
30251
30251
  className
30252
30252
  ),
30253
30253
  children: [
@@ -30257,6 +30257,9 @@ function TableIconText({ icon, children, className }) {
30257
30257
  }
30258
30258
  );
30259
30259
  }
30260
+
30261
+ // src/web/components/Modal.tsx
30262
+ var import_react_dom2 = __toESM(require_react_dom(), 1);
30260
30263
  var footerAlignClasses = {
30261
30264
  left: "justify-start",
30262
30265
  center: "justify-center",
@@ -30278,6 +30281,7 @@ function Modal({
30278
30281
  cancelDisabled = false,
30279
30282
  confirmDisabled = false,
30280
30283
  closeOnBackdrop = true,
30284
+ closeOnEscape = true,
30281
30285
  containerClassName,
30282
30286
  contentClassName,
30283
30287
  buttonClassName
@@ -30286,16 +30290,19 @@ function Modal({
30286
30290
  if (!open) {
30287
30291
  return;
30288
30292
  }
30293
+ const previousOverflow = document.body.style.overflow;
30294
+ document.body.style.overflow = "hidden";
30289
30295
  const handleKeyDown = (event) => {
30290
- if (event.key === "Escape") {
30296
+ if (event.key === "Escape" && closeOnEscape) {
30291
30297
  onCancel();
30292
30298
  }
30293
30299
  };
30294
30300
  window.addEventListener("keydown", handleKeyDown);
30295
30301
  return () => {
30302
+ document.body.style.overflow = previousOverflow;
30296
30303
  window.removeEventListener("keydown", handleKeyDown);
30297
30304
  };
30298
- }, [open, onCancel]);
30305
+ }, [open, onCancel, closeOnEscape]);
30299
30306
  if (!open) {
30300
30307
  return null;
30301
30308
  }
@@ -30304,11 +30311,15 @@ function Modal({
30304
30311
  footerLayout === "split" && "min-w-0 flex-1 basis-0",
30305
30312
  footerLayout !== "split" && buttonClassName
30306
30313
  );
30307
- return /* @__PURE__ */ jsx(
30314
+ const modal = /* @__PURE__ */ jsx(
30308
30315
  "div",
30309
30316
  {
30310
- className: "fixed inset-0 z-50 flex items-center justify-center p-4 backdrop-blur-[12px] bg-storm-gray-850/40",
30311
- onClick: closeOnBackdrop ? onCancel : void 0,
30317
+ className: "fixed inset-0 z-[100] flex items-center justify-center p-4 backdrop-blur-[12px] bg-storm-gray-850/40",
30318
+ onClick: closeOnBackdrop ? (event) => {
30319
+ if (event.target === event.currentTarget) {
30320
+ onCancel();
30321
+ }
30322
+ } : void 0,
30312
30323
  role: "presentation",
30313
30324
  children: /* @__PURE__ */ jsxs(
30314
30325
  "div",
@@ -30318,14 +30329,14 @@ function Modal({
30318
30329
  "aria-labelledby": "homepad-modal-title",
30319
30330
  ...subtitle ? { "aria-describedby": "homepad-modal-subtitle" } : {},
30320
30331
  className: cn(
30321
- "flex w-full max-w-2xl flex-col gap-6 rounded-2xl bg-white p-4 opacity-100 md:p-6",
30332
+ "flex max-h-[min(90dvh,calc(100dvh-2rem))] w-full max-w-2xl flex-col gap-6 rounded-2xl bg-white p-4 opacity-100 md:p-6",
30322
30333
  containerClassName
30323
30334
  ),
30324
30335
  onClick: (event) => {
30325
30336
  event.stopPropagation();
30326
30337
  },
30327
30338
  children: [
30328
- /* @__PURE__ */ jsxs("header", { className: cn("flex", icon ? "items-center gap-2.5" : void 0), children: [
30339
+ /* @__PURE__ */ jsxs("header", { className: cn("flex shrink-0", icon ? "items-center gap-2.5" : void 0), children: [
30329
30340
  icon ? /* @__PURE__ */ jsx(
30330
30341
  "div",
30331
30342
  {
@@ -30341,7 +30352,7 @@ function Modal({
30341
30352
  "h2",
30342
30353
  {
30343
30354
  id: "homepad-modal-title",
30344
- className: "font-sans text-lg font-bold leading-6 tracking-normal text-black",
30355
+ className: "typography-title-sm tracking-normal text-black",
30345
30356
  children: title
30346
30357
  }
30347
30358
  ),
@@ -30349,13 +30360,13 @@ function Modal({
30349
30360
  "p",
30350
30361
  {
30351
30362
  id: "homepad-modal-subtitle",
30352
- className: "font-sans text-xs font-normal leading-4 tracking-normal text-storm-gray-400",
30363
+ className: "typography-caption tracking-normal text-storm-gray-400",
30353
30364
  children: subtitle
30354
30365
  }
30355
30366
  ) : null
30356
30367
  ] })
30357
30368
  ] }),
30358
- /* @__PURE__ */ jsx("div", { className: cn("min-w-0", contentClassName), children }),
30369
+ /* @__PURE__ */ jsx("div", { className: cn("min-h-0 min-w-0 flex-1 overflow-y-auto", contentClassName), children }),
30359
30370
  /* @__PURE__ */ jsxs(
30360
30371
  "footer",
30361
30372
  {
@@ -30394,6 +30405,7 @@ function Modal({
30394
30405
  )
30395
30406
  }
30396
30407
  );
30408
+ return typeof document !== "undefined" ? (0, import_react_dom2.createPortal)(modal, document.body) : modal;
30397
30409
  }
30398
30410
  var DRAWER_TRANSITION_MS = 300;
30399
30411
  function Drawer({
@@ -30497,7 +30509,7 @@ function Drawer({
30497
30509
  "h2",
30498
30510
  {
30499
30511
  id: "homepad-drawer-title",
30500
- className: "font-sans text-[18px] font-bold leading-6 tracking-normal text-black",
30512
+ className: "typography-title-sm tracking-normal text-black",
30501
30513
  children: title
30502
30514
  }
30503
30515
  ),
@@ -30505,7 +30517,7 @@ function Drawer({
30505
30517
  "p",
30506
30518
  {
30507
30519
  id: "homepad-drawer-subtitle",
30508
- className: "font-sans text-sm font-normal leading-[19px] tracking-normal text-storm-gray-400",
30520
+ className: "typography-body tracking-normal text-storm-gray-400",
30509
30521
  children: subtitle
30510
30522
  }
30511
30523
  ) : null
@@ -30581,8 +30593,8 @@ function HistoryTimeline({ events }) {
30581
30593
  ) : null
30582
30594
  ] }),
30583
30595
  /* @__PURE__ */ jsxs("div", { className: "flex min-w-0 flex-1 flex-col gap-2 pt-1.5", children: [
30584
- /* @__PURE__ */ jsx("p", { className: "font-sans text-sm font-medium leading-[19px] tracking-normal text-slate-blue", children: event.title }),
30585
- /* @__PURE__ */ jsx("p", { className: "font-sans text-xs font-normal leading-4 tracking-normal text-storm-gray-300", children: event.timestamp })
30596
+ /* @__PURE__ */ jsx("p", { className: "typography-14 font-medium tracking-normal text-slate-blue", children: event.title }),
30597
+ /* @__PURE__ */ jsx("p", { className: "typography-caption tracking-normal text-storm-gray-300", children: event.timestamp })
30586
30598
  ] })
30587
30599
  ] }, event.id);
30588
30600
  }) });
@@ -30833,7 +30845,7 @@ function ConfirmModal({
30833
30845
  "h2",
30834
30846
  {
30835
30847
  id: "homepad-confirm-modal-title",
30836
- className: "font-sans text-xl font-bold leading-6.75 tracking-normal text-black",
30848
+ className: "typography-title tracking-normal text-black",
30837
30849
  children: title
30838
30850
  }
30839
30851
  ),
@@ -30841,7 +30853,7 @@ function ConfirmModal({
30841
30853
  "div",
30842
30854
  {
30843
30855
  id: "homepad-confirm-modal-description",
30844
- className: "text-center font-sans text-sm font-normal leading-4.75 tracking-normal text-storm-gray-400",
30856
+ className: "text-center typography-body tracking-normal text-storm-gray-400",
30845
30857
  children: description
30846
30858
  }
30847
30859
  )