@wso2/oxygen-ui 0.17.0 → 0.18.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.
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { BoxProps } from '@mui/material';
|
|
3
|
+
/**
|
|
4
|
+
* Visual status of a trial, derived from the days remaining.
|
|
5
|
+
*/
|
|
6
|
+
export type TrialBadgeStatus = 'active' | 'ending-soon' | 'critical' | 'expired';
|
|
7
|
+
/**
|
|
8
|
+
* Props for the TrialBadge component
|
|
9
|
+
*/
|
|
10
|
+
export interface TrialBadgeProps extends Omit<BoxProps, 'children'> {
|
|
11
|
+
/**
|
|
12
|
+
* Number of days left in the trial. Fractional values are allowed: the exact value drives
|
|
13
|
+
* the status and ring, and the displayed count is rounded up. Values below 0 are treated as 0 (expired).
|
|
14
|
+
*/
|
|
15
|
+
daysLeft: number;
|
|
16
|
+
/**
|
|
17
|
+
* Total length of the trial in days. Used to compute the progress ring.
|
|
18
|
+
* @default 14
|
|
19
|
+
*/
|
|
20
|
+
totalDays?: number;
|
|
21
|
+
/**
|
|
22
|
+
* Days left at or below which the badge switches to the "ending soon" state.
|
|
23
|
+
* @default 7
|
|
24
|
+
*/
|
|
25
|
+
endingSoonThreshold?: number;
|
|
26
|
+
/**
|
|
27
|
+
* Days left at or below which the badge switches to the "critical" state
|
|
28
|
+
* and shows the upgrade link.
|
|
29
|
+
* @default 3
|
|
30
|
+
*/
|
|
31
|
+
criticalThreshold?: number;
|
|
32
|
+
/**
|
|
33
|
+
* Called when the badge is clicked, in addition to any `onClick`. When set (or when
|
|
34
|
+
* `upgradeHref` or `onClick` is set) the whole badge is rendered as a button.
|
|
35
|
+
*/
|
|
36
|
+
onUpgrade?: React.MouseEventHandler<HTMLElement>;
|
|
37
|
+
/**
|
|
38
|
+
* When set, the whole badge renders as an anchor pointing to this URL.
|
|
39
|
+
*/
|
|
40
|
+
upgradeHref?: string;
|
|
41
|
+
/**
|
|
42
|
+
* Whether to show the "Upgrade now" text in the critical and expired states.
|
|
43
|
+
* @default true
|
|
44
|
+
*/
|
|
45
|
+
showUpgrade?: boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Primary line while the trial is running. Receives the days left.
|
|
48
|
+
* @default (days) => `${days} day(s) left`
|
|
49
|
+
*/
|
|
50
|
+
getTitle?: (daysLeft: number) => React.ReactNode;
|
|
51
|
+
/**
|
|
52
|
+
* Primary line once the trial has expired.
|
|
53
|
+
* @default 'Trial expired'
|
|
54
|
+
*/
|
|
55
|
+
expiredLabel?: React.ReactNode;
|
|
56
|
+
/**
|
|
57
|
+
* Secondary line while no upgrade prompt is shown.
|
|
58
|
+
* @default 'of free trial'
|
|
59
|
+
*/
|
|
60
|
+
subtitle?: React.ReactNode;
|
|
61
|
+
/**
|
|
62
|
+
* Text of the upgrade link.
|
|
63
|
+
* @default 'Upgrade now'
|
|
64
|
+
*/
|
|
65
|
+
upgradeLabel?: React.ReactNode;
|
|
66
|
+
/**
|
|
67
|
+
* Optional usage summary. When set, hovering or focusing the badge opens a panel listing
|
|
68
|
+
* how much of each resource is used, with an upgrade button. When omitted, no panel is shown.
|
|
69
|
+
*/
|
|
70
|
+
usage?: TrialBadgeUsage;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* A resource listed in the usage panel, shown as `count/limit`.
|
|
74
|
+
*/
|
|
75
|
+
export interface TrialBadgeUsageItem {
|
|
76
|
+
/**
|
|
77
|
+
* Stable key for the row. Falls back to the label.
|
|
78
|
+
*/
|
|
79
|
+
key?: string;
|
|
80
|
+
/**
|
|
81
|
+
* Name of the resource, e.g. "REST APIs".
|
|
82
|
+
*/
|
|
83
|
+
label: React.ReactNode;
|
|
84
|
+
/**
|
|
85
|
+
* The count shown for this resource, out of `limit`. The bar and its color follow
|
|
86
|
+
* `count / limit`: a higher share means more of the quota is taken, so it turns yellow and then red.
|
|
87
|
+
*/
|
|
88
|
+
count: number;
|
|
89
|
+
/**
|
|
90
|
+
* The total allowed for this resource.
|
|
91
|
+
*/
|
|
92
|
+
limit: number;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* A titled group of resources in the usage panel.
|
|
96
|
+
*/
|
|
97
|
+
export interface TrialBadgeUsageSection {
|
|
98
|
+
/**
|
|
99
|
+
* Stable key for the section. Falls back to the title.
|
|
100
|
+
*/
|
|
101
|
+
key?: string;
|
|
102
|
+
/**
|
|
103
|
+
* Heading of the section.
|
|
104
|
+
*/
|
|
105
|
+
title: React.ReactNode;
|
|
106
|
+
/**
|
|
107
|
+
* The resources to list. The section total is the sum of their counts and limits.
|
|
108
|
+
*/
|
|
109
|
+
items: TrialBadgeUsageItem[];
|
|
110
|
+
/**
|
|
111
|
+
* Text after the section total, e.g. `left` gives "14 of 30 left".
|
|
112
|
+
* The total is shown only when this is passed.
|
|
113
|
+
*/
|
|
114
|
+
totalSuffix?: React.ReactNode;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Content of the usage panel shown when hovering or focusing the badge.
|
|
118
|
+
* Pass `sections` for several titled groups, or `items` (with an optional `title`) for one.
|
|
119
|
+
*/
|
|
120
|
+
export interface TrialBadgeUsage {
|
|
121
|
+
/**
|
|
122
|
+
* Titled groups of resources. Takes precedence over `items`.
|
|
123
|
+
*/
|
|
124
|
+
sections?: TrialBadgeUsageSection[];
|
|
125
|
+
/**
|
|
126
|
+
* The resources to list when there is a single group and no `sections`.
|
|
127
|
+
*/
|
|
128
|
+
items?: TrialBadgeUsageItem[];
|
|
129
|
+
/**
|
|
130
|
+
* Heading of the single group made from `items`.
|
|
131
|
+
* @default 'Components left'
|
|
132
|
+
*/
|
|
133
|
+
title?: React.ReactNode;
|
|
134
|
+
/**
|
|
135
|
+
* Text after the total of the single group made from `items`.
|
|
136
|
+
* The total is shown only when this is passed.
|
|
137
|
+
*/
|
|
138
|
+
totalSuffix?: React.ReactNode;
|
|
139
|
+
/**
|
|
140
|
+
* Text shown at the bottom left of the panel. Pass `null` to hide it.
|
|
141
|
+
* @default 'Unlimited on Pro'
|
|
142
|
+
*/
|
|
143
|
+
footerText?: React.ReactNode;
|
|
144
|
+
/**
|
|
145
|
+
* Label of the panel's upgrade button.
|
|
146
|
+
* @default 'Upgrade'
|
|
147
|
+
*/
|
|
148
|
+
upgradeLabel?: React.ReactNode;
|
|
149
|
+
/**
|
|
150
|
+
* Called when the panel's upgrade button is clicked.
|
|
151
|
+
*/
|
|
152
|
+
onUpgrade?: React.MouseEventHandler<HTMLElement>;
|
|
153
|
+
/**
|
|
154
|
+
* When set, the panel's upgrade button renders as an anchor pointing to this URL.
|
|
155
|
+
*/
|
|
156
|
+
upgradeHref?: string;
|
|
157
|
+
/**
|
|
158
|
+
* Share (0-1) of the limit above which a bar turns yellow. At or below it the bar is green.
|
|
159
|
+
* @default 0.5
|
|
160
|
+
*/
|
|
161
|
+
warningThreshold?: number;
|
|
162
|
+
/**
|
|
163
|
+
* Share (0-1) of the limit at or above which a bar turns red.
|
|
164
|
+
* @default 0.75
|
|
165
|
+
*/
|
|
166
|
+
criticalThreshold?: number;
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Color tone of a quota, from the share of its limit that is taken.
|
|
170
|
+
*/
|
|
171
|
+
export type TrialBadgeUsageTone = 'error' | 'warning' | 'success';
|
|
172
|
+
/**
|
|
173
|
+
* Resolve the status of a trial from the days left and thresholds.
|
|
174
|
+
*/
|
|
175
|
+
export declare function getTrialBadgeStatus(daysLeft: number, endingSoonThreshold?: number, criticalThreshold?: number): TrialBadgeStatus;
|
|
176
|
+
/**
|
|
177
|
+
* TrialBadge component - A compact pill showing the remaining days of a free trial.
|
|
178
|
+
* The color changes with the time left, and in the last days (and after expiry)
|
|
179
|
+
* the second line becomes an "Upgrade now" link.
|
|
180
|
+
*
|
|
181
|
+
* @example
|
|
182
|
+
* ```tsx
|
|
183
|
+
* <TrialBadge daysLeft={12} />
|
|
184
|
+
* ```
|
|
185
|
+
*
|
|
186
|
+
* @example
|
|
187
|
+
* ```tsx
|
|
188
|
+
* <TrialBadge daysLeft={2} onUpgrade={() => navigate('/billing')} />
|
|
189
|
+
* ```
|
|
190
|
+
*/
|
|
191
|
+
declare const TrialBadge: React.FC<TrialBadgeProps>;
|
|
192
|
+
export default TrialBadge;
|
|
@@ -34,6 +34,8 @@ export { default as RelativeTime } from './RelativeTime';
|
|
|
34
34
|
export type { RelativeTimeProps } from './RelativeTime';
|
|
35
35
|
export { default as StatCard } from './StatCard';
|
|
36
36
|
export type { StatCardProps } from './StatCard';
|
|
37
|
+
export { default as TrialBadge, getTrialBadgeStatus } from './TrialBadge';
|
|
38
|
+
export type { TrialBadgeProps, TrialBadgeStatus, TrialBadgeUsage, TrialBadgeUsageItem, TrialBadgeUsageSection, TrialBadgeUsageTone, } from './TrialBadge';
|
|
37
39
|
export { default as ThemeSwitcher, ThemeSelect } from './ThemeSwitcher';
|
|
38
40
|
export type { ThemeSwitcherProps, ThemeSelectProps } from './ThemeSwitcher';
|
|
39
41
|
export { default as TimeRangeFilter } from './TimeRangeFilter';
|