@mediaradar/design-components 0.57.0 → 0.58.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 +68 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +32 -1
- package/dist/index.d.ts +32 -1
- package/dist/index.js +62 -0
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/scripts/tailwind-coverage.mjs +3 -1
package/dist/index.d.cts
CHANGED
|
@@ -4070,4 +4070,35 @@ declare function formatRelative(d: Date, opts?: DateFormatOptions): string;
|
|
|
4070
4070
|
*/
|
|
4071
4071
|
declare function defaultDateOrder(country: string | null | undefined): DateOrder;
|
|
4072
4072
|
|
|
4073
|
-
|
|
4073
|
+
type Currency = "USD" | "CAD" | "GBP" | "EUR";
|
|
4074
|
+
interface NumberFormatOptions {
|
|
4075
|
+
/** The person's interface language (`en-US`, `en-GB`, `en-CA`, …). Default `en-US`. */
|
|
4076
|
+
language?: string;
|
|
4077
|
+
}
|
|
4078
|
+
interface MoneyFormatOptions extends NumberFormatOptions {
|
|
4079
|
+
/** Default `USD`. */
|
|
4080
|
+
currency?: Currency;
|
|
4081
|
+
/**
|
|
4082
|
+
* True where US and Canadian dollars can appear together (multi-country
|
|
4083
|
+
* accounts, comparisons): CAD shows "CA$" and USD "US$". Otherwise both
|
|
4084
|
+
* are a plain "$", as each country writes its own dollar.
|
|
4085
|
+
*/
|
|
4086
|
+
mixedDollars?: boolean;
|
|
4087
|
+
}
|
|
4088
|
+
/** The missing-value mark. The table explains it on hover ("No data"). */
|
|
4089
|
+
declare const NO_VALUE = "\u2014";
|
|
4090
|
+
/** A count (ads, impressions, advertisers): "12.4K", "8,450". */
|
|
4091
|
+
declare function formatCount(value: number | null | undefined, opts?: NumberFormatOptions): string;
|
|
4092
|
+
/** A count in full, for the hover: "12,400". */
|
|
4093
|
+
declare function formatCountFull(value: number | null | undefined): string;
|
|
4094
|
+
/** Spend: "$448.7M", "£1.2bn", "−$85K", "$8,450". */
|
|
4095
|
+
declare function formatMoney(value: number | null | undefined, opts?: MoneyFormatOptions): string;
|
|
4096
|
+
/** Spend in full, for the hover: "$448,700,000". */
|
|
4097
|
+
declare function formatMoneyFull(value: number | null | undefined, opts?: MoneyFormatOptions): string;
|
|
4098
|
+
/**
|
|
4099
|
+
* A percentage, given in percent (18.4 for 18.4%): always one decimal
|
|
4100
|
+
* ("3.0%"), and "<0.1%" for anything above zero that would round to 0.0.
|
|
4101
|
+
*/
|
|
4102
|
+
declare function formatPercent(value: number | null | undefined, _opts?: NumberFormatOptions): string;
|
|
4103
|
+
|
|
4104
|
+
export { AISpark, type AISparkProps, AdvertiserNoResults, type AdvertiserNoResultsProps, AdvertiserQuickFilter, type AdvertiserQuickFilterProps, AdvertiserSearchPrompt, type AdvertiserSearchPromptProps, AllFiltersButton, type AllFiltersButtonProps, type AxisMonthLabel, Badge, type BadgeKind, type BadgeProps, type BadgeTone, BarChartPlaceholder, type BarChartPlaceholderProps, BarList, type BarListProps, type BarListRow, Button, type ButtonProps, Card, type CardProps, ChartLegend, type ChartLegendProps, CheckBox, CheckBoxBox, type CheckBoxBoxProps, type CheckBoxProps, ChipContent, type ChipContentProps, type ChipVariant, type CommonProps, CopyButton, type CopyButtonProps, type Currency, DEFAULT_SEARCH_MATCH, DataScopeFilter, type DataScopeFilterProps, DataTable, type DataTableColumn, type DataTableColumnWidth, type DataTableDensity, type DataTableProps, type DateFormatOptions, type DateGranularity, type DateOrder, DateRangeFilter, type DateRangeFilterProps, type DateRangeFormatOptions, DateRangePicker, type DateRangePickerProps, Delta, type DeltaProps, Drawer, type DrawerProps, type DrawerSize, EmptyState, type EmptyStateProps, type EmptyStateSize, FilterChipBar, type FilterChipBarProps, FilterDrawer, type FilterDrawerProps, type FilterDrawerSection, FilterDropdownFooter, type FilterDropdownFooterProps, Freshness, type FreshnessLevel, type FreshnessProps, InfoTip, type InfoTipProps, InlineMessage, type InlineMessageProps, type InlineMessageTone, LegendItem, type LegendItemProps, type LegendMark, LineChartPlaceholder, type LineChartPlaceholderProps, MediaLabel, type MediaLabelProps, type MediaType, Menu, MenuItem, type MenuItemProps, MenuLabel, type MenuProps, MenuSeparator, Modal, type ModalProps, type ModalSize, type MoneyFormatOptions, MultiSelectFilter, type MultiSelectFilterProps, type MultiSelectGroup, NO_RESULTS_BODY, NO_RESULTS_TITLE, NO_VALUE, NameListModal, type NameListModalProps, type NoResultsAction, NoResultsEmptyState, type NoResultsEmptyStateProps, type NumberFormatOptions, PRIMARY_ACTION_CLASS, PageHeader, type PageHeaderProps, Pager, type PagerProps, type PickerColumn, type PickerFilter, type PickerRow, PieChartPlaceholder, type PieChartPlaceholderProps, PrimaryBadge, type PrimaryBadgeProps, type PubBreak, PublisherBreakdownList, type PublisherBreakdownListProps, QUIET_ACTION_CLASS, SearchBar, type SearchBarProps, type SearchBarSize, type SearchBarVariant, type SearchMatchMode, type SearchMatchValue, type SearchScope, SectionHeading, type SectionHeadingProps, SectionRail, type SectionRailProps, SegmentedControl, type SegmentedControlProps, type SegmentedControlSize, type SegmentedOption, SelectAllVisible, type SelectAllVisibleProps, SelectFilter, type SelectFilterProps, SelectedSection, type SelectedSectionProps, SelectionPicker, type SelectionPickerAccountList, type SelectionPickerProps, SortButton, type SortButtonProps, type SortDir, type SortState, StackedColumnPlaceholder, type StackedColumnPlaceholderProps, StatStrip, type StatStripProps, StatTile, type StatTileProps, SuggestionChip, type SuggestionChipProps, type SummaryGroup, type SummaryGroupItemValue, type TabItem, TablePagination, type TablePaginationProps, Tabs, type TabsProps, Tag, type TagProps, TextField, type TextFieldProps, type TextFieldSize, Toast, type ToastProps, type ToastTone, Toggle, ToggleChip, type ToggleChipProps, type ToggleProps, Tooltip, type TooltipProps, WorkspaceAvatar, type WorkspaceAvatarProps, WorkspaceSelectedCard, type WorkspaceSelectedCardProps, ariaSortFor, buttonVariants, chipTriggerClass, cycleSort, defaultDateOrder, formatCount, formatCountFull, formatDate, formatDateRange, formatDateTime, formatIsoDate, formatMoney, formatMoneyFull, formatMonth, formatMonthAxis, formatOpenRange, formatPercent, formatQuarter, formatRelative, formatTime, formatWeek, noResultsBody, resolveRange, sortProp };
|
package/dist/index.d.ts
CHANGED
|
@@ -4070,4 +4070,35 @@ declare function formatRelative(d: Date, opts?: DateFormatOptions): string;
|
|
|
4070
4070
|
*/
|
|
4071
4071
|
declare function defaultDateOrder(country: string | null | undefined): DateOrder;
|
|
4072
4072
|
|
|
4073
|
-
|
|
4073
|
+
type Currency = "USD" | "CAD" | "GBP" | "EUR";
|
|
4074
|
+
interface NumberFormatOptions {
|
|
4075
|
+
/** The person's interface language (`en-US`, `en-GB`, `en-CA`, …). Default `en-US`. */
|
|
4076
|
+
language?: string;
|
|
4077
|
+
}
|
|
4078
|
+
interface MoneyFormatOptions extends NumberFormatOptions {
|
|
4079
|
+
/** Default `USD`. */
|
|
4080
|
+
currency?: Currency;
|
|
4081
|
+
/**
|
|
4082
|
+
* True where US and Canadian dollars can appear together (multi-country
|
|
4083
|
+
* accounts, comparisons): CAD shows "CA$" and USD "US$". Otherwise both
|
|
4084
|
+
* are a plain "$", as each country writes its own dollar.
|
|
4085
|
+
*/
|
|
4086
|
+
mixedDollars?: boolean;
|
|
4087
|
+
}
|
|
4088
|
+
/** The missing-value mark. The table explains it on hover ("No data"). */
|
|
4089
|
+
declare const NO_VALUE = "\u2014";
|
|
4090
|
+
/** A count (ads, impressions, advertisers): "12.4K", "8,450". */
|
|
4091
|
+
declare function formatCount(value: number | null | undefined, opts?: NumberFormatOptions): string;
|
|
4092
|
+
/** A count in full, for the hover: "12,400". */
|
|
4093
|
+
declare function formatCountFull(value: number | null | undefined): string;
|
|
4094
|
+
/** Spend: "$448.7M", "£1.2bn", "−$85K", "$8,450". */
|
|
4095
|
+
declare function formatMoney(value: number | null | undefined, opts?: MoneyFormatOptions): string;
|
|
4096
|
+
/** Spend in full, for the hover: "$448,700,000". */
|
|
4097
|
+
declare function formatMoneyFull(value: number | null | undefined, opts?: MoneyFormatOptions): string;
|
|
4098
|
+
/**
|
|
4099
|
+
* A percentage, given in percent (18.4 for 18.4%): always one decimal
|
|
4100
|
+
* ("3.0%"), and "<0.1%" for anything above zero that would round to 0.0.
|
|
4101
|
+
*/
|
|
4102
|
+
declare function formatPercent(value: number | null | undefined, _opts?: NumberFormatOptions): string;
|
|
4103
|
+
|
|
4104
|
+
export { AISpark, type AISparkProps, AdvertiserNoResults, type AdvertiserNoResultsProps, AdvertiserQuickFilter, type AdvertiserQuickFilterProps, AdvertiserSearchPrompt, type AdvertiserSearchPromptProps, AllFiltersButton, type AllFiltersButtonProps, type AxisMonthLabel, Badge, type BadgeKind, type BadgeProps, type BadgeTone, BarChartPlaceholder, type BarChartPlaceholderProps, BarList, type BarListProps, type BarListRow, Button, type ButtonProps, Card, type CardProps, ChartLegend, type ChartLegendProps, CheckBox, CheckBoxBox, type CheckBoxBoxProps, type CheckBoxProps, ChipContent, type ChipContentProps, type ChipVariant, type CommonProps, CopyButton, type CopyButtonProps, type Currency, DEFAULT_SEARCH_MATCH, DataScopeFilter, type DataScopeFilterProps, DataTable, type DataTableColumn, type DataTableColumnWidth, type DataTableDensity, type DataTableProps, type DateFormatOptions, type DateGranularity, type DateOrder, DateRangeFilter, type DateRangeFilterProps, type DateRangeFormatOptions, DateRangePicker, type DateRangePickerProps, Delta, type DeltaProps, Drawer, type DrawerProps, type DrawerSize, EmptyState, type EmptyStateProps, type EmptyStateSize, FilterChipBar, type FilterChipBarProps, FilterDrawer, type FilterDrawerProps, type FilterDrawerSection, FilterDropdownFooter, type FilterDropdownFooterProps, Freshness, type FreshnessLevel, type FreshnessProps, InfoTip, type InfoTipProps, InlineMessage, type InlineMessageProps, type InlineMessageTone, LegendItem, type LegendItemProps, type LegendMark, LineChartPlaceholder, type LineChartPlaceholderProps, MediaLabel, type MediaLabelProps, type MediaType, Menu, MenuItem, type MenuItemProps, MenuLabel, type MenuProps, MenuSeparator, Modal, type ModalProps, type ModalSize, type MoneyFormatOptions, MultiSelectFilter, type MultiSelectFilterProps, type MultiSelectGroup, NO_RESULTS_BODY, NO_RESULTS_TITLE, NO_VALUE, NameListModal, type NameListModalProps, type NoResultsAction, NoResultsEmptyState, type NoResultsEmptyStateProps, type NumberFormatOptions, PRIMARY_ACTION_CLASS, PageHeader, type PageHeaderProps, Pager, type PagerProps, type PickerColumn, type PickerFilter, type PickerRow, PieChartPlaceholder, type PieChartPlaceholderProps, PrimaryBadge, type PrimaryBadgeProps, type PubBreak, PublisherBreakdownList, type PublisherBreakdownListProps, QUIET_ACTION_CLASS, SearchBar, type SearchBarProps, type SearchBarSize, type SearchBarVariant, type SearchMatchMode, type SearchMatchValue, type SearchScope, SectionHeading, type SectionHeadingProps, SectionRail, type SectionRailProps, SegmentedControl, type SegmentedControlProps, type SegmentedControlSize, type SegmentedOption, SelectAllVisible, type SelectAllVisibleProps, SelectFilter, type SelectFilterProps, SelectedSection, type SelectedSectionProps, SelectionPicker, type SelectionPickerAccountList, type SelectionPickerProps, SortButton, type SortButtonProps, type SortDir, type SortState, StackedColumnPlaceholder, type StackedColumnPlaceholderProps, StatStrip, type StatStripProps, StatTile, type StatTileProps, SuggestionChip, type SuggestionChipProps, type SummaryGroup, type SummaryGroupItemValue, type TabItem, TablePagination, type TablePaginationProps, Tabs, type TabsProps, Tag, type TagProps, TextField, type TextFieldProps, type TextFieldSize, Toast, type ToastProps, type ToastTone, Toggle, ToggleChip, type ToggleChipProps, type ToggleProps, Tooltip, type TooltipProps, WorkspaceAvatar, type WorkspaceAvatarProps, WorkspaceSelectedCard, type WorkspaceSelectedCardProps, ariaSortFor, buttonVariants, chipTriggerClass, cycleSort, defaultDateOrder, formatCount, formatCountFull, formatDate, formatDateRange, formatDateTime, formatIsoDate, formatMoney, formatMoneyFull, formatMonth, formatMonthAxis, formatOpenRange, formatPercent, formatQuarter, formatRelative, formatTime, formatWeek, noResultsBody, resolveRange, sortProp };
|
package/dist/index.js
CHANGED
|
@@ -5902,6 +5902,62 @@ function defaultDateOrder(country) {
|
|
|
5902
5902
|
const c = (country ?? "").toUpperCase();
|
|
5903
5903
|
return c === "US" || c === "CA" || c === "" ? "mdy" : "dmy";
|
|
5904
5904
|
}
|
|
5905
|
+
|
|
5906
|
+
// src/numbers.ts
|
|
5907
|
+
var US = { units: ["K", "M", "B", "T"] };
|
|
5908
|
+
var STYLES = {
|
|
5909
|
+
"en-US": US,
|
|
5910
|
+
"en-CA": US,
|
|
5911
|
+
"en-GB": { units: ["k", "m", "bn", "tn"] }
|
|
5912
|
+
};
|
|
5913
|
+
var styleFor = (language) => STYLES[language ?? "en-US"] ?? US;
|
|
5914
|
+
var NO_VALUE = "\u2014";
|
|
5915
|
+
var MINUS = "\u2212";
|
|
5916
|
+
var SHORTEN_FROM = 1e4;
|
|
5917
|
+
var isMissing = (v) => v === null || v === void 0 || Number.isNaN(v);
|
|
5918
|
+
var withCommas = (n) => Math.round(n).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
|
5919
|
+
function shortAbs(abs, style) {
|
|
5920
|
+
if (abs < SHORTEN_FROM) return withCommas(abs);
|
|
5921
|
+
let tier = Math.min(Math.floor(Math.log10(abs) / 3), 4);
|
|
5922
|
+
let scaled = Math.round(abs / 1e3 ** tier * 10) / 10;
|
|
5923
|
+
if (scaled >= 1e3 && tier < 4) {
|
|
5924
|
+
tier += 1;
|
|
5925
|
+
scaled = Math.round(abs / 1e3 ** tier * 10) / 10;
|
|
5926
|
+
}
|
|
5927
|
+
const text = Number.isInteger(scaled) ? withCommas(scaled) : scaled.toFixed(1);
|
|
5928
|
+
return `${text}${style.units[tier - 1]}`;
|
|
5929
|
+
}
|
|
5930
|
+
function symbol(opts) {
|
|
5931
|
+
const currency = opts.currency ?? "USD";
|
|
5932
|
+
if (currency === "GBP") return "\xA3";
|
|
5933
|
+
if (currency === "EUR") return "\u20AC";
|
|
5934
|
+
if (opts.mixedDollars) return currency === "CAD" ? "CA$" : "US$";
|
|
5935
|
+
return "$";
|
|
5936
|
+
}
|
|
5937
|
+
var sign = (v) => v < 0 ? MINUS : "";
|
|
5938
|
+
function formatCount(value, opts = {}) {
|
|
5939
|
+
if (isMissing(value)) return NO_VALUE;
|
|
5940
|
+
return sign(value) + shortAbs(Math.abs(value), styleFor(opts.language));
|
|
5941
|
+
}
|
|
5942
|
+
function formatCountFull(value) {
|
|
5943
|
+
if (isMissing(value)) return NO_VALUE;
|
|
5944
|
+
return sign(value) + withCommas(Math.abs(value));
|
|
5945
|
+
}
|
|
5946
|
+
function formatMoney(value, opts = {}) {
|
|
5947
|
+
if (isMissing(value)) return NO_VALUE;
|
|
5948
|
+
return sign(value) + symbol(opts) + shortAbs(Math.abs(value), styleFor(opts.language));
|
|
5949
|
+
}
|
|
5950
|
+
function formatMoneyFull(value, opts = {}) {
|
|
5951
|
+
if (isMissing(value)) return NO_VALUE;
|
|
5952
|
+
return sign(value) + symbol(opts) + withCommas(Math.abs(value));
|
|
5953
|
+
}
|
|
5954
|
+
function formatPercent(value, _opts = {}) {
|
|
5955
|
+
if (isMissing(value)) return NO_VALUE;
|
|
5956
|
+
const abs = Math.abs(value);
|
|
5957
|
+
if (abs > 0 && abs < 0.05) return `${value < 0 ? MINUS : ""}<0.1%`;
|
|
5958
|
+
const text = (Math.round(abs * 10) / 10).toFixed(1);
|
|
5959
|
+
return text === "0.0" ? "0.0%" : `${sign(value)}${text}%`;
|
|
5960
|
+
}
|
|
5905
5961
|
export {
|
|
5906
5962
|
AISpark,
|
|
5907
5963
|
AdvertiserNoResults,
|
|
@@ -5943,6 +5999,7 @@ export {
|
|
|
5943
5999
|
MultiSelectFilter,
|
|
5944
6000
|
NO_RESULTS_BODY,
|
|
5945
6001
|
NO_RESULTS_TITLE,
|
|
6002
|
+
NO_VALUE,
|
|
5946
6003
|
NameListModal,
|
|
5947
6004
|
NoResultsEmptyState,
|
|
5948
6005
|
PRIMARY_ACTION_CLASS,
|
|
@@ -5980,13 +6037,18 @@ export {
|
|
|
5980
6037
|
chipTriggerClass,
|
|
5981
6038
|
cycleSort,
|
|
5982
6039
|
defaultDateOrder,
|
|
6040
|
+
formatCount,
|
|
6041
|
+
formatCountFull,
|
|
5983
6042
|
formatDate,
|
|
5984
6043
|
formatDateRange,
|
|
5985
6044
|
formatDateTime,
|
|
5986
6045
|
formatIsoDate,
|
|
6046
|
+
formatMoney,
|
|
6047
|
+
formatMoneyFull,
|
|
5987
6048
|
formatMonth,
|
|
5988
6049
|
formatMonthAxis,
|
|
5989
6050
|
formatOpenRange,
|
|
6051
|
+
formatPercent,
|
|
5990
6052
|
formatQuarter,
|
|
5991
6053
|
formatRelative,
|
|
5992
6054
|
formatTime,
|