rift-ds 1.23.0 → 1.25.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (124) hide show
  1. package/README.md +4 -4
  2. package/behaviors/shell.css +119 -0
  3. package/bin/templates/blocks/components/blocks/AppShell.module.css +69 -15
  4. package/bin/templates/blocks/components/blocks/AppShell.tsx +45 -30
  5. package/bin/templates/blocks/registry.json +1 -1
  6. package/chat/ChatAgentPane.css +6 -6
  7. package/chat/ChatLauncher.d.ts +3 -3
  8. package/chat/ChatWidget.css +260 -8
  9. package/chat/ChatWidget.d.ts +41 -6
  10. package/chat/ChatWidget.js +49 -2
  11. package/chat/index.d.ts +1 -1
  12. package/chat/registry.json.d.ts +1 -1
  13. package/chat/registry.json.js +1 -1
  14. package/components/AppLayout/AppLayout.css +17 -4
  15. package/components/AppLayout/AppLayout.d.ts +8 -5
  16. package/components/AppLayout/AppLayout.js +2 -0
  17. package/components/AppSidebar/AppSidebar.css +108 -23
  18. package/components/AppSidebar/AppSidebar.d.ts +8 -5
  19. package/components/AppSidebar/AppSidebar.js +6 -3
  20. package/components/Attachment/Attachment.css +8 -0
  21. package/components/Attachment/AttachmentViewer.js +26 -5
  22. package/components/Attachment/fileTypes.d.ts +4 -0
  23. package/components/CurrencyInput/CurrencyInput.css +12 -0
  24. package/components/CurrencyInput/CurrencyInput.d.ts +51 -0
  25. package/components/CurrencyInput/CurrencyInput.js +158 -0
  26. package/components/DataTable/columnTypes.js +4 -16
  27. package/components/DatePicker/DatePicker.d.ts +2 -0
  28. package/components/DatePicker/DatePicker.js +44 -131
  29. package/components/DatePicker/MonthGrid.d.ts +56 -0
  30. package/components/DatePicker/MonthGrid.js +65 -0
  31. package/components/DatePicker/calendar.d.ts +42 -0
  32. package/components/DatePicker/calendar.js +108 -0
  33. package/components/DateRangePicker/DateRangePicker.css +92 -0
  34. package/components/DateRangePicker/DateRangePicker.d.ts +86 -0
  35. package/components/DateRangePicker/DateRangePicker.js +294 -0
  36. package/components/Deadline/Deadline.css +82 -0
  37. package/components/Deadline/Deadline.d.ts +44 -0
  38. package/components/Deadline/Deadline.js +94 -0
  39. package/components/Deadline/deadlineStatus.d.ts +15 -0
  40. package/components/Deadline/deadlineStatus.js +13 -0
  41. package/components/DescriptionList/DescriptionList.css +184 -0
  42. package/components/DescriptionList/DescriptionList.d.ts +64 -0
  43. package/components/DescriptionList/DescriptionList.js +100 -0
  44. package/components/DescriptionList/DescriptionListCopy.d.ts +18 -0
  45. package/components/DescriptionList/DescriptionListCopy.js +45 -0
  46. package/components/DocumentViewer/DocumentViewer.css +188 -0
  47. package/components/DocumentViewer/DocumentViewer.d.ts +59 -0
  48. package/components/DocumentViewer/DocumentViewer.js +185 -0
  49. package/components/ErrorSummary/ErrorSummary.css +94 -0
  50. package/components/ErrorSummary/ErrorSummary.d.ts +34 -0
  51. package/components/ErrorSummary/ErrorSummary.js +70 -0
  52. package/components/ErrorSummary/fieldErrors.d.ts +36 -0
  53. package/components/ErrorSummary/fieldErrors.js +19 -0
  54. package/components/Field/Field.css +12 -0
  55. package/components/Field/Field.d.ts +10 -2
  56. package/components/Field/Field.js +12 -5
  57. package/components/Heading/Heading.css +129 -0
  58. package/components/Heading/Heading.d.ts +31 -0
  59. package/components/Heading/Heading.js +39 -0
  60. package/components/Input/Input.css +120 -0
  61. package/components/Input/Input.d.ts +20 -1
  62. package/components/Input/Input.js +70 -5
  63. package/components/Link/Link.css +84 -0
  64. package/components/Link/Link.d.ts +43 -0
  65. package/components/Link/Link.js +74 -0
  66. package/components/List/List.css +173 -0
  67. package/components/List/List.d.ts +44 -0
  68. package/components/List/List.js +60 -0
  69. package/components/MaskedInput/MaskedInput.css +16 -0
  70. package/components/MaskedInput/MaskedInput.d.ts +57 -0
  71. package/components/MaskedInput/MaskedInput.js +142 -0
  72. package/components/MaskedInput/mask.d.ts +58 -0
  73. package/components/MaskedInput/mask.js +106 -0
  74. package/components/ShaderScene/ShaderScene.css +19 -0
  75. package/components/ShaderScene/ShaderScene.d.ts +82 -0
  76. package/components/ShaderScene/ShaderScene.js +144 -0
  77. package/components/ShaderScene/assemble.d.ts +5 -0
  78. package/components/ShaderScene/assemble.js +74 -0
  79. package/components/ShaderScene/common.glsl.d.ts +6 -0
  80. package/components/ShaderScene/common.glsl.js +49 -0
  81. package/components/ShaderScene/passes.d.ts +2 -0
  82. package/components/ShaderScene/passes.js +93 -0
  83. package/components/ShaderScene/renderer.d.ts +35 -0
  84. package/components/ShaderScene/renderer.js +125 -0
  85. package/components/ShaderScene/scenes.d.ts +20 -0
  86. package/components/ShaderScene/scenes.js +184 -0
  87. package/components/ShaderScene/types.d.ts +70 -0
  88. package/components/ShaderScene/types.js +8 -0
  89. package/components/SignaturePad/SignaturePad.css +141 -0
  90. package/components/SignaturePad/SignaturePad.d.ts +68 -0
  91. package/components/SignaturePad/SignaturePad.js +287 -0
  92. package/components/SignaturePad/signature.d.ts +32 -0
  93. package/components/SignaturePad/signature.js +46 -0
  94. package/components/Text/Text.css +129 -0
  95. package/components/Text/Text.d.ts +36 -0
  96. package/components/Text/Text.js +36 -0
  97. package/components/ThemePicker/ThemePicker.css +6 -0
  98. package/components/ThemePicker/ThemePicker.js +20 -11
  99. package/components/ThreadPanel/ThreadPanel.css +65 -36
  100. package/components/ThreadPanel/ThreadPanel.d.ts +5 -5
  101. package/components/ThreadPanel/ThreadPanel.js +1 -1
  102. package/components/Widget/Widget.css +111 -0
  103. package/components/Widget/Widget.d.ts +15 -1
  104. package/components/Widget/Widget.js +63 -11
  105. package/components/Widget/WidgetDisclosure.d.ts +30 -0
  106. package/components/Widget/WidgetDisclosure.js +52 -0
  107. package/components/registry.json +112 -3
  108. package/components/registry.json.d.ts +112 -3
  109. package/components/registry.json.js +2 -2
  110. package/format/index.d.ts +15 -0
  111. package/format/index.js +17 -0
  112. package/format/money.d.ts +89 -0
  113. package/format/money.js +187 -0
  114. package/format/relative.d.ts +49 -0
  115. package/format/relative.js +50 -0
  116. package/index.d.ts +13 -0
  117. package/index.js +46 -0
  118. package/package.json +9 -2
  119. package/tokens/motion.d.ts +4 -0
  120. package/tokens/motion.js +4 -0
  121. package/tokens/presets/plum.css +234 -240
  122. package/tokens/tokens-dark.css +2 -2
  123. package/tokens/tokens-light.css +2 -2
  124. package/tokens/values.json.js +1 -1
