@ciromaciel/auth-react 1.4.1 → 1.5.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/README.md +5 -1
- package/dist/index.esm.js +46 -15
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +46 -15
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3986,6 +3986,13 @@ const ROLE_LABELS = {
|
|
|
3986
3986
|
member: 'Membro'
|
|
3987
3987
|
};
|
|
3988
3988
|
|
|
3989
|
+
/*
|
|
3990
|
+
* From this share of the limit on, the strip invites to upgrade. Below it the
|
|
3991
|
+
* strip only informs: "Assinatura" is the door that is always there, and a
|
|
3992
|
+
* second link to the same modal right above it was two doors to one room.
|
|
3993
|
+
*/
|
|
3994
|
+
const UPGRADE_THRESHOLD = 0.8;
|
|
3995
|
+
|
|
3989
3996
|
/**
|
|
3990
3997
|
* @typedef {Object} UserInformationItem
|
|
3991
3998
|
* @property {string} [id] - Stable key
|
|
@@ -3998,8 +4005,12 @@ const ROLE_LABELS = {
|
|
|
3998
4005
|
* @property {number} [used] - How many of the plan's resources are in use
|
|
3999
4006
|
* @property {number|null} [limit] - The plan's ceiling; `null` hides the meter
|
|
4000
4007
|
* @property {string} [unit] - What is counted, in the plural: "projetos"
|
|
4001
|
-
* @property {
|
|
4002
|
-
*
|
|
4008
|
+
* @property {boolean} [canUpgrade=false] - There is a plan above this one. Without
|
|
4009
|
+
* it the invite never shows, however full the plan is: on the last rung there
|
|
4010
|
+
* is nowhere to go
|
|
4011
|
+
* @property {string} [actionLabel='Fazer upgrade']
|
|
4012
|
+
* @property {Function} [onClick] - Opens the plans. The invite shows only with
|
|
4013
|
+
* `canUpgrade` and usage at 80% of the limit or more
|
|
4003
4014
|
*
|
|
4004
4015
|
* @typedef {Object} UserInformationOrganization
|
|
4005
4016
|
* @property {string} name
|
|
@@ -4187,6 +4198,15 @@ function ContextStrip({
|
|
|
4187
4198
|
const role = organization?.role ? ROLE_LABELS[organization.role] || organization.role : null;
|
|
4188
4199
|
const hasMeter = plan && Number.isFinite(plan.used) && Number.isFinite(plan.limit) && plan.limit > 0;
|
|
4189
4200
|
const ratio = hasMeter ? Math.min(1, Math.max(0, plan.used / plan.limit)) : 0;
|
|
4201
|
+
const isFull = hasMeter && plan.used >= plan.limit;
|
|
4202
|
+
const showsInvite = hasMeter && plan.canUpgrade === true && typeof plan.onClick === 'function' && ratio >= UPGRADE_THRESHOLD;
|
|
4203
|
+
/*
|
|
4204
|
+
* "Limite atingido" sits on the badge's line, whose left side is empty
|
|
4205
|
+
* when there is no organization. Next to the count it would wrap to two
|
|
4206
|
+
* lines beside the invite. With an organization there, it falls back to
|
|
4207
|
+
* the count.
|
|
4208
|
+
*/
|
|
4209
|
+
const limitNoticeOnTop = isFull && !organization?.name;
|
|
4190
4210
|
return /*#__PURE__*/jsxRuntime.jsxs(core.Stack, {
|
|
4191
4211
|
gap: 8,
|
|
4192
4212
|
px: padded ? 16 : 0,
|
|
@@ -4199,7 +4219,12 @@ function ContextStrip({
|
|
|
4199
4219
|
children: [(organization?.name || plan?.name) && /*#__PURE__*/jsxRuntime.jsxs(core.Group, {
|
|
4200
4220
|
gap: 8,
|
|
4201
4221
|
wrap: "nowrap",
|
|
4202
|
-
children: [
|
|
4222
|
+
children: [limitNoticeOnTop && /*#__PURE__*/jsxRuntime.jsx(core.Text, {
|
|
4223
|
+
fz: 12,
|
|
4224
|
+
fw: 700,
|
|
4225
|
+
c: "red.8",
|
|
4226
|
+
children: "Limite atingido"
|
|
4227
|
+
}), organization?.name && /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
4203
4228
|
children: [/*#__PURE__*/jsxRuntime.jsx(iconsReact.IconBuilding, {
|
|
4204
4229
|
size: 14,
|
|
4205
4230
|
stroke: 1.5,
|
|
@@ -4253,7 +4278,7 @@ function ContextStrip({
|
|
|
4253
4278
|
children: /*#__PURE__*/jsxRuntime.jsx(core.Box, {
|
|
4254
4279
|
h: "100%",
|
|
4255
4280
|
w: `${ratio * 100}%`,
|
|
4256
|
-
bg:
|
|
4281
|
+
bg: isFull ? 'red.8' : 'gray.9'
|
|
4257
4282
|
})
|
|
4258
4283
|
}), /*#__PURE__*/jsxRuntime.jsxs(core.Group, {
|
|
4259
4284
|
justify: "space-between",
|
|
@@ -4261,18 +4286,24 @@ function ContextStrip({
|
|
|
4261
4286
|
wrap: "nowrap",
|
|
4262
4287
|
children: [/*#__PURE__*/jsxRuntime.jsx(core.Text, {
|
|
4263
4288
|
fz: 12,
|
|
4264
|
-
fw: 500,
|
|
4265
|
-
c:
|
|
4266
|
-
children: `${plan.used} de ${plan.limit}${plan.unit ? ` ${plan.unit}` : ''}`
|
|
4267
|
-
}),
|
|
4268
|
-
component: "button",
|
|
4269
|
-
type: "button",
|
|
4270
|
-
fz: 12,
|
|
4271
|
-
fw: 700,
|
|
4272
|
-
c: "gray.9",
|
|
4273
|
-
underline: "always",
|
|
4289
|
+
fw: isFull ? 700 : 500,
|
|
4290
|
+
c: isFull ? 'red.8' : 'gray.6',
|
|
4291
|
+
children: `${plan.used} de ${plan.limit}${plan.unit ? ` ${plan.unit}` : ''}${isFull && !limitNoticeOnTop ? ' · limite atingido' : ''}`
|
|
4292
|
+
}), showsInvite && /*#__PURE__*/jsxRuntime.jsx(core.UnstyledButton, {
|
|
4274
4293
|
onClick: plan.onClick,
|
|
4275
|
-
|
|
4294
|
+
fz: 11,
|
|
4295
|
+
fw: 800,
|
|
4296
|
+
lts: "0.5px",
|
|
4297
|
+
c: "white",
|
|
4298
|
+
bg: "gray.9",
|
|
4299
|
+
px: 8,
|
|
4300
|
+
py: 3,
|
|
4301
|
+
lh: 1.4,
|
|
4302
|
+
style: {
|
|
4303
|
+
flex: 'none',
|
|
4304
|
+
whiteSpace: 'nowrap'
|
|
4305
|
+
},
|
|
4306
|
+
children: plan.actionLabel || 'Fazer upgrade'
|
|
4276
4307
|
})]
|
|
4277
4308
|
})]
|
|
4278
4309
|
})]
|