@malexander-tech/ui 0.2.0 → 0.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.
Files changed (38) hide show
  1. package/dist/components/Alert.d.ts +4 -2
  2. package/dist/components/Alert.d.ts.map +1 -1
  3. package/dist/components/Alert.js +5 -2
  4. package/dist/components/Button.d.ts +19 -4
  5. package/dist/components/Button.d.ts.map +1 -1
  6. package/dist/components/Button.js +16 -4
  7. package/dist/components/Drawer.d.ts +12 -0
  8. package/dist/components/Drawer.d.ts.map +1 -0
  9. package/dist/components/Drawer.js +58 -0
  10. package/dist/components/Field.d.ts +22 -3
  11. package/dist/components/Field.d.ts.map +1 -1
  12. package/dist/components/Field.js +19 -10
  13. package/dist/components/FormActions.d.ts +6 -0
  14. package/dist/components/FormActions.d.ts.map +1 -0
  15. package/dist/components/FormActions.js +4 -0
  16. package/dist/components/FormErrorSummary.d.ts +9 -0
  17. package/dist/components/FormErrorSummary.d.ts.map +1 -0
  18. package/dist/components/FormErrorSummary.js +16 -0
  19. package/dist/components/FormLayout.d.ts +6 -0
  20. package/dist/components/FormLayout.d.ts.map +1 -0
  21. package/dist/components/FormLayout.js +4 -0
  22. package/dist/components/FormRow.d.ts +6 -0
  23. package/dist/components/FormRow.d.ts.map +1 -0
  24. package/dist/components/FormRow.js +4 -0
  25. package/dist/components/FormSection.d.ts +8 -0
  26. package/dist/components/FormSection.d.ts.map +1 -0
  27. package/dist/components/FormSection.js +6 -0
  28. package/dist/components/HeaderShell.d.ts +13 -0
  29. package/dist/components/HeaderShell.d.ts.map +1 -0
  30. package/dist/components/HeaderShell.js +27 -0
  31. package/dist/components/SideNavShell.d.ts +12 -0
  32. package/dist/components/SideNavShell.d.ts.map +1 -0
  33. package/dist/components/SideNavShell.js +30 -0
  34. package/dist/index.d.ts +17 -1
  35. package/dist/index.d.ts.map +1 -1
  36. package/dist/index.js +8 -0
  37. package/dist/styles.css +343 -3
  38. package/package.json +6 -6
@@ -1,9 +1,11 @@
1
1
  import type { ComponentPropsWithRef, ReactNode } from "react";
2
- export type AlertTone = "error" | "success" | "warning";
2
+ export type AlertTone = "error" | "info" | "success" | "warning";
3
3
  export type AlertProps = ComponentPropsWithRef<"div"> & {
4
- title: string;
4
+ /** Optional heading; without it the alert has no title row. */
5
+ title?: string;
5
6
  tone: AlertTone;
6
7
  children: ReactNode;
7
8
  };
9
+ /** Live by default (`alert` for errors, `status` otherwise); pass `role="none"` for a static alert. */
8
10
  export declare function Alert({ children, className, role, title, tone, ...props }: AlertProps): import("react").JSX.Element;
9
11
  //# sourceMappingURL=Alert.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Alert.d.ts","sourceRoot":"","sources":["../../src/components/Alert.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAC9D,MAAM,MAAM,SAAS,GAAG,OAAO,GAAG,SAAS,GAAG,SAAS,CAAC;AACxD,MAAM,MAAM,UAAU,GAAG,qBAAqB,CAAC,KAAK,CAAC,GAAG;IACtD,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,SAAS,CAAC;IAChB,QAAQ,EAAE,SAAS,CAAC;CACrB,CAAC;AAMF,wBAAgB,KAAK,CAAC,EACpB,QAAQ,EACR,SAAS,EACT,IAAI,EACJ,KAAK,EACL,IAAI,EACJ,GAAG,KAAK,EACT,EAAE,UAAU,+BAmBZ"}
1
+ {"version":3,"file":"Alert.d.ts","sourceRoot":"","sources":["../../src/components/Alert.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAC9D,MAAM,MAAM,SAAS,GAAG,OAAO,GAAG,MAAM,GAAG,SAAS,GAAG,SAAS,CAAC;AACjE,MAAM,MAAM,UAAU,GAAG,qBAAqB,CAAC,KAAK,CAAC,GAAG;IACtD,+DAA+D;IAC/D,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,SAAS,CAAC;IAChB,QAAQ,EAAE,SAAS,CAAC;CACrB,CAAC;AAOF,uGAAuG;AACvG,wBAAgB,KAAK,CAAC,EACpB,QAAQ,EACR,SAAS,EACT,IAAI,EACJ,KAAK,EACL,IAAI,EACJ,GAAG,KAAK,EACT,EAAE,UAAU,+BA2BZ"}
@@ -1,11 +1,14 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
1
+ import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
2
2
  const toneLabel = {
3
3
  error: "Error",
4
+ info: "Info",
4
5
  success: "Success",
5
6
  warning: "Warning",
6
7
  };
8
+ /** Live by default (`alert` for errors, `status` otherwise); pass `role="none"` for a static alert. */
7
9
  export function Alert({ children, className, role, title, tone, ...props }) {
10
+ const tonePrefix = (_jsxs("span", { className: "mat-alert__tone", children: [toneLabel[tone], ": "] }));
8
11
  return (_jsxs("div", { ...props, className: ["mat-alert", `mat-alert--${tone}`, className]
9
12
  .filter(Boolean)
10
- .join(" "), role: role ?? (tone === "error" ? "alert" : "status"), children: [_jsx("span", { "aria-hidden": "true", className: "mat-alert__accent" }), _jsxs("div", { children: [_jsxs("strong", { className: "mat-alert__title", children: [_jsxs("span", { className: "mat-alert__tone", children: [toneLabel[tone], ": "] }), title] }), _jsx("div", { className: "mat-alert__body", children: children })] })] }));
13
+ .join(" "), role: role ?? (tone === "error" ? "alert" : "status"), children: [_jsx("span", { "aria-hidden": "true", className: "mat-alert__accent" }), _jsxs("div", { children: [title ? (_jsxs("strong", { className: "mat-alert__title", children: [tonePrefix, title] })) : null, _jsxs("div", { className: "mat-alert__body", children: [title ? null : tonePrefix, children] })] })] }));
11
14
  }