@@ -21,7 +21,11 @@
21
21
  /* The vertical padding sits inside the viewport height; content-box
22
22
  sizing ran the rail 40px past the bottom and clipped the profile. */
23
23
  box-sizing: border-box;
24
- background-color: var(--color-bg-page-primary);
24
+ /* The flush rail, the shell recipe's (src/behaviors/shell.css): the
25
+ shell plane behind a hairline divider. A host that marks itself a
26
+ shell sets both; a rail standing alone takes the same look. */
27
+ background-color: var(--ds-shell-rail-bg, var(--color-bg-app-shell));
28
+ border-inline-end: var(--border-025) solid var(--ds-shell-rail-divider, var(--color-bg-container-border));
25
29
  /* The logo mark draws in currentColor; without a colour of its own the
26
30
  rail inherited the host's, and the mark vanished on a dark host. */
27
31
  color: var(--color-text-primary);
@@ -49,13 +53,15 @@
49
53
  top: var(--ds-sidebar-float-inset, 20px);
50
54
  inset-inline-start: var(--ds-sidebar-float-inset, 20px);
51
55
  height: calc(100dvh - var(--ds-sidebar-float-inset, 20px) * 2);
52
- background-color: var(--color-bg-glass);
53
- border: var(--border-025) solid var(--color-bg-container-border);
54
- border-radius: var(--radius-600);
55
- box-shadow: var(--shadow-floating);
56
+ /* The shell recipe's glass card (src/behaviors/shell.css), with its
57
+ values as fallbacks for a rail standing outside a shell host. */
58
+ background-color: var(--ds-shell-glass, var(--color-bg-glass));
59
+ border: var(--border-025) solid var(--ds-shell-edge-border, var(--color-bg-container-border));
60
+ border-radius: var(--ds-shell-radius, var(--radius-600));
61
+ box-shadow: var(--ds-shell-edge-shadow, var(--shadow-floating));
56
62
  /* The glass token is deliberately translucent; this blur is what keeps
57
63
  content behind the rail readable through it. */
58
- backdrop-filter: blur(24px);
64
+ backdrop-filter: var(--ds-shell-glass-blur, blur(24px));
59
65
  }
60
66
 
61
67
  /* The inset layout's gap: between the content surface and the viewport
@@ -71,7 +77,9 @@
71
77
  from the edges (AppLayout's inset layout)
72
78
  ============================================ */
73
79
  .ds-app-sidebar--inset {
74
- background-color: var(--color-bg-app-shell);
80
+ background-color: var(--ds-shell-rail-bg, var(--color-bg-app-shell));
81
+ /* The content surface's raised edge is the seam; the rail needs none. */
82
+ border-inline-end-color: transparent;
75
83
  }
