@mediaradar/design-components 0.41.0 → 0.43.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/approved-components.json +1 -1
- package/dist/index.cjs +25 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +50 -3
- package/dist/index.d.ts +50 -3
- package/dist/index.js +25 -12
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -481,6 +481,11 @@ declare function CheckBoxBox({ checked, indeterminate, disabled, className }: Ch
|
|
|
481
481
|
* `granularity="month"` rounds every range out to whole months (presets,
|
|
482
482
|
* clicked days and Apply alike), shows months on the trigger, and adds a
|
|
483
483
|
* "Data is monthly" note beside Cancel/Apply.
|
|
484
|
+
* `formatDate` / `formatRange` write every day-level date the component shows
|
|
485
|
+
* (dates line, a custom span on the chip, Start/End fields, compare-to dates),
|
|
486
|
+
* e.g. to follow a person's date-format setting. What `onChange` and `onApply`
|
|
487
|
+
* report keeps the canonical "Nov 14, 2026" form, since apps parse it.
|
|
488
|
+
* Month-level labels ("Nov 2025") have no day to order and stay as they are.
|
|
484
489
|
* @a11y Trigger is a <button> with aria-expanded and an aria-label from the
|
|
485
490
|
* caption; the panel is role="dialog" and Escape closes it. Focus is not
|
|
486
491
|
* moved into the panel, so it is reached by tabbing.
|
|
@@ -492,6 +497,7 @@ declare function CheckBoxBox({ checked, indeterminate, disabled, className }: Ch
|
|
|
492
497
|
* <DateRangeFilter caption="Dates" showDates shortDates placement="right" />
|
|
493
498
|
* <DateRangeFilter presetSet="creativeIntel" defaultValue="Last 7 days" onChange={setRange} />
|
|
494
499
|
* <DateRangeFilter presetSet="creativeIntel" value={preset} range={[start, end]} onChange={setPreset} onRangeChange={(s, e) => setRange({ start: s, end: e })} />
|
|
500
|
+
* <DateRangeFilter caption="Dates" showDates formatDate={formatDate} formatRange={formatDateRange} />
|
|
495
501
|
* <DateRangeFilter presetSet="creativeIntel" excludePresets={["Rolling 3 months", "Rolling 6 months"]} emptyLabel="Any time" onRangeChange={setRange} />
|
|
496
502
|
* <DateRangeFilter
|
|
497
503
|
* presetSet="creativeIntel"
|
|
@@ -586,8 +592,25 @@ interface DateRangeFilterProps {
|
|
|
586
592
|
* "Data is monthly". Defaults to 'day'.
|
|
587
593
|
*/
|
|
588
594
|
granularity?: "day" | "month";
|
|
595
|
+
/**
|
|
596
|
+
* Writes each date the component shows: the dates line, a custom span on
|
|
597
|
+
* the chip, the Start/End fields and the compare-to dates. For following a
|
|
598
|
+
* person's date-format setting ("14 Nov 2026", "2026-11-14"). Defaults to
|
|
599
|
+
* "Nov 14, 2026" (with `shortDates` off, the dates line keeps its long
|
|
600
|
+
* "November 14, 2026" form only while no formatter is given). Display only:
|
|
601
|
+
* `onChange` and `onApply` still report "Nov 14, 2026 – ...", since apps
|
|
602
|
+
* parse those labels. Month-level labels ("Nov 2025") are left as they are.
|
|
603
|
+
*/
|
|
604
|
+
formatDate?: (d: Date) => string;
|
|
605
|
+
/**
|
|
606
|
+
* Writes a span (dates line, custom span on the chip, compare-to dates) when
|
|
607
|
+
* it reads more briefly than two full dates ("4–17 Oct 2026"). Takes
|
|
608
|
+
* precedence over `formatDate` for spans. Defaults to
|
|
609
|
+
* `${formatDate(start)} – ${formatDate(end)}`, or one date when they match.
|
|
610
|
+
*/
|
|
611
|
+
formatRange?: (start: Date, end: Date) => string;
|
|
589
612
|
}
|
|
590
|
-
declare function DateRangeFilter({ caption, defaultValue, value: controlledValue, range: controlledRange, align, placement, onChange, onRangeChange, showDates, shortDates, icon, presetSet, excludePresets, emptyLabel, today: todayProp, initialRange, compare, onApply, testIdPrefix, granularity, }: DateRangeFilterProps): react.JSX.Element;
|
|
613
|
+
declare function DateRangeFilter({ caption, defaultValue, value: controlledValue, range: controlledRange, align, placement, onChange, onRangeChange, showDates, shortDates, icon, presetSet, excludePresets, emptyLabel, today: todayProp, initialRange, compare, onApply, testIdPrefix, granularity, formatDate, formatRange, }: DateRangeFilterProps): react.JSX.Element;
|
|
591
614
|
|
|
592
615
|
/**
|
|
593
616
|
* @pattern SearchBar
|
|
@@ -2341,7 +2364,7 @@ type DateGranularity = 'month' | 'quarter' | 'year';
|
|
|
2341
2364
|
/** Resolve a label to its actual [start, end] span, ending at `today`. */
|
|
2342
2365
|
declare function resolveRange(label: string, today?: Date): [Date, Date];
|
|
2343
2366
|
/** @deprecated Use DateRangeFilter, with `granularity="month"` for monthly data. */
|
|
2344
|
-
declare function DateRangePicker({ defaultValue, granularity, align, presets, onChange, onRangeChange, showFooter, today, years, }: {
|
|
2367
|
+
declare function DateRangePicker({ defaultValue, granularity, align, presets, onChange, onRangeChange, showFooter, today, years, formatDate, formatRange, }: {
|
|
2345
2368
|
defaultValue?: string;
|
|
2346
2369
|
align?: 'left' | 'right';
|
|
2347
2370
|
/**
|
|
@@ -2364,6 +2387,19 @@ declare function DateRangePicker({ defaultValue, granularity, align, presets, on
|
|
|
2364
2387
|
/** Years offered in the Custom Range selects. Defaults to the last four,
|
|
2365
2388
|
* ending with `today`'s year. */
|
|
2366
2389
|
years?: number[];
|
|
2390
|
+
/**
|
|
2391
|
+
* Writes each date in the dates line above the label, e.g. to follow a
|
|
2392
|
+
* person's date-format setting ("14 Nov 2026", "2026-11-14"). Defaults to
|
|
2393
|
+
* "Nov 14, 2026". Only what's shown changes: the label and `onChange` keep
|
|
2394
|
+
* the canonical form.
|
|
2395
|
+
*/
|
|
2396
|
+
formatDate?: (d: Date) => string;
|
|
2397
|
+
/**
|
|
2398
|
+
* Writes the whole dates line, for a span that reads more briefly than two
|
|
2399
|
+
* full dates. Takes precedence over `formatDate`. Defaults to
|
|
2400
|
+
* `${formatDate(start)} – ${formatDate(end)}`.
|
|
2401
|
+
*/
|
|
2402
|
+
formatRange?: (start: Date, end: Date) => string;
|
|
2367
2403
|
}): react.JSX.Element;
|
|
2368
2404
|
type DateRangePickerProps = Parameters<typeof DateRangePicker>[0];
|
|
2369
2405
|
|
|
@@ -2627,6 +2663,11 @@ interface PageHeaderProps {
|
|
|
2627
2663
|
description?: ReactNode;
|
|
2628
2664
|
/** The page's main actions, right-aligned -- usually one primary Button. */
|
|
2629
2665
|
actions?: ReactNode;
|
|
2666
|
+
/**
|
|
2667
|
+
* A status on the title line, after the title -- one Badge saying what
|
|
2668
|
+
* state the thing this page shows is in ("Active", "Trial").
|
|
2669
|
+
*/
|
|
2670
|
+
meta?: ReactNode;
|
|
2630
2671
|
/**
|
|
2631
2672
|
* The way back up, above the title: an arrow and the parent section's name,
|
|
2632
2673
|
* "Competitive intel". Give `href`; add `onClick` to route client-side
|
|
@@ -2651,6 +2692,7 @@ interface PageHeaderProps {
|
|
|
2651
2692
|
* title: ReactNode -- the page's name
|
|
2652
2693
|
* description?: ReactNode -- one line, about 70 characters at most, on what the user can do here
|
|
2653
2694
|
* actions?: ReactNode -- primary actions, right-aligned
|
|
2695
|
+
* meta?: ReactNode -- one status Badge on the title line
|
|
2654
2696
|
* @tokens text-micro, uppercase, tracking-wider, text-text-tertiary,
|
|
2655
2697
|
* hover:text-text-primary, focus-visible:outline-border-focus, rounded-control, text-xl, font-semibold, tracking-tight, text-text-primary, text-sm, text-text-secondary, max-w-2xl
|
|
2656
2698
|
* @use at the top of every top-level page.
|
|
@@ -2661,6 +2703,10 @@ interface PageHeaderProps {
|
|
|
2661
2703
|
* @avoid putting the description to the right of the title. It competes with
|
|
2662
2704
|
* the actions and wraps unpredictably on narrow screens.
|
|
2663
2705
|
* @avoid more than one primary action in `actions`.
|
|
2706
|
+
* @use `meta` on a detail page for the one status of the thing it shows (an
|
|
2707
|
+
* account's "Active" Badge), on the title line.
|
|
2708
|
+
* @avoid putting counts, dates or several pills in `meta`; that belongs in the
|
|
2709
|
+
* page body.
|
|
2664
2710
|
* @avoid a description on every page by habit. Use one only where a first-time
|
|
2665
2711
|
* user would not know what the page is for; a pipe-separated subtitle beside
|
|
2666
2712
|
* the title is the pattern this replaces.
|
|
@@ -2674,9 +2720,10 @@ interface PageHeaderProps {
|
|
|
2674
2720
|
* description="Build tables from MediaRadar data and export them whenever you need."
|
|
2675
2721
|
* actions={<Button><Plus /> New report</Button>}
|
|
2676
2722
|
* />
|
|
2723
|
+
* <PageHeader title="Northwind" back={{ label: "Accounts", href: "/accounts" }} meta={<Badge tone="success">Active</Badge>} />
|
|
2677
2724
|
* ```
|
|
2678
2725
|
*/
|
|
2679
|
-
declare function PageHeader({ title, description, actions, back, className }: PageHeaderProps): react.JSX.Element;
|
|
2726
|
+
declare function PageHeader({ title, description, actions, meta, back, className }: PageHeaderProps): react.JSX.Element;
|
|
2680
2727
|
|
|
2681
2728
|
type ModalSize = "sm" | "md" | "lg" | "xl";
|
|
2682
2729
|
interface ModalProps {
|
package/dist/index.d.ts
CHANGED
|
@@ -481,6 +481,11 @@ declare function CheckBoxBox({ checked, indeterminate, disabled, className }: Ch
|
|
|
481
481
|
* `granularity="month"` rounds every range out to whole months (presets,
|
|
482
482
|
* clicked days and Apply alike), shows months on the trigger, and adds a
|
|
483
483
|
* "Data is monthly" note beside Cancel/Apply.
|
|
484
|
+
* `formatDate` / `formatRange` write every day-level date the component shows
|
|
485
|
+
* (dates line, a custom span on the chip, Start/End fields, compare-to dates),
|
|
486
|
+
* e.g. to follow a person's date-format setting. What `onChange` and `onApply`
|
|
487
|
+
* report keeps the canonical "Nov 14, 2026" form, since apps parse it.
|
|
488
|
+
* Month-level labels ("Nov 2025") have no day to order and stay as they are.
|
|
484
489
|
* @a11y Trigger is a <button> with aria-expanded and an aria-label from the
|
|
485
490
|
* caption; the panel is role="dialog" and Escape closes it. Focus is not
|
|
486
491
|
* moved into the panel, so it is reached by tabbing.
|
|
@@ -492,6 +497,7 @@ declare function CheckBoxBox({ checked, indeterminate, disabled, className }: Ch
|
|
|
492
497
|
* <DateRangeFilter caption="Dates" showDates shortDates placement="right" />
|
|
493
498
|
* <DateRangeFilter presetSet="creativeIntel" defaultValue="Last 7 days" onChange={setRange} />
|
|
494
499
|
* <DateRangeFilter presetSet="creativeIntel" value={preset} range={[start, end]} onChange={setPreset} onRangeChange={(s, e) => setRange({ start: s, end: e })} />
|
|
500
|
+
* <DateRangeFilter caption="Dates" showDates formatDate={formatDate} formatRange={formatDateRange} />
|
|
495
501
|
* <DateRangeFilter presetSet="creativeIntel" excludePresets={["Rolling 3 months", "Rolling 6 months"]} emptyLabel="Any time" onRangeChange={setRange} />
|
|
496
502
|
* <DateRangeFilter
|
|
497
503
|
* presetSet="creativeIntel"
|
|
@@ -586,8 +592,25 @@ interface DateRangeFilterProps {
|
|
|
586
592
|
* "Data is monthly". Defaults to 'day'.
|
|
587
593
|
*/
|
|
588
594
|
granularity?: "day" | "month";
|
|
595
|
+
/**
|
|
596
|
+
* Writes each date the component shows: the dates line, a custom span on
|
|
597
|
+
* the chip, the Start/End fields and the compare-to dates. For following a
|
|
598
|
+
* person's date-format setting ("14 Nov 2026", "2026-11-14"). Defaults to
|
|
599
|
+
* "Nov 14, 2026" (with `shortDates` off, the dates line keeps its long
|
|
600
|
+
* "November 14, 2026" form only while no formatter is given). Display only:
|
|
601
|
+
* `onChange` and `onApply` still report "Nov 14, 2026 – ...", since apps
|
|
602
|
+
* parse those labels. Month-level labels ("Nov 2025") are left as they are.
|
|
603
|
+
*/
|
|
604
|
+
formatDate?: (d: Date) => string;
|
|
605
|
+
/**
|
|
606
|
+
* Writes a span (dates line, custom span on the chip, compare-to dates) when
|
|
607
|
+
* it reads more briefly than two full dates ("4–17 Oct 2026"). Takes
|
|
608
|
+
* precedence over `formatDate` for spans. Defaults to
|
|
609
|
+
* `${formatDate(start)} – ${formatDate(end)}`, or one date when they match.
|
|
610
|
+
*/
|
|
611
|
+
formatRange?: (start: Date, end: Date) => string;
|
|
589
612
|
}
|
|
590
|
-
declare function DateRangeFilter({ caption, defaultValue, value: controlledValue, range: controlledRange, align, placement, onChange, onRangeChange, showDates, shortDates, icon, presetSet, excludePresets, emptyLabel, today: todayProp, initialRange, compare, onApply, testIdPrefix, granularity, }: DateRangeFilterProps): react.JSX.Element;
|
|
613
|
+
declare function DateRangeFilter({ caption, defaultValue, value: controlledValue, range: controlledRange, align, placement, onChange, onRangeChange, showDates, shortDates, icon, presetSet, excludePresets, emptyLabel, today: todayProp, initialRange, compare, onApply, testIdPrefix, granularity, formatDate, formatRange, }: DateRangeFilterProps): react.JSX.Element;
|
|
591
614
|
|
|
592
615
|
/**
|
|
593
616
|
* @pattern SearchBar
|
|
@@ -2341,7 +2364,7 @@ type DateGranularity = 'month' | 'quarter' | 'year';
|
|
|
2341
2364
|
/** Resolve a label to its actual [start, end] span, ending at `today`. */
|
|
2342
2365
|
declare function resolveRange(label: string, today?: Date): [Date, Date];
|
|
2343
2366
|
/** @deprecated Use DateRangeFilter, with `granularity="month"` for monthly data. */
|
|
2344
|
-
declare function DateRangePicker({ defaultValue, granularity, align, presets, onChange, onRangeChange, showFooter, today, years, }: {
|
|
2367
|
+
declare function DateRangePicker({ defaultValue, granularity, align, presets, onChange, onRangeChange, showFooter, today, years, formatDate, formatRange, }: {
|
|
2345
2368
|
defaultValue?: string;
|
|
2346
2369
|
align?: 'left' | 'right';
|
|
2347
2370
|
/**
|
|
@@ -2364,6 +2387,19 @@ declare function DateRangePicker({ defaultValue, granularity, align, presets, on
|
|
|
2364
2387
|
/** Years offered in the Custom Range selects. Defaults to the last four,
|
|
2365
2388
|
* ending with `today`'s year. */
|
|
2366
2389
|
years?: number[];
|
|
2390
|
+
/**
|
|
2391
|
+
* Writes each date in the dates line above the label, e.g. to follow a
|
|
2392
|
+
* person's date-format setting ("14 Nov 2026", "2026-11-14"). Defaults to
|
|
2393
|
+
* "Nov 14, 2026". Only what's shown changes: the label and `onChange` keep
|
|
2394
|
+
* the canonical form.
|
|
2395
|
+
*/
|
|
2396
|
+
formatDate?: (d: Date) => string;
|
|
2397
|
+
/**
|
|
2398
|
+
* Writes the whole dates line, for a span that reads more briefly than two
|
|
2399
|
+
* full dates. Takes precedence over `formatDate`. Defaults to
|
|
2400
|
+
* `${formatDate(start)} – ${formatDate(end)}`.
|
|
2401
|
+
*/
|
|
2402
|
+
formatRange?: (start: Date, end: Date) => string;
|
|
2367
2403
|
}): react.JSX.Element;
|
|
2368
2404
|
type DateRangePickerProps = Parameters<typeof DateRangePicker>[0];
|
|
2369
2405
|
|
|
@@ -2627,6 +2663,11 @@ interface PageHeaderProps {
|
|
|
2627
2663
|
description?: ReactNode;
|
|
2628
2664
|
/** The page's main actions, right-aligned -- usually one primary Button. */
|
|
2629
2665
|
actions?: ReactNode;
|
|
2666
|
+
/**
|
|
2667
|
+
* A status on the title line, after the title -- one Badge saying what
|
|
2668
|
+
* state the thing this page shows is in ("Active", "Trial").
|
|
2669
|
+
*/
|
|
2670
|
+
meta?: ReactNode;
|
|
2630
2671
|
/**
|
|
2631
2672
|
* The way back up, above the title: an arrow and the parent section's name,
|
|
2632
2673
|
* "Competitive intel". Give `href`; add `onClick` to route client-side
|
|
@@ -2651,6 +2692,7 @@ interface PageHeaderProps {
|
|
|
2651
2692
|
* title: ReactNode -- the page's name
|
|
2652
2693
|
* description?: ReactNode -- one line, about 70 characters at most, on what the user can do here
|
|
2653
2694
|
* actions?: ReactNode -- primary actions, right-aligned
|
|
2695
|
+
* meta?: ReactNode -- one status Badge on the title line
|
|
2654
2696
|
* @tokens text-micro, uppercase, tracking-wider, text-text-tertiary,
|
|
2655
2697
|
* hover:text-text-primary, focus-visible:outline-border-focus, rounded-control, text-xl, font-semibold, tracking-tight, text-text-primary, text-sm, text-text-secondary, max-w-2xl
|
|
2656
2698
|
* @use at the top of every top-level page.
|
|
@@ -2661,6 +2703,10 @@ interface PageHeaderProps {
|
|
|
2661
2703
|
* @avoid putting the description to the right of the title. It competes with
|
|
2662
2704
|
* the actions and wraps unpredictably on narrow screens.
|
|
2663
2705
|
* @avoid more than one primary action in `actions`.
|
|
2706
|
+
* @use `meta` on a detail page for the one status of the thing it shows (an
|
|
2707
|
+
* account's "Active" Badge), on the title line.
|
|
2708
|
+
* @avoid putting counts, dates or several pills in `meta`; that belongs in the
|
|
2709
|
+
* page body.
|
|
2664
2710
|
* @avoid a description on every page by habit. Use one only where a first-time
|
|
2665
2711
|
* user would not know what the page is for; a pipe-separated subtitle beside
|
|
2666
2712
|
* the title is the pattern this replaces.
|
|
@@ -2674,9 +2720,10 @@ interface PageHeaderProps {
|
|
|
2674
2720
|
* description="Build tables from MediaRadar data and export them whenever you need."
|
|
2675
2721
|
* actions={<Button><Plus /> New report</Button>}
|
|
2676
2722
|
* />
|
|
2723
|
+
* <PageHeader title="Northwind" back={{ label: "Accounts", href: "/accounts" }} meta={<Badge tone="success">Active</Badge>} />
|
|
2677
2724
|
* ```
|
|
2678
2725
|
*/
|
|
2679
|
-
declare function PageHeader({ title, description, actions, back, className }: PageHeaderProps): react.JSX.Element;
|
|
2726
|
+
declare function PageHeader({ title, description, actions, meta, back, className }: PageHeaderProps): react.JSX.Element;
|
|
2680
2727
|
|
|
2681
2728
|
type ModalSize = "sm" | "md" | "lg" | "xl";
|
|
2682
2729
|
interface ModalProps {
|
package/dist/index.js
CHANGED
|
@@ -815,9 +815,15 @@ function DateRangeFilter({
|
|
|
815
815
|
compare,
|
|
816
816
|
onApply,
|
|
817
817
|
testIdPrefix,
|
|
818
|
-
granularity = "day"
|
|
818
|
+
granularity = "day",
|
|
819
|
+
formatDate,
|
|
820
|
+
formatRange
|
|
819
821
|
}) {
|
|
820
822
|
const monthly = granularity === "month";
|
|
823
|
+
const formatted = !!(formatDate || formatRange);
|
|
824
|
+
const showDate = formatDate ?? fmt;
|
|
825
|
+
const showRange = (s, e) => formatRange ? formatRange(s, e) : sameDay(s, e) ? showDate(s) : `${showDate(s)} \u2013 ${showDate(e)}`;
|
|
826
|
+
const showValue = (v, s, e) => formatted && !monthly && (v === `${fmt(s)} \u2014 ${fmt(e)}` || v === `${fmt(s)} \u2013 ${fmt(e)}`) ? showRange(s, e) : v;
|
|
821
827
|
const snap = (s, e) => monthly ? [firstOfMonth(s), lastOfMonth(e)] : [s, e];
|
|
822
828
|
const controlled = controlledValue !== void 0 && controlledRange !== void 0;
|
|
823
829
|
const startsEmpty = !controlled && !!emptyLabel;
|
|
@@ -828,7 +834,7 @@ function DateRangeFilter({
|
|
|
828
834
|
const initShortcut = matchShortcut(SHORTCUTS, controlled ? controlledValue : defaultValue);
|
|
829
835
|
const initRange = controlled ? controlledRange : initShortcut === "Custom" && initialRange ? snap(...initialRange) : snap(...presetRange(initShortcut === "Custom" ? "Rolling 12 months" : initShortcut, today));
|
|
830
836
|
const compareLabel = (id) => compare?.options.find((o) => o.id === id)?.label;
|
|
831
|
-
const dateLine = (s, e) => monthly ? `${fmtMonth(s)} \u2013 ${fmtMonth(e)}` : shortDates ? `${fmt(s)} \u2013 ${fmt(e)}` : fullRangeLabel(s, e);
|
|
837
|
+
const dateLine = (s, e) => monthly ? `${fmtMonth(s)} \u2013 ${fmtMonth(e)}` : formatted ? showRange(s, e) : shortDates ? `${fmt(s)} \u2013 ${fmt(e)}` : fullRangeLabel(s, e);
|
|
832
838
|
const [open, setOpen] = useState3(false);
|
|
833
839
|
const [uncontrolledValue, setUncontrolledValue] = useState3(
|
|
834
840
|
startsEmpty ? emptyLabel : showDates ? presetLabel(initShortcut) : defaultValue || "Last 7 days"
|
|
@@ -845,7 +851,7 @@ function DateRangeFilter({
|
|
|
845
851
|
setAppliedCmp(compare?.value);
|
|
846
852
|
}, [compare?.value]);
|
|
847
853
|
const compareName = `${useId2()}-compare`;
|
|
848
|
-
const displayValue = controlled ? showDates ? presetLabel(initShortcut) : controlledValue : uncontrolledValue;
|
|
854
|
+
const displayValue = controlled ? showDates ? presetLabel(initShortcut) : showValue(controlledValue, initRange[0], initRange[1]) : showValue(uncontrolledValue, committed.current.start, committed.current.end);
|
|
849
855
|
const displayDatesLine = controlled ? dateLine(initRange[0], initRange[1]) : uncontrolledDatesLine;
|
|
850
856
|
const [shortcut, setShortcut] = useState3(initShortcut);
|
|
851
857
|
const [start, setStart] = useState3(initRange[0]);
|
|
@@ -972,9 +978,9 @@ function DateRangeFilter({
|
|
|
972
978
|
)) }),
|
|
973
979
|
/* @__PURE__ */ jsxs7("div", { className: "flex flex-col p-4", children: [
|
|
974
980
|
/* @__PURE__ */ jsxs7("div", { className: "flex items-end gap-3", children: [
|
|
975
|
-
/* @__PURE__ */ jsx8(Field, { label: "Start date", value: start ?
|
|
981
|
+
/* @__PURE__ */ jsx8(Field, { label: "Start date", value: start ? showDate(start) : "\u2014" }),
|
|
976
982
|
/* @__PURE__ */ jsx8("span", { className: "pb-2.5 text-text-tertiary", children: "\u2014" }),
|
|
977
|
-
/* @__PURE__ */ jsx8(Field, { label: "End date", value: end ?
|
|
983
|
+
/* @__PURE__ */ jsx8(Field, { label: "End date", value: end ? showDate(end) : start ? showDate(start) : "\u2014" })
|
|
978
984
|
] }),
|
|
979
985
|
/* @__PURE__ */ jsx8("div", { className: "my-4 border-t border-border-default" }),
|
|
980
986
|
/* @__PURE__ */ jsx8("div", { className: "flex gap-8", children: [0, 1].map((offset) => {
|
|
@@ -1042,7 +1048,7 @@ function DateRangeFilter({
|
|
|
1042
1048
|
}
|
|
1043
1049
|
),
|
|
1044
1050
|
/* @__PURE__ */ jsx8("span", { className: `w-44 shrink-0 ${on ? "font-semibold text-text-primary" : "text-text-secondary"}`, children: o.label }),
|
|
1045
|
-
start && /* @__PURE__ */ jsx8("span", { className: "tabular-nums text-text-tertiary", children: spanLabel(...compareSpan(start, end ?? start, o.id)) })
|
|
1051
|
+
start && /* @__PURE__ */ jsx8("span", { className: "tabular-nums text-text-tertiary", children: (formatted ? showRange : spanLabel)(...compareSpan(start, end ?? start, o.id)) })
|
|
1046
1052
|
]
|
|
1047
1053
|
},
|
|
1048
1054
|
o.id
|
|
@@ -3993,9 +3999,11 @@ function resolveRange(label, today = startOfToday()) {
|
|
|
3993
3999
|
}
|
|
3994
4000
|
return [new Date(end.getFullYear(), end.getMonth() - 6, 1), end];
|
|
3995
4001
|
}
|
|
3996
|
-
function spanLabel2(label, today) {
|
|
4002
|
+
function spanLabel2(label, today, formatDate, formatRange) {
|
|
3997
4003
|
const [s, e] = resolveRange(label, today);
|
|
3998
|
-
|
|
4004
|
+
if (formatRange) return formatRange(s, e);
|
|
4005
|
+
const f = formatDate ?? fmtDate;
|
|
4006
|
+
return `${f(s)} \u2013 ${f(e)}`;
|
|
3999
4007
|
}
|
|
4000
4008
|
function MiniSelect({ value, onChange, options }) {
|
|
4001
4009
|
return /* @__PURE__ */ jsx39(
|
|
@@ -4020,7 +4028,9 @@ function DateRangePicker({
|
|
|
4020
4028
|
onRangeChange,
|
|
4021
4029
|
showFooter = false,
|
|
4022
4030
|
today,
|
|
4023
|
-
years
|
|
4031
|
+
years,
|
|
4032
|
+
formatDate,
|
|
4033
|
+
formatRange
|
|
4024
4034
|
}) {
|
|
4025
4035
|
const end = useMemo4(() => today ?? startOfToday(), [today]);
|
|
4026
4036
|
const yearOptions = years ?? [3, 2, 1, 0].map((n) => end.getFullYear() - n);
|
|
@@ -4079,7 +4089,7 @@ function DateRangePicker({
|
|
|
4079
4089
|
className: chipTriggerClass(),
|
|
4080
4090
|
children: [
|
|
4081
4091
|
/* @__PURE__ */ jsxs35("span", { className: "flex flex-col gap-1 text-left leading-none", children: [
|
|
4082
|
-
/* @__PURE__ */ jsx39("span", { className: "text-control-caption text-text-tertiary", children: spanLabel2(value, end) }),
|
|
4092
|
+
/* @__PURE__ */ jsx39("span", { className: "text-control-caption text-text-tertiary", children: spanLabel2(value, end, formatDate, formatRange) }),
|
|
4083
4093
|
/* @__PURE__ */ jsx39("span", { className: "text-[12px] font-medium text-text-primary", children: value })
|
|
4084
4094
|
] }),
|
|
4085
4095
|
/* @__PURE__ */ jsx39(ChevronDown9, { size: 14, "aria-hidden": "true", className: cn("shrink-0 text-text-secondary transition-transform", open && "rotate-180") })
|
|
@@ -4449,7 +4459,7 @@ function SectionHeading({ title, description, actions, as: Tag2 = "h2", id, clas
|
|
|
4449
4459
|
// src/PageHeader.tsx
|
|
4450
4460
|
import { ArrowLeft } from "lucide-react";
|
|
4451
4461
|
import { jsx as jsx45, jsxs as jsxs39 } from "react/jsx-runtime";
|
|
4452
|
-
function PageHeader({ title, description, actions, back, className }) {
|
|
4462
|
+
function PageHeader({ title, description, actions, meta, back, className }) {
|
|
4453
4463
|
return /* @__PURE__ */ jsxs39("header", { className: cn("flex flex-wrap items-center justify-between gap-x-6 gap-y-3", className), children: [
|
|
4454
4464
|
/* @__PURE__ */ jsxs39("div", { className: "min-w-0", children: [
|
|
4455
4465
|
back && /* @__PURE__ */ jsxs39(
|
|
@@ -4464,7 +4474,10 @@ function PageHeader({ title, description, actions, back, className }) {
|
|
|
4464
4474
|
]
|
|
4465
4475
|
}
|
|
4466
4476
|
),
|
|
4467
|
-
/* @__PURE__ */
|
|
4477
|
+
meta ? /* @__PURE__ */ jsxs39("div", { className: "flex flex-wrap items-center gap-x-2.5 gap-y-1", children: [
|
|
4478
|
+
/* @__PURE__ */ jsx45("h1", { className: "text-xl font-semibold tracking-tight text-text-primary", children: title }),
|
|
4479
|
+
meta
|
|
4480
|
+
] }) : /* @__PURE__ */ jsx45("h1", { className: "text-xl font-semibold tracking-tight text-text-primary", children: title }),
|
|
4468
4481
|
description && /* @__PURE__ */ jsx45("p", { className: "mt-0.5 max-w-2xl text-sm text-text-secondary", children: description })
|
|
4469
4482
|
] }),
|
|
4470
4483
|
actions && /* @__PURE__ */ jsx45("div", { className: "flex shrink-0 items-center gap-2", children: actions })
|