@@ -1,7 +1,22 @@
1
- import type { ComponentPropsWithRef, ReactNode } from "react";
2
- export type ButtonProps = ComponentPropsWithRef<"button"> & {
1
+ import type { ComponentPropsWithRef, ElementType, ReactNode } from "react";
2
+ export type ButtonVariant = "primary" | "secondary" | "danger";
3
+ export type ButtonSize = "md" | "sm";
4
+ interface ButtonStyleProps {
3
5
  children: ReactNode;
4
- variant?: "primary" | "secondary";
6
+ variant?: ButtonVariant;
7
+ size?: ButtonSize;
8
+ }
9
+ export type ButtonAsButtonProps = ButtonStyleProps & Omit<ComponentPropsWithRef<"button">, keyof ButtonStyleProps> & {
10
+ href?: never;
11
+ as?: never;
5
12
  };
6
- export declare function Button({ children, className, variant, type, ...props }: ButtonProps): import("react").JSX.Element;
13
+ export type ButtonAsLinkProps = ButtonStyleProps & Omit<ComponentPropsWithRef<"a">, keyof ButtonStyleProps | "href"> & {
14
+ href: string;
15
+ /** Link component to render instead of `<a>`, e.g. Next `Link`. Receives `href`, `className`, `children` and the rest. */
16
+ as?: ElementType;
17
+ };
18
+ /** `href` renders a link (`<a>`, or `as`) with button styles; otherwise a `<button>`. */
19
+ export type ButtonProps = ButtonAsButtonProps | ButtonAsLinkProps;
20
+ export declare function Button(props: ButtonProps): import("react").JSX.Element;
21
+ export {};
7
22
  //# sourceMappingURL=Button.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Button.d.ts","sourceRoot":"","sources":["../../src/components/Button.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAE9D,MAAM,MAAM,WAAW,GAAG,qBAAqB,CAAC,QAAQ,CAAC,GAAG;IAC1D,QAAQ,EAAE,SAAS,CAAC;IACpB,OAAO,CAAC,EAAE,SAAS,GAAG,WAAW,CAAC;CACnC,CAAC;AAEF,wBAAgB,MAAM,CAAC,EACrB,QAAQ,EACR,SAAS,EACT,OAAmB,EACnB,IAAe,EACf,GAAG,KAAK,EACT,EAAE,WAAW,+BAYb"}
1
+ {"version":3,"file":"Button.d.ts","sourceRoot":"","sources":["../../src/components/Button.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAE3E,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,WAAW,GAAG,QAAQ,CAAC;AAC/D,MAAM,MAAM,UAAU,GAAG,IAAI,GAAG,IAAI,CAAC;AAErC,UAAU,gBAAgB;IACxB,QAAQ,EAAE,SAAS,CAAC;IACpB,OAAO,CAAC,EAAE,aAAa,CAAC;IACxB,IAAI,CAAC,EAAE,UAAU,CAAC;CACnB;AAED,MAAM,MAAM,mBAAmB,GAAG,gBAAgB,GAChD,IAAI,CAAC,qBAAqB,CAAC,QAAQ,CAAC,EAAE,MAAM,gBAAgB,CAAC,GAAG;IAC9D,IAAI,CAAC,EAAE,KAAK,CAAC;IACb,EAAE,CAAC,EAAE,KAAK,CAAC;CACZ,CAAC;AAEJ,MAAM,MAAM,iBAAiB,GAAG,gBAAgB,GAC9C,IAAI,CAAC,qBAAqB,CAAC,GAAG,CAAC,EAAE,MAAM,gBAAgB,GAAG,MAAM,CAAC,GAAG;IAClE,IAAI,EAAE,MAAM,CAAC;IACb,0HAA0H;IAC1H,EAAE,CAAC,EAAE,WAAW,CAAC;CAClB,CAAC;AAEJ,yFAAyF;AACzF,MAAM,MAAM,WAAW,GAAG,mBAAmB,GAAG,iBAAiB,CAAC;AAElE,wBAAgB,MAAM,CAAC,KAAK,EAAE,WAAW,+BA8BxC"}
@@ -1,6 +1,18 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- export function Button({ children, className, variant = "primary", type = "button", ...props }) {
3
- return (_jsx("button", { ...props, className: ["mat-button", `mat-button--${variant}`, className]
4
- .filter(Boolean)
5
- .join(" "), type: type, children: children }));
2
+ export function Button(props) {
3
+ const { className, size = "md", variant = "primary" } = props;
4
+ const classes = [
5
+ "mat-button",
6
+ `mat-button--${variant}`,
7
+ size === "sm" && "mat-button--sm",
8
+ className,
9
+ ]
10
+ .filter(Boolean)
11
+ .join(" ");
12
+ if (props.href !== undefined) {
13
+ const { as: Link = "a", className: _className, size: _size, variant: _variant, ...linkProps } = props;
14
+ return _jsx(Link, { ...linkProps, className: classes });
15
+ }
16
+ const { className: _className, size: _size, type = "button", variant: _variant, ...buttonProps } = props;
17
+ return _jsx("button", { ...buttonProps, className: classes, type: type });
6
18
  }
@@ -0,0 +1,12 @@
1
+ import { type ComponentPropsWithRef, type ReactNode } from "react";
2
+ export type DrawerProps = Omit<ComponentPropsWithRef<"dialog">, "open"> & {
3
+ open: boolean;
4
+ onClose: () => void;
5
+ label: string;
6
+ closeLabel?: string;
7
+ heading?: ReactNode;
8
+ side?: "start" | "end";
9
+ children: ReactNode;
10
+ };
11
+ export declare function Drawer({ open, onClose, label, closeLabel, heading, side, children, className, ref, onCancel, onClick, onKeyDown, ...props }: DrawerProps): import("react").JSX.Element;
12
+ //# sourceMappingURL=Drawer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Drawer.d.ts","sourceRoot":"","sources":["../../src/components/Drawer.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,qBAAqB,EAC1B,KAAK,SAAS,EAGf,MAAM,OAAO,CAAC;AAIf,MAAM,MAAM,WAAW,GAAG,IAAI,CAAC,qBAAqB,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC,GAAG;IACxE,IAAI,EAAE,OAAO,CAAC;IACd,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,SAAS,CAAC;IACpB,IAAI,CAAC,EAAE,OAAO,GAAG,KAAK,CAAC;IACvB,QAAQ,EAAE,SAAS,CAAC;CACrB,CAAC;AAEF,wBAAgB,MAAM,CAAC,EACrB,IAAI,EACJ,OAAO,EACP,KAAK,EACL,UAAoB,EACpB,OAAO,EACP,IAAc,EACd,QAAQ,EACR,SAAS,EACT,GAAG,EACH,QAAQ,EACR,OAAO,EACP,SAAS,EACT,GAAG,KAAK,EACT,EAAE,WAAW,+BAsFb"}
@@ -0,0 +1,58 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useEffect, useRef, } from "react";
3
+ import { Button } from "./Button.js";
4
+ export function Drawer({ open, onClose, label, closeLabel = "Close", heading, side = "start", children, className, ref, onCancel, onClick, onKeyDown, ...props }) {
5
+ const dialogRef = useRef(null);
6
+ useEffect(() => {
7
+ const dialog = dialogRef.current;
8
+ if (!dialog)
9
+ return;
10
+ if (!open) {
11
+ dialog.close();
12
+ return;
13
+ }
14
+ const opener = document.activeElement;
15
+ dialog.showModal();
16
+ return () => {
17
+ dialog.close();
18
+ if (opener instanceof HTMLElement)
19
+ opener.focus();
20
+ };
21
+ }, [open]);
22
+ return (
23
+ // The rule's role map treats `dialog` as non-interactive, but a modal <dialog> owns its own
24
+ // Escape (cancel), backdrop click and Tab handling.
25
+ // eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions
26
+ _jsxs("dialog", { ...props, ref: (element) => {
27
+ dialogRef.current = element;
28
+ if (typeof ref === "function")
29
+ return ref(element);
30
+ if (ref)
31
+ ref.current = element;
32
+ }, "aria-label": label, className: ["mat-drawer", `mat-drawer--${side}`, className]
33
+ .filter(Boolean)
34
+ .join(" "), onCancel: (event) => {
35
+ event.preventDefault();
36
+ onCancel?.(event);
37
+ onClose();
38
+ }, onClick: (event) => {
39
+ onClick?.(event);
40
+ if (event.target === event.currentTarget)
41
+ onClose();
42
+ }, onKeyDown: (event) => {
43
+ onKeyDown?.(event);
44
+ if (event.key !== "Tab")
45
+ return;
46
+ const focusable = event.currentTarget.querySelectorAll('a[href],button:not(:disabled),input:not(:disabled),select,textarea,[tabindex]:not([tabindex="-1"])');
47
+ const first = focusable[0];
48
+ const last = focusable[focusable.length - 1];
49
+ if (event.shiftKey && document.activeElement === first) {
50
+ event.preventDefault();
51
+ last?.focus();
52
+ }
53
+ else if (!event.shiftKey && document.activeElement === last) {
54
+ event.preventDefault();
55
+ first?.focus();
56
+ }
57
+ }, children: [_jsxs("div", { className: "mat-drawer__header", children: [_jsx("div", { className: "mat-drawer__heading", children: heading }), _jsx(Button, { "aria-label": closeLabel, className: "mat-drawer__close", onClick: onClose, variant: "secondary", children: _jsx("svg", { "aria-hidden": "true", fill: "none", height: "24", viewBox: "0 0 24 24", width: "24", children: _jsx("path", { d: "M6 6l12 12M18 6L6 18", stroke: "currentColor", strokeLinecap: "round", strokeWidth: "2.5" }) }) })] }), _jsx("div", { className: "mat-drawer__body", children: children })] }));
58
+ }
@@ -1,9 +1,28 @@
1
- import type { ComponentPropsWithRef } from "react";
2
- export type FieldProps = Omit<ComponentPropsWithRef<"input">, "id"> & {
1
+ import type { ComponentPropsWithRef, ReactNode } from "react";
2
+ /** Props to spread onto the control a render-prop `Field` renders. */
3
+ export interface FieldControlProps {
4
+ id: string;
5
+ className: "mat-field__input";
6
+ "aria-describedby"?: string;
7
+ "aria-invalid"?: true;
8
+ }
9
+ interface FieldBaseProps {
3
10
  label: string;
4
11
  helperText?: string;
12
+ /** Shown below the control with `role="alert"`; also marks the control invalid. */
5
13
  error?: string;
6
14
  id?: string;
15
+ className?: string;
16
+ required?: boolean;
17
+ }
18
+ export type FieldInputProps = FieldBaseProps & Omit<ComponentPropsWithRef<"input">, keyof FieldBaseProps | "children"> & {
19
+ children?: never;
7
20
  };
8
- export declare function Field({ "aria-describedby": consumerDescribedBy, className, disabled, error, helperText, id: providedId, label, required, ...inputProps }: FieldProps): import("react").JSX.Element;
21
+ export type FieldRenderProps = FieldBaseProps & {
22
+ /** Render any labelled control (`select`, `textarea`, custom) with the props spread onto it. */
23
+ children: (control: FieldControlProps) => ReactNode;
24
+ };
25
+ export type FieldProps = FieldInputProps | FieldRenderProps;
26
+ export declare function Field(props: FieldProps): import("react").JSX.Element;
27
+ export {};
9
28
  //# sourceMappingURL=Field.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Field.d.ts","sourceRoot":"","sources":["../../src/components/Field.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,OAAO,CAAC;AAEnD,MAAM,MAAM,UAAU,GAAG,IAAI,CAAC,qBAAqB,CAAC,OAAO,CAAC,EAAE,IAAI,CAAC,GAAG;IACpE,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,EAAE,CAAC,EAAE,MAAM,CAAC;CACb,CAAC;AACF,wBAAgB,KAAK,CAAC,EACpB,kBAAkB,EAAE,mBAAmB,EACvC,SAAS,EACT,QAAQ,EACR,KAAK,EACL,UAAU,EACV,EAAE,EAAE,UAAU,EACd,KAAK,EACL,QAAQ,EACR,GAAG,UAAU,EACd,EAAE,UAAU,+BAsCZ"}
1
+ {"version":3,"file":"Field.d.ts","sourceRoot":"","sources":["../../src/components/Field.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAG9D,sEAAsE;AACtE,MAAM,WAAW,iBAAiB;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,kBAAkB,CAAC;IAC9B,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,cAAc,CAAC,EAAE,IAAI,CAAC;CACvB;AAED,UAAU,cAAc;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,mFAAmF;IACnF,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,MAAM,eAAe,GAAG,cAAc,GAC1C,IAAI,CAAC,qBAAqB,CAAC,OAAO,CAAC,EAAE,MAAM,cAAc,GAAG,UAAU,CAAC,GAAG;IACxE,QAAQ,CAAC,EAAE,KAAK,CAAC;CAClB,CAAC;AAEJ,MAAM,MAAM,gBAAgB,GAAG,cAAc,GAAG;IAC9C,gGAAgG;IAChG,QAAQ,EAAE,CAAC,OAAO,EAAE,iBAAiB,KAAK,SAAS,CAAC;CACrD,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG,eAAe,GAAG,gBAAgB,CAAC;AAE5D,wBAAgB,KAAK,CAAC,KAAK,EAAE,UAAU,+BAwEtC"}
@@ -1,15 +1,24 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useId } from "react";
3
- export function Field({ "aria-describedby": consumerDescribedBy, className, disabled, error, helperText, id: providedId, label, required, ...inputProps }) {
3
+ export function Field(props) {
4
4
  const generatedId = useId();
5
+ const { children, className, error, helperText, id: providedId, label, required, } = props;
5
6
  const id = providedId ?? generatedId;
6
- const message = error ?? helperText;
7
- const messageId = message ? `${id}-message` : undefined;
8
- const describedBy = [consumerDescribedBy, messageId].filter(Boolean).join(" ") || undefined;
9
- return (_jsxs("div", { className: ["mat-field", className].filter(Boolean).join(" "), children: [_jsxs("label", { className: "mat-field__label", htmlFor: id, children: [label, required ? _jsx("span", { "aria-hidden": "true", children: " *" }) : null] }), _jsx("input", { ...inputProps, "aria-describedby": describedBy, "aria-invalid": error ? true : undefined, className: "mat-field__input", disabled: disabled, id: id, required: required }), message ? (_jsx("p", { className: [
10
- "mat-field__message",
11
- error ? "mat-field__message--error" : "",
12
- ]
13
- .filter(Boolean)
14
- .join(" "), id: messageId, role: error ? "alert" : undefined, children: message })) : null] }));
7
+ const helperId = helperText ? `${id}-helper` : undefined;
8
+ const errorId = error ? `${id}-error` : undefined;
9
+ let control;
10
+ if (typeof children === "function") {
11
+ control = children({
12
+ id,
13
+ className: "mat-field__input",
14
+ "aria-describedby": [helperId, errorId].filter(Boolean).join(" ") || undefined,
15
+ "aria-invalid": error ? true : undefined,
16
+ });
17
+ }
18
+ else {
19
+ const { "aria-describedby": consumerDescribedBy, children: _children, className: _className, error: _error, helperText: _helperText, id: _id, label: _label, ...inputProps } = props;
20
+ control = (_jsx("input", { ...inputProps, "aria-describedby": [consumerDescribedBy, helperId, errorId].filter(Boolean).join(" ") ||
21
+ undefined, "aria-invalid": error ? true : undefined, className: "mat-field__input", id: id }));
22
+ }
23
+ return (_jsxs("div", { className: ["mat-field", className].filter(Boolean).join(" "), children: [_jsxs("label", { className: "mat-field__label", htmlFor: id, children: [label, required ? _jsx("span", { "aria-hidden": "true", children: " *" }) : null] }), control, helperText ? (_jsx("p", { className: "mat-field__message", id: helperId, children: helperText })) : null, error ? (_jsx("p", { className: "mat-field__message mat-field__message--error", id: errorId, role: "alert", children: error })) : null] }));
15
24
  }
@@ -0,0 +1,6 @@
1
+ import type { ComponentPropsWithRef, ReactNode } from "react";
2
+ export type FormActionsProps = ComponentPropsWithRef<"div"> & {
3
+ status?: ReactNode;
4
+ };
5
+ export declare function FormActions({ children, className, status, ...props }: FormActionsProps): import("react").JSX.Element;
6
+ //# sourceMappingURL=FormActions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FormActions.d.ts","sourceRoot":"","sources":["../../src/components/FormActions.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAE9D,MAAM,MAAM,gBAAgB,GAAG,qBAAqB,CAAC,KAAK,CAAC,GAAG;IAC5D,MAAM,CAAC,EAAE,SAAS,CAAC;CACpB,CAAC;AAEF,wBAAgB,WAAW,CAAC,EAC1B,QAAQ,EACR,SAAS,EACT,MAAM,EACN,GAAG,KAAK,EACT,EAAE,gBAAgB,+BAUlB"}
@@ -0,0 +1,4 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ export function FormActions({ children, className, status, ...props }) {
3
+ return (_jsxs("div", { ...props, className: ["mat-form-actions", className].filter(Boolean).join(" "), children: [status, _jsx("div", { className: "mat-form-actions__buttons", children: children })] }));
4
+ }
@@ -0,0 +1,9 @@
1
+ import { type ReactNode } from "react";
2
+ import { type AlertProps } from "./Alert.js";
3
+ export type FormErrorSummaryProps = Omit<AlertProps, "tone" | "title" | "children"> & {
4
+ title: string;
5
+ children: ReactNode;
6
+ focusKey?: unknown;
7
+ };
8
+ export declare function FormErrorSummary({ children, className, focusKey, ref, title, ...props }: FormErrorSummaryProps): import("react").JSX.Element;
9
+ //# sourceMappingURL=FormErrorSummary.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FormErrorSummary.d.ts","sourceRoot":"","sources":["../../src/components/FormErrorSummary.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAqB,MAAM,OAAO,CAAC;AAE1D,OAAO,EAAS,KAAK,UAAU,EAAE,MAAM,YAAY,CAAC;AAEpD,MAAM,MAAM,qBAAqB,GAAG,IAAI,CACtC,UAAU,EACV,MAAM,GAAG,OAAO,GAAG,UAAU,CAC9B,GAAG;IACF,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,SAAS,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AAEF,wBAAgB,gBAAgB,CAAC,EAC/B,QAAQ,EACR,SAAS,EACT,QAAQ,EACR,GAAG,EACH,KAAK,EACL,GAAG,KAAK,EACT,EAAE,qBAAqB,+BAuBvB"}
@@ -0,0 +1,16 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useEffect, useRef } from "react";
3
+ import { Alert } from "./Alert.js";
4
+ export function FormErrorSummary({ children, className, focusKey, ref, title, ...props }) {
5
+ const nodeRef = useRef(null);
6
+ useEffect(() => {
7
+ nodeRef.current?.focus();
8
+ }, [focusKey]);
9
+ return (_jsx(Alert, { ...props, className: [className].filter(Boolean).join(" "), ref: (element) => {
10
+ nodeRef.current = element;
11
+ if (typeof ref === "function")
12
+ return ref(element);
13
+ if (ref)
14
+ ref.current = element;
15
+ }, tabIndex: -1, title: title, tone: "error", children: children }));
16
+ }
@@ -0,0 +1,6 @@
1
+ import type { ComponentPropsWithRef, ReactNode } from "react";
2
+ export type FormLayoutProps = ComponentPropsWithRef<"form"> & {
3
+ requiredNote?: ReactNode;
4
+ };
5
+ export declare function FormLayout({ children, className, noValidate, requiredNote, ...props }: FormLayoutProps): import("react").JSX.Element;
6
+ //# sourceMappingURL=FormLayout.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FormLayout.d.ts","sourceRoot":"","sources":["../../src/components/FormLayout.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAE9D,MAAM,MAAM,eAAe,GAAG,qBAAqB,CAAC,MAAM,CAAC,GAAG;IAC5D,YAAY,CAAC,EAAE,SAAS,CAAC;CAC1B,CAAC;AAEF,wBAAgB,UAAU,CAAC,EACzB,QAAQ,EACR,SAAS,EACT,UAAiB,EACjB,YAAY,EACZ,GAAG,KAAK,EACT,EAAE,eAAe,+BAyBjB"}
@@ -0,0 +1,4 @@
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ export function FormLayout({ children, className, noValidate = true, requiredNote, ...props }) {
3
+ return (_jsxs("form", { ...props, className: ["mat-form", className].filter(Boolean).join(" "), noValidate: noValidate, children: [requiredNote !== undefined ? (_jsxs("p", { className: "mat-form__required-note", children: [typeof requiredNote === "string" && /^\s*\*/.test(requiredNote) ? (_jsxs(_Fragment, { children: [_jsx("span", { "aria-hidden": "true", children: "*" }), requiredNote.replace(/^\s*\*/, "")] })) : (requiredNote), _jsx("span", { className: "mat-form__vh", children: "Fields marked with an asterisk are required" })] })) : null, children] }));
4
+ }
@@ -0,0 +1,6 @@
1
+ import type { ComponentPropsWithRef, ReactNode } from "react";
2
+ export type FormRowProps = ComponentPropsWithRef<"div"> & {
3
+ children: ReactNode;
4
+ };
5
+ export declare function FormRow({ children, className, ...props }: FormRowProps): import("react").JSX.Element;
6
+ //# sourceMappingURL=FormRow.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FormRow.d.ts","sourceRoot":"","sources":["../../src/components/FormRow.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAE9D,MAAM,MAAM,YAAY,GAAG,qBAAqB,CAAC,KAAK,CAAC,GAAG;IACxD,QAAQ,EAAE,SAAS,CAAC;CACrB,CAAC;AAEF,wBAAgB,OAAO,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,EAAE,YAAY,+BAStE"}
@@ -0,0 +1,4 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ export function FormRow({ children, className, ...props }) {
3
+ return (_jsx("div", { ...props, className: ["mat-form-row", className].filter(Boolean).join(" "), children: children }));
4
+ }
@@ -0,0 +1,8 @@
1
+ import type { ComponentPropsWithRef, ReactNode } from "react";
2
+ export type FormSectionProps = Omit<ComponentPropsWithRef<"fieldset">, "legend"> & {
3
+ legend: string;
4
+ description?: ReactNode;
5
+ children: ReactNode;
6
+ };
7
+ export declare function FormSection({ children, className, description, legend, ...props }: FormSectionProps): import("react").JSX.Element;
8
+ //# sourceMappingURL=FormSection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FormSection.d.ts","sourceRoot":"","sources":["../../src/components/FormSection.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAG9D,MAAM,MAAM,gBAAgB,GAAG,IAAI,CACjC,qBAAqB,CAAC,UAAU,CAAC,EACjC,QAAQ,CACT,GAAG;IACF,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,SAAS,CAAC;IACxB,QAAQ,EAAE,SAAS,CAAC;CACrB,CAAC;AAEF,wBAAgB,WAAW,CAAC,EAC1B,QAAQ,EACR,SAAS,EACT,WAAW,EACX,MAAM,EACN,GAAG,KAAK,EACT,EAAE,gBAAgB,+BAkBlB"}
@@ -0,0 +1,6 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useId } from "react";
3
+ export function FormSection({ children, className, description, legend, ...props }) {
4
+ const descriptionId = useId();
5
+ return (_jsxs("fieldset", { ...props, ...(description ? { "aria-describedby": descriptionId } : {}), className: ["mat-form-section", className].filter(Boolean).join(" "), children: [_jsx("legend", { className: "mat-form-section__legend", children: legend }), description ? (_jsx("p", { className: "mat-form-section__description", id: descriptionId, children: description })) : null, children] }));
6
+ }
@@ -0,0 +1,13 @@
1
+ import { type ComponentPropsWithRef, type ReactNode } from "react";
2
+ export type HeaderShellProps = ComponentPropsWithRef<"div"> & {
3
+ brand: ReactNode;
4
+ nav?: ReactNode;
5
+ navLabel: string;
6
+ actions?: ReactNode;
7
+ footer?: ReactNode;
8
+ children: ReactNode;
9
+ menuLabel?: string;
10
+ closeLabel?: string;
11
+ };
12
+ export declare function HeaderShell({ brand, nav, navLabel, actions, footer, children, menuLabel, closeLabel, className, ...props }: HeaderShellProps): import("react").JSX.Element;
13
+ //# sourceMappingURL=HeaderShell.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HeaderShell.d.ts","sourceRoot":"","sources":["../../src/components/HeaderShell.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,qBAAqB,EAC1B,KAAK,SAAS,EAIf,MAAM,OAAO,CAAC;AAKf,MAAM,MAAM,gBAAgB,GAAG,qBAAqB,CAAC,KAAK,CAAC,GAAG;IAC5D,KAAK,EAAE,SAAS,CAAC;IACjB,GAAG,CAAC,EAAE,SAAS,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,SAAS,CAAC;IACpB,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,QAAQ,EAAE,SAAS,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAKF,wBAAgB,WAAW,CAAC,EAC1B,KAAK,EACL,GAAG,EACH,QAAQ,EACR,OAAO,EACP,MAAM,EACN,QAAQ,EACR,SAAkB,EAClB,UAAU,EACV,SAAS,EACT,GAAG,KAAK,EACT,EAAE,gBAAgB,+BAqFlB"}
@@ -0,0 +1,27 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useEffect, useId, useState, } from "react";
3
+ import { Button } from "./Button.js";
4
+ import { Drawer } from "./Drawer.js";
5
+ // Must match the 768px media queries in styles.css; custom properties can't be used in media queries.
6
+ const wideViewport = "(min-width: 768px)";
7
+ export function HeaderShell({ brand, nav, navLabel, actions, footer, children, menuLabel = "Menu", closeLabel, className, ...props }) {
8
+ const [open, setOpen] = useState(false);
9
+ const drawerId = useId();
10
+ const hasMenu = Boolean(nav || actions);
11
+ useEffect(() => {
12
+ const query = window.matchMedia(wideViewport);
13
+ const onChange = () => {
14
+ if (query.matches)
15
+ setOpen(false);
16
+ };
17
+ query.addEventListener("change", onChange);
18
+ return () => query.removeEventListener("change", onChange);
19
+ }, []);
20
+ return (_jsxs("div", { ...props, className: ["mat-header-shell", className].filter(Boolean).join(" "), children: [_jsxs("header", { className: "mat-header-shell__header", children: [_jsx("div", { className: "mat-header-shell__brand", children: brand }), nav && (_jsx("nav", { "aria-label": navLabel, className: "mat-header-shell__nav", children: nav })), actions && _jsx("div", { className: "mat-header-shell__actions", children: actions }), hasMenu && (_jsx(Button, { "aria-controls": drawerId, "aria-expanded": open, "aria-label": menuLabel, className: "mat-header-shell__menu", onClick: () => setOpen((value) => !value), variant: "secondary", children: _jsx("svg", { "aria-hidden": "true", fill: "none", height: "24", viewBox: "0 0 24 24", width: "24", children: _jsx("path", { d: "M4 7h16M4 12h16M4 17h16", stroke: "currentColor", strokeLinecap: "round", strokeWidth: "2.5" }) }) }))] }), _jsx("main", { className: "mat-header-shell__main", children: children }), footer && _jsx("footer", { className: "mat-header-shell__footer", children: footer }), hasMenu && (_jsxs(Drawer, { closeLabel: closeLabel, heading: brand, id: drawerId, label: menuLabel, onClose: () => setOpen(false), open: open, side: "end", children: [open && nav && (
21
+ // Links activate with a click event from mouse and keyboard alike, so no key handler is needed.
22
+ // eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-noninteractive-element-interactions
23
+ _jsx("nav", { "aria-label": navLabel, className: "mat-header-shell__drawer-nav", onClick: (event) => {
24
+ if (event.target.closest("a"))
25
+ setOpen(false);
26
+ }, children: nav })), open && actions && (_jsx("div", { className: "mat-header-shell__drawer-actions", children: actions }))] }))] }));
27
+ }
@@ -0,0 +1,12 @@
1
+ import { type ComponentPropsWithRef, type ReactNode } from "react";
2
+ export type SideNavShellProps = ComponentPropsWithRef<"div"> & {
3
+ brand: ReactNode;
4
+ nav?: ReactNode;
5
+ navLabel: string;
6
+ actions?: ReactNode;
7
+ children: ReactNode;
8
+ menuLabel?: string;
9
+ closeLabel?: string;
10
+ };
11
+ export declare function SideNavShell({ brand, nav, navLabel, actions, children, menuLabel, closeLabel, className, ...props }: SideNavShellProps): import("react").JSX.Element;
12
+ //# sourceMappingURL=SideNavShell.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SideNavShell.d.ts","sourceRoot":"","sources":["../../src/components/SideNavShell.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,qBAAqB,EAC1B,KAAK,SAAS,EAIf,MAAM,OAAO,CAAC;AAKf,MAAM,MAAM,iBAAiB,GAAG,qBAAqB,CAAC,KAAK,CAAC,GAAG;IAC7D,KAAK,EAAE,SAAS,CAAC;IACjB,GAAG,CAAC,EAAE,SAAS,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,SAAS,CAAC;IACpB,QAAQ,EAAE,SAAS,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAKF,wBAAgB,YAAY,CAAC,EAC3B,KAAK,EACL,GAAG,EACH,QAAQ,EACR,OAAO,EACP,QAAQ,EACR,SAAkB,EAClB,UAAU,EACV,SAAS,EACT,GAAG,KAAK,EACT,EAAE,iBAAiB,+BA6FnB"}
@@ -0,0 +1,30 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useEffect, useId, useState, } from "react";
3
+ import { Button } from "./Button.js";
4
+ import { Drawer } from "./Drawer.js";
5
+ // Must match the 768px media query in styles.css.
6
+ const wideViewport = "(min-width: 768px)";
7
+ export function SideNavShell({ brand, nav, navLabel, actions, children, menuLabel = "Menu", closeLabel, className, ...props }) {
8
+ const [open, setOpen] = useState(false);
9
+ const drawerId = useId();
10
+ const hasMenu = Boolean(nav || actions);
11
+ useEffect(() => {
12
+ const query = window.matchMedia(wideViewport);
13
+ const onChange = () => {
14
+ if (query.matches)
15
+ setOpen(false);
16
+ };
17
+ query.addEventListener("change", onChange);
18
+ return () => query.removeEventListener("change", onChange);
19
+ }, []);
20
+ return (_jsxs("div", { ...props, className: ["mat-side-nav-shell", className].filter(Boolean).join(" "), children: [_jsxs("div", { className: "mat-side-nav-shell__sidebar", children: [_jsx("div", { className: "mat-side-nav-shell__brand", children: brand }), nav && (_jsx("nav", { "aria-label": navLabel, className: "mat-side-nav-shell__nav", children: nav })), actions && (_jsx("div", { className: "mat-side-nav-shell__actions", children: actions })), hasMenu && (_jsx(Button, { "aria-controls": drawerId, "aria-expanded": open, "aria-label": menuLabel, className: "mat-side-nav-shell__menu", onClick: () => setOpen((value) => !value), variant: "secondary", children: _jsx("svg", { "aria-hidden": "true", fill: "none", height: "24", viewBox: "0 0 24 24", width: "24", children: _jsx("path", { d: "M4 7h16M4 12h16M4 17h16", stroke: "currentColor", strokeLinecap: "round", strokeWidth: "2.5" }) }) }))] }), _jsx("main", { className: "mat-side-nav-shell__main",
21
+ // main scrolls on its own, and axe's scrollable-region-focusable requires keyboard access to it.
22
+ // eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex
23
+ tabIndex: 0, children: children }), hasMenu && (_jsxs(Drawer, { closeLabel: closeLabel, heading: brand, id: drawerId, label: menuLabel, onClose: () => setOpen(false), open: open, side: "start", children: [open && nav && (
24
+ // Links activate with a click event from mouse and keyboard alike.
25
+ // eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-noninteractive-element-interactions
26
+ _jsx("nav", { "aria-label": navLabel, className: "mat-side-nav-shell__drawer-nav", onClick: (event) => {
27
+ if (event.target.closest("a"))
28
+ setOpen(false);
29
+ }, children: nav })), open && actions && (_jsx("div", { className: "mat-side-nav-shell__drawer-actions", children: actions }))] }))] }));
30
+ }
package/dist/index.d.ts CHANGED
@@ -1,9 +1,25 @@
1
1
  export type { AlertProps, AlertTone } from "./components/Alert.js";