76
84
 
77
85
  /* ============================================
@@ -85,6 +93,12 @@
85
93
  overflow-x: hidden;
86
94
  flex: 1;
87
95
  min-height: 0;
96
+ /* The scroller clips at its edge, and the logo row sits on it: the
97
+ collapse toggle's hover pill, a --gap-100 step out from the icon, lost
98
+ its top to it. A pill's worth of room inside the top edge, taken back
99
+ from the rail's padding, so nothing moves. */
100
+ padding-top: var(--gap-100);
101
+ margin-top: calc(-1 * var(--gap-100));
88
102
  }
89
103
 
90
104
  /* ============================================
@@ -349,6 +363,15 @@
349
363
  transition: opacity var(--motion-duration-base) var(--motion-ease-standard);
350
364
  }
351
365
 
366
+ /* Collapsed, the row is a 40px circle, and its clip follows the curve: the
367
+ corner badge, which overhangs the icon seat's top end, lost its corner
368
+ to it. The collapsed row draws nothing that needs the clip (the label
369
+ and chevron truncate themselves, and the hover circle is the row's own
370
+ fill), so it lets the badge hang over. */
371
+ .ds-app-sidebar:not(.ds-app-sidebar--expanded) .ds-app-sidebar__btn {
372
+ overflow: visible;
373
+ }
374
+
352
375
  .ds-app-sidebar--expanded .ds-app-sidebar__btn-corner-badge {
353
376
  opacity: 0;
354
377
  transition-duration: var(--motion-duration-fast);
@@ -536,6 +559,12 @@
536
559
  grid-area: 1 / 1;
537
560
  }
538
561
 
562
+ /* The footer's controls start on the rail's leading line, the logo's, the
563
+ row icons' and the avatar's, a step deeper than the top slot. */
564
+ .ds-app-sidebar__footer > .ds-app-sidebar__footer-slot:not(.ds-app-sidebar__footer-slot--collapsed) {
565
+ padding-inline: var(--padding-500);
566
+ }
567
+
539
568
  .ds-app-sidebar__footer-slot--collapsed {
540
569
  display: flex;
541
570
  flex-direction: column;
@@ -599,12 +628,13 @@
599
628
  opacity: 1;
600
629
  }
601
630
 
631
+ /* The profile pairs its lines as EntitySwitcher does: the name in
632
+ paragraph-sm emphasis, the second line in caption, secondary. */
602
633
  .ds-app-sidebar__profile-name {
603
- font-family: var(--font-paragraph-emphasis-family);
604
- font-size: var(--font-paragraph-emphasis-size);
605
- font-weight: var(--font-paragraph-emphasis-weight);
606
- line-height: var(--font-paragraph-emphasis-line-height);
607
- letter-spacing: var(--font-paragraph-emphasis-letter-spacing);
634
+ font-family: var(--font-paragraph-sm-emphasis-family);
635
+ font-size: var(--font-paragraph-sm-emphasis-size);
636
+ font-weight: var(--font-paragraph-sm-emphasis-weight);
637
+ line-height: var(--font-paragraph-sm-emphasis-line-height);
608
638
  color: var(--color-text-primary);
609
639
  white-space: nowrap;
610
640
  overflow: hidden;
@@ -612,11 +642,11 @@
612
642
  }
613
643
 
614
644
  .ds-app-sidebar__profile-email {
615
- font-family: var(--font-paragraph-family);
616
- font-size: var(--font-paragraph-size);
617
- font-weight: var(--font-paragraph-weight);
618
- line-height: var(--font-paragraph-line-height);
619
- color: var(--color-text-tertiary);
645
+ font-family: var(--font-caption-family);
646
+ font-size: var(--font-caption-size);
647
+ font-weight: var(--font-caption-weight);
648
+ line-height: var(--font-caption-line-height);
649
+ color: var(--color-text-secondary);
620
650
  white-space: nowrap;
621
651
  overflow: hidden;
622
652
  text-overflow: ellipsis;
@@ -702,11 +732,13 @@
702
732
  top: var(--ds-sidebar-float-inset, 20px);
703
733
  inset-inline-start: calc(var(--ds-sidebar-float-inset, 20px) + 64px + var(--gap-300));
704
734
  height: calc(100dvh - var(--ds-sidebar-float-inset, 20px) * 2);
705
- background-color: var(--color-bg-glass);
706
- border: var(--border-025) solid var(--color-bg-container-border);
707
- border-radius: var(--radius-600);
708
- box-shadow: var(--shadow-floating);
709
- backdrop-filter: blur(24px);
735
+ /* The shell recipe's glass card (src/behaviors/shell.css), with its
736
+ values as fallbacks for a rail standing outside a shell host. */
737
+ background-color: var(--ds-shell-glass, var(--color-bg-glass));
738
+ border: var(--border-025) solid var(--ds-shell-edge-border, var(--color-bg-container-border));
739
+ border-radius: var(--ds-shell-radius, var(--radius-600));
740
+ box-shadow: var(--ds-shell-edge-shadow, var(--shadow-floating));
741
+ backdrop-filter: var(--ds-shell-glass-blur, blur(24px));
710
742
  }
711
743
 
