@partrunner-ai/ui 2.1.0 → 2.2.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.
package/dist/index.js CHANGED
@@ -4038,6 +4038,7 @@ var TableRoot = forwardRef(function TableRoot2({
4038
4038
  density = "default",
4039
4039
  stickyFirstColumn = false,
4040
4040
  maxHeight,
4041
+ bare = false,
4041
4042
  className,
4042
4043
  children,
4043
4044
  "aria-label": ariaLabel,
@@ -4072,6 +4073,7 @@ var TableRoot = forwardRef(function TableRoot2({
4072
4073
  className: classes(
4073
4074
  "pr-table__scroll",
4074
4075
  "pr-table__scroll--compound",
4076
+ bare && "pr-table__scroll--bare",
4075
4077
  maxHeight !== void 0 && "pr-table__scroll--capped",
4076
4078
  containerClassName
4077
4079
  ),
@@ -4781,6 +4783,7 @@ function Popover({
4781
4783
  defaultOpen,
4782
4784
  onOpenChange,
4783
4785
  maxHeight,
4786
+ minimumSpace,
4784
4787
  matchTriggerWidth = false
4785
4788
  }) {
4786
4789
  const align = useMemo(() => alignFromChildren2(children), [children]);
@@ -4790,7 +4793,8 @@ function Popover({
4790
4793
  onOpenChange,
4791
4794
  align: ANCHOR_ALIGN2[align],
4792
4795
  matchTriggerWidth,
4793
- maxHeight
4796
+ maxHeight,
4797
+ minimumSpace
4794
4798
  });
4795
4799
  const close = useCallback(
4796
4800
  (options) => {
@@ -5624,6 +5628,31 @@ var Toolbar = forwardRef(function Toolbar2({ className, ...rest }, ref) {
5624
5628
  }
5625
5629
  );
5626
5630
  });
5631
+ var ToolbarGroup = forwardRef(function ToolbarGroup2({ className, ...rest }, ref) {
5632
+ return /* @__PURE__ */ jsx(
5633
+ "div",
5634
+ {
5635
+ ref,
5636
+ ...rest,
5637
+ "data-slot": "toolbar-group",
5638
+ className: ["pr-toolbar__group", className].filter(Boolean).join(" ")
5639
+ }
5640
+ );
5641
+ });
5642
+ var ToolbarSpacer = forwardRef(
5643
+ function ToolbarSpacer2({ className, ...rest }, ref) {
5644
+ return /* @__PURE__ */ jsx(
5645
+ "div",
5646
+ {
5647
+ ref,
5648
+ ...rest,
5649
+ "aria-hidden": true,
5650
+ "data-slot": "toolbar-spacer",
5651
+ className: ["pr-toolbar__spacer", className].filter(Boolean).join(" ")
5652
+ }
5653
+ );
5654
+ }
5655
+ );
5627
5656
  var IconButton = forwardRef(
5628
5657
  function IconButton2({
5629
5658
  label,
@@ -5712,6 +5741,598 @@ function ConfirmDialog({
5712
5741
  );
5713
5742
  }
5714
5743
 
5715
- export { AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogMedia, AlertDialogRoot, AlertDialogTitle, AlertDialogTrigger, AmbientBackground, Badge, Button, Calendar, Card, CardContent, CardDescription, CardHeader, CardTitle, Checkbox, CheckboxGroup, Combobox, ConfirmDialog, CopyField, DataTable, DatePicker, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogLayer, DialogRoot, DialogTitle, DialogTrigger, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuTrigger, EmptyState, FileDropzone, FormField, IconButton, Input, Label, MultiSelect, NavigationTabs, OtpInput, PageHeader, Pagination, Popover, PopoverContent, PopoverDescription, PopoverHeader, PopoverTitle, PopoverTrigger, ProgressBar, ProgressDots, ProgressRing, RadioGroup, RichSelect, RichSelectContent, RichSelectEmpty, RichSelectGroup, RichSelectItem, RichSelectLabel, RichSelectSearch, RichSelectSeparator, RichSelectTrigger, RichSelectValue, Select, Separator, SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetRoot, SheetTitle, SheetTrigger, Skeleton, Slot, Spinner, StatTile, Stepper, Switch, Table2 as Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow, Tabs, TabsContent, TabsList, TabsTrigger, Textarea, Toolbar, Tooltip, ValidationSummary, formatCalendarDate, isCalendarDate, menuStyle, parseCalendarDate, registerDialogLayerPortal, resolveActiveNavigationHref, serializeCalendarDate, useAnchoredMenu };
5744
+ // src/tone.ts
5745
+ var TINT_TONES = [
5746
+ "yellow",
5747
+ "blue",
5748
+ "amber",
5749
+ "purple",
5750
+ "green",
5751
+ "rose"
5752
+ ];
5753
+ function toneFromString(seed, palette = TINT_TONES) {
5754
+ if (palette.length === 0) return "blue";
5755
+ let hash = 2166136261;
5756
+ for (let index = 0; index < seed.length; index += 1) {
5757
+ hash ^= seed.charCodeAt(index);
5758
+ hash = Math.imul(hash, 16777619) >>> 0;
5759
+ }
5760
+ return palette[hash % palette.length] ?? palette[0];
5761
+ }
5762
+ var StatusDot = forwardRef(function StatusDot2({ tone, size = "sm", label, className, ...rest }, ref) {
5763
+ return /* @__PURE__ */ jsx(
5764
+ "span",
5765
+ {
5766
+ ref,
5767
+ ...rest,
5768
+ role: label ? "img" : void 0,
5769
+ "aria-label": label,
5770
+ "aria-hidden": label ? void 0 : true,
5771
+ "data-slot": "status-dot",
5772
+ className: ["pr-status-dot", `pr-status-dot--${tone}`, `pr-status-dot--${size}`, className].filter(Boolean).join(" ")
5773
+ }
5774
+ );
5775
+ });
5776
+ var ICON_PX = { sm: 14, md: 18, lg: 22 };
5777
+ var IconTile = forwardRef(function IconTile2({ icon: Icon, tone = "neutral", size = "md", className, ...rest }, ref) {
5778
+ return /* @__PURE__ */ jsx(
5779
+ "span",
5780
+ {
5781
+ ref,
5782
+ ...rest,
5783
+ "aria-hidden": true,
5784
+ "data-slot": "icon-tile",
5785
+ className: ["pr-icon-tile", `pr-icon-tile--${tone}`, `pr-icon-tile--${size}`, className].filter(Boolean).join(" "),
5786
+ children: /* @__PURE__ */ jsx(Icon, { size: ICON_PX[size], strokeWidth: 2, "aria-hidden": true })
5787
+ }
5788
+ );
5789
+ });
5790
+ function avatarInitials(name, locale) {
5791
+ const words = name.trim().split(/\s+/).filter(Boolean).slice(0, 2);
5792
+ return words.map((word) => {
5793
+ const first = Array.from(word)[0] ?? "";
5794
+ return locale ? first.toLocaleUpperCase(locale) : first.toLocaleUpperCase();
5795
+ }).join("");
5796
+ }
5797
+ var Avatar = forwardRef(function Avatar2({ name, src, size = "sm", tone, decorative = false, locale, className, ...rest }, ref) {
5798
+ const [imageFailed, setImageFailed] = useState(false);
5799
+ useEffect(() => {
5800
+ setImageFailed(false);
5801
+ }, [src]);
5802
+ const resolvedTone = tone ?? toneFromString(name);
5803
+ const showImage = Boolean(src) && !imageFailed;
5804
+ return /* @__PURE__ */ jsx(
5805
+ "span",
5806
+ {
5807
+ ref,
5808
+ ...rest,
5809
+ role: decorative ? void 0 : "img",
5810
+ "aria-label": decorative ? void 0 : name,
5811
+ "aria-hidden": decorative ? true : void 0,
5812
+ "data-slot": "avatar",
5813
+ className: ["pr-avatar", `pr-avatar--${resolvedTone}`, `pr-avatar--${size}`, className].filter(Boolean).join(" "),
5814
+ children: showImage ? /* @__PURE__ */ jsx(
5815
+ "img",
5816
+ {
5817
+ className: "pr-avatar__image",
5818
+ src,
5819
+ alt: "",
5820
+ onError: () => setImageFailed(true)
5821
+ }
5822
+ ) : /* @__PURE__ */ jsx("span", { className: "pr-avatar__initials", "aria-hidden": true, children: avatarInitials(name, locale) })
5823
+ }
5824
+ );
5825
+ });
5826
+ var Page = forwardRef(function Page2({ width = "default", className, ...rest }, ref) {
5827
+ return /* @__PURE__ */ jsx(
5828
+ "div",
5829
+ {
5830
+ ref,
5831
+ ...rest,
5832
+ "data-slot": "page",
5833
+ className: ["pr-page", width === "default" ? null : `pr-page--${width}`, className].filter(Boolean).join(" ")
5834
+ }
5835
+ );
5836
+ });
5837
+ var SectionHeading = forwardRef(
5838
+ function SectionHeading2({ eyebrow, title, description, actions, headingLevel = 2, className, ...rest }, ref) {
5839
+ const Heading = headingLevel === 3 ? "h3" : "h2";
5840
+ return /* @__PURE__ */ jsxs(
5841
+ "header",
5842
+ {
5843
+ ref,
5844
+ ...rest,
5845
+ "data-slot": "section-heading",
5846
+ className: ["pr-section-heading", className].filter(Boolean).join(" "),
5847
+ children: [
5848
+ /* @__PURE__ */ jsxs("div", { className: "pr-section-heading__text", children: [
5849
+ eyebrow != null && eyebrow !== false ? /* @__PURE__ */ jsx("p", { className: "pr-section-heading__eyebrow", children: eyebrow }) : null,
5850
+ /* @__PURE__ */ jsx(Heading, { className: "pr-section-heading__title", children: title }),
5851
+ description != null ? /* @__PURE__ */ jsx("p", { className: "pr-section-heading__description", children: description }) : null
5852
+ ] }),
5853
+ actions != null ? /* @__PURE__ */ jsx("div", { className: "pr-section-heading__actions", children: actions }) : null
5854
+ ]
5855
+ }
5856
+ );
5857
+ }
5858
+ );
5859
+ var StatTileGrid = forwardRef(function StatTileGrid2({ columns = 4, className, ...rest }, ref) {
5860
+ return /* @__PURE__ */ jsx(
5861
+ "div",
5862
+ {
5863
+ ref,
5864
+ ...rest,
5865
+ "data-slot": "stat-tile-grid",
5866
+ className: ["pr-stat-grid", `pr-stat-grid--cols-${columns}`, className].filter(Boolean).join(" ")
5867
+ }
5868
+ );
5869
+ });
5870
+ var SearchField = forwardRef(function SearchField2({ inputSize = "sm", fullWidth = false, containerClassName, ...rest }, ref) {
5871
+ return /* @__PURE__ */ jsx(
5872
+ Input,
5873
+ {
5874
+ ref,
5875
+ type: "search",
5876
+ inputSize,
5877
+ leading: /* @__PURE__ */ jsx(Search, { size: 14, "aria-hidden": true }),
5878
+ fullWidth,
5879
+ containerClassName: [
5880
+ "pr-search-field",
5881
+ fullWidth ? "pr-search-field--block" : null,
5882
+ containerClassName
5883
+ ].filter(Boolean).join(" "),
5884
+ ...rest
5885
+ }
5886
+ );
5887
+ });
5888
+ var FilterChip = forwardRef(function FilterChip2({
5889
+ active = false,
5890
+ count,
5891
+ tone = "neutral",
5892
+ dot = false,
5893
+ icon: Icon,
5894
+ type = "button",
5895
+ className,
5896
+ children,
5897
+ ...rest
5898
+ }, ref) {
5899
+ return /* @__PURE__ */ jsxs(
5900
+ "button",
5901
+ {
5902
+ ref,
5903
+ ...rest,
5904
+ type,
5905
+ "aria-pressed": active,
5906
+ "data-slot": "filter-chip",
5907
+ "data-state": active ? "active" : "inactive",
5908
+ className: ["pr-filter-chip", className].filter(Boolean).join(" "),
5909
+ children: [
5910
+ dot ? /* @__PURE__ */ jsx(StatusDot, { tone, className: "pr-filter-chip__dot" }) : Icon ? /* @__PURE__ */ jsx(Icon, { size: 14, "aria-hidden": true, className: "pr-filter-chip__icon" }) : null,
5911
+ /* @__PURE__ */ jsx("span", { className: "pr-filter-chip__label", children }),
5912
+ typeof count === "number" ? /* @__PURE__ */ jsx("span", { className: "pr-filter-chip__count", children: count }) : null
5913
+ ]
5914
+ }
5915
+ );
5916
+ });
5917
+ var FilterChipRow = forwardRef(function FilterChipRow2({ className, ...rest }, ref) {
5918
+ return /* @__PURE__ */ jsx(
5919
+ "div",
5920
+ {
5921
+ ref,
5922
+ role: "group",
5923
+ ...rest,
5924
+ "data-slot": "filter-chip-row",
5925
+ className: ["pr-filter-chip-row", className].filter(Boolean).join(" ")
5926
+ }
5927
+ );
5928
+ });
5929
+ function SegmentedControl({
5930
+ value,
5931
+ onChange,
5932
+ options,
5933
+ size = "md",
5934
+ fullWidth = false,
5935
+ className,
5936
+ id,
5937
+ dir = "ltr",
5938
+ "aria-label": ariaLabel,
5939
+ "aria-labelledby": ariaLabelledBy
5940
+ }) {
5941
+ const generatedId = useId();
5942
+ const groupId = id ?? generatedId;
5943
+ const refs = useRef(/* @__PURE__ */ new Map());
5944
+ const enabled = options.filter((option) => !option.disabled);
5945
+ const checked = enabled.find((option) => option.value === value) ?? null;
5946
+ const focusable = checked ?? enabled[0] ?? null;
5947
+ const allDisabled = enabled.length === 0;
5948
+ const select = (option) => {
5949
+ refs.current.get(option.value)?.focus();
5950
+ if (option.value !== value) onChange(option.value);
5951
+ };
5952
+ const step = (from, delta) => {
5953
+ if (enabled.length === 0) return;
5954
+ const index = enabled.findIndex((option) => option.value === from);
5955
+ const next = enabled[(index + delta + enabled.length) % enabled.length];
5956
+ if (next) select(next);
5957
+ };
5958
+ const onKeyDown = (event, option) => {
5959
+ const forward = dir === "rtl" ? "ArrowLeft" : "ArrowRight";
5960
+ const backward = dir === "rtl" ? "ArrowRight" : "ArrowLeft";
5961
+ if (event.key === forward || event.key === "ArrowDown") {
5962
+ event.preventDefault();
5963
+ step(option.value, 1);
5964
+ } else if (event.key === backward || event.key === "ArrowUp") {
5965
+ event.preventDefault();
5966
+ step(option.value, -1);
5967
+ } else if (event.key === "Home") {
5968
+ event.preventDefault();
5969
+ if (enabled[0]) select(enabled[0]);
5970
+ } else if (event.key === "End") {
5971
+ event.preventDefault();
5972
+ const last = enabled[enabled.length - 1];
5973
+ if (last) select(last);
5974
+ }
5975
+ };
5976
+ return /* @__PURE__ */ jsx(
5977
+ "div",
5978
+ {
5979
+ id: groupId,
5980
+ role: "radiogroup",
5981
+ "aria-label": ariaLabel,
5982
+ "aria-labelledby": ariaLabelledBy,
5983
+ "aria-disabled": allDisabled || void 0,
5984
+ dir,
5985
+ "data-slot": "segmented-control",
5986
+ className: [
5987
+ "pr-segmented",
5988
+ `pr-segmented--${size}`,
5989
+ fullWidth ? "pr-segmented--block" : null,
5990
+ className
5991
+ ].filter(Boolean).join(" "),
5992
+ children: options.map((option) => {
5993
+ const isChecked = checked?.value === option.value;
5994
+ const Icon = option.icon;
5995
+ return /* @__PURE__ */ jsxs(
5996
+ "button",
5997
+ {
5998
+ ref: (node) => {
5999
+ if (node) refs.current.set(option.value, node);
6000
+ else refs.current.delete(option.value);
6001
+ },
6002
+ id: `${groupId}-${option.value}`,
6003
+ type: "button",
6004
+ role: "radio",
6005
+ "aria-checked": isChecked,
6006
+ tabIndex: !option.disabled && focusable?.value === option.value ? 0 : -1,
6007
+ disabled: option.disabled,
6008
+ "data-slot": "segmented-option",
6009
+ "data-state": isChecked ? "checked" : "unchecked",
6010
+ className: "pr-segmented__option",
6011
+ onClick: () => {
6012
+ if (!option.disabled) select(option);
6013
+ },
6014
+ onKeyDown: (event) => onKeyDown(event, option),
6015
+ children: [
6016
+ Icon ? /* @__PURE__ */ jsx(Icon, { size: 14, "aria-hidden": true, className: "pr-segmented__icon" }) : null,
6017
+ /* @__PURE__ */ jsx("span", { className: "pr-segmented__label", children: option.label }),
6018
+ typeof option.count === "number" ? /* @__PURE__ */ jsx("span", { className: "pr-segmented__count", children: option.count }) : null
6019
+ ]
6020
+ },
6021
+ option.value
6022
+ );
6023
+ })
6024
+ }
6025
+ );
6026
+ }
6027
+ var TableFrame = forwardRef(function TableFrame2({
6028
+ title,
6029
+ description,
6030
+ count,
6031
+ countLabel,
6032
+ icon: Icon,
6033
+ actions,
6034
+ footer,
6035
+ shadow = true,
6036
+ className,
6037
+ children,
6038
+ ...rest
6039
+ }, ref) {
6040
+ const hasHeader = title != null || description != null || actions != null;
6041
+ const showCount = title != null && typeof count === "number";
6042
+ const heading = hasHeader ? /* @__PURE__ */ jsxs("span", { className: "pr-table-frame__title", children: [
6043
+ Icon ? /* @__PURE__ */ jsx(Icon, { size: 16, "aria-hidden": true, className: "pr-table-frame__icon" }) : null,
6044
+ title != null ? /* @__PURE__ */ jsx("span", { className: "pr-table-frame__title-text", children: title }) : null,
6045
+ showCount ? /* @__PURE__ */ jsx(
6046
+ Badge,
6047
+ {
6048
+ tone: "neutral",
6049
+ size: "sm",
6050
+ className: "pr-table-frame__count",
6051
+ role: countLabel ? "img" : void 0,
6052
+ "aria-label": countLabel ? countLabel(count) : void 0,
6053
+ children: count
6054
+ }
6055
+ ) : null
6056
+ ] }) : null;
6057
+ return /* @__PURE__ */ jsxs(
6058
+ Card,
6059
+ {
6060
+ ref,
6061
+ padding: "md",
6062
+ shadow,
6063
+ ...rest,
6064
+ "data-slot": "table-frame",
6065
+ className: ["pr-table-frame", className].filter(Boolean).join(" "),
6066
+ children: [
6067
+ hasHeader ? /* @__PURE__ */ jsx(
6068
+ CardHeader,
6069
+ {
6070
+ className: "pr-table-frame__header",
6071
+ title: title != null || Icon || showCount ? heading : void 0,
6072
+ description,
6073
+ actions
6074
+ }
6075
+ ) : null,
6076
+ /* @__PURE__ */ jsx(CardContent, { bleed: true, className: "pr-table-frame__body", children }),
6077
+ footer != null ? /* @__PURE__ */ jsx("div", { className: "pr-table-frame__footer", children: footer }) : null
6078
+ ]
6079
+ }
6080
+ );
6081
+ });
6082
+ var TableSkeleton = forwardRef(function TableSkeleton2({ rows = 6, columns = 5, label, className, ...rest }, ref) {
6083
+ return /* @__PURE__ */ jsxs(
6084
+ "div",
6085
+ {
6086
+ ref,
6087
+ role: "status",
6088
+ "aria-live": "polite",
6089
+ "aria-busy": "true",
6090
+ ...rest,
6091
+ "data-slot": "table-skeleton",
6092
+ className: ["pr-table-skeleton", className].filter(Boolean).join(" "),
6093
+ children: [
6094
+ /* @__PURE__ */ jsx("span", { className: "pr-visually-hidden", children: label }),
6095
+ /* @__PURE__ */ jsx("div", { className: "pr-table__skeleton", "aria-hidden": true, children: Array.from({ length: rows }, (_, row) => /* @__PURE__ */ jsx("div", { className: "pr-table__skeleton-row", children: Array.from({ length: columns }, (_2, column) => /* @__PURE__ */ jsx("div", { className: "pr-table__skeleton-cell" }, column)) }, row)) })
6096
+ ]
6097
+ }
6098
+ );
6099
+ });
6100
+ var EMPTY_DATE_RANGE = { from: "", to: "" };
6101
+ function isSameDateRange(a, b) {
6102
+ return a.from === b.from && a.to === b.to;
6103
+ }
6104
+ function isValidDateRange(value, limits = {}) {
6105
+ const from = value.from ? parseCalendarDate(value.from) : null;
6106
+ const to = value.to ? parseCalendarDate(value.to) : null;
6107
+ if (value.from && !from) return false;
6108
+ if (value.to && !to) return false;
6109
+ if (to && !from) return false;
6110
+ if (from && to && from.getTime() > to.getTime()) return false;
6111
+ const min = limits.min ? parseCalendarDate(limits.min) : null;
6112
+ const max = limits.max ? parseCalendarDate(limits.max) : null;
6113
+ for (const bound of [from, to]) {
6114
+ if (!bound) continue;
6115
+ if (min && bound.getTime() < min.getTime()) return false;
6116
+ if (max && bound.getTime() > max.getTime()) return false;
6117
+ }
6118
+ return true;
6119
+ }
6120
+ var DEFAULT_LOCALE = "es-MX";
6121
+ function formatDateRange(range, locale, labels) {
6122
+ if (!isValidDateRange(range)) return labels.allTime;
6123
+ const from = range.from ? parseCalendarDate(range.from) : null;
6124
+ const to = range.to ? parseCalendarDate(range.to) : null;
6125
+ if (!from) return labels.allTime;
6126
+ const resolved = locale ?? DEFAULT_LOCALE;
6127
+ const dayMonth = new Intl.DateTimeFormat(resolved, {
6128
+ day: "numeric",
6129
+ month: "short",
6130
+ timeZone: "UTC"
6131
+ });
6132
+ const dayMonthYear = new Intl.DateTimeFormat(resolved, {
6133
+ day: "numeric",
6134
+ month: "short",
6135
+ year: "numeric",
6136
+ timeZone: "UTC"
6137
+ });
6138
+ if (!to) return `${labels.from} ${dayMonthYear.format(from)}`;
6139
+ const sameYear = from.getUTCFullYear() === to.getUTCFullYear();
6140
+ return `${(sameYear ? dayMonth : dayMonthYear).format(from)} \u2013 ${dayMonthYear.format(to)}`;
6141
+ }
6142
+ function toCalendarRange(value) {
6143
+ return { start: value.from || null, end: value.to || null };
6144
+ }
6145
+ function fromCalendarRange(range) {
6146
+ return { from: range.start ?? "", to: range.end ?? "" };
6147
+ }
6148
+ function DateRangeFilter({
6149
+ value,
6150
+ onChange,
6151
+ presets,
6152
+ labels,
6153
+ locale,
6154
+ size = "sm",
6155
+ min,
6156
+ max,
6157
+ calendar,
6158
+ className,
6159
+ id: providedId,
6160
+ "aria-label": ariaLabel
6161
+ }) {
6162
+ const generatedId = useId();
6163
+ const id = providedId ?? generatedId;
6164
+ const triggerRef = useRef(null);
6165
+ const [open, setOpen] = useState(false);
6166
+ const [draft, setDraft] = useState(value);
6167
+ const limits = useMemo(() => ({ min, max }), [min, max]);
6168
+ const valueValid = isValidDateRange(value, limits);
6169
+ const isEmpty = valueValid && !value.from && !value.to;
6170
+ const presetStates = useMemo(
6171
+ () => presets.map((preset) => ({
6172
+ preset,
6173
+ valid: isValidDateRange(preset.range, limits)
6174
+ })),
6175
+ [presets, limits]
6176
+ );
6177
+ const activePreset = useMemo(
6178
+ () => valueValid ? presetStates.find(({ preset, valid }) => valid && isSameDateRange(preset.range, value))?.preset : void 0,
6179
+ [presetStates, value, valueValid]
6180
+ );
6181
+ const triggerLabel = !valueValid ? labels.allTime : isEmpty ? labels.allTime : activePreset?.label ?? formatDateRange(value, locale, labels);
6182
+ const handleOpenChange = useCallback(
6183
+ (next) => {
6184
+ if (next) setDraft(isValidDateRange(value, limits) ? value : EMPTY_DATE_RANGE);
6185
+ setOpen(next);
6186
+ },
6187
+ [limits, value]
6188
+ );
6189
+ const commit = (next) => {
6190
+ if (!isValidDateRange(next, limits)) return;
6191
+ if (!isSameDateRange(next, value)) onChange(next);
6192
+ setOpen(false);
6193
+ queueMicrotask(() => triggerRef.current?.focus());
6194
+ };
6195
+ const draftValid = isValidDateRange(draft, limits);
6196
+ const draftFrom = draft.from ? parseCalendarDate(draft.from) : null;
6197
+ const draftTo = draft.to ? parseCalendarDate(draft.to) : null;
6198
+ const resolvedLocale = locale ?? DEFAULT_LOCALE;
6199
+ const boundFormat = new Intl.DateTimeFormat(resolvedLocale, {
6200
+ day: "numeric",
6201
+ month: "short",
6202
+ year: "numeric",
6203
+ timeZone: "UTC"
6204
+ });
6205
+ return /* @__PURE__ */ jsx(
6206
+ "div",
6207
+ {
6208
+ className: ["pr-date-range", className].filter(Boolean).join(" "),
6209
+ "data-slot": "date-range-filter",
6210
+ children: /* @__PURE__ */ jsxs(Popover, { open, onOpenChange: handleOpenChange, maxHeight: 520, minimumSpace: 400, children: [
6211
+ /* @__PURE__ */ jsxs(
6212
+ PopoverTrigger,
6213
+ {
6214
+ ref: triggerRef,
6215
+ id,
6216
+ "aria-label": ariaLabel,
6217
+ "data-state": open ? "open" : "closed",
6218
+ "data-active": valueValid && !isEmpty ? "" : void 0,
6219
+ "data-invalid": valueValid ? void 0 : "",
6220
+ className: [
6221
+ "pr-date-range__trigger",
6222
+ `pr-date-range__trigger--${size}`,
6223
+ valueValid && !isEmpty ? "pr-date-range__trigger--active" : null,
6224
+ open ? "pr-date-range__trigger--open" : null
6225
+ ].filter(Boolean).join(" "),
6226
+ children: [
6227
+ /* @__PURE__ */ jsx(CalendarDays, { size: 14, "aria-hidden": true, className: "pr-date-range__icon" }),
6228
+ /* @__PURE__ */ jsx("span", { className: "pr-date-range__value", children: triggerLabel }),
6229
+ /* @__PURE__ */ jsx(ChevronDown, { size: 14, "aria-hidden": true, className: "pr-date-range__chevron" })
6230
+ ]
6231
+ }
6232
+ ),
6233
+ /* @__PURE__ */ jsxs(
6234
+ PopoverContent,
6235
+ {
6236
+ align: "start",
6237
+ padding: "none",
6238
+ "aria-label": labels.dialog,
6239
+ className: "pr-date-range__content",
6240
+ children: [
6241
+ /* @__PURE__ */ jsxs("div", { role: "group", "aria-label": ariaLabel, className: "pr-date-range__presets", children: [
6242
+ /* @__PURE__ */ jsx(PresetOption, { active: isEmpty, onSelect: () => commit(EMPTY_DATE_RANGE), children: labels.allTime }),
6243
+ presetStates.map(({ preset, valid }) => /* @__PURE__ */ jsx(
6244
+ PresetOption,
6245
+ {
6246
+ active: activePreset?.id === preset.id,
6247
+ disabled: !valid,
6248
+ onSelect: () => commit(preset.range),
6249
+ children: preset.label
6250
+ },
6251
+ preset.id
6252
+ ))
6253
+ ] }),
6254
+ /* @__PURE__ */ jsxs("div", { className: "pr-date-range__custom", children: [
6255
+ /* @__PURE__ */ jsx("p", { className: "pr-date-range__custom-title", id: `${id}-custom`, children: labels.custom }),
6256
+ /* @__PURE__ */ jsxs("dl", { className: "pr-date-range__bounds", children: [
6257
+ /* @__PURE__ */ jsxs("div", { className: "pr-date-range__bound", children: [
6258
+ /* @__PURE__ */ jsx("dt", { children: labels.from }),
6259
+ /* @__PURE__ */ jsx("dd", { children: draftFrom ? boundFormat.format(draftFrom) : "\u2014" })
6260
+ ] }),
6261
+ /* @__PURE__ */ jsxs("div", { className: "pr-date-range__bound", children: [
6262
+ /* @__PURE__ */ jsx("dt", { children: labels.to }),
6263
+ /* @__PURE__ */ jsx("dd", { children: draftTo ? boundFormat.format(draftTo) : "\u2014" })
6264
+ ] })
6265
+ ] }),
6266
+ /* @__PURE__ */ jsx(
6267
+ Calendar,
6268
+ {
6269
+ mode: "range",
6270
+ value: toCalendarRange(draft),
6271
+ onValueChange: (next) => setDraft(fromCalendarRange(next)),
6272
+ locale: resolvedLocale,
6273
+ min,
6274
+ max,
6275
+ "aria-labelledby": `${id}-custom`,
6276
+ className: "pr-date-range__calendar",
6277
+ ...calendar
6278
+ }
6279
+ ),
6280
+ /* @__PURE__ */ jsxs("div", { className: "pr-date-range__actions", children: [
6281
+ /* @__PURE__ */ jsx(
6282
+ Button,
6283
+ {
6284
+ type: "button",
6285
+ variant: "ghost",
6286
+ size: "sm",
6287
+ disabled: !draft.from && !draft.to,
6288
+ onClick: () => setDraft(EMPTY_DATE_RANGE),
6289
+ children: labels.clear
6290
+ }
6291
+ ),
6292
+ /* @__PURE__ */ jsx(
6293
+ Button,
6294
+ {
6295
+ type: "button",
6296
+ variant: "secondary",
6297
+ size: "sm",
6298
+ disabled: !draftValid,
6299
+ onClick: () => commit(draft),
6300
+ children: labels.apply
6301
+ }
6302
+ )
6303
+ ] })
6304
+ ] })
6305
+ ]
6306
+ }
6307
+ )
6308
+ ] })
6309
+ }
6310
+ );
6311
+ }
6312
+ function PresetOption({
6313
+ active,
6314
+ disabled = false,
6315
+ onSelect,
6316
+ children
6317
+ }) {
6318
+ return /* @__PURE__ */ jsxs(
6319
+ "button",
6320
+ {
6321
+ type: "button",
6322
+ "aria-pressed": active,
6323
+ "aria-disabled": disabled || void 0,
6324
+ disabled,
6325
+ "data-state": active ? "active" : "inactive",
6326
+ className: "pr-date-range__preset",
6327
+ onClick: disabled ? void 0 : onSelect,
6328
+ children: [
6329
+ /* @__PURE__ */ jsx("span", { className: "pr-date-range__preset-label", children }),
6330
+ active ? /* @__PURE__ */ jsx(Check, { size: 14, "aria-hidden": true, className: "pr-date-range__check" }) : null
6331
+ ]
6332
+ }
6333
+ );
6334
+ }
6335
+
6336
+ export { AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogMedia, AlertDialogRoot, AlertDialogTitle, AlertDialogTrigger, AmbientBackground, Avatar, Badge, Button, Calendar, Card, CardContent, CardDescription, CardHeader, CardTitle, Checkbox, CheckboxGroup, Combobox, ConfirmDialog, CopyField, DataTable, DatePicker, DateRangeFilter, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogLayer, DialogRoot, DialogTitle, DialogTrigger, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuTrigger, EMPTY_DATE_RANGE, EmptyState, FileDropzone, FilterChip, FilterChipRow, FormField, IconButton, IconTile, Input, Label, MultiSelect, NavigationTabs, OtpInput, Page, PageHeader, Pagination, Popover, PopoverContent, PopoverDescription, PopoverHeader, PopoverTitle, PopoverTrigger, ProgressBar, ProgressDots, ProgressRing, RadioGroup, RichSelect, RichSelectContent, RichSelectEmpty, RichSelectGroup, RichSelectItem, RichSelectLabel, RichSelectSearch, RichSelectSeparator, RichSelectTrigger, RichSelectValue, SearchField, SectionHeading, SegmentedControl, Select, Separator, SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetRoot, SheetTitle, SheetTrigger, Skeleton, Slot, Spinner, StatTile, StatTileGrid, StatusDot, Stepper, Switch, TINT_TONES, Table2 as Table, TableBody, TableCaption, TableCell, TableFooter, TableFrame, TableHead, TableHeader, TableRow, TableSkeleton, Tabs, TabsContent, TabsList, TabsTrigger, Textarea, Toolbar, ToolbarGroup, ToolbarSpacer, Tooltip, ValidationSummary, avatarInitials, formatCalendarDate, formatDateRange, isCalendarDate, isSameDateRange, isValidDateRange, menuStyle, parseCalendarDate, registerDialogLayerPortal, resolveActiveNavigationHref, serializeCalendarDate, toneFromString, useAnchoredMenu };
5716
6337
  //# sourceMappingURL=index.js.map
5717
6338
  //# sourceMappingURL=index.js.map