2
2
  export { Alert } from "./components/Alert.js";
3
- export type { ButtonProps } from "./components/Button.js";
3
+ export type { ButtonAsButtonProps, ButtonAsLinkProps, ButtonProps, ButtonSize, ButtonVariant, } from "./components/Button.js";
4
4
  export { Button } from "./components/Button.js";
5
5
  export type { CardProps } from "./components/Card.js";
6
6
  export { Card } from "./components/Card.js";
7
+ export type { DrawerProps } from "./components/Drawer.js";
8
+ export { Drawer } from "./components/Drawer.js";
7
9
  export type { FieldProps } from "./components/Field.js";
8
10
  export { Field } from "./components/Field.js";
11
+ export type { FormActionsProps } from "./components/FormActions.js";
12
+ export { FormActions } from "./components/FormActions.js";
13
+ export type { FormErrorSummaryProps } from "./components/FormErrorSummary.js";
14
+ export { FormErrorSummary } from "./components/FormErrorSummary.js";
15
+ export type { FormLayoutProps } from "./components/FormLayout.js";
16
+ export { FormLayout } from "./components/FormLayout.js";
17
+ export type { FormRowProps } from "./components/FormRow.js";
18
+ export { FormRow } from "./components/FormRow.js";
19
+ export type { FormSectionProps } from "./components/FormSection.js";
20
+ export { FormSection } from "./components/FormSection.js";
21
+ export type { HeaderShellProps } from "./components/HeaderShell.js";
22
+ export { HeaderShell } from "./components/HeaderShell.js";
23
+ export type { SideNavShellProps } from "./components/SideNavShell.js";
24
+ export { SideNavShell } from "./components/SideNavShell.js";
9
25
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AACnE,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAC9C,YAAY,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAChD,YAAY,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAC5C,YAAY,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AACnE,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAC9C,YAAY,EACV,mBAAmB,EACnB,iBAAiB,EACjB,WAAW,EACX,UAAU,EACV,aAAa,GACd,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAChD,YAAY,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAC5C,YAAY,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAChD,YAAY,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAC9C,YAAY,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AACpE,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC1D,YAAY,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;AAC9E,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AACpE,YAAY,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAClE,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AACxD,YAAY,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAClD,YAAY,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AACpE,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC1D,YAAY,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AACpE,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC1D,YAAY,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACtE,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC"}
package/dist/index.js CHANGED
@@ -1,4 +1,12 @@
1
1
  export { Alert } from "./components/Alert.js";
