@mediaradar/design-components 0.60.0 → 0.61.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 +16 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +17 -6
- package/dist/index.d.ts +17 -6
- package/dist/index.js +16 -7
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -3945,7 +3945,13 @@ interface FilterDrawerSection<Id extends string = string> {
|
|
|
3945
3945
|
className?: string;
|
|
3946
3946
|
"aria-hidden"?: boolean | "true" | "false";
|
|
3947
3947
|
}>;
|
|
3948
|
-
/**
|
|
3948
|
+
/**
|
|
3949
|
+
* How many picks the filter holds. Above 0 it shows as a count badge on the
|
|
3950
|
+
* row and beside the filter's title in its panel ("3"; screen readers hear
|
|
3951
|
+
* "3 selected").
|
|
3952
|
+
*/
|
|
3953
|
+
count?: number;
|
|
3954
|
+
/** For a filter that isn't a count ("Off"): a text badge on the row instead. Ignored when `count` is above 0. */
|
|
3949
3955
|
badge?: string | null;
|
|
3950
3956
|
/** One line saying what the filter means; an info tip beside its name in its panel. */
|
|
3951
3957
|
info?: string;
|
|
@@ -3957,7 +3963,10 @@ interface FilterDrawerProps<Id extends string = string> extends CommonProps {
|
|
|
3957
3963
|
sections: FilterDrawerSection<Id>[];
|
|
3958
3964
|
/** One filter's contents, shown when its row is opened. The page owns the draft. */
|
|
3959
3965
|
renderSection: (id: Id) => ReactNode;
|
|
3960
|
-
/**
|
|
3966
|
+
/**
|
|
3967
|
+
* @deprecated No longer shown: the AllFiltersButton on the page carries the
|
|
3968
|
+
* total, and each row carries its own count. Kept so existing pages compile.
|
|
3969
|
+
*/
|
|
3961
3970
|
activeCount?: number;
|
|
3962
3971
|
/** Empties one filter in the draft: Clear inside a filter's panel. */
|
|
3963
3972
|
onClearSection: (id: Id) => void;
|
|
@@ -3980,7 +3989,10 @@ interface FilterDrawerProps<Id extends string = string> extends CommonProps {
|
|
|
3980
3989
|
* title. The page keeps the draft and renders each filter's contents;
|
|
3981
3990
|
* FilterDrawer owns the list, the navigation, the slide between the two and
|
|
3982
3991
|
* the footer: Clear inside a filter; Clear all, Cancel and See
|
|
3983
|
-
* results on the list. Opened from AllFiltersButton
|
|
3992
|
+
* results on the list. Opened from AllFiltersButton, which carries the
|
|
3993
|
+
* total. A filter with picks shows their number as a count badge (the
|
|
3994
|
+
* style guide's Badge, brandSolid, count) on its row and beside its title
|
|
3995
|
+
* in its panel.
|
|
3984
3996
|
* @tokens border-t, border-b, border-border-default, px-5, py-3.5, text-sm,
|
|
3985
3997
|
* font-medium, text-text-primary, text-text-secondary, text-brand-primaryAction,
|
|
3986
3998
|
* hover:bg-subtle, rounded-control, focus-visible:outline-border-focus,
|
|
@@ -4013,8 +4025,7 @@ interface FilterDrawerProps<Id extends string = string> extends CommonProps {
|
|
|
4013
4025
|
* <FilterDrawer
|
|
4014
4026
|
* open={open}
|
|
4015
4027
|
* onClose={() => setOpen(false)}
|
|
4016
|
-
*
|
|
4017
|
-
* sections={[{ id: "brand", label: "Brand", icon: Package, badge: draft.brands.length ? `${draft.brands.length} selected` : null }]}
|
|
4028
|
+
* sections={[{ id: "brand", label: "Brand", icon: Package, count: draft.brands.length }]}
|
|
4018
4029
|
* renderSection={(id) => <BrandPicker value={draft.brands} onChange={...} />}
|
|
4019
4030
|
* onClearSection={(id) => setDraft((d) => ({ ...d, [id]: [] }))}
|
|
4020
4031
|
* onClearAll={() => setDraft(empty)}
|
|
@@ -4022,7 +4033,7 @@ interface FilterDrawerProps<Id extends string = string> extends CommonProps {
|
|
|
4022
4033
|
* />
|
|
4023
4034
|
* ```
|
|
4024
4035
|
*/
|
|
4025
|
-
declare function FilterDrawer<Id extends string>({ open, onClose, sections, renderSection, activeCount, onClearSection, onClearAll, onApply, focus, size, testIdPrefix, }: FilterDrawerProps<Id>): react.JSX.Element;
|
|
4036
|
+
declare function FilterDrawer<Id extends string>({ open, onClose, sections, renderSection, activeCount: _activeCount, onClearSection, onClearAll, onApply, focus, size, testIdPrefix, }: FilterDrawerProps<Id>): react.JSX.Element;
|
|
4026
4037
|
|
|
4027
4038
|
interface AllFiltersButtonProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, "children">, CommonProps {
|
|
4028
4039
|
/** Filters narrowing the page; the badge shows when above 0. */
|
package/dist/index.d.ts
CHANGED
|
@@ -3945,7 +3945,13 @@ interface FilterDrawerSection<Id extends string = string> {
|
|
|
3945
3945
|
className?: string;
|
|
3946
3946
|
"aria-hidden"?: boolean | "true" | "false";
|
|
3947
3947
|
}>;
|
|
3948
|
-
/**
|
|
3948
|
+
/**
|
|
3949
|
+
* How many picks the filter holds. Above 0 it shows as a count badge on the
|
|
3950
|
+
* row and beside the filter's title in its panel ("3"; screen readers hear
|
|
3951
|
+
* "3 selected").
|
|
3952
|
+
*/
|
|
3953
|
+
count?: number;
|
|
3954
|
+
/** For a filter that isn't a count ("Off"): a text badge on the row instead. Ignored when `count` is above 0. */
|
|
3949
3955
|
badge?: string | null;
|
|
3950
3956
|
/** One line saying what the filter means; an info tip beside its name in its panel. */
|
|
3951
3957
|
info?: string;
|
|
@@ -3957,7 +3963,10 @@ interface FilterDrawerProps<Id extends string = string> extends CommonProps {
|
|
|
3957
3963
|
sections: FilterDrawerSection<Id>[];
|
|
3958
3964
|
/** One filter's contents, shown when its row is opened. The page owns the draft. */
|
|
3959
3965
|
renderSection: (id: Id) => ReactNode;
|
|
3960
|
-
/**
|
|
3966
|
+
/**
|
|
3967
|
+
* @deprecated No longer shown: the AllFiltersButton on the page carries the
|
|
3968
|
+
* total, and each row carries its own count. Kept so existing pages compile.
|
|
3969
|
+
*/
|
|
3961
3970
|
activeCount?: number;
|
|
3962
3971
|
/** Empties one filter in the draft: Clear inside a filter's panel. */
|
|
3963
3972
|
onClearSection: (id: Id) => void;
|
|
@@ -3980,7 +3989,10 @@ interface FilterDrawerProps<Id extends string = string> extends CommonProps {
|
|
|
3980
3989
|
* title. The page keeps the draft and renders each filter's contents;
|
|
3981
3990
|
* FilterDrawer owns the list, the navigation, the slide between the two and
|
|
3982
3991
|
* the footer: Clear inside a filter; Clear all, Cancel and See
|
|
3983
|
-
* results on the list. Opened from AllFiltersButton
|
|
3992
|
+
* results on the list. Opened from AllFiltersButton, which carries the
|
|
3993
|
+
* total. A filter with picks shows their number as a count badge (the
|
|
3994
|
+
* style guide's Badge, brandSolid, count) on its row and beside its title
|
|
3995
|
+
* in its panel.
|
|
3984
3996
|
* @tokens border-t, border-b, border-border-default, px-5, py-3.5, text-sm,
|
|
3985
3997
|
* font-medium, text-text-primary, text-text-secondary, text-brand-primaryAction,
|
|
3986
3998
|
* hover:bg-subtle, rounded-control, focus-visible:outline-border-focus,
|
|
@@ -4013,8 +4025,7 @@ interface FilterDrawerProps<Id extends string = string> extends CommonProps {
|
|
|
4013
4025
|
* <FilterDrawer
|
|
4014
4026
|
* open={open}
|
|
4015
4027
|
* onClose={() => setOpen(false)}
|
|
4016
|
-
*
|
|
4017
|
-
* sections={[{ id: "brand", label: "Brand", icon: Package, badge: draft.brands.length ? `${draft.brands.length} selected` : null }]}
|
|
4028
|
+
* sections={[{ id: "brand", label: "Brand", icon: Package, count: draft.brands.length }]}
|
|
4018
4029
|
* renderSection={(id) => <BrandPicker value={draft.brands} onChange={...} />}
|
|
4019
4030
|
* onClearSection={(id) => setDraft((d) => ({ ...d, [id]: [] }))}
|
|
4020
4031
|
* onClearAll={() => setDraft(empty)}
|
|
@@ -4022,7 +4033,7 @@ interface FilterDrawerProps<Id extends string = string> extends CommonProps {
|
|
|
4022
4033
|
* />
|
|
4023
4034
|
* ```
|
|
4024
4035
|
*/
|
|
4025
|
-
declare function FilterDrawer<Id extends string>({ open, onClose, sections, renderSection, activeCount, onClearSection, onClearAll, onApply, focus, size, testIdPrefix, }: FilterDrawerProps<Id>): react.JSX.Element;
|
|
4036
|
+
declare function FilterDrawer<Id extends string>({ open, onClose, sections, renderSection, activeCount: _activeCount, onClearSection, onClearAll, onApply, focus, size, testIdPrefix, }: FilterDrawerProps<Id>): react.JSX.Element;
|
|
4026
4037
|
|
|
4027
4038
|
interface AllFiltersButtonProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, "children">, CommonProps {
|
|
4028
4039
|
/** Filters narrowing the page; the badge shows when above 0. */
|
package/dist/index.js
CHANGED
|
@@ -5838,7 +5838,7 @@ function FilterDrawer({
|
|
|
5838
5838
|
onClose,
|
|
5839
5839
|
sections,
|
|
5840
5840
|
renderSection,
|
|
5841
|
-
activeCount
|
|
5841
|
+
activeCount: _activeCount,
|
|
5842
5842
|
onClearSection,
|
|
5843
5843
|
onClearAll,
|
|
5844
5844
|
onApply,
|
|
@@ -5908,11 +5908,11 @@ function FilterDrawer({
|
|
|
5908
5908
|
{
|
|
5909
5909
|
size: 17,
|
|
5910
5910
|
"aria-hidden": "true",
|
|
5911
|
-
className: x
|
|
5911
|
+
className: inUse(x) ? "text-brand-primaryAction" : "text-text-secondary"
|
|
5912
5912
|
}
|
|
5913
5913
|
),
|
|
5914
5914
|
/* @__PURE__ */ jsx61("span", { className: "flex-1 text-sm font-medium text-text-primary", children: x.label }),
|
|
5915
|
-
|
|
5915
|
+
/* @__PURE__ */ jsx61(SectionMark, { section: x }),
|
|
5916
5916
|
/* @__PURE__ */ jsx61(ChevronRight7, { size: 16, "aria-hidden": "true", className: "shrink-0 text-text-secondary" })
|
|
5917
5917
|
]
|
|
5918
5918
|
}
|
|
@@ -5939,11 +5939,9 @@ function FilterDrawer({
|
|
|
5939
5939
|
}
|
|
5940
5940
|
),
|
|
5941
5941
|
focused.label,
|
|
5942
|
+
(focused.count ?? 0) > 0 && /* @__PURE__ */ jsx61(CountBadge, { count: focused.count }),
|
|
5942
5943
|
focused.info && /* @__PURE__ */ jsx61(InfoTip, { text: focused.info, label: `About ${focused.label}` })
|
|
5943
|
-
] }) :
|
|
5944
|
-
"Filters",
|
|
5945
|
-
activeCount > 0 && /* @__PURE__ */ jsx61(Badge, { tone: "brandSolid", kind: "count", children: activeCount })
|
|
5946
|
-
] }),
|
|
5944
|
+
] }) : "Filters",
|
|
5947
5945
|
footer: focused ? (
|
|
5948
5946
|
// Picks are kept as they're made; only See results, on the list, applies them.
|
|
5949
5947
|
/* @__PURE__ */ jsx61("div", { className: "flex w-full items-center", children: /* @__PURE__ */ jsx61(Button, { variant: "link", size: "md", onClick: () => onClearSection(focused.id), className: "px-0", children: "Clear" }) })
|
|
@@ -5989,6 +5987,17 @@ function FilterDrawer({
|
|
|
5989
5987
|
}
|
|
5990
5988
|
);
|
|
5991
5989
|
}
|
|
5990
|
+
var inUse = (x) => (x.count ?? 0) > 0 || !!x.badge;
|
|
5991
|
+
function CountBadge({ count }) {
|
|
5992
|
+
return /* @__PURE__ */ jsxs53(Badge, { tone: "brandSolid", kind: "count", children: [
|
|
5993
|
+
count,
|
|
5994
|
+
/* @__PURE__ */ jsx61("span", { className: "sr-only", children: " selected" })
|
|
5995
|
+
] });
|
|
5996
|
+
}
|
|
5997
|
+
function SectionMark({ section }) {
|
|
5998
|
+
if ((section.count ?? 0) > 0) return /* @__PURE__ */ jsx61(CountBadge, { count: section.count });
|
|
5999
|
+
return section.badge ? /* @__PURE__ */ jsx61(Badge, { tone: "brand", children: section.badge }) : null;
|
|
6000
|
+
}
|
|
5992
6001
|
|
|
5993
6002
|
// src/AllFiltersButton.tsx
|
|
5994
6003
|
import { forwardRef as forwardRef13 } from "react";
|