712
744
  .ds-app-sidebar__panel--floating.ds-app-sidebar__panel--panel-mode {
@@ -721,8 +753,16 @@
721
753
  divider between the two levels, and the inset content surface starts
722
754
  beyond both (AppLayout reserves the panel's width while it shows). The
723
755
  trailing edge needs no border: the surface's own edge ends the panel. */
756
+ /* Flush: the panel continues the rail on its shell colour, and the rail's
757
+ own divider is the seam between them, so the panel's leading hairline
758
+ would double it. */
759
+ .ds-app-sidebar__panel:not(.ds-app-sidebar__panel--floating, .ds-app-sidebar__panel--inset) {
760
+ background-color: var(--ds-shell-rail-bg, var(--color-bg-app-shell));
761
+ border-inline-start-color: transparent;
762
+ }
763
+
724
764
  .ds-app-sidebar__panel--inset {
725
- background-color: var(--color-bg-app-shell);
765
+ background-color: var(--ds-shell-rail-bg, var(--color-bg-app-shell));
726
766
  border-inline-end-color: transparent;
727
767
  }
728
768
 
@@ -992,3 +1032,48 @@
992
1032
  .material-symbols-rounded:not(:where(.ds-app-sidebar__top-slot *, .ds-app-sidebar__footer-slot *)) {
993
1033
  color: inherit;
994
1034
  }
1035
+
1036
+ /* The toggle's pressed pill, ThreadPanel's: a passive hover and active fill
1037
+ a gap step out from the 24px icon, drawn behind it so the icon's box and
1038
+ the row's alignment stay as they are. Expanded only; collapsed, the toggle
1039
+ has no width to draw around. */
1040
+ .ds-app-sidebar__toggle-tip {
1041
+ flex: none;
1042
+ }
1043
+
1044
+ /* Collapsed, the rail is too narrow for the tooltip and the toggle is gone;
1045
+ the panel stays out of the way. */
1046
+ .ds-app-sidebar:not(.ds-app-sidebar--expanded) .ds-app-sidebar__toggle-tip .ds-tooltip__panel {
1047
+ display: none;
1048
+ }
1049
+
1050
+ /* In the phone drawer the toggle is the drawer's close, a glyph that names
1051
+ itself, and it takes the focus as the drawer opens: a tooltip there
1052
+ would rise over the brand name on every open, so the drawer has none. */
1053
+ .ds-app-sidebar--mobile-open .ds-app-sidebar__toggle-tip .ds-tooltip__panel {
1054
+ display: none;
1055
+ }
1056
+
1057
+ .ds-app-sidebar--expanded .ds-app-sidebar__toggle {
1058
+ position: relative;
1059
+ z-index: 0;
1060
+ overflow: visible;
1061
+ }
1062
+
1063
+ .ds-app-sidebar__toggle::before {
1064
+ content: '';
1065
+ position: absolute;
1066
+ inset: calc(-1 * var(--gap-100));
1067
+ z-index: -1;
1068
+ border-radius: var(--radius-pill);
1069
+ background-color: transparent;
1070
+ transition: background-color var(--motion-duration-fast) var(--motion-ease-standard);
1071
+ }
1072
+
1073
+ .ds-app-sidebar__toggle:hover::before {
1074
+ background-color: var(--color-action-passive-bg-hover);
1075
+ }
1076
+
1077
+ .ds-app-sidebar__toggle:active::before {
1078
+ background-color: var(--color-action-passive-bg-active);
1079
+ }
@@ -61,7 +61,7 @@ export interface AppSidebarProfile {
61
61
  /** Avatar image URL */
62
62
  avatarUrl?: string;
63
63
  }
64
- /** How the rail meets the page: edge to edge, floating as a card, or flush beside an inset content surface. */
64
+ /** The three app shell modes, how the rail meets the page: edge to edge behind a hairline, floating as a card, or flush beside a raised inset surface. */
65
65
  export type AppSidebarLayout = 'flush' | 'floating' | 'inset';
66
66
  /** Props owned by AppSidebar itself — everything else falls through to the `<nav>`. */
67
67
  type AppSidebarOwnProps = {
@@ -99,13 +99,16 @@ type AppSidebarOwnProps = {
99
99
  /** Callback when profile more button clicked */
100
100
  onProfileMore?: () => void;
101
101
  /**
102
- * How the rail meets the page. `flush` runs it edge to edge on the page
103
- * colour. `floating` floats it off the viewport edges as a glass card:
102
+ * How the rail meets the page, one of the three app shell modes. `flush`
103
+ * runs it edge to edge on the shell colour behind a hairline divider,
104
+ * nothing raised. `floating` floats it off the viewport edges as a glass card:
104
105
  * inset with rounded corners, the translucent glass fill over a backdrop
105
106
  * blur, and the floating shadow (the inset defaults to 20px and is
106
107
  * overridable via the --ds-sidebar-float-inset custom property). `inset`
107
- * runs it flush on the app shell colour, beside a content surface inset
108
- * from the edges, as AppLayout's `inset` layout draws it. Defaults to
108
+ * runs it flush on the app shell colour, beside a raised content surface
109
+ * inset from the edges, as AppLayout's `inset` layout draws it. Inside a
110
+ * host that marks itself a shell (AppLayout, a chat or template page), the
111
+ * rail reads that host's mode from the shell recipe. Defaults to
109
112
  * `flush` (or `floating` while the deprecated `floating` is set).
110
113
  */
111
114
  layout?: AppSidebarLayout;
@@ -9,6 +9,8 @@ import { mediaAbove, mediaBelow, BREAKPOINT_TABLET_PX, BREAKPOINT_MOBILE_PX } fr
9
9
  import { Avatar } from "../Avatar/Avatar.js";
10
10
  import { PixelAvatar } from "../PixelAvatar/PixelAvatar.js";
11
11
  import { SidebarPanel } from "../SidebarPanel/SidebarPanel.js";
12
+ import { Tooltip } from "../Tooltip/Tooltip.js";
13
+ import "../../behaviors/shell.css";
12
14
  import "./AppSidebar.css";
13
15
  import "../../behaviors/direction.css";
14
16
  import "../../fonts/material-symbols.css";
@@ -104,6 +106,7 @@ const AppSidebar = React.forwardRef(function AppSidebar2({
104
106
  return () => band.removeEventListener("change", onChange);
105
107
  }, []);
106
108
  const [mobileOpen, setMobileOpen] = useState(false);
109
+ const toggleLabel = mobileOpen ? closeLabel : isExpanded ? collapseLabel : expandLabel;
107
110
  const drawerRef = useRef(null);
108
111
  const setDrawerRef = (node) => {
109
112
  drawerRef.current = node;
@@ -299,15 +302,15 @@ const AppSidebar = React.forwardRef(function AppSidebar2({
299
302
  ]
300
303
  }
301
304
  ),
302
- /* @__PURE__ */ jsx(
305
+ /* @__PURE__ */ jsx(Tooltip, { content: toggleLabel, position: "start", className: `${baseClass}__toggle-tip`, children: /* @__PURE__ */ jsx(
303
306
  "button",
304
307
  {
305
308
  className: `${baseClass}__toggle`,
306
309
  onClick: mobileOpen ? closeMobile : toggleExpanded,
307
- "aria-label": mobileOpen ? closeLabel : isExpanded ? collapseLabel : expandLabel,
310
+ "aria-label": toggleLabel,
308
311
  children: /* @__PURE__ */ jsx("span", { className: "material-symbols-rounded ds-mirror-rtl", children: mobileOpen ? "close" : isExpanded ? "left_panel_close" : "left_panel_open" })
309
312
  }
310
- )
313
+ ) })
311
314
  ] }),
312
315
  topSlot && /* @__PURE__ */ jsx(
313
316
  "div",
@@ -812,6 +812,14 @@ button.ds-attachment-group__single:focus-visible {
812
812
  background-size: 26px 26px;
813
813
  }
814
814
 
815
+ .ds-attachment-viewer__document {
816
+ align-self: stretch;
817
+ flex: 1 1 auto;
818
+ min-width: 0;
819
+ border-radius: var(--radius-200);
820
+ background-color: var(--color-bg-container-primary);
821
+ }
822
+
815
823
  .ds-attachment-viewer__image {
816
824
  display: block;
817
825
  max-width: 100%;
@@ -5,6 +5,7 @@ import ReactDOM from "react-dom";
5
5
  import { Button } from "../Button/Button.js";
6
6
  import { CircularButton } from "../CircularButton/CircularButton.js";
7
7
  import { formatBytes } from "./fileTypes.js";
8
+ import { DocumentViewer } from "../DocumentViewer/DocumentViewer.js";
8
9
  import { renderTypeMark } from "./typeMark.js";
9
10
  import { useMounted } from "../../behaviors/useMounted.js";
10
11
  import { useLayer } from "../../behaviors/useLayer.js";
@@ -80,10 +81,15 @@ const AttachmentViewer = React.forwardRef(
80
81
  if (item) {
81
82
  const failed = item.status === "error" || item.status === "unavailable";
82
83
  const custom = failed ? void 0 : renderPreview?.(item);
83
- const imageSrc = item.src ?? item.previewSrc;
84
- if (custom !== void 0 && custom !== null && custom !== false) {
84
+ const imageSrc = item.src ?? item.previewSrc ?? (item.kind === "image" ? item.fileUrl : void 0);
85
+ const documentKind = item.kind === "pdf" || item.kind === "text" || item.kind === "code";
86
+ const showDocument = !failed && documentKind && Boolean(item.fileUrl);
87
+ const hasCustom = custom !== void 0 && custom !== null && custom !== false;
88
+ let emptyStage = null;
89
+ if (hasCustom) {
85
90
  stage = custom;
86
- } else if (!failed && imageSrc) {
91
+ } else if (showDocument) ;
92
+ else if (!failed && imageSrc) {
87
93
  stage = /* @__PURE__ */ jsx(
88
94
  "img",
89
95
  {
@@ -94,8 +100,9 @@ const AttachmentViewer = React.forwardRef(
94
100
  );
95
101
  } else if (!failed && item.excerpt) {
96
102
  stage = /* @__PURE__ */ jsx("p", { className: `${baseClass}__text`, children: item.excerpt });
97
- } else {
98
- stage = /* @__PURE__ */ jsxs("div", { className: `${baseClass}__empty`, children: [
103
+ }
104
+ if (!hasCustom && stage === null) {
105
+ emptyStage = /* @__PURE__ */ jsxs("div", { className: `${baseClass}__empty`, children: [
99
106
  /* @__PURE__ */ jsx("span", { className: `${baseClass}__empty-mark`, children: renderTypeMark(item.name, item.kind, { typeLabel: item.typeLabel }) }),
100
107
  /* @__PURE__ */ jsx("p", { className: `${baseClass}__empty-title`, children: failed ? failedLabel : noPreviewLabel }),
101
108
  /* @__PURE__ */ jsx("p", { className: `${baseClass}__empty-detail`, children: failed ? item.error ?? failedDescription : [item.name, sizeText].filter(Boolean).join(" · ") }),
@@ -121,6 +128,20 @@ const AttachmentViewer = React.forwardRef(
121
128
  )
122
129
  ] })
123
130
  ] });
131
+ stage = showDocument ? /* @__PURE__ */ jsx(
132
+ DocumentViewer,
133
+ {
134
+ className: `${baseClass}__document`,
135
+ bare: true,
136
+ src: item.fileUrl ?? "",
137
+ title: item.name,
138
+ fileName: item.name,
139
+ mimeType: item.mimeType,
140
+ download: false,
141
+ openInNewTab: false,
142
+ fallback: emptyStage
143
+ }
144
+ ) : emptyStage;
124
145
  }
125
146
  }
126
147
  const viewer = /* @__PURE__ */ jsxs("div", { className: containerClasses, children: [
@@ -102,6 +102,10 @@ export interface AttachmentItem {
102
102
  /** Full-size image for the viewer, when the preview is a thumbnail.
103
103
  Defaults to `previewSrc`. */
104
104
  src?: string;
105
+ /** The file itself, for the viewer to show a PDF or a text file in place
106
+ (through DocumentViewer) and for a picture with no `src`. Distinct
107
+ from `src`, which is always an image. */
108
+ fileUrl?: string;
105
109
  /** Intrinsic width of the preview, to reserve its shape before it loads. */
106
110
  width?: number;
107
111
  /** Intrinsic height of the preview. */
@@ -0,0 +1,12 @@
1
+ /* ============================================
2
+ CURRENCY INPUT
3
+ An Input with the currency as its prefix or
4
+ suffix; the field itself, its affixes and its
5
+ states are Input's. The amount sets in tabular
6
+ figures, so the digits hold still as they are
7
+ grouped on blur.
8
+ ============================================ */
9
+
10
+ .ds-currency-input .ds-input__field {
11
+ font-variant-numeric: tabular-nums;
12
+ }
@@ -0,0 +1,51 @@
1
+ import { default as React } from 'react';
2
+ import { DecimalString } from '../../format/money';
3
+ /** Props owned by CurrencyInput itself; everything else falls through to the visible `<input>`. */
4
+ type CurrencyInputOwnProps = {
5
+ /** Label text above the field. */
6
+ label?: string;
7
+ /** The amount as a decimal string (`"1234.50"`), or `null` for none (controlled). Pair with `onValueChange`. */
8
+ value?: DecimalString | null;
9
+ /** The amount the field starts with (uncontrolled). */
10
+ defaultValue?: DecimalString | null;
11
+ /** Called with the amount as a normalised decimal string as the reader types, or `null` while the field holds no number. Fires alongside the native `onChange`. */
12
+ onValueChange?: (value: DecimalString | null) => void;
13
+ /** The ISO 4217 code of the currency, such as `USD`, `EUR` or `JPY`. Defaults to `USD`. */
14
+ currency?: string;
15
+ /** How the currency shows inside the field: its symbol, its code, or nothing (when the label already says it). The side it sits on follows the locale. */
16
+ currencyDisplay?: 'symbol' | 'code' | 'none';
17
+ /** Digits after the point. Defaults to the currency's own: 0 for JPY, 2 for USD, 3 for KWD. */
18
+ fractionDigits?: number;
19
+ /** Accept a negative amount (a refund, an adjustment). Defaults to false. */
20
+ allowNegative?: boolean;
21
+ /** The smallest amount, as a decimal string. A value below it is raised to it when the field loses focus. */
22
+ min?: DecimalString;
23
+ /** The largest amount, as a decimal string. A value above it is lowered to it when the field loses focus. */
24
+ max?: DecimalString;
25
+ /** How much the Up and Down arrow keys add or take away, as a decimal string. Defaults to `"1"`. */
26
+ step?: DecimalString;
27
+ /** The BCP 47 locale the amount is read and written in, such as `de-DE`. Defaults to the nearest LocaleProvider's, else `en-US`. */
28
+ locale?: string;
29
+ /** Component size (not the native character-width `size` attribute). */
30
+ size?: 'default' | 'compact';
31
+ /** Helper text below the field. */
32
+ helperText?: string;
33
+ /** The error message under the field; setting it marks the field invalid. */
34
+ errorText?: React.ReactNode;
35
+ /** Error state without a message of its own. */
36
+ error?: boolean;
37
+ /** The form field name. The form receives the normalised decimal string through a hidden input, never the formatted text. */
38
+ name?: string;
39
+ /** Additional CSS classes, applied to the wrapper. */
40
+ className?: string;
41
+ };
42
+ export interface CurrencyInputProps extends CurrencyInputOwnProps, Omit<React.ComponentPropsWithRef<'input'>, keyof CurrencyInputOwnProps | 'type' | 'prefix'> {
43
+ }
44
+ /**
45
+ * An amount of money. The value is a decimal string, never a float, so a
46
+ * cent is never lost; the field reads the locale's own marks and a pasted
47
+ * amount in any convention, groups the digits once the reader moves on, and
48
+ * places the currency where the locale writes it.
49
+ */
50
+ export declare function CurrencyInput({ label, value: valueProp, defaultValue, onValueChange, currency, currencyDisplay, fractionDigits, allowNegative, min, max, step, locale: localeProp, size, helperText, errorText, error, name, disabled, className, onChange, onFocus, onBlur, onKeyDown, onPaste, ref, ...rest }: CurrencyInputProps): React.JSX.Element;
51
+ export {};
@@ -0,0 +1,158 @@
1
+ "use client";
2
+ import { jsxs, Fragment, jsx } from "react/jsx-runtime";
3
+ import { useState, useMemo, useRef, useEffect } from "react";
4
+ import { Input } from "../Input/Input.js";
5
+ import { useLocale } from "../../behaviors/LocaleProvider.js";
6
+ import { currencyFractionDigits, addDecimal, subtractDecimal, compareDecimal, parseDecimal } from "../../format/money.js";
7
+ import "./CurrencyInput.css";
8
+ function affixFor(currency, locale, display) {
9
+ if (display === "none") return null;
10
+ const parts = new Intl.NumberFormat(locale, { style: "currency", currency, currencyDisplay: display }).formatToParts(1);
11
+ const at = parts.findIndex((p) => p.type === "currency");
12
+ if (at === -1) return null;
13
+ const firstNumber = parts.findIndex((p) => p.type === "integer");
14
+ return { text: parts[at].value, side: at < firstNumber ? "prefix" : "suffix" };
15
+ }
16
+ const decimalMarkOf = (locale) => new Intl.NumberFormat(locale).formatToParts(1.5).find((p) => p.type === "decimal")?.value ?? ".";
17
+ const editingText = (value, locale) => value == null ? "" : value.replace(".", decimalMarkOf(locale)).replace("-", "−");
18
+ function restingText(value, locale, digits) {
19
+ if (value == null) return "";
20
+ const format = new Intl.NumberFormat(locale, { minimumFractionDigits: digits, maximumFractionDigits: digits });
21
+ return format.format(value);
22
+ }
23
+ const TYPABLE = /^[\p{Nd}.,'’\s٫٬\-−]*$/u;
24
+ function CurrencyInput({
25
+ label,
26
+ value: valueProp,
27
+ defaultValue = null,
28
+ onValueChange,
29
+ currency = "USD",
30
+ currencyDisplay = "symbol",
31
+ fractionDigits,
32
+ allowNegative = false,
33
+ min,
34
+ max,
35
+ step = "1",
36
+ locale: localeProp,
37
+ size = "default",
38
+ helperText,
39
+ errorText,
40
+ error,
41
+ name,
42
+ disabled,
43
+ className = "",
44
+ onChange,
45
+ onFocus,
46
+ onBlur,
47
+ onKeyDown,
48
+ onPaste,
49
+ ref,
50
+ ...rest
51
+ }) {
52
+ const locale = useLocale(localeProp);
53
+ const digits = fractionDigits ?? currencyFractionDigits(currency);
54
+ const controlled = valueProp !== void 0;
55
+ const [uncontrolled, setUncontrolled] = useState(defaultValue);
56
+ const value = controlled ? valueProp : uncontrolled;
57
+ const [focused, setFocused] = useState(false);
58
+ const [text, setText] = useState(() => restingText(value, locale, digits));
59
+ const affix = useMemo(() => affixFor(currency, locale, currencyDisplay), [currency, locale, currencyDisplay]);
60
+ const lastEmitted = useRef(value);
61
+ useEffect(() => {
62
+ if (!focused) setText(restingText(value, locale, digits));
63
+ else if (value !== lastEmitted.current) setText(editingText(value, locale));
64
+ lastEmitted.current = value;
65
+ }, [value, locale, digits]);
66
+ const clamp = (amount) => {
67
+ if (amount == null) return null;
68
+ let next = amount;
69
+ if (!allowNegative && compareDecimal(next, "0") < 0) next = "0";
70
+ if (min !== void 0 && compareDecimal(next, min) < 0) next = min;
71
+ if (max !== void 0 && compareDecimal(next, max) > 0) next = max;
72
+ return parseDecimal(next, { fractionDigits: digits });
73
+ };
74
+ const commit = (amount) => {
75
+ lastEmitted.current = amount;
76
+ if (!controlled) setUncontrolled(amount);
77
+ onValueChange?.(amount);
78
+ };
79
+ const read = (raw) => {
80
+ const parsed = parseDecimal(raw, { locale });
81
+ if (parsed == null) return null;
82
+ return !allowNegative && compareDecimal(parsed, "0") < 0 ? parsed.replace("-", "") : parsed;
83
+ };
84
+ const handleChange = (event) => {
85
+ const raw = event.target.value;
86
+ if (!TYPABLE.test(raw)) return;
87
+ if (!allowNegative && /[-−]/.test(raw)) return;
88
+ setText(raw);
89
+ onChange?.(event);
90
+ const parsed = read(raw);
91
+ if (parsed !== value) commit(parsed);
92
+ };
93
+ const handlePaste = (event) => {
94
+ onPaste?.(event);
95
+ if (event.defaultPrevented) return;
96
+ const pasted = event.clipboardData.getData("text");
97
+ if (TYPABLE.test(pasted)) return;
98
+ event.preventDefault();
99
+ const parsed = read(pasted);
100
+ if (parsed == null) return;
101
+ setText(editingText(parsed, locale));
102
+ commit(parsed);
103
+ };
104
+ const handleFocus = (event) => {
105
+ setFocused(true);
106
+ setText(editingText(value, locale));
107
+ onFocus?.(event);
108
+ };
109
+ const handleBlur = (event) => {
110
+ setFocused(false);
111
+ const settled = clamp(value);
112
+ if (settled !== value) commit(settled);
113
+ setText(restingText(settled, locale, digits));
114
+ onBlur?.(event);
115
+ };
116
+ const handleKeyDown = (event) => {
117
+ onKeyDown?.(event);
118
+ if (event.defaultPrevented || event.key !== "ArrowUp" && event.key !== "ArrowDown") return;
119
+ event.preventDefault();
120
+ const base = value ?? "0";
121
+ const next = clamp(event.key === "ArrowUp" ? addDecimal(base, step) : subtractDecimal(base, step));
122
+ if (next === value) return;
123
+ commit(next);
124
+ setText(editingText(next, locale));
125
+ };
126
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
127
+ /* @__PURE__ */ jsx(
128
+ Input,
129
+ {
130
+ ...rest,
131
+ id: rest.id ?? name,
132
+ ref,
133
+ className: ["ds-currency-input", className].filter(Boolean).join(" "),
134
+ label,
135
+ size,
136
+ type: "text",
137
+ inputMode: "decimal",
138
+ autoComplete: rest.autoComplete ?? "off",
139
+ value: text,
140
+ disabled,
141
+ error,
142
+ helperText,
143
+ errorText,
144
+ prefix: affix?.side === "prefix" ? affix.text : void 0,
145
+ suffix: affix?.side === "suffix" ? affix.text : void 0,
146
+ onChange: handleChange,
147
+ onPaste: handlePaste,
148
+ onFocus: handleFocus,
149
+ onBlur: handleBlur,
150
+ onKeyDown: handleKeyDown
151
+ }
152
+ ),
153
+ name && /* @__PURE__ */ jsx("input", { type: "hidden", name, value: value ?? "", disabled })
154
+ ] });
155
+ }
156
+ export {
157
+ CurrencyInput
158
+ };
@@ -1,3 +1,5 @@
1
+ import { formatMoney } from "../../format/money.js";
2
+ import { formatRelative } from "../../format/relative.js";
1
3
  const TYPE_DEFAULTS = {
2
4
  text: { align: "start", filter: "text", editor: "text" },
3
5
  number: { align: "end", filter: "number", editor: "number" },
@@ -21,26 +23,12 @@ const absoluteDate = (date, format, style) => new Intl.DateTimeFormat(format?.lo
21
23
  dateStyle: style ?? (format?.date && format.date !== "relative" ? format.date : "medium"),
22
24
  timeZone: "UTC"
23
25
  }).format(date);
24
- const MS_PER_DAY = 864e5;
25
- const relativeDate = (date, format, now) => {
26
- const today = Date.UTC(now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate());
27
- const days = Math.round((date.getTime() - today) / MS_PER_DAY);
28
- const rtf = new Intl.RelativeTimeFormat(format?.locale ?? DEFAULT_LOCALE, { numeric: "auto" });
29
- if (Math.abs(days) < 7) return rtf.format(days, "day");
30
- if (Math.abs(days) < 30) return rtf.format(Math.round(days / 7), "week");
31
- if (Math.abs(days) < 365) return rtf.format(Math.round(days / 30), "month");
32
- return rtf.format(Math.round(days / 365), "year");
33
- };
26
+ const relativeDate = (date, format, now) => formatRelative(date, { now, locale: format?.locale ?? DEFAULT_LOCALE, minUnit: "day" });
34
27
  const formatNumber = (type, value, format) => {
35
28
  const locale = format?.locale ?? DEFAULT_LOCALE;
36
29
  const digits = format?.fractionDigits;
37
30
  if (type === "currency")
38
- return new Intl.NumberFormat(locale, {
39
- style: "currency",
40
- currency: format?.currency ?? "USD",
41
- minimumFractionDigits: digits ?? 0,
42
- maximumFractionDigits: digits ?? 0
43
- }).format(value);
31
+ return formatMoney(value, { currency: format?.currency ?? "USD", locale, fractionDigits: digits ?? 0 });
44
32
  if (type === "progress")
45
33
  return new Intl.NumberFormat(locale, {
46
34
  style: "percent",
@@ -14,6 +14,8 @@ type DatePickerOwnProps = {
14
14
  max?: string;
15
15
  /** Callback when a date is selected */
16
16
  onDateSelect?: (date: string) => void;
17
+ /** Mark further days unavailable, beyond `min` and `max`: weekends, holidays, booked days. Given each day as a `YYYY-MM-DD` string; focus skips past none of them, but none can be chosen. */
18
+ isDateDisabled?: (date: string) => boolean;
17
19
  /** Accessible name of the previous-month button. */
18
20
  previousLabel?: string;
19
21
  /** Accessible name of the next-month button. */