@skdx/react-blocks 0.1.0 → 0.35.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 +1 -1
- package/dist/chat-composer/ChatComposer.cjs +2 -0
- package/dist/chat-composer/ChatComposer.d.cts +20 -0
- package/dist/chat-composer/ChatComposer.d.ts +20 -0
- package/dist/chat-composer/ChatComposer.js +2 -0
- package/dist/chat-composer/index.d.cts +2 -0
- package/dist/chat-composer/index.d.ts +2 -0
- package/dist/chat-composer/types.d.cts +96 -0
- package/dist/chat-composer/types.d.ts +96 -0
- package/dist/chat-message/ChatMessage.cjs +2 -0
- package/dist/chat-message/ChatMessage.d.cts +23 -0
- package/dist/chat-message/ChatMessage.d.ts +23 -0
- package/dist/chat-message/ChatMessage.js +2 -0
- package/dist/chat-message/index.d.cts +2 -0
- package/dist/chat-message/index.d.ts +2 -0
- package/dist/chat-message/types.d.cts +57 -0
- package/dist/chat-message/types.d.ts +57 -0
- package/dist/comment/Comment.cjs +2 -0
- package/dist/comment/Comment.d.cts +22 -0
- package/dist/comment/Comment.d.ts +22 -0
- package/dist/comment/Comment.js +2 -0
- package/dist/comment/index.d.cts +2 -0
- package/dist/comment/index.d.ts +2 -0
- package/dist/comment/types.d.cts +47 -0
- package/dist/comment/types.d.ts +47 -0
- package/dist/comment-thread/CommentThread.cjs +2 -0
- package/dist/comment-thread/CommentThread.d.cts +21 -0
- package/dist/comment-thread/CommentThread.d.ts +21 -0
- package/dist/comment-thread/CommentThread.js +2 -0
- package/dist/comment-thread/index.d.cts +2 -0
- package/dist/comment-thread/index.d.ts +2 -0
- package/dist/comment-thread/types.d.cts +46 -0
- package/dist/comment-thread/types.d.ts +46 -0
- package/dist/confirm-dialog/ConfirmDialog.cjs +2 -0
- package/dist/confirm-dialog/ConfirmDialog.d.cts +31 -0
- package/dist/confirm-dialog/ConfirmDialog.d.ts +31 -0
- package/dist/confirm-dialog/ConfirmDialog.js +2 -0
- package/dist/confirm-dialog/index.d.cts +2 -0
- package/dist/confirm-dialog/index.d.ts +2 -0
- package/dist/confirm-dialog/types.d.cts +114 -0
- package/dist/confirm-dialog/types.d.ts +114 -0
- package/dist/conversation-list/ConversationList.cjs +2 -0
- package/dist/conversation-list/ConversationList.d.cts +20 -0
- package/dist/conversation-list/ConversationList.d.ts +20 -0
- package/dist/conversation-list/ConversationList.js +2 -0
- package/dist/conversation-list/index.d.cts +2 -0
- package/dist/conversation-list/index.d.ts +2 -0
- package/dist/conversation-list/types.d.cts +94 -0
- package/dist/conversation-list/types.d.ts +94 -0
- package/dist/dashboard-layout/DashboardLayout.cjs +1 -1
- package/dist/dashboard-layout/DashboardLayout.js +1 -1
- package/dist/empty-state/EmptyState.cjs +2 -0
- package/dist/empty-state/EmptyState.d.cts +21 -0
- package/dist/empty-state/EmptyState.d.ts +21 -0
- package/dist/empty-state/EmptyState.js +2 -0
- package/dist/empty-state/index.d.cts +2 -0
- package/dist/empty-state/index.d.ts +2 -0
- package/dist/empty-state/types.d.cts +36 -0
- package/dist/empty-state/types.d.ts +36 -0
- package/dist/filter-bar/FilterBar.cjs +2 -0
- package/dist/filter-bar/FilterBar.d.cts +23 -0
- package/dist/filter-bar/FilterBar.d.ts +23 -0
- package/dist/filter-bar/FilterBar.js +2 -0
- package/dist/filter-bar/index.d.cts +2 -0
- package/dist/filter-bar/index.d.ts +2 -0
- package/dist/filter-bar/types.d.cts +81 -0
- package/dist/filter-bar/types.d.ts +81 -0
- package/dist/forgot-password-page/ForgotPasswordPage.cjs +2 -0
- package/dist/forgot-password-page/ForgotPasswordPage.d.cts +20 -0
- package/dist/forgot-password-page/ForgotPasswordPage.d.ts +20 -0
- package/dist/forgot-password-page/ForgotPasswordPage.js +2 -0
- package/dist/forgot-password-page/index.d.cts +2 -0
- package/dist/forgot-password-page/index.d.ts +2 -0
- package/dist/forgot-password-page/types.d.cts +54 -0
- package/dist/forgot-password-page/types.d.ts +54 -0
- package/dist/form-section/FormSection.cjs +2 -0
- package/dist/form-section/FormSection.d.cts +22 -0
- package/dist/form-section/FormSection.d.ts +22 -0
- package/dist/form-section/FormSection.js +2 -0
- package/dist/form-section/index.d.cts +2 -0
- package/dist/form-section/index.d.ts +2 -0
- package/dist/form-section/types.d.cts +27 -0
- package/dist/form-section/types.d.ts +27 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +19 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.js +1 -1
- package/dist/internal/AuthPanel.d.cts +54 -0
- package/dist/internal/AuthPanel.d.ts +54 -0
- package/dist/internal/Region.d.cts +17 -0
- package/dist/internal/Region.d.ts +17 -0
- package/dist/internal/formValue.d.cts +6 -0
- package/dist/internal/formValue.d.ts +6 -0
- package/dist/notification-center/NotificationCenter.cjs +2 -0
- package/dist/notification-center/NotificationCenter.d.cts +21 -0
- package/dist/notification-center/NotificationCenter.d.ts +21 -0
- package/dist/notification-center/NotificationCenter.js +2 -0
- package/dist/notification-center/index.d.cts +2 -0
- package/dist/notification-center/index.d.ts +2 -0
- package/dist/notification-center/types.d.cts +104 -0
- package/dist/notification-center/types.d.ts +104 -0
- package/dist/onboarding-checklist/OnboardingChecklist.cjs +2 -0
- package/dist/onboarding-checklist/OnboardingChecklist.d.cts +25 -0
- package/dist/onboarding-checklist/OnboardingChecklist.d.ts +25 -0
- package/dist/onboarding-checklist/OnboardingChecklist.js +2 -0
- package/dist/onboarding-checklist/index.d.cts +2 -0
- package/dist/onboarding-checklist/index.d.ts +2 -0
- package/dist/onboarding-checklist/types.d.cts +67 -0
- package/dist/onboarding-checklist/types.d.ts +67 -0
- package/dist/reset-password-page/ResetPasswordPage.cjs +2 -0
- package/dist/reset-password-page/ResetPasswordPage.d.cts +20 -0
- package/dist/reset-password-page/ResetPasswordPage.d.ts +20 -0
- package/dist/reset-password-page/ResetPasswordPage.js +2 -0
- package/dist/reset-password-page/index.d.cts +2 -0
- package/dist/reset-password-page/index.d.ts +2 -0
- package/dist/reset-password-page/types.d.cts +64 -0
- package/dist/reset-password-page/types.d.ts +64 -0
- package/dist/sign-in-page/SignInPage.cjs +1 -1
- package/dist/sign-in-page/SignInPage.d.cts +1 -1
- package/dist/sign-in-page/SignInPage.d.ts +1 -1
- package/dist/sign-in-page/SignInPage.js +1 -1
- package/dist/sign-up-page/SignUpPage.cjs +2 -0
- package/dist/sign-up-page/SignUpPage.d.cts +21 -0
- package/dist/sign-up-page/SignUpPage.d.ts +21 -0
- package/dist/sign-up-page/SignUpPage.js +2 -0
- package/dist/sign-up-page/index.d.cts +2 -0
- package/dist/sign-up-page/index.d.ts +2 -0
- package/dist/sign-up-page/types.d.cts +100 -0
- package/dist/sign-up-page/types.d.ts +100 -0
- package/dist/stat-card/StatCard.cjs +2 -0
- package/dist/stat-card/StatCard.d.cts +22 -0
- package/dist/stat-card/StatCard.d.ts +22 -0
- package/dist/stat-card/StatCard.js +2 -0
- package/dist/stat-card/index.d.cts +2 -0
- package/dist/stat-card/index.d.ts +2 -0
- package/dist/stat-card/types.d.cts +71 -0
- package/dist/stat-card/types.d.ts +71 -0
- package/dist/usage-card/UsageCard.cjs +2 -0
- package/dist/usage-card/UsageCard.d.cts +17 -0
- package/dist/usage-card/UsageCard.d.ts +17 -0
- package/dist/usage-card/UsageCard.js +2 -0
- package/dist/usage-card/index.d.cts +2 -0
- package/dist/usage-card/index.d.ts +2 -0
- package/dist/usage-card/types.d.cts +50 -0
- package/dist/usage-card/types.d.ts +50 -0
- package/dist/usage-card/usage.d.cts +18 -0
- package/dist/usage-card/usage.d.ts +18 -0
- package/dist/user-menu/UserMenu.cjs +2 -0
- package/dist/user-menu/UserMenu.d.cts +19 -0
- package/dist/user-menu/UserMenu.d.ts +19 -0
- package/dist/user-menu/UserMenu.js +2 -0
- package/dist/user-menu/index.d.cts +2 -0
- package/dist/user-menu/index.d.ts +2 -0
- package/dist/user-menu/types.d.cts +89 -0
- package/dist/user-menu/types.d.ts +89 -0
- package/dist/verification-page/VerificationPage.cjs +2 -0
- package/dist/verification-page/VerificationPage.d.cts +20 -0
- package/dist/verification-page/VerificationPage.d.ts +20 -0
- package/dist/verification-page/VerificationPage.js +2 -0
- package/dist/verification-page/index.d.cts +2 -0
- package/dist/verification-page/index.d.ts +2 -0
- package/dist/verification-page/types.d.cts +89 -0
- package/dist/verification-page/types.d.ts +89 -0
- package/dist/workspace-switcher/WorkspaceSwitcher.cjs +2 -0
- package/dist/workspace-switcher/WorkspaceSwitcher.d.cts +25 -0
- package/dist/workspace-switcher/WorkspaceSwitcher.d.ts +25 -0
- package/dist/workspace-switcher/WorkspaceSwitcher.js +2 -0
- package/dist/workspace-switcher/index.d.cts +2 -0
- package/dist/workspace-switcher/index.d.ts +2 -0
- package/dist/workspace-switcher/types.d.cts +151 -0
- package/dist/workspace-switcher/types.d.ts +151 -0
- package/package.json +197 -6
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type * as React from 'react';
|
|
2
|
+
import type { SignUpPageProps } from './types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Sign-up block: an error alert, one button per third-party provider, and the
|
|
5
|
+
* credentials form — name, email, password, confirmation and terms — reporting
|
|
6
|
+
* through `onSignUp`.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```tsx
|
|
10
|
+
* <SignUpPage
|
|
11
|
+
* confirmPasswordLabel="Confirm password"
|
|
12
|
+
* terms={<>I accept the <a href="/terms">terms</a>.</>}
|
|
13
|
+
* error={error}
|
|
14
|
+
* onSignUp={(detail) => void register(detail)}
|
|
15
|
+
* />
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export declare const SignUpPage: {
|
|
19
|
+
({ title, providers, error, pending, nameLabel, emailLabel, passwordLabel, confirmPasswordLabel, passwordMismatchMessage, terms, submitLabel, getProviderLabel, footer, onSignUp, children, ...props }: SignUpPageProps): React.ReactNode;
|
|
20
|
+
displayName: string;
|
|
21
|
+
};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import{Button as I,Checkbox as z,Divider as G,Field as u,Form as J,PasswordInput as R,TextField as w}from"@skdx/react";import{PasswordInputField as T,PasswordInputToggle as q}from"@skdx/react/primitives/password-input";import{TextFieldInput as E}from"@skdx/react/primitives/text-field";import*as C from"react";import{Alert as L,Heading as _}from"@skdx/react";import{jsx as g,jsxs as O}from"react/jsx-runtime";var h=({parts:e,title:r,error:i,footer:a,children:s,...l})=>{let p=C.useId();return g("section",{"aria-labelledby":p,...l,...e.root,children:O("div",{...e.panel,children:[g(_,{as:"h1",id:p,...e.title,children:r}),i?g(L,{status:"danger",...e.error,children:i}):null,s,a&&e.footer?g("div",{...e.footer,children:a}):null]})})};h.displayName="AuthPanel";function f(e,r){let i=e.get(r);return typeof i=="string"?i:""}function W(...e){let r="";for(let i of e)i&&(r=r?`${r} ${i}`:i);return r}function n(e,r,i){let a=r==="root",s=a?`skdx-${e}`:`skdx-${e}__${r}`,l={className:W(s,i),"data-part":r};return a&&(l["data-skdx-component"]=e),l}import{defaultProviderLabel as K}from"../sign-in-page/SignInPage.js";import{jsx as t,jsxs as c}from"react/jsx-runtime";var v="confirmPassword";function Q(e){let r=e.elements.namedItem(v);return r instanceof HTMLInputElement?r:null}var N=({title:e="Create account",providers:r,error:i,pending:a=!1,nameLabel:s,emailLabel:l="Email",passwordLabel:p="Password",confirmPasswordLabel:P,passwordMismatchMessage:H="Passwords do not match",terms:x,submitLabel:M="Create account",getProviderLabel:U=K,footer:D,onSignUp:F,children:V,...k})=>{let b=r??[],$=o=>{o.preventDefault();let d=o.currentTarget,m=new FormData(d),y=f(m,"password"),A=P===void 0?null:Q(d);if(A&&A.value!==y){A.setCustomValidity(H),d.reportValidity();return}let S={providerId:"credentials",email:f(m,"email"),password:y};s!==void 0&&(S.name=f(m,"name")),x!==void 0&&(S.termsAccepted=m.get("terms")!==null),F?.(S)},B=o=>{let d=o.target;d instanceof HTMLInputElement&&d.name===v&&d.setCustomValidity("")};return c(h,{...k,parts:{root:n("sign-up-page","root",k.className),panel:n("sign-up-page","panel"),title:n("sign-up-page","title"),error:n("sign-up-page","error"),footer:n("sign-up-page","footer")},title:e,error:i,footer:D,children:[b.length>0?t("div",{...n("sign-up-page","providers"),children:b.map(o=>t(I,{type:"button","data-provider":o.id,onClick:()=>{F?.({providerId:o.id})},...n("sign-up-page","provider"),children:U(o)},o.id))}):null,b.length>0?t(G,{...n("sign-up-page","divider")}):null,c(J,{onSubmit:$,onChange:B,...n("sign-up-page","form"),children:[s!==void 0?t(u,{label:s,required:!0,...n("sign-up-page","field"),children:t(w,{name:"name",required:!0,children:t(E,{autoComplete:"name"})})}):null,t(u,{label:l,required:!0,...n("sign-up-page","field"),children:t(w,{name:"email",required:!0,children:t(E,{type:"email",autoComplete:"email"})})}),t(u,{label:p,required:!0,...n("sign-up-page","field"),children:c(R,{name:"password",required:!0,children:[t(T,{autoComplete:"new-password"}),t(q,{})]})}),P!==void 0?t(u,{label:P,required:!0,...n("sign-up-page","field"),children:c(R,{name:v,required:!0,children:[t(T,{autoComplete:"new-password"}),t(q,{})]})}):null,V,x!==void 0?t(u,{label:x,required:!0,...n("sign-up-page","terms"),children:t(z,{name:"terms",required:!0})}):null,t(I,{type:"submit",loading:a,disabled:a,...n("sign-up-page","submit"),children:M})]})]})};N.displayName="SignUpPage";export{N as SignUpPage};
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import type * as React from 'react';
|
|
2
|
+
import type { SignInProvider } from '../sign-in-page/index.cjs';
|
|
3
|
+
/** What {@link SignUpPageProps.onSignUp} is called with when a provider or the form is used. */
|
|
4
|
+
export interface SignUpDetail {
|
|
5
|
+
/** The `id` of the provider the user chose, or `'credentials'` for the form. */
|
|
6
|
+
providerId: string;
|
|
7
|
+
/**
|
|
8
|
+
* Name submitted by the credentials form, present only while the name field renders.
|
|
9
|
+
* @default undefined — no name field rendered, or a provider button was used.
|
|
10
|
+
*/
|
|
11
|
+
name?: string | undefined;
|
|
12
|
+
/**
|
|
13
|
+
* Email address submitted by the credentials form.
|
|
14
|
+
* @default undefined — a provider button carries no field values.
|
|
15
|
+
*/
|
|
16
|
+
email?: string | undefined;
|
|
17
|
+
/**
|
|
18
|
+
* Password submitted by the credentials form, already matched against the confirmation.
|
|
19
|
+
* @default undefined — a provider button carries no field values.
|
|
20
|
+
*/
|
|
21
|
+
password?: string | undefined;
|
|
22
|
+
/**
|
|
23
|
+
* Whether the terms checkbox was ticked, present only while the terms field renders.
|
|
24
|
+
* @default undefined — no terms field rendered, or a provider button was used.
|
|
25
|
+
*/
|
|
26
|
+
termsAccepted?: boolean | undefined;
|
|
27
|
+
}
|
|
28
|
+
/** Props for the {@link SignUpPage} block. */
|
|
29
|
+
export interface SignUpPageProps extends React.ComponentPropsWithRef<'section'> {
|
|
30
|
+
/**
|
|
31
|
+
* Heading text, rendered into a derived `<h1>` that names the section.
|
|
32
|
+
* @default 'Create account'
|
|
33
|
+
*/
|
|
34
|
+
title?: string | undefined;
|
|
35
|
+
/**
|
|
36
|
+
* Third-party providers, each rendering one button above the credentials form.
|
|
37
|
+
* @default undefined — no provider region and no divider render.
|
|
38
|
+
*/
|
|
39
|
+
providers?: ReadonlyArray<SignInProvider> | undefined;
|
|
40
|
+
/**
|
|
41
|
+
* Message rendered into a derived error Alert above the form; the block never clears it.
|
|
42
|
+
* @default undefined — no error region renders.
|
|
43
|
+
*/
|
|
44
|
+
error?: string | undefined;
|
|
45
|
+
/**
|
|
46
|
+
* Marks the request in flight, making the submit button busy and unusable while the fields stay editable.
|
|
47
|
+
* @default false
|
|
48
|
+
*/
|
|
49
|
+
pending?: boolean | undefined;
|
|
50
|
+
/**
|
|
51
|
+
* Label of the name field; supplying it is what makes that field render at all.
|
|
52
|
+
* @default undefined — no name field renders.
|
|
53
|
+
*/
|
|
54
|
+
nameLabel?: string | undefined;
|
|
55
|
+
/**
|
|
56
|
+
* Label of the email field in the credentials form.
|
|
57
|
+
* @default 'Email'
|
|
58
|
+
*/
|
|
59
|
+
emailLabel?: string | undefined;
|
|
60
|
+
/**
|
|
61
|
+
* Label of the password field in the credentials form.
|
|
62
|
+
* @default 'Password'
|
|
63
|
+
*/
|
|
64
|
+
passwordLabel?: string | undefined;
|
|
65
|
+
/**
|
|
66
|
+
* Label of the confirmation field; supplying it is what makes that field render at all.
|
|
67
|
+
* @default undefined — no confirmation field renders and no matching is done.
|
|
68
|
+
*/
|
|
69
|
+
confirmPasswordLabel?: string | undefined;
|
|
70
|
+
/**
|
|
71
|
+
* Validation message shown on the confirmation field when the two passwords differ.
|
|
72
|
+
* @default 'Passwords do not match'
|
|
73
|
+
*/
|
|
74
|
+
passwordMismatchMessage?: string | undefined;
|
|
75
|
+
/**
|
|
76
|
+
* Terms copy and links, rendered as the label of a required checkbox before the submit button.
|
|
77
|
+
* @default undefined — no terms field renders.
|
|
78
|
+
*/
|
|
79
|
+
terms?: React.ReactNode | undefined;
|
|
80
|
+
/**
|
|
81
|
+
* Text of the credentials form's submit button.
|
|
82
|
+
* @default 'Create account'
|
|
83
|
+
*/
|
|
84
|
+
submitLabel?: string | undefined;
|
|
85
|
+
/**
|
|
86
|
+
* Words a provider button's text from its entry, replacing the built-in wording.
|
|
87
|
+
* @default defaultProviderLabel — reads "Sign in with Google".
|
|
88
|
+
*/
|
|
89
|
+
getProviderLabel?: ((provider: SignInProvider) => string) | undefined;
|
|
90
|
+
/**
|
|
91
|
+
* Navigation rendered below the form, such as a link back to the sign-in page.
|
|
92
|
+
* @default undefined — no footer region renders.
|
|
93
|
+
*/
|
|
94
|
+
footer?: React.ReactNode | undefined;
|
|
95
|
+
/**
|
|
96
|
+
* Fires when a provider button is activated or the form is submitted with matching, valid fields.
|
|
97
|
+
* @default undefined — no-op if omitted.
|
|
98
|
+
*/
|
|
99
|
+
onSignUp?: ((detail: SignUpDetail) => void) | undefined;
|
|
100
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import type * as React from 'react';
|
|
2
|
+
import type { SignInProvider } from '../sign-in-page/index.js';
|
|
3
|
+
/** What {@link SignUpPageProps.onSignUp} is called with when a provider or the form is used. */
|
|
4
|
+
export interface SignUpDetail {
|
|
5
|
+
/** The `id` of the provider the user chose, or `'credentials'` for the form. */
|
|
6
|
+
providerId: string;
|
|
7
|
+
/**
|
|
8
|
+
* Name submitted by the credentials form, present only while the name field renders.
|
|
9
|
+
* @default undefined — no name field rendered, or a provider button was used.
|
|
10
|
+
*/
|
|
11
|
+
name?: string | undefined;
|
|
12
|
+
/**
|
|
13
|
+
* Email address submitted by the credentials form.
|
|
14
|
+
* @default undefined — a provider button carries no field values.
|
|
15
|
+
*/
|
|
16
|
+
email?: string | undefined;
|
|
17
|
+
/**
|
|
18
|
+
* Password submitted by the credentials form, already matched against the confirmation.
|
|
19
|
+
* @default undefined — a provider button carries no field values.
|
|
20
|
+
*/
|
|
21
|
+
password?: string | undefined;
|
|
22
|
+
/**
|
|
23
|
+
* Whether the terms checkbox was ticked, present only while the terms field renders.
|
|
24
|
+
* @default undefined — no terms field rendered, or a provider button was used.
|
|
25
|
+
*/
|
|
26
|
+
termsAccepted?: boolean | undefined;
|
|
27
|
+
}
|
|
28
|
+
/** Props for the {@link SignUpPage} block. */
|
|
29
|
+
export interface SignUpPageProps extends React.ComponentPropsWithRef<'section'> {
|
|
30
|
+
/**
|
|
31
|
+
* Heading text, rendered into a derived `<h1>` that names the section.
|
|
32
|
+
* @default 'Create account'
|
|
33
|
+
*/
|
|
34
|
+
title?: string | undefined;
|
|
35
|
+
/**
|
|
36
|
+
* Third-party providers, each rendering one button above the credentials form.
|
|
37
|
+
* @default undefined — no provider region and no divider render.
|
|
38
|
+
*/
|
|
39
|
+
providers?: ReadonlyArray<SignInProvider> | undefined;
|
|
40
|
+
/**
|
|
41
|
+
* Message rendered into a derived error Alert above the form; the block never clears it.
|
|
42
|
+
* @default undefined — no error region renders.
|
|
43
|
+
*/
|
|
44
|
+
error?: string | undefined;
|
|
45
|
+
/**
|
|
46
|
+
* Marks the request in flight, making the submit button busy and unusable while the fields stay editable.
|
|
47
|
+
* @default false
|
|
48
|
+
*/
|
|
49
|
+
pending?: boolean | undefined;
|
|
50
|
+
/**
|
|
51
|
+
* Label of the name field; supplying it is what makes that field render at all.
|
|
52
|
+
* @default undefined — no name field renders.
|
|
53
|
+
*/
|
|
54
|
+
nameLabel?: string | undefined;
|
|
55
|
+
/**
|
|
56
|
+
* Label of the email field in the credentials form.
|
|
57
|
+
* @default 'Email'
|
|
58
|
+
*/
|
|
59
|
+
emailLabel?: string | undefined;
|
|
60
|
+
/**
|
|
61
|
+
* Label of the password field in the credentials form.
|
|
62
|
+
* @default 'Password'
|
|
63
|
+
*/
|
|
64
|
+
passwordLabel?: string | undefined;
|
|
65
|
+
/**
|
|
66
|
+
* Label of the confirmation field; supplying it is what makes that field render at all.
|
|
67
|
+
* @default undefined — no confirmation field renders and no matching is done.
|
|
68
|
+
*/
|
|
69
|
+
confirmPasswordLabel?: string | undefined;
|
|
70
|
+
/**
|
|
71
|
+
* Validation message shown on the confirmation field when the two passwords differ.
|
|
72
|
+
* @default 'Passwords do not match'
|
|
73
|
+
*/
|
|
74
|
+
passwordMismatchMessage?: string | undefined;
|
|
75
|
+
/**
|
|
76
|
+
* Terms copy and links, rendered as the label of a required checkbox before the submit button.
|
|
77
|
+
* @default undefined — no terms field renders.
|
|
78
|
+
*/
|
|
79
|
+
terms?: React.ReactNode | undefined;
|
|
80
|
+
/**
|
|
81
|
+
* Text of the credentials form's submit button.
|
|
82
|
+
* @default 'Create account'
|
|
83
|
+
*/
|
|
84
|
+
submitLabel?: string | undefined;
|
|
85
|
+
/**
|
|
86
|
+
* Words a provider button's text from its entry, replacing the built-in wording.
|
|
87
|
+
* @default defaultProviderLabel — reads "Sign in with Google".
|
|
88
|
+
*/
|
|
89
|
+
getProviderLabel?: ((provider: SignInProvider) => string) | undefined;
|
|
90
|
+
/**
|
|
91
|
+
* Navigation rendered below the form, such as a link back to the sign-in page.
|
|
92
|
+
* @default undefined — no footer region renders.
|
|
93
|
+
*/
|
|
94
|
+
footer?: React.ReactNode | undefined;
|
|
95
|
+
/**
|
|
96
|
+
* Fires when a provider button is activated or the form is submitted with matching, valid fields.
|
|
97
|
+
* @default undefined — no-op if omitted.
|
|
98
|
+
*/
|
|
99
|
+
onSignUp?: ((detail: SignUpDetail) => void) | undefined;
|
|
100
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
"use strict";var N=Object.create;var u=Object.defineProperty;var R=Object.getOwnPropertyDescriptor;var $=Object.getOwnPropertyNames;var A=Object.getPrototypeOf,T=Object.prototype.hasOwnProperty;var h=(t,a)=>{for(var d in a)u(t,d,{get:a[d],enumerable:!0})},P=(t,a,d,i)=>{if(a&&typeof a=="object"||typeof a=="function")for(let s of $(a))!T.call(t,s)&&s!==d&&u(t,s,{get:()=>a[s],enumerable:!(i=R(a,s))||i.enumerable});return t};var H=(t,a,d)=>(d=t!=null?N(A(t)):{},P(a||!t||!t.__esModule?u(d,"default",{value:t,enumerable:!0}):d,t)),V=t=>P(u({},"__esModule",{value:!0}),t);var w={};h(w,{StatCard:()=>c});module.exports=V(w);var g=H(require("react"),1),n=require("@skdx/react");function _(...t){let a="";for(let d of t)d&&(a=a?`${a} ${d}`:d);return a}function e(t,a,d){let i=a==="root",s=i?`skdx-${t}`:`skdx-${t}__${a}`,l={className:_(s,d),"data-part":a};return i&&(l["data-skdx-component"]=t),l}var r=require("react/jsx-runtime"),c=({label:t,value:a,change:d,trend:i,sentiment:s,changeLabel:l,trendIcon:f,icon:x,description:m,progress:v,visual:b,footer:y,actions:k,loading:o=!1,...S})=>{let p=g.useId(),C=d!==void 0&&!o;return(0,r.jsxs)("div",{role:"group","aria-labelledby":p,"aria-busy":o||void 0,"data-trend":i,"data-sentiment":s,"data-state":o?"loading":void 0,...S,...e("stat-card","root",S.className),children:[(0,r.jsxs)("div",{...e("stat-card","header"),children:[x?(0,r.jsx)("span",{"aria-hidden":"true",...e("stat-card","icon"),children:x}):null,(0,r.jsx)("span",{id:p,...e("stat-card","label"),children:t}),k?(0,r.jsx)("div",{...e("stat-card","actions"),children:k}):null]}),(0,r.jsxs)("div",{...e("stat-card","body"),children:[(0,r.jsx)("span",{...e("stat-card","value"),children:o?(0,r.jsx)(n.Skeleton,{shape:"line"}):(0,r.jsx)(n.Text,{as:"span",variant:"numeric",children:a})}),C?(0,r.jsxs)("span",{"data-trend":i,"data-sentiment":s,...e("stat-card","trend"),children:[f?(0,r.jsx)("span",{"aria-hidden":"true",...e("stat-card","trend-icon"),children:f}):null,l?(0,r.jsx)(n.VisuallyHidden,{children:l}):null,d]}):null]}),m?(0,r.jsx)(n.Text,{as:"p",tone:"muted",...e("stat-card","description"),children:m}):null,typeof v=="number"?(0,r.jsx)(n.Progress,{value:v,"aria-labelledby":p,...e("stat-card","progress")}):null,b?(0,r.jsx)("div",{...e("stat-card","visual"),children:b}):null,y?(0,r.jsx)("div",{...e("stat-card","footer"),children:y}):null]})};c.displayName="StatCard";0&&(module.exports={StatCard});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { StatCardProps } from './types.cjs';
|
|
3
|
+
/**
|
|
4
|
+
* KPI tile block: a label, a value, an optional trend with sentiment colour,
|
|
5
|
+
* a description, a derived progress bar and a visual region, all inside one
|
|
6
|
+
* `role="group"` named by its own label.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```tsx
|
|
10
|
+
* <StatCard
|
|
11
|
+
* label="Revenue"
|
|
12
|
+
* value="$12,400"
|
|
13
|
+
* change="+12.4%"
|
|
14
|
+
* trend="up"
|
|
15
|
+
* sentiment="positive"
|
|
16
|
+
* />
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export declare const StatCard: {
|
|
20
|
+
({ label, value, change, trend, sentiment, changeLabel, trendIcon, icon, description, progress, visual, footer, actions, loading, ...props }: StatCardProps): React.ReactNode;
|
|
21
|
+
displayName: string;
|
|
22
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { StatCardProps } from './types.js';
|
|
3
|
+
/**
|
|
4
|
+
* KPI tile block: a label, a value, an optional trend with sentiment colour,
|
|
5
|
+
* a description, a derived progress bar and a visual region, all inside one
|
|
6
|
+
* `role="group"` named by its own label.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```tsx
|
|
10
|
+
* <StatCard
|
|
11
|
+
* label="Revenue"
|
|
12
|
+
* value="$12,400"
|
|
13
|
+
* change="+12.4%"
|
|
14
|
+
* trend="up"
|
|
15
|
+
* sentiment="positive"
|
|
16
|
+
* />
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export declare const StatCard: {
|
|
20
|
+
({ label, value, change, trend, sentiment, changeLabel, trendIcon, icon, description, progress, visual, footer, actions, loading, ...props }: StatCardProps): React.ReactNode;
|
|
21
|
+
displayName: string;
|
|
22
|
+
};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import*as S from"react";import{Progress as N,Skeleton as R,Text as k,VisuallyHidden as $}from"@skdx/react";function C(...e){let r="";for(let d of e)d&&(r=r?`${r} ${d}`:d);return r}function t(e,r,d){let s=r==="root",i=s?`skdx-${e}`:`skdx-${e}__${r}`,n={className:C(i,d),"data-part":r};return s&&(n["data-skdx-component"]=e),n}import{jsx as a,jsxs as o}from"react/jsx-runtime";var P=({label:e,value:r,change:d,trend:s,sentiment:i,changeLabel:n,trendIcon:p,icon:c,description:f,progress:x,visual:m,footer:v,actions:b,loading:l=!1,...y})=>{let u=S.useId(),g=d!==void 0&&!l;return o("div",{role:"group","aria-labelledby":u,"aria-busy":l||void 0,"data-trend":s,"data-sentiment":i,"data-state":l?"loading":void 0,...y,...t("stat-card","root",y.className),children:[o("div",{...t("stat-card","header"),children:[c?a("span",{"aria-hidden":"true",...t("stat-card","icon"),children:c}):null,a("span",{id:u,...t("stat-card","label"),children:e}),b?a("div",{...t("stat-card","actions"),children:b}):null]}),o("div",{...t("stat-card","body"),children:[a("span",{...t("stat-card","value"),children:l?a(R,{shape:"line"}):a(k,{as:"span",variant:"numeric",children:r})}),g?o("span",{"data-trend":s,"data-sentiment":i,...t("stat-card","trend"),children:[p?a("span",{"aria-hidden":"true",...t("stat-card","trend-icon"),children:p}):null,n?a($,{children:n}):null,d]}):null]}),f?a(k,{as:"p",tone:"muted",...t("stat-card","description"),children:f}):null,typeof x=="number"?a(N,{value:x,"aria-labelledby":u,...t("stat-card","progress")}):null,m?a("div",{...t("stat-card","visual"),children:m}):null,v?a("div",{...t("stat-card","footer"),children:v}):null]})};P.displayName="StatCard";export{P as StatCard};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import type * as React from 'react';
|
|
2
|
+
/** Props for the {@link StatCard} block. */
|
|
3
|
+
export interface StatCardProps extends React.ComponentPropsWithRef<'div'> {
|
|
4
|
+
/** Name of the metric, rendered into the label that names the group through aria-labelledby. */
|
|
5
|
+
label: string;
|
|
6
|
+
/**
|
|
7
|
+
* The metric's current reading, already formatted by the consumer for its locale.
|
|
8
|
+
* @default undefined — the value region renders empty.
|
|
9
|
+
*/
|
|
10
|
+
value?: React.ReactNode | undefined;
|
|
11
|
+
/**
|
|
12
|
+
* Already-formatted delta text such as "+12.4%", rendered inside the trend region.
|
|
13
|
+
* @default undefined — no trend region renders.
|
|
14
|
+
*/
|
|
15
|
+
change?: string | undefined;
|
|
16
|
+
/**
|
|
17
|
+
* Direction of the change only, mirrored to data-trend on the root and the trend part.
|
|
18
|
+
* @default undefined — no direction is written.
|
|
19
|
+
*/
|
|
20
|
+
trend?: 'up' | 'down' | 'neutral' | undefined;
|
|
21
|
+
/**
|
|
22
|
+
* Whether the change is good or bad, independent of trend, mirrored to data-sentiment.
|
|
23
|
+
* @default undefined — the trend renders in the skin's neutral colour.
|
|
24
|
+
*/
|
|
25
|
+
sentiment?: 'positive' | 'negative' | 'neutral' | undefined;
|
|
26
|
+
/**
|
|
27
|
+
* Visually hidden text read before the change, such as "Increased by".
|
|
28
|
+
* @default undefined — only the change text itself is announced.
|
|
29
|
+
*/
|
|
30
|
+
changeLabel?: string | undefined;
|
|
31
|
+
/**
|
|
32
|
+
* Decorative glyph rendered beside the change text inside the trend region.
|
|
33
|
+
* @default undefined — no trend icon renders.
|
|
34
|
+
*/
|
|
35
|
+
trendIcon?: React.ReactNode | undefined;
|
|
36
|
+
/**
|
|
37
|
+
* Decorative glyph rendered beside the label in the card header.
|
|
38
|
+
* @default undefined — no icon region renders.
|
|
39
|
+
*/
|
|
40
|
+
icon?: React.ReactNode | undefined;
|
|
41
|
+
/**
|
|
42
|
+
* Supporting text rendered below the value, in the skin's muted tone.
|
|
43
|
+
* @default undefined — no description region renders.
|
|
44
|
+
*/
|
|
45
|
+
description?: string | undefined;
|
|
46
|
+
/**
|
|
47
|
+
* Percentage from 0 to 100, rendered into a derived Progress named by the label.
|
|
48
|
+
* @default undefined — no progress bar renders.
|
|
49
|
+
*/
|
|
50
|
+
progress?: number | undefined;
|
|
51
|
+
/**
|
|
52
|
+
* A chart or sparkline the card sizes a region for; the consumer draws its contents.
|
|
53
|
+
* @default undefined — no visual region renders.
|
|
54
|
+
*/
|
|
55
|
+
visual?: React.ReactNode | undefined;
|
|
56
|
+
/**
|
|
57
|
+
* Content rendered in a footer region below the card's other regions.
|
|
58
|
+
* @default undefined — no footer region renders.
|
|
59
|
+
*/
|
|
60
|
+
footer?: React.ReactNode | undefined;
|
|
61
|
+
/**
|
|
62
|
+
* Controls rendered at the end of the header, such as a menu button.
|
|
63
|
+
* @default undefined — no actions region renders.
|
|
64
|
+
*/
|
|
65
|
+
actions?: React.ReactNode | undefined;
|
|
66
|
+
/**
|
|
67
|
+
* Shows a skeleton in the value region and withholds the trend while true.
|
|
68
|
+
* @default false
|
|
69
|
+
*/
|
|
70
|
+
loading?: boolean | undefined;
|
|
71
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import type * as React from 'react';
|
|
2
|
+
/** Props for the {@link StatCard} block. */
|
|
3
|
+
export interface StatCardProps extends React.ComponentPropsWithRef<'div'> {
|
|
4
|
+
/** Name of the metric, rendered into the label that names the group through aria-labelledby. */
|
|
5
|
+
label: string;
|
|
6
|
+
/**
|
|
7
|
+
* The metric's current reading, already formatted by the consumer for its locale.
|
|
8
|
+
* @default undefined — the value region renders empty.
|
|
9
|
+
*/
|
|
10
|
+
value?: React.ReactNode | undefined;
|
|
11
|
+
/**
|
|
12
|
+
* Already-formatted delta text such as "+12.4%", rendered inside the trend region.
|
|
13
|
+
* @default undefined — no trend region renders.
|
|
14
|
+
*/
|
|
15
|
+
change?: string | undefined;
|
|
16
|
+
/**
|
|
17
|
+
* Direction of the change only, mirrored to data-trend on the root and the trend part.
|
|
18
|
+
* @default undefined — no direction is written.
|
|
19
|
+
*/
|
|
20
|
+
trend?: 'up' | 'down' | 'neutral' | undefined;
|
|
21
|
+
/**
|
|
22
|
+
* Whether the change is good or bad, independent of trend, mirrored to data-sentiment.
|
|
23
|
+
* @default undefined — the trend renders in the skin's neutral colour.
|
|
24
|
+
*/
|
|
25
|
+
sentiment?: 'positive' | 'negative' | 'neutral' | undefined;
|
|
26
|
+
/**
|
|
27
|
+
* Visually hidden text read before the change, such as "Increased by".
|
|
28
|
+
* @default undefined — only the change text itself is announced.
|
|
29
|
+
*/
|
|
30
|
+
changeLabel?: string | undefined;
|
|
31
|
+
/**
|
|
32
|
+
* Decorative glyph rendered beside the change text inside the trend region.
|
|
33
|
+
* @default undefined — no trend icon renders.
|
|
34
|
+
*/
|
|
35
|
+
trendIcon?: React.ReactNode | undefined;
|
|
36
|
+
/**
|
|
37
|
+
* Decorative glyph rendered beside the label in the card header.
|
|
38
|
+
* @default undefined — no icon region renders.
|
|
39
|
+
*/
|
|
40
|
+
icon?: React.ReactNode | undefined;
|
|
41
|
+
/**
|
|
42
|
+
* Supporting text rendered below the value, in the skin's muted tone.
|
|
43
|
+
* @default undefined — no description region renders.
|
|
44
|
+
*/
|
|
45
|
+
description?: string | undefined;
|
|
46
|
+
/**
|
|
47
|
+
* Percentage from 0 to 100, rendered into a derived Progress named by the label.
|
|
48
|
+
* @default undefined — no progress bar renders.
|
|
49
|
+
*/
|
|
50
|
+
progress?: number | undefined;
|
|
51
|
+
/**
|
|
52
|
+
* A chart or sparkline the card sizes a region for; the consumer draws its contents.
|
|
53
|
+
* @default undefined — no visual region renders.
|
|
54
|
+
*/
|
|
55
|
+
visual?: React.ReactNode | undefined;
|
|
56
|
+
/**
|
|
57
|
+
* Content rendered in a footer region below the card's other regions.
|
|
58
|
+
* @default undefined — no footer region renders.
|
|
59
|
+
*/
|
|
60
|
+
footer?: React.ReactNode | undefined;
|
|
61
|
+
/**
|
|
62
|
+
* Controls rendered at the end of the header, such as a menu button.
|
|
63
|
+
* @default undefined — no actions region renders.
|
|
64
|
+
*/
|
|
65
|
+
actions?: React.ReactNode | undefined;
|
|
66
|
+
/**
|
|
67
|
+
* Shows a skeleton in the value region and withholds the trend while true.
|
|
68
|
+
* @default false
|
|
69
|
+
*/
|
|
70
|
+
loading?: boolean | undefined;
|
|
71
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
"use strict";var L=Object.create;var g=Object.defineProperty;var C=Object.getOwnPropertyDescriptor;var A=Object.getOwnPropertyNames;var S=Object.getPrototypeOf,h=Object.prototype.hasOwnProperty;var T=(e,a)=>{for(var t in a)g(e,t,{get:a[t],enumerable:!0})},$=(e,a,t,r)=>{if(a&&typeof a=="object"||typeof a=="function")for(let n of A(a))!h.call(e,n)&&n!==t&&g(e,n,{get:()=>a[n],enumerable:!(r=C(a,n))||r.enumerable});return e};var _=(e,a,t)=>(t=e!=null?L(S(e)):{},$(a||!e||!e.__esModule?g(t,"default",{value:e,enumerable:!0}):t,e)),z=e=>$(g({},"__esModule",{value:!0}),e);var q={};T(q,{UsageCard:()=>f});module.exports=z(q);var y=_(require("react"),1),c=require("@skdx/react");function I(...e){let a="";for(let t of e)t&&(a=a?`${a} ${t}`:t);return a}function i(e,a,t){let r=a==="root",n=r?`skdx-${e}`:`skdx-${e}__${a}`,l={className:I(n,t),"data-part":a};return r&&(l["data-skdx-component"]=e),l}function m(e){return Number.isNaN(e)?0:Math.max(e,0)}function k(e,a){let t=m(e),r=m(a);return r===0?{limit:r,overLimit:t>0,range:null}:{limit:r,overLimit:t>r,range:{max:r,value:Math.min(t,r)}}}var s=require("react/jsx-runtime"),f=({label:e,used:a,limit:t,unit:r,formatValue:n=String,unlimitedLabel:l="Unlimited",description:x,actions:b,footer:v,status:P,...U})=>{let p=y.useId(),R=m(a),o,M=!1,u=null;if(t===null)o=l;else if(t!==void 0){let d=k(R,t);M=d.overLimit,u=d.range,o=`/ ${n(d.limit)}`}return(0,s.jsxs)("div",{role:"group","aria-labelledby":p,"data-state":M?"over-limit":void 0,"data-status":P,...U,...i("usage-card","root",U.className),children:[(0,s.jsxs)("div",{...i("usage-card","header"),children:[(0,s.jsx)("span",{id:p,...i("usage-card","label"),children:e}),b?(0,s.jsx)("div",{...i("usage-card","actions"),children:b}):null]}),(0,s.jsxs)("div",{...i("usage-card","value"),children:[(0,s.jsx)("span",{...i("usage-card","used"),children:n(R)}),o!==void 0?(0,s.jsx)("span",{...i("usage-card","limit"),children:o}):null,r?(0,s.jsx)("span",{...i("usage-card","unit"),children:r}):null]}),u?(0,s.jsx)(c.Progress,{role:"meter",min:0,max:u.max,value:u.value,"aria-labelledby":p,getValueLabel:(d,w,N)=>`${n(d)} / ${n(N)}${r?` ${r}`:""}`,...i("usage-card","progress")}):null,x?(0,s.jsx)(c.Text,{as:"p",tone:"muted",...i("usage-card","description"),children:x}):null,v?(0,s.jsx)("div",{...i("usage-card","footer"),children:v}):null]})};f.displayName="UsageCard";0&&(module.exports={UsageCard});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { UsageCardProps } from './types.cjs';
|
|
3
|
+
/**
|
|
4
|
+
* Quota tile block: a label, the amount used against a limit, a derived
|
|
5
|
+
* meter and a status colour, all inside one `role="group"` named by its own
|
|
6
|
+
* label. Handles a finite, zero, unlimited or unknown limit without division
|
|
7
|
+
* errors, and derives over-limit from the numbers rather than a status prop.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```tsx
|
|
11
|
+
* <UsageCard label="Storage" used={42} limit={50} unit="GB" />
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
export declare const UsageCard: {
|
|
15
|
+
({ label, used, limit, unit, formatValue, unlimitedLabel, description, actions, footer, status, ...props }: UsageCardProps): React.ReactNode;
|
|
16
|
+
displayName: string;
|
|
17
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { UsageCardProps } from './types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Quota tile block: a label, the amount used against a limit, a derived
|
|
5
|
+
* meter and a status colour, all inside one `role="group"` named by its own
|
|
6
|
+
* label. Handles a finite, zero, unlimited or unknown limit without division
|
|
7
|
+
* errors, and derives over-limit from the numbers rather than a status prop.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```tsx
|
|
11
|
+
* <UsageCard label="Storage" used={42} limit={50} unit="GB" />
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
export declare const UsageCard: {
|
|
15
|
+
({ label, used, limit, unit, formatValue, unlimitedLabel, description, actions, footer, status, ...props }: UsageCardProps): React.ReactNode;
|
|
16
|
+
displayName: string;
|
|
17
|
+
};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import*as M from"react";import{Progress as N,Text as L}from"@skdx/react";function P(...t){let r="";for(let a of t)a&&(r=r?`${r} ${a}`:a);return r}function s(t,r,a){let e=r==="root",i=e?`skdx-${t}`:`skdx-${t}__${r}`,l={className:P(i,a),"data-part":r};return e&&(l["data-skdx-component"]=t),l}function g(t){return Number.isNaN(t)?0:Math.max(t,0)}function R(t,r){let a=g(t),e=g(r);return e===0?{limit:e,overLimit:a>0,range:null}:{limit:e,overLimit:a>e,range:{max:e,value:Math.min(a,e)}}}import{jsx as n,jsxs as c}from"react/jsx-runtime";var $=({label:t,used:r,limit:a,unit:e,formatValue:i=String,unlimitedLabel:l="Unlimited",description:p,actions:f,footer:x,status:k,...b})=>{let m=M.useId(),v=g(r),o,U=!1,u=null;if(a===null)o=l;else if(a!==void 0){let d=R(v,a);U=d.overLimit,u=d.range,o=`/ ${i(d.limit)}`}return c("div",{role:"group","aria-labelledby":m,"data-state":U?"over-limit":void 0,"data-status":k,...b,...s("usage-card","root",b.className),children:[c("div",{...s("usage-card","header"),children:[n("span",{id:m,...s("usage-card","label"),children:t}),f?n("div",{...s("usage-card","actions"),children:f}):null]}),c("div",{...s("usage-card","value"),children:[n("span",{...s("usage-card","used"),children:i(v)}),o!==void 0?n("span",{...s("usage-card","limit"),children:o}):null,e?n("span",{...s("usage-card","unit"),children:e}):null]}),u?n(N,{role:"meter",min:0,max:u.max,value:u.value,"aria-labelledby":m,getValueLabel:(d,C,y)=>`${i(d)} / ${i(y)}${e?` ${e}`:""}`,...s("usage-card","progress")}):null,p?n(L,{as:"p",tone:"muted",...s("usage-card","description"),children:p}):null,x?n("div",{...s("usage-card","footer"),children:x}):null]})};$.displayName="UsageCard";export{$ as UsageCard};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type * as React from 'react';
|
|
2
|
+
/** Props for the {@link UsageCard} block. */
|
|
3
|
+
export interface UsageCardProps extends React.ComponentPropsWithRef<'div'> {
|
|
4
|
+
/** Name of the quota, rendered into the label that names the group through aria-labelledby. */
|
|
5
|
+
label: string;
|
|
6
|
+
/** The current amount consumed, formatted by formatValue for the value region and the meter. */
|
|
7
|
+
used: number;
|
|
8
|
+
/**
|
|
9
|
+
* The finite cap `used` is measured against; `null` renders `unlimitedLabel`
|
|
10
|
+
* instead of a number. No meter or limit text renders when omitted.
|
|
11
|
+
* @default undefined — the limit is unknown, so no limit text or meter renders.
|
|
12
|
+
*/
|
|
13
|
+
limit?: number | null | undefined;
|
|
14
|
+
/**
|
|
15
|
+
* Unit label rendered after the limit text, such as "GB" or "seats".
|
|
16
|
+
* @default undefined — no unit region renders.
|
|
17
|
+
*/
|
|
18
|
+
unit?: string | undefined;
|
|
19
|
+
/**
|
|
20
|
+
* Formats `used` and `limit` for the consumer's own locale and precision.
|
|
21
|
+
* @default String — the raw number is rendered as-is.
|
|
22
|
+
*/
|
|
23
|
+
formatValue?: ((value: number) => string) | undefined;
|
|
24
|
+
/**
|
|
25
|
+
* Text rendered in place of a limit number when `limit` is `null`.
|
|
26
|
+
* @default 'Unlimited'
|
|
27
|
+
*/
|
|
28
|
+
unlimitedLabel?: string | undefined;
|
|
29
|
+
/**
|
|
30
|
+
* Supporting copy rendered below the meter, in the skin's muted tone.
|
|
31
|
+
* @default undefined — no description region renders.
|
|
32
|
+
*/
|
|
33
|
+
description?: string | undefined;
|
|
34
|
+
/**
|
|
35
|
+
* Controls rendered at the end of the header, such as a manage-plan link.
|
|
36
|
+
* @default undefined — no actions region renders.
|
|
37
|
+
*/
|
|
38
|
+
actions?: React.ReactNode | undefined;
|
|
39
|
+
/**
|
|
40
|
+
* Content rendered in a footer region below the card, such as renewal or reset metadata.
|
|
41
|
+
* @default undefined — no footer region renders.
|
|
42
|
+
*/
|
|
43
|
+
footer?: React.ReactNode | undefined;
|
|
44
|
+
/**
|
|
45
|
+
* Colour role written to data-status, tinting the meter fill and the used amount.
|
|
46
|
+
* Over-limit is derived automatically; this axis is policy the consumer decides.
|
|
47
|
+
* @default undefined — the skin's own default colour.
|
|
48
|
+
*/
|
|
49
|
+
status?: 'info' | 'success' | 'warning' | 'danger' | (string & {}) | undefined;
|
|
50
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type * as React from 'react';
|
|
2
|
+
/** Props for the {@link UsageCard} block. */
|
|
3
|
+
export interface UsageCardProps extends React.ComponentPropsWithRef<'div'> {
|
|
4
|
+
/** Name of the quota, rendered into the label that names the group through aria-labelledby. */
|
|
5
|
+
label: string;
|
|
6
|
+
/** The current amount consumed, formatted by formatValue for the value region and the meter. */
|
|
7
|
+
used: number;
|
|
8
|
+
/**
|
|
9
|
+
* The finite cap `used` is measured against; `null` renders `unlimitedLabel`
|
|
10
|
+
* instead of a number. No meter or limit text renders when omitted.
|
|
11
|
+
* @default undefined — the limit is unknown, so no limit text or meter renders.
|
|
12
|
+
*/
|
|
13
|
+
limit?: number | null | undefined;
|
|
14
|
+
/**
|
|
15
|
+
* Unit label rendered after the limit text, such as "GB" or "seats".
|
|
16
|
+
* @default undefined — no unit region renders.
|
|
17
|
+
*/
|
|
18
|
+
unit?: string | undefined;
|
|
19
|
+
/**
|
|
20
|
+
* Formats `used` and `limit` for the consumer's own locale and precision.
|
|
21
|
+
* @default String — the raw number is rendered as-is.
|
|
22
|
+
*/
|
|
23
|
+
formatValue?: ((value: number) => string) | undefined;
|
|
24
|
+
/**
|
|
25
|
+
* Text rendered in place of a limit number when `limit` is `null`.
|
|
26
|
+
* @default 'Unlimited'
|
|
27
|
+
*/
|
|
28
|
+
unlimitedLabel?: string | undefined;
|
|
29
|
+
/**
|
|
30
|
+
* Supporting copy rendered below the meter, in the skin's muted tone.
|
|
31
|
+
* @default undefined — no description region renders.
|
|
32
|
+
*/
|
|
33
|
+
description?: string | undefined;
|
|
34
|
+
/**
|
|
35
|
+
* Controls rendered at the end of the header, such as a manage-plan link.
|
|
36
|
+
* @default undefined — no actions region renders.
|
|
37
|
+
*/
|
|
38
|
+
actions?: React.ReactNode | undefined;
|
|
39
|
+
/**
|
|
40
|
+
* Content rendered in a footer region below the card, such as renewal or reset metadata.
|
|
41
|
+
* @default undefined — no footer region renders.
|
|
42
|
+
*/
|
|
43
|
+
footer?: React.ReactNode | undefined;
|
|
44
|
+
/**
|
|
45
|
+
* Colour role written to data-status, tinting the meter fill and the used amount.
|
|
46
|
+
* Over-limit is derived automatically; this axis is policy the consumer decides.
|
|
47
|
+
* @default undefined — the skin's own default colour.
|
|
48
|
+
*/
|
|
49
|
+
status?: 'info' | 'success' | 'warning' | 'danger' | (string & {}) | undefined;
|
|
50
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/** @internal Clamps a raw amount into a safe non-negative number: `NaN` becomes `0`, a negative clamps to `0`. */
|
|
2
|
+
export declare function normalizeUsage(value: number): number;
|
|
3
|
+
/** @internal The `[0, max]` range a finite, positive limit renders as a meter. */
|
|
4
|
+
export interface UsageMeterRange {
|
|
5
|
+
max: number;
|
|
6
|
+
value: number;
|
|
7
|
+
}
|
|
8
|
+
/** @internal What a finite limit resolves to: its normalized value, whether usage exceeds it, and the meter range to render. */
|
|
9
|
+
export interface UsageMeterResult {
|
|
10
|
+
limit: number;
|
|
11
|
+
overLimit: boolean;
|
|
12
|
+
range: UsageMeterRange | null;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* @internal Derives the meter range and over-limit flag for a finite limit.
|
|
16
|
+
* A zero limit renders no meter but counts as over-limit as soon as anything is used.
|
|
17
|
+
*/
|
|
18
|
+
export declare function usageMeter(used: number, limit: number): UsageMeterResult;
|