2
2
  export { Button } from "./components/Button.js";
3
3
  export { Card } from "./components/Card.js";
4
+ export { Drawer } from "./components/Drawer.js";
4
5
  export { Field } from "./components/Field.js";
6
+ export { FormActions } from "./components/FormActions.js";
7
+ export { FormErrorSummary } from "./components/FormErrorSummary.js";
8
+ export { FormLayout } from "./components/FormLayout.js";
9
+ export { FormRow } from "./components/FormRow.js";
10
+ export { FormSection } from "./components/FormSection.js";
11
+ export { HeaderShell } from "./components/HeaderShell.js";
12
+ export { SideNavShell } from "./components/SideNavShell.js";
package/dist/styles.css CHANGED
@@ -31,11 +31,12 @@
31
31
  justify-content: center;
32
32
  min-height: var(--mat-control-min-height);
33
33
  padding: var(--mat-space-4) var(--mat-space-6);
34
+ text-decoration: none;
34
35
  }
35
- .mat-button:hover:not(:disabled) {
36
+ .mat-button:hover:not(:disabled):not([aria-disabled="true"]) {
36
37
  background: var(--mat-color-action-primary-hover);
37
38
  }
38
- .mat-button:active:not(:disabled) {
39
+ .mat-button:active:not(:disabled):not([aria-disabled="true"]) {
39
40
  box-shadow: none;
40
41
  transform: translate(var(--mat-pressed-offset), var(--mat-pressed-offset));
41
42
  }
@@ -45,6 +46,7 @@
45
46
  outline-offset: 3px;
46
47
  }
47
48
  .mat-button:disabled,
49
+ .mat-button[aria-disabled="true"],
48
50
  .mat-field__input:disabled {
49
51
  cursor: not-allowed;
50
52
  opacity: 0.55;
@@ -53,9 +55,22 @@
53
55
  background: var(--mat-color-surface-card);
54
56
  color: var(--mat-color-text-default);
55
57
  }
56
- .mat-button--secondary:hover:not(:disabled) {
58
+ .mat-button--secondary:hover:not(:disabled):not([aria-disabled="true"]) {
57
59
  background: var(--mat-color-surface-card-hover);
58
60
  }
61
+ .mat-button--danger {
62
+ background: var(--mat-color-feedback-error);
63
+ color: var(--mat-color-text-on-danger);
64
+ }
65
+ .mat-button--danger:hover:not(:disabled):not([aria-disabled="true"]) {
66
+ background: var(--mat-color-action-danger-hover);
67
+ }
68
+ .mat-button--sm {
69
+ font-size: var(--mat-font-size-sm);
70
+ line-height: var(--mat-line-height-sm);
71
+ min-height: var(--mat-control-min-height-sm);
72
+ padding: 0 var(--mat-space-4);
73
+ }
59
74
  .mat-card {
60
75
  background: var(--mat-color-surface-card);
61
76
  border-radius: var(--mat-control-radius);
@@ -79,6 +94,14 @@
79
94
  padding: 0 var(--mat-space-4);
80
95
  width: 100%;
81
96
  }
97
+ select.mat-field__input,
98
+ textarea.mat-field__input {
99
+ font: inherit;
100
+ }
101
+ textarea.mat-field__input {
102
+ padding: var(--mat-space-3) var(--mat-space-4);
103
+ resize: vertical;
104
+ }
82
105
  .mat-field__message {
83
106
  font-size: var(--mat-font-size-sm);
84
107
  line-height: var(--mat-line-height-sm);
@@ -90,6 +113,70 @@
90
113
  .mat-field:has(.mat-field__message--error) .mat-field__input {
91
114
  border-color: var(--mat-color-feedback-error);
92
115
  }
116
+ .mat-form {
117
+ color: var(--mat-color-text-default);
118
+ display: grid;
119
+ font-family: var(--mat-font-family-base);
120
+ font-size: var(--mat-font-size-md);
121
+ gap: var(--mat-space-6);
122
+ grid-template-columns: 1fr;
123
+ margin: 0;
124
+ max-width: 40rem;
125
+ }
126
+ .mat-form__required-note {
127
+ font-size: var(--mat-font-size-sm);
128
+ line-height: var(--mat-line-height-sm);
129
+ margin: 0;
130
+ }
131
+ .mat-form__vh {
132
+ block-size: 1px;
133
+ clip-path: inset(50%);
134
+ inline-size: 1px;
135
+ overflow: hidden;
136
+ position: absolute;
137
+ white-space: nowrap;
138
+ }
139
+ .mat-form-section {
140
+ border: 0;
141
+ display: grid;
142
+ gap: var(--mat-space-4);
143
+ margin: 0;
144
+ min-inline-size: 0;
145
+ padding: 0;
146
+ }
147
+ .mat-form-section legend,
148
+ .mat-form-section__legend {
149
+ font-size: var(--mat-font-size-md);
150
+ font-weight: 700;
151
+ padding: 0;
152
+ }
153
+ .mat-form-section__description {
154
+ font-size: var(--mat-font-size-sm);
155
+ margin: 0;
156
+ }
157
+ .mat-form-row {
158
+ align-items: start;
159
+ display: grid;
160
+ gap: var(--mat-space-4);
161
+ grid-template-columns: 1fr;
162
+ }
163
+ /* 768px matches the shells. */
164
+ @media (min-width: 768px) {
165
+ .mat-form-row {
166
+ grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
167
+ }
168
+ }
169
+ .mat-form-actions {
170
+ display: grid;
171
+ gap: var(--mat-space-4);
172
+ }
173
+ .mat-form-actions__buttons {
174
+ align-items: center;
175
+ display: flex;
176
+ flex-wrap: wrap;
177
+ gap: var(--mat-space-4);
178
+ justify-content: flex-start;
179
+ }
93
180
  .mat-alert {
94
181
  align-items: flex-start;
95
182
  background: var(--mat-color-surface-card);
@@ -115,6 +202,9 @@
115
202
  .mat-alert--warning {
116
203
  color: var(--mat-color-feedback-warning);
117
204
  }
205
+ .mat-alert--info {
206
+ color: var(--mat-color-feedback-info);
207
+ }
118
208
  .mat-alert__title {
119
209
  color: var(--mat-color-text-default);
120
210
  display: block;
@@ -129,5 +219,255 @@
129
219
  }
130
220
  .mat-alert__body {
131
221
  color: var(--mat-color-text-default);
222
+ }
223
+ .mat-alert__title + .mat-alert__body {
132
224
  margin-top: var(--mat-space-1);
133
225
  }
226
+
227
+ .mat-drawer {
228
+ background: var(--mat-color-surface-card);
229
+ border: 0;
230
+ box-sizing: border-box;
231
+ color: var(--mat-color-text-default);
232
+ font-family: var(--mat-font-family-base);
233
+ font-size: var(--mat-font-size-md);
234
+ height: 100%;
235
+ inline-size: 85vw;
236
+ inset-block: 0;
237
+ line-height: var(--mat-line-height-md);
238
+ margin: 0;
239
+ max-height: 100%;
240
+ max-width: 100%;
241
+ padding: 0;
242
+ }
243
+ .mat-drawer[open] {
244
+ display: flex;
245
+ flex-direction: column;
246
+ }
247
+ .mat-drawer--start {
248
+ border-inline-end: var(--mat-border-width) solid
249
+ var(--mat-color-border-default);
250
+ inset-inline: 0 auto;
251
+ }
252
+ .mat-drawer--end {
253
+ border-inline-start: var(--mat-border-width) solid
254
+ var(--mat-color-border-default);
255
+ inset-inline: auto 0;
256
+ }
257
+ .mat-drawer::backdrop {
258
+ background: rgb(0 0 0 / 40%);
259
+ }
260
+ .mat-drawer__header {
261
+ align-items: center;
262
+ border-bottom: var(--mat-border-width) solid var(--mat-color-border-default);
263
+ display: flex;
264
+ gap: var(--mat-space-4);
265
+ justify-content: space-between;
266
+ padding: var(--mat-space-3) var(--mat-space-6);
267
+ }
268
+ .mat-drawer__heading {
269
+ font-weight: 700;
270
+ }
271
+ .mat-drawer__close,
272
+ .mat-header-shell__menu {
273
+ inline-size: var(--mat-control-min-height);
274
+ padding: 0;
275
+ }
276
+ .mat-drawer__body {
277
+ display: flex;
278
+ flex: 1;
279
+ flex-direction: column;
280
+ gap: var(--mat-space-4);
281
+ overflow-y: auto;
282
+ padding: var(--mat-space-6);
283
+ }
284
+ @media (prefers-reduced-motion: no-preference) {
285
+ .mat-drawer--start[open] {
286
+ animation: mat-drawer-enter-start 180ms ease-out;
287
+ }
288
+ .mat-drawer--end[open] {
289
+ animation: mat-drawer-enter-end 180ms ease-out;
290
+ }
291
+ @keyframes mat-drawer-enter-start {
292
+ from {
293
+ transform: translateX(-100%);
294
+ }
295
+ }
296
+ @keyframes mat-drawer-enter-end {
297
+ from {
298
+ transform: translateX(100%);
299
+ }
300
+ }
301
+ }
302
+
303
+ .mat-header-shell {
304
+ background: var(--mat-color-surface-page);
305
+ color: var(--mat-color-text-default);
306
+ display: grid;
307
+ font-family: var(--mat-font-family-base);
308
+ grid-template-rows: auto 1fr auto;
309
+ min-height: 100vh;
310
+ }
311
+ .mat-header-shell__header {
312
+ align-items: center;
313
+ background: var(--mat-color-surface-card);
314
+ border-bottom: var(--mat-border-width) solid var(--mat-color-border-default);
315
+ display: flex;
316
+ gap: var(--mat-space-4);
317
+ padding: var(--mat-space-3) var(--mat-space-6);
318
+ position: sticky;
319
+ top: 0;
320
+ z-index: 1;
321
+ }
322
+ .mat-header-shell__brand {
323
+ font-weight: 700;
324
+ margin-inline-end: auto;
325
+ }
326
+ .mat-header-shell__nav,
327
+ .mat-header-shell__actions {
328
+ display: none;
329
+ }
330
+ .mat-header-shell__nav {
331
+ gap: var(--mat-space-1);
332
+ }
333
+ .mat-header-shell__actions {
334
+ gap: var(--mat-space-3);
335
+ }
336
+ :where(.mat-header-shell__nav, .mat-header-shell__drawer-nav) a {
337
+ align-items: center;
338
+ border: var(--mat-border-width) solid transparent;
339
+ border-radius: var(--mat-control-radius);
340
+ box-sizing: border-box;
341
+ color: var(--mat-color-text-default);
342
+ display: inline-flex;
343
+ font-size: var(--mat-font-size-md);
344
+ font-weight: 700;
345
+ min-height: var(--mat-control-min-height);
346
+ padding: 0 var(--mat-space-4);
347
+ text-decoration: none;
348
+ }
349
+ :where(.mat-header-shell__nav, .mat-header-shell__drawer-nav) a:hover {
350
+ background: var(--mat-color-surface-card-hover);
351
+ }
352
+ :where(.mat-header-shell__nav, .mat-header-shell__drawer-nav)
353
+ a[aria-current="page"] {
354
+ background: var(--mat-color-action-primary);
355
+ border-color: var(--mat-color-border-default);
356
+ color: var(--mat-color-text-on-primary);
357
+ }
358
+ :where(.mat-header-shell__nav, .mat-header-shell__drawer-nav)
359
+ a[aria-current="page"]:hover {
360
+ background: var(--mat-color-action-primary-hover);
361
+ }
362
+ :where(.mat-header-shell__nav, .mat-header-shell__drawer-nav) a:focus-visible {
363
+ outline: 3px solid var(--mat-color-focus-ring);
364
+ outline-offset: 3px;
365
+ }
366
+ .mat-header-shell__main {
367
+ padding: var(--mat-space-6);
368
+ }
369
+ .mat-header-shell__footer {
370
+ background: var(--mat-color-surface-card);
371
+ border-top: var(--mat-border-width) solid var(--mat-color-border-default);
372
+ padding: var(--mat-space-4) var(--mat-space-6);
373
+ }
374
+ .mat-header-shell__drawer-nav {
375
+ display: grid;
376
+ gap: var(--mat-space-1);
377
+ }
378
+ .mat-header-shell__drawer-nav a {
379
+ display: flex;
380
+ }
381
+ .mat-header-shell__drawer-actions {
382
+ border-top: var(--mat-border-width) solid var(--mat-color-border-default);
383
+ display: grid;
384
+ gap: var(--mat-space-3);
385
+ margin-top: auto;
386
+ padding-top: var(--mat-space-6);
387
+ }
388
+ .mat-header-shell__drawer-actions > * {
389
+ inline-size: 100%;
390
+ }
391
+ /* 768px must match the matchMedia query in HeaderShell.tsx; custom properties can't be used in media queries. */
392
+ @media (min-width: 768px) {
393
+ .mat-header-shell__nav,
394
+ .mat-header-shell__actions {
395
+ align-items: center;
396
+ display: flex;
397
+ }
398
+ .mat-header-shell__menu {
399
+ display: none;
400
+ }
401
+ }
402
+
403
+ .mat-side-nav-shell {
404
+ background: var(--mat-color-surface-page);
405
+ color: var(--mat-color-text-default);
406
+ display: grid;
407
+ font-family: var(--mat-font-family-base);
408
+ grid-template-rows: auto minmax(0, 1fr);
409
+ height: 100vh;
410
+ }
411
+ .mat-side-nav-shell__sidebar {
412
+ align-items: center;
413
+ background: var(--mat-color-surface-card);
414
+ border-bottom: var(--mat-border-width) solid var(--mat-color-border-default);
415
+ display: flex;
416
+ gap: var(--mat-space-4);
417
+ padding: var(--mat-space-3) var(--mat-space-6);
418
+ }
419
+ .mat-side-nav-shell__brand {
420
+ font-weight: 700;
421
+ margin-inline-end: auto;
422
+ }
423
+ .mat-side-nav-shell__nav,
424
+ .mat-side-nav-shell__actions {
425
+ display: none;
426
+ }
427
+ .mat-side-nav-shell__menu {
428
+ inline-size: var(--mat-control-min-height);
429
+ padding: 0;
430
+ }
431
+ .mat-side-nav-shell__main {
432
+ min-width: 0;
433
+ overflow: auto;
434
+ padding: var(--mat-space-6);
435
+ }
436
+ .mat-side-nav-shell__drawer-nav {
437
+ display: grid;
438
+ gap: var(--mat-space-4);
439
+ }
440
+ .mat-side-nav-shell__drawer-actions {
441
+ border-top: var(--mat-border-width) solid var(--mat-color-border-default);
442
+ display: grid;
443
+ gap: var(--mat-space-3);
444
+ margin-top: auto;
445
+ padding-top: var(--mat-space-6);
446
+ }
447
+ /* Must match wideViewport in SideNavShell.tsx. */
448
+ @media (min-width: 768px) {
449
+ .mat-side-nav-shell {
450
+ /* No layout-width token exists; scale with density spacing (240px Touch, 200px Compact). */
451
+ grid-template-columns: calc(var(--mat-space-6) * 10) minmax(0, 1fr);
452
+ grid-template-rows: minmax(0, 1fr);
453
+ }
454
+ .mat-side-nav-shell__sidebar {
455
+ align-items: stretch;
456
+ border-bottom: 0;
457
+ border-right: var(--mat-border-width) solid var(--mat-color-border-default);
458
+ flex-direction: column;
459
+ overflow-y: auto;
460
+ padding: var(--mat-space-6);
461
+ }
462
+ .mat-side-nav-shell__nav,
463
+ .mat-side-nav-shell__actions {
464
+ display: grid;
465
+ gap: var(--mat-space-4);
466
+ }
467
+ .mat-side-nav-shell__actions {
468
+ margin-top: auto;
469
+ }
470
+ .mat-side-nav-shell__menu {
471
+ display: none;
472
+ }
473
+ }
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "@malexander-tech/ui",
3
- "version": "0.2.0",
3
+ "version": "0.5.0",
4
+ "license": "MIT",
4
5
  "type": "module",
5
6
  "files": [
6
7
  "dist"
@@ -21,16 +22,15 @@
21
22
  "react-dom": "^19.0.0"
22
23
  },
23
24
  "dependencies": {
24
- "@malexander-tech/tokens": "0.2.0"
25
+ "@malexander-tech/tokens": "0.5.0"
25
26
  },
26
27
  "publishConfig": {
27
- "registry": "https://registry.npmjs.org",
28
- "access": "public"
28
+ "access": "public",
29
+ "registry": "https://registry.npmjs.org"
29
30
  },
30
31
  "repository": {
31
32
  "type": "git",
32
33
  "url": "https://github.com/malexandertech/malexandertech-design-system.git",
33
34
  "directory": "packages/ui"
34
- },
35
- "license": "MIT"
35
+ }
36
36
  }