@syscore/ui-library 2.0.0-beta-publish-workflow-beta.4 → 2.0.0-beta-publish-workflow-beta.5
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/client/components/ui/copy.tsx +68 -0
- package/client/components/ui/credit-card-preview.tsx +118 -0
- package/client/components/ui/drop-zone.tsx +127 -0
- package/client/components/ui/field-group.tsx +103 -0
- package/client/components/ui/file-upload-trigger.tsx +98 -0
- package/client/components/ui/inline-notice.tsx +39 -0
- package/client/components/ui/labeled-divider.tsx +32 -0
- package/client/components/ui/meta-row.tsx +39 -0
- package/client/components/ui/modal-panel.tsx +164 -0
- package/client/components/ui/pill-button.tsx +116 -0
- package/client/components/ui/profile-avatar.tsx +176 -0
- package/client/components/ui/resource-thumbnail.tsx +20 -0
- package/client/components/ui/social-button.tsx +70 -0
- package/client/components/ui/status-pill.tsx +58 -0
- package/client/components/ui/text-link.tsx +63 -0
- package/client/global.css +2768 -0
- package/dist/index.cjs.js +1 -1
- package/dist/index.d.ts +75 -0
- package/dist/index.es.js +606 -0
- package/package.json +1 -1
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { cn } from "@/lib/utils";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Copy — body text with a colour, weight and measure chosen by prop.
|
|
6
|
+
*
|
|
7
|
+
* The DS `Text` component has a `variant` but no colour/tone prop, so every
|
|
8
|
+
* coloured line of copy would otherwise need a call-site className, which
|
|
9
|
+
* RULE #-3A forbids. `Copy` keeps the DS typography class (so the type scale
|
|
10
|
+
* stays the DS's) and adds the tone as a modifier it applies to itself.
|
|
11
|
+
*
|
|
12
|
+
* It also corrects the line-height: `.body-base` in the DS is 22.4px, while the
|
|
13
|
+
* auth designs specify 21px. The modifier is a combined selector in CSS
|
|
14
|
+
* (`.body-base.copy`) so it wins on specificity without `!important`.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
type CopyTone = "default" | "muted" | "subtle" | "link" | "error" | "inverse";
|
|
18
|
+
type CopySize = "base" | "small";
|
|
19
|
+
type CopyWeight = "regular" | "medium" | "semibold";
|
|
20
|
+
type CopyAlign = "start" | "center" | "end";
|
|
21
|
+
|
|
22
|
+
interface CopyProps extends React.HTMLAttributes<HTMLElement> {
|
|
23
|
+
as?: React.ElementType;
|
|
24
|
+
tone?: CopyTone;
|
|
25
|
+
size?: CopySize;
|
|
26
|
+
weight?: CopyWeight;
|
|
27
|
+
align?: CopyAlign;
|
|
28
|
+
italic?: boolean;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const sizeClass: Record<CopySize, string> = {
|
|
32
|
+
base: "body-base",
|
|
33
|
+
small: "body-small",
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
const Copy = React.forwardRef<HTMLElement, CopyProps>(
|
|
37
|
+
(
|
|
38
|
+
{
|
|
39
|
+
as: Component = "span",
|
|
40
|
+
tone = "default",
|
|
41
|
+
size = "base",
|
|
42
|
+
weight = "regular",
|
|
43
|
+
align,
|
|
44
|
+
italic = false,
|
|
45
|
+
className,
|
|
46
|
+
...props
|
|
47
|
+
},
|
|
48
|
+
ref,
|
|
49
|
+
) => (
|
|
50
|
+
<Component
|
|
51
|
+
ref={ref}
|
|
52
|
+
className={cn(
|
|
53
|
+
sizeClass[size],
|
|
54
|
+
"copy",
|
|
55
|
+
`copy--${tone}`,
|
|
56
|
+
`copy--${weight}`,
|
|
57
|
+
align && `copy--align-${align}`,
|
|
58
|
+
italic && "copy--italic",
|
|
59
|
+
className,
|
|
60
|
+
)}
|
|
61
|
+
{...props}
|
|
62
|
+
/>
|
|
63
|
+
),
|
|
64
|
+
);
|
|
65
|
+
Copy.displayName = "Copy";
|
|
66
|
+
|
|
67
|
+
export { Copy };
|
|
68
|
+
export type { CopyProps, CopyTone, CopySize, CopyWeight, CopyAlign };
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { cn } from "@/lib/utils";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* CreditCardPreview — the decorative card mock beside the payment amount.
|
|
6
|
+
*
|
|
7
|
+
* Purely presentational: it never holds real card data. The number is always
|
|
8
|
+
* rendered as static dots, so there is nothing here for a caller to leak — the
|
|
9
|
+
* live PAN/expiry/CVC are collected by the DS `Input`s in the Card Details
|
|
10
|
+
* column, and in a real integration would belong to the payment provider's
|
|
11
|
+
* hosted fields.
|
|
12
|
+
*
|
|
13
|
+
* It owns its own appearance (RULE #-3A row 4) — see
|
|
14
|
+
* `DS_PENDING_CSS:CreditCardPreview` in `src/index.css`.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
type CardBrand = "visa" | "mastercard" | "generic";
|
|
18
|
+
|
|
19
|
+
interface CreditCardPreviewProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
20
|
+
/** Shown on the card face; falls back to a placeholder while empty. */
|
|
21
|
+
holderName?: string;
|
|
22
|
+
/** Formatted expiry, e.g. "04 / 27". Dots while empty. */
|
|
23
|
+
expiry?: string;
|
|
24
|
+
brand?: CardBrand;
|
|
25
|
+
label?: string;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const ChipIcon = () => (
|
|
29
|
+
<svg
|
|
30
|
+
className="credit-card-preview__chip"
|
|
31
|
+
viewBox="0 0 34 26"
|
|
32
|
+
role="presentation"
|
|
33
|
+
aria-hidden="true"
|
|
34
|
+
>
|
|
35
|
+
<rect x="0.5" y="0.5" width="33" height="25" rx="4.5" />
|
|
36
|
+
<path d="M0.5 8.5h8m17 0h8m-33 9h8m17 0h8" />
|
|
37
|
+
<rect x="8.5" y="0.5" width="17" height="25" />
|
|
38
|
+
</svg>
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
const BrandMark = ({ brand }: { brand: CardBrand }) => {
|
|
42
|
+
if (brand === "visa") {
|
|
43
|
+
return (
|
|
44
|
+
<span className="credit-card-preview__brand credit-card-preview__brand--visa">
|
|
45
|
+
VISA
|
|
46
|
+
</span>
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (brand === "mastercard") {
|
|
51
|
+
return (
|
|
52
|
+
<span
|
|
53
|
+
className="credit-card-preview__brand credit-card-preview__brand--mastercard"
|
|
54
|
+
aria-label="Mastercard"
|
|
55
|
+
>
|
|
56
|
+
<span className="credit-card-preview__mc-circle" />
|
|
57
|
+
<span className="credit-card-preview__mc-circle" />
|
|
58
|
+
</span>
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return null;
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
const CreditCardPreview = React.forwardRef<
|
|
66
|
+
HTMLDivElement,
|
|
67
|
+
CreditCardPreviewProps
|
|
68
|
+
>(
|
|
69
|
+
(
|
|
70
|
+
{
|
|
71
|
+
holderName,
|
|
72
|
+
expiry,
|
|
73
|
+
brand = "visa",
|
|
74
|
+
label = "Credit Card",
|
|
75
|
+
className,
|
|
76
|
+
...props
|
|
77
|
+
},
|
|
78
|
+
ref,
|
|
79
|
+
) => (
|
|
80
|
+
<div
|
|
81
|
+
ref={ref}
|
|
82
|
+
className={cn("credit-card-preview", className)}
|
|
83
|
+
role="img"
|
|
84
|
+
aria-label={`${label} preview`}
|
|
85
|
+
{...props}
|
|
86
|
+
>
|
|
87
|
+
<span className="credit-card-preview__label">{label}</span>
|
|
88
|
+
|
|
89
|
+
<ChipIcon />
|
|
90
|
+
|
|
91
|
+
<span className="credit-card-preview__number" aria-hidden="true">
|
|
92
|
+
{[0, 1, 2, 3].map((group) => (
|
|
93
|
+
<span key={group} className="credit-card-preview__group">
|
|
94
|
+
{[0, 1, 2, 3].map((dot) => (
|
|
95
|
+
<span key={dot} className="credit-card-preview__dot" />
|
|
96
|
+
))}
|
|
97
|
+
</span>
|
|
98
|
+
))}
|
|
99
|
+
</span>
|
|
100
|
+
|
|
101
|
+
<span className="credit-card-preview__footer">
|
|
102
|
+
<span className="credit-card-preview__identity">
|
|
103
|
+
<span className="credit-card-preview__name">
|
|
104
|
+
{holderName?.trim() ? holderName : "Card holder"}
|
|
105
|
+
</span>
|
|
106
|
+
<span className="credit-card-preview__expiry">
|
|
107
|
+
Exp. {expiry?.trim() ? expiry : "•• / ••"}
|
|
108
|
+
</span>
|
|
109
|
+
</span>
|
|
110
|
+
<BrandMark brand={brand} />
|
|
111
|
+
</span>
|
|
112
|
+
</div>
|
|
113
|
+
),
|
|
114
|
+
);
|
|
115
|
+
CreditCardPreview.displayName = "CreditCardPreview";
|
|
116
|
+
|
|
117
|
+
export { CreditCardPreview };
|
|
118
|
+
export type { CreditCardPreviewProps, CardBrand };
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { cn } from "@/lib/utils";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* DropZone — the circular drag-and-drop target for a profile image.
|
|
6
|
+
*
|
|
7
|
+
* Figma 12701:34738: a 220px circle, blue-100 (#eff5fb) fill, 4px DASHED
|
|
8
|
+
* cyan-300 (#39c9ea) border, 1000px radius, 16px padding, 16px gap, contents
|
|
9
|
+
* centred. `active` is the drag-over state.
|
|
10
|
+
*
|
|
11
|
+
* Renders a <button> so it is keyboard-reachable: a div with drop handlers is
|
|
12
|
+
* invisible to anyone not using a mouse, and the same click opens the file
|
|
13
|
+
* picker.
|
|
14
|
+
*
|
|
15
|
+
* It owns the hidden <input type="file"> so no caller has to render a raw input.
|
|
16
|
+
* Pass `inputRef` if a sibling control (Figma's "Select from file") needs to
|
|
17
|
+
* open the same picker.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
interface DropZoneProps extends Omit<React.ComponentProps<"button">, "onDrop"> {
|
|
21
|
+
/** URL of the 32px mark. Rendered by this component so callers pass no <img>. */
|
|
22
|
+
iconSrc?: string;
|
|
23
|
+
iconWidth?: number;
|
|
24
|
+
iconHeight?: number;
|
|
25
|
+
/** Escape hatch for a mark that is not an image. */
|
|
26
|
+
icon?: React.ReactNode;
|
|
27
|
+
/** Fires with the dropped or selected files. */
|
|
28
|
+
onFiles?: (files: FileList) => void;
|
|
29
|
+
active?: boolean;
|
|
30
|
+
/** File-input `accept` list. Omit to allow anything. */
|
|
31
|
+
accept?: string;
|
|
32
|
+
multiple?: boolean;
|
|
33
|
+
/** Ref to the internal file input, so a sibling button can open the picker. */
|
|
34
|
+
inputRef?: React.Ref<HTMLInputElement>;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const DropZone = React.forwardRef<HTMLButtonElement, DropZoneProps>(
|
|
38
|
+
(
|
|
39
|
+
{
|
|
40
|
+
iconSrc,
|
|
41
|
+
iconWidth = 30,
|
|
42
|
+
iconHeight = 30,
|
|
43
|
+
icon,
|
|
44
|
+
onFiles,
|
|
45
|
+
active = false,
|
|
46
|
+
accept,
|
|
47
|
+
multiple = false,
|
|
48
|
+
inputRef,
|
|
49
|
+
children,
|
|
50
|
+
className,
|
|
51
|
+
type = "button",
|
|
52
|
+
onClick,
|
|
53
|
+
...props
|
|
54
|
+
},
|
|
55
|
+
ref,
|
|
56
|
+
) => {
|
|
57
|
+
const [dragging, setDragging] = React.useState(false);
|
|
58
|
+
const internalInput = React.useRef<HTMLInputElement | null>(null);
|
|
59
|
+
|
|
60
|
+
const mark =
|
|
61
|
+
icon ??
|
|
62
|
+
(iconSrc ? (
|
|
63
|
+
<img src={iconSrc} alt="" width={iconWidth} height={iconHeight} />
|
|
64
|
+
) : null);
|
|
65
|
+
|
|
66
|
+
const setInput = (node: HTMLInputElement | null) => {
|
|
67
|
+
internalInput.current = node;
|
|
68
|
+
if (typeof inputRef === "function") inputRef(node);
|
|
69
|
+
else if (inputRef) {
|
|
70
|
+
(inputRef as React.MutableRefObject<HTMLInputElement | null>).current = node;
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
return (
|
|
75
|
+
<>
|
|
76
|
+
<button
|
|
77
|
+
ref={ref}
|
|
78
|
+
type={type}
|
|
79
|
+
className={cn(
|
|
80
|
+
"drop-zone",
|
|
81
|
+
(active || dragging) && "drop-zone--active",
|
|
82
|
+
className,
|
|
83
|
+
)}
|
|
84
|
+
onClick={(event) => {
|
|
85
|
+
onClick?.(event);
|
|
86
|
+
if (!event.defaultPrevented) internalInput.current?.click();
|
|
87
|
+
}}
|
|
88
|
+
onDragOver={(event) => {
|
|
89
|
+
event.preventDefault();
|
|
90
|
+
setDragging(true);
|
|
91
|
+
}}
|
|
92
|
+
onDragLeave={() => setDragging(false)}
|
|
93
|
+
onDrop={(event) => {
|
|
94
|
+
event.preventDefault();
|
|
95
|
+
setDragging(false);
|
|
96
|
+
if (event.dataTransfer?.files?.length) onFiles?.(event.dataTransfer.files);
|
|
97
|
+
}}
|
|
98
|
+
{...props}
|
|
99
|
+
>
|
|
100
|
+
{mark ? (
|
|
101
|
+
<span className="drop-zone__icon" aria-hidden="true">
|
|
102
|
+
{mark}
|
|
103
|
+
</span>
|
|
104
|
+
) : null}
|
|
105
|
+
<span className="drop-zone__label">{children}</span>
|
|
106
|
+
</button>
|
|
107
|
+
<input
|
|
108
|
+
ref={setInput}
|
|
109
|
+
className="drop-zone__input"
|
|
110
|
+
type="file"
|
|
111
|
+
accept={accept}
|
|
112
|
+
multiple={multiple}
|
|
113
|
+
tabIndex={-1}
|
|
114
|
+
onChange={(event) => {
|
|
115
|
+
if (event.target.files?.length) onFiles?.(event.target.files);
|
|
116
|
+
// Clear so re-picking the same file fires change again.
|
|
117
|
+
event.target.value = "";
|
|
118
|
+
}}
|
|
119
|
+
/>
|
|
120
|
+
</>
|
|
121
|
+
);
|
|
122
|
+
},
|
|
123
|
+
);
|
|
124
|
+
DropZone.displayName = "DropZone";
|
|
125
|
+
|
|
126
|
+
export { DropZone };
|
|
127
|
+
export type { DropZoneProps };
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { cn } from "@/lib/utils";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* FieldGroup / Field — the connected input stack.
|
|
6
|
+
*
|
|
7
|
+
* Figma: a vertical run of 60px-tall cells that share one 12px outer radius and
|
|
8
|
+
* collapse their 1px borders into each other (`margin-bottom: -1px`). Only the
|
|
9
|
+
* first and last cells are rounded. Each cell carries its own state colour:
|
|
10
|
+
*
|
|
11
|
+
* default blue-50 (#fbfdfe) bg / blue-200 (#cbe0f1) border
|
|
12
|
+
* focus white bg / cyan-300 (#39c9ea) border, raised z-index
|
|
13
|
+
* invalid coral-50 (#fefcfb) bg / coral-200 (#f8dfd8) border
|
|
14
|
+
*
|
|
15
|
+
* All appearance lives in the `.field-group` / `.field` classes this component
|
|
16
|
+
* applies to itself (DS_PENDING_CSS:auth in src/index.css) — callers pass props,
|
|
17
|
+
* never className (RULE #-3A).
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
interface FieldGroupProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
21
|
+
as?: React.ElementType;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const FieldGroup = React.forwardRef<HTMLDivElement, FieldGroupProps>(
|
|
25
|
+
({ as: Component = "div", className, ...props }, ref) => (
|
|
26
|
+
<Component ref={ref} className={cn("field-group", className)} {...props} />
|
|
27
|
+
),
|
|
28
|
+
);
|
|
29
|
+
FieldGroup.displayName = "FieldGroup";
|
|
30
|
+
|
|
31
|
+
type FieldState = "default" | "invalid";
|
|
32
|
+
|
|
33
|
+
/** `hint` is the italic plum treatment for an alternate-route row. */
|
|
34
|
+
type FieldStaticTone = "value" | "hint";
|
|
35
|
+
|
|
36
|
+
interface FieldProps extends Omit<React.ComponentProps<"input">, "size"> {
|
|
37
|
+
/** Trailing 22px control slot(s) — an eye toggle, a help icon, a checkmark. */
|
|
38
|
+
actions?: React.ReactNode;
|
|
39
|
+
/** Renders the value as static text instead of an editable input. */
|
|
40
|
+
staticValue?: React.ReactNode;
|
|
41
|
+
staticTone?: FieldStaticTone;
|
|
42
|
+
state?: FieldState;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const Field = React.forwardRef<HTMLInputElement, FieldProps>(
|
|
46
|
+
(
|
|
47
|
+
{ actions, staticValue, staticTone = "value", state = "default", className, ...props },
|
|
48
|
+
ref,
|
|
49
|
+
) => (
|
|
50
|
+
<div
|
|
51
|
+
className={cn("field", state === "invalid" && "field--invalid", className)}
|
|
52
|
+
>
|
|
53
|
+
{staticValue !== undefined ? (
|
|
54
|
+
<span className={cn("field-static", `field-static--${staticTone}`)}>
|
|
55
|
+
{staticValue}
|
|
56
|
+
</span>
|
|
57
|
+
) : (
|
|
58
|
+
<input ref={ref} className="field-input" {...props} />
|
|
59
|
+
)}
|
|
60
|
+
{actions ? <span className="field-actions">{actions}</span> : null}
|
|
61
|
+
</div>
|
|
62
|
+
),
|
|
63
|
+
);
|
|
64
|
+
Field.displayName = "Field";
|
|
65
|
+
|
|
66
|
+
/** A 22px trailing slot inside a Field — matches the Figma `actions` frame. */
|
|
67
|
+
type FieldActionTone = "default" | "confirm";
|
|
68
|
+
|
|
69
|
+
interface FieldActionProps extends React.ComponentProps<"button"> {
|
|
70
|
+
/** Non-interactive indicator (e.g. the email checkmark) rather than a control. */
|
|
71
|
+
static?: boolean;
|
|
72
|
+
/** `confirm` is the emerald-500 verified state from Figma 12935:28088. */
|
|
73
|
+
tone?: FieldActionTone;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const FieldAction = React.forwardRef<HTMLButtonElement, FieldActionProps>(
|
|
77
|
+
(
|
|
78
|
+
{ static: isStatic, tone = "default", className, children, type = "button", ...props },
|
|
79
|
+
ref,
|
|
80
|
+
) => {
|
|
81
|
+
const classes = cn("field-action", `field-action--${tone}`, className);
|
|
82
|
+
|
|
83
|
+
return isStatic ? (
|
|
84
|
+
<span className={classes} aria-hidden="true">
|
|
85
|
+
{children}
|
|
86
|
+
</span>
|
|
87
|
+
) : (
|
|
88
|
+
<button ref={ref} type={type} className={classes} {...props}>
|
|
89
|
+
{children}
|
|
90
|
+
</button>
|
|
91
|
+
);
|
|
92
|
+
},
|
|
93
|
+
);
|
|
94
|
+
FieldAction.displayName = "FieldAction";
|
|
95
|
+
|
|
96
|
+
export { FieldGroup, Field, FieldAction };
|
|
97
|
+
export type {
|
|
98
|
+
FieldGroupProps,
|
|
99
|
+
FieldProps,
|
|
100
|
+
FieldActionProps,
|
|
101
|
+
FieldActionTone,
|
|
102
|
+
FieldStaticTone,
|
|
103
|
+
};
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { cn } from "@/lib/utils";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* FileUploadTrigger — a button that opens the native file picker and owns
|
|
6
|
+
* the hidden `<input type="file">`, so no caller has to render a raw input
|
|
7
|
+
* (same ownership principle as `DropZone`, applied to a different shape:
|
|
8
|
+
* an inline trigger for a multi-file list with per-item remove, not a large
|
|
9
|
+
* circular drag target for a single image — `DropZone`'s own Figma-specific
|
|
10
|
+
* 220px circle doesn't fit that case).
|
|
11
|
+
*
|
|
12
|
+
* Renders its own `<button>` using the DS's already-published `.button` /
|
|
13
|
+
* `.button--*` classes directly, the same convention every other ds-pending
|
|
14
|
+
* component follows (`DropZone`, `PillButton`, `SocialButton` all render a
|
|
15
|
+
* raw `<button>` with their own class names, never the compiled `Button`
|
|
16
|
+
* React component). Importing `Button` from `@syscore/ui-library` here would
|
|
17
|
+
* make this file, once `ds:writeback`'d into `IWBI-DESIGN-SYSTEM`, import
|
|
18
|
+
* the very package it is part of — a self-referential import that happens
|
|
19
|
+
* to resolve locally against an already-built `dist/` but is not safe on a
|
|
20
|
+
* clean checkout or CI publish. No new CSS needed: `secondary-light` is an
|
|
21
|
+
* existing, already-shipped variant, so this only needs the class names,
|
|
22
|
+
* not a new visual design.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
const BUTTON_VARIANT_CLASS: Record<string, string> = {
|
|
26
|
+
clear: "button--clear",
|
|
27
|
+
default: "button--default",
|
|
28
|
+
"primary-gradient": "button--primary-gradient",
|
|
29
|
+
"primary-dark": "button--primary-dark",
|
|
30
|
+
"secondary-light": "button--secondary-light",
|
|
31
|
+
"tertiary-light": "button--tertiary-light",
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
interface FileUploadTriggerProps
|
|
35
|
+
extends Omit<React.ComponentProps<"button">, "onChange"> {
|
|
36
|
+
/** Fires with the selected files. */
|
|
37
|
+
onFiles?: (files: FileList) => void;
|
|
38
|
+
/** File-input `accept` list. Omit to allow anything. */
|
|
39
|
+
accept?: string;
|
|
40
|
+
multiple?: boolean;
|
|
41
|
+
/** Matches the DS `Button`'s existing variant names — see BUTTON_VARIANT_CLASS. */
|
|
42
|
+
variant?: keyof typeof BUTTON_VARIANT_CLASS;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const FileUploadTrigger = React.forwardRef<HTMLButtonElement, FileUploadTriggerProps>(
|
|
46
|
+
(
|
|
47
|
+
{
|
|
48
|
+
onFiles,
|
|
49
|
+
accept,
|
|
50
|
+
multiple = false,
|
|
51
|
+
variant = "secondary-light",
|
|
52
|
+
children,
|
|
53
|
+
className,
|
|
54
|
+
type = "button",
|
|
55
|
+
onClick,
|
|
56
|
+
disabled,
|
|
57
|
+
...props
|
|
58
|
+
},
|
|
59
|
+
ref,
|
|
60
|
+
) => {
|
|
61
|
+
const inputRef = React.useRef<HTMLInputElement | null>(null);
|
|
62
|
+
|
|
63
|
+
return (
|
|
64
|
+
<>
|
|
65
|
+
<button
|
|
66
|
+
ref={ref}
|
|
67
|
+
type={type}
|
|
68
|
+
disabled={disabled}
|
|
69
|
+
className={cn("button", BUTTON_VARIANT_CLASS[variant], className)}
|
|
70
|
+
onClick={(event) => {
|
|
71
|
+
onClick?.(event);
|
|
72
|
+
if (!event.defaultPrevented) inputRef.current?.click();
|
|
73
|
+
}}
|
|
74
|
+
{...props}
|
|
75
|
+
>
|
|
76
|
+
<span className="button-text body-base">{children}</span>
|
|
77
|
+
</button>
|
|
78
|
+
<input
|
|
79
|
+
ref={inputRef}
|
|
80
|
+
type="file"
|
|
81
|
+
hidden
|
|
82
|
+
accept={accept}
|
|
83
|
+
multiple={multiple}
|
|
84
|
+
tabIndex={-1}
|
|
85
|
+
onChange={(event) => {
|
|
86
|
+
if (event.target.files?.length) onFiles?.(event.target.files);
|
|
87
|
+
// Clear so re-picking the same file fires change again.
|
|
88
|
+
event.target.value = "";
|
|
89
|
+
}}
|
|
90
|
+
/>
|
|
91
|
+
</>
|
|
92
|
+
);
|
|
93
|
+
},
|
|
94
|
+
);
|
|
95
|
+
FileUploadTrigger.displayName = "FileUploadTrigger";
|
|
96
|
+
|
|
97
|
+
export { FileUploadTrigger };
|
|
98
|
+
export type { FileUploadTriggerProps };
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { cn } from "@/lib/utils";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* InlineNotice — a flat, in-flow status message.
|
|
6
|
+
*
|
|
7
|
+
* Unlike a toast or a banner it never floats: it takes a slot in the form and
|
|
8
|
+
* pushes content down, which is what RULE #1B requires of an API error (visible
|
|
9
|
+
* on the same page, never a redirect or reload).
|
|
10
|
+
*
|
|
11
|
+
* Figma (12656:28192): coral-100 (#fcf4f2) fill, 8px radius, 48px tall, 16/24
|
|
12
|
+
* padding, italic 16/21 coral-800 (#bc4324) text. That is the only tone the
|
|
13
|
+
* design specifies, so it is the only one implemented.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
/* Only `error` is specified in the design; other tones are not invented here. */
|
|
17
|
+
type NoticeTone = "error";
|
|
18
|
+
|
|
19
|
+
interface InlineNoticeProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
20
|
+
tone?: NoticeTone;
|
|
21
|
+
children: React.ReactNode;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const InlineNotice = React.forwardRef<HTMLDivElement, InlineNoticeProps>(
|
|
25
|
+
({ tone = "error", children, className, ...props }, ref) => (
|
|
26
|
+
<div
|
|
27
|
+
ref={ref}
|
|
28
|
+
className={cn("inline-notice", `inline-notice--${tone}`, className)}
|
|
29
|
+
role={tone === "error" ? "alert" : "status"}
|
|
30
|
+
{...props}
|
|
31
|
+
>
|
|
32
|
+
<span className="inline-notice__text">{children}</span>
|
|
33
|
+
</div>
|
|
34
|
+
),
|
|
35
|
+
);
|
|
36
|
+
InlineNotice.displayName = "InlineNotice";
|
|
37
|
+
|
|
38
|
+
export { InlineNotice };
|
|
39
|
+
export type { InlineNoticeProps, NoticeTone };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { cn } from "@/lib/utils";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* LabeledDivider — a centred label flanked by two short rules ("— OR —").
|
|
6
|
+
*
|
|
7
|
+
* Figma: 32px-high row, 4px gap, two 32px × 1.5px round-capped cyan-100
|
|
8
|
+
* (#d6f4fb) rules, label in overline-medium cyan-800.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
interface LabeledDividerProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
12
|
+
children: React.ReactNode;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const LabeledDivider = React.forwardRef<HTMLDivElement, LabeledDividerProps>(
|
|
16
|
+
({ children, className, ...props }, ref) => (
|
|
17
|
+
<div
|
|
18
|
+
ref={ref}
|
|
19
|
+
className={cn("labeled-divider", className)}
|
|
20
|
+
role="separator"
|
|
21
|
+
{...props}
|
|
22
|
+
>
|
|
23
|
+
<span className="labeled-divider__rule" aria-hidden="true" />
|
|
24
|
+
<span className="labeled-divider__label overline-medium">{children}</span>
|
|
25
|
+
<span className="labeled-divider__rule" aria-hidden="true" />
|
|
26
|
+
</div>
|
|
27
|
+
),
|
|
28
|
+
);
|
|
29
|
+
LabeledDivider.displayName = "LabeledDivider";
|
|
30
|
+
|
|
31
|
+
export { LabeledDivider };
|
|
32
|
+
export type { LabeledDividerProps };
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { cn } from "@/lib/utils";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* MetaRow — centred small links separated by a 3px dot.
|
|
6
|
+
*
|
|
7
|
+
* Figma 12695:33990: 16px gap, 10.5px block padding, links in Mazzard Medium
|
|
8
|
+
* 14/19.6 blue-600 (#2e74ad), with a gray-300 (#cbcdd2) 3px dot between each
|
|
9
|
+
* pair. The dot is drawn by the component between children, so callers pass
|
|
10
|
+
* only the links and never a separator.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
interface MetaRowProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
14
|
+
children: React.ReactNode;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const MetaRow = React.forwardRef<HTMLDivElement, MetaRowProps>(
|
|
18
|
+
({ children, className, ...props }, ref) => {
|
|
19
|
+
const items = React.Children.toArray(children).filter(Boolean);
|
|
20
|
+
|
|
21
|
+
return (
|
|
22
|
+
<div ref={ref} className={cn("meta-row", className)} {...props}>
|
|
23
|
+
{items.map((child, index) => (
|
|
24
|
+
// eslint-disable-next-line react/no-array-index-key
|
|
25
|
+
<React.Fragment key={index}>
|
|
26
|
+
{index > 0 ? (
|
|
27
|
+
<span className="meta-row__dot" aria-hidden="true" />
|
|
28
|
+
) : null}
|
|
29
|
+
{child}
|
|
30
|
+
</React.Fragment>
|
|
31
|
+
))}
|
|
32
|
+
</div>
|
|
33
|
+
);
|
|
34
|
+
},
|
|
35
|
+
);
|
|
36
|
+
MetaRow.displayName = "MetaRow";
|
|
37
|
+
|
|
38
|
+
export { MetaRow };
|
|
39
|
+
export type { MetaRowProps };
|