@cocso-ui/react 1.11.0 → 1.12.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 (92) hide show
  1. package/dist/cjs/components/breadcrumb/breadcrumb.d.ts +24 -3
  2. package/dist/cjs/components/breadcrumb/breadcrumb.js +44 -2
  3. package/dist/cjs/components/breadcrumb/breadcrumb.module.css.js +2 -2
  4. package/dist/cjs/components/card/card.d.ts +49 -2
  5. package/dist/cjs/components/card/card.js +76 -10
  6. package/dist/cjs/components/card/card.module.css.js +2 -2
  7. package/dist/cjs/components/copy-button/copy-button.d.ts +29 -0
  8. package/dist/cjs/components/copy-button/copy-button.js +67 -0
  9. package/dist/cjs/components/empty-state/empty-state.d.ts +30 -0
  10. package/dist/cjs/components/empty-state/empty-state.js +50 -0
  11. package/dist/cjs/components/empty-state/empty-state.module.css.js +9 -0
  12. package/dist/cjs/components/file-uploader/file-uploader.d.ts +80 -0
  13. package/dist/cjs/components/file-uploader/file-uploader.js +258 -0
  14. package/dist/cjs/components/file-uploader/file-uploader.module.css.js +9 -0
  15. package/dist/cjs/components/form-field/form-field-context.d.ts +31 -0
  16. package/dist/cjs/components/form-field/form-field-context.js +53 -0
  17. package/dist/cjs/components/form-field/form-field-parts.d.ts +52 -0
  18. package/dist/cjs/components/form-field/form-field-parts.js +109 -0
  19. package/dist/cjs/components/form-field/form-field.d.ts +44 -0
  20. package/dist/cjs/components/form-field/form-field.js +61 -0
  21. package/dist/cjs/components/form-field/form-field.module.css.js +9 -0
  22. package/dist/cjs/components/info-popover/info-popover.d.ts +43 -0
  23. package/dist/cjs/components/info-popover/info-popover.js +57 -0
  24. package/dist/cjs/components/info-popover/info-popover.module.css.js +9 -0
  25. package/dist/cjs/components/loading-overlay/loading-overlay.d.ts +33 -0
  26. package/dist/cjs/components/loading-overlay/loading-overlay.js +68 -0
  27. package/dist/cjs/components/loading-overlay/loading-overlay.module.css.js +9 -0
  28. package/dist/cjs/components/number-input/number-input.d.ts +39 -0
  29. package/dist/cjs/components/number-input/number-input.js +167 -0
  30. package/dist/cjs/components/section-header/section-header.d.ts +48 -0
  31. package/dist/cjs/components/section-header/section-header.js +210 -0
  32. package/dist/cjs/components/section-header/section-header.module.css.js +9 -0
  33. package/dist/cjs/components/segmented-control/segmented-control.d.ts +55 -0
  34. package/dist/cjs/components/segmented-control/segmented-control.js +119 -0
  35. package/dist/cjs/components/segmented-control/segmented-control.module.css.js +9 -0
  36. package/dist/cjs/components/selection-chip/selection-chip.d.ts +22 -0
  37. package/dist/cjs/components/selection-chip/selection-chip.js +32 -0
  38. package/dist/cjs/components/selection-chip/selection-chip.module.css.js +9 -0
  39. package/dist/cjs/components/skeleton/skeleton.d.ts +7 -1
  40. package/dist/cjs/components/skeleton/skeleton.js +20 -2
  41. package/dist/cjs/components/summary-card/summary-card.d.ts +47 -0
  42. package/dist/cjs/components/summary-card/summary-card.js +89 -0
  43. package/dist/cjs/components/summary-card/summary-card.module.css.js +9 -0
  44. package/dist/cjs/index.d.ts +15 -2
  45. package/dist/cjs/index.js +24 -0
  46. package/dist/esm/components/breadcrumb/breadcrumb.d.mts +24 -3
  47. package/dist/esm/components/breadcrumb/breadcrumb.mjs +44 -2
  48. package/dist/esm/components/breadcrumb/breadcrumb.module.css.mjs +1 -1
  49. package/dist/esm/components/card/card.d.mts +49 -2
  50. package/dist/esm/components/card/card.mjs +76 -10
  51. package/dist/esm/components/card/card.module.css.mjs +1 -1
  52. package/dist/esm/components/copy-button/copy-button.d.mts +29 -0
  53. package/dist/esm/components/copy-button/copy-button.mjs +65 -0
  54. package/dist/esm/components/empty-state/empty-state.d.mts +30 -0
  55. package/dist/esm/components/empty-state/empty-state.mjs +48 -0
  56. package/dist/esm/components/empty-state/empty-state.module.css.mjs +3 -0
  57. package/dist/esm/components/file-uploader/file-uploader.d.mts +80 -0
  58. package/dist/esm/components/file-uploader/file-uploader.mjs +256 -0
  59. package/dist/esm/components/file-uploader/file-uploader.module.css.mjs +3 -0
  60. package/dist/esm/components/form-field/form-field-context.d.mts +31 -0
  61. package/dist/esm/components/form-field/form-field-context.mjs +49 -0
  62. package/dist/esm/components/form-field/form-field-parts.d.mts +52 -0
  63. package/dist/esm/components/form-field/form-field-parts.mjs +105 -0
  64. package/dist/esm/components/form-field/form-field.d.mts +44 -0
  65. package/dist/esm/components/form-field/form-field.mjs +59 -0
  66. package/dist/esm/components/form-field/form-field.module.css.mjs +3 -0
  67. package/dist/esm/components/info-popover/info-popover.d.mts +43 -0
  68. package/dist/esm/components/info-popover/info-popover.mjs +55 -0
  69. package/dist/esm/components/info-popover/info-popover.module.css.mjs +3 -0
  70. package/dist/esm/components/loading-overlay/loading-overlay.d.mts +33 -0
  71. package/dist/esm/components/loading-overlay/loading-overlay.mjs +66 -0
  72. package/dist/esm/components/loading-overlay/loading-overlay.module.css.mjs +3 -0
  73. package/dist/esm/components/number-input/number-input.d.mts +39 -0
  74. package/dist/esm/components/number-input/number-input.mjs +165 -0
  75. package/dist/esm/components/section-header/section-header.d.mts +48 -0
  76. package/dist/esm/components/section-header/section-header.mjs +208 -0
  77. package/dist/esm/components/section-header/section-header.module.css.mjs +3 -0
  78. package/dist/esm/components/segmented-control/segmented-control.d.mts +55 -0
  79. package/dist/esm/components/segmented-control/segmented-control.mjs +117 -0
  80. package/dist/esm/components/segmented-control/segmented-control.module.css.mjs +3 -0
  81. package/dist/esm/components/selection-chip/selection-chip.d.mts +22 -0
  82. package/dist/esm/components/selection-chip/selection-chip.mjs +30 -0
  83. package/dist/esm/components/selection-chip/selection-chip.module.css.mjs +3 -0
  84. package/dist/esm/components/skeleton/skeleton.d.mts +7 -1
  85. package/dist/esm/components/skeleton/skeleton.mjs +20 -2
  86. package/dist/esm/components/summary-card/summary-card.d.mts +47 -0
  87. package/dist/esm/components/summary-card/summary-card.mjs +87 -0
  88. package/dist/esm/components/summary-card/summary-card.module.css.mjs +3 -0
  89. package/dist/esm/index.css +2 -2
  90. package/dist/esm/index.d.mts +15 -2
  91. package/dist/esm/index.mjs +12 -0
  92. package/package.json +1 -1
@@ -4,8 +4,48 @@ import { Children } from 'react';
4
4
  import { cn } from '../../cn.mjs';
5
5
  import styles from './breadcrumb.module.css.mjs';
6
6
  import { jsx, jsxs } from 'react/jsx-runtime';
7
+ import { useRender } from '@base-ui/react/use-render';
8
+ import { mergeProps } from '@base-ui/react/merge-props';
7
9
 
8
- /** Navigation hierarchy indicator with configurable separator. */
10
+ function BreadcrumbLink({
11
+ href,
12
+ render,
13
+ children
14
+ }) {
15
+ return useRender({
16
+ render,
17
+ props: mergeProps({
18
+ className: styles.link,
19
+ href
20
+ }, {
21
+ children
22
+ }),
23
+ defaultTagName: "a"
24
+ });
25
+ }
26
+ function renderStep(item, isCurrent, renderLink) {
27
+ if (isCurrent) {
28
+ return /*#__PURE__*/jsx("span", {
29
+ "aria-current": "page",
30
+ children: item.label
31
+ });
32
+ }
33
+ if (item.href === undefined) {
34
+ return /*#__PURE__*/jsx("span", {
35
+ children: item.label
36
+ });
37
+ }
38
+ return /*#__PURE__*/jsx(BreadcrumbLink, {
39
+ href: item.href,
40
+ render: renderLink,
41
+ children: item.label
42
+ });
43
+ }
44
+
45
+ /**
46
+ * Navigation hierarchy indicator with configurable separator. Pass the path as
47
+ * `items`, or compose the steps yourself as `children`.
48
+ */
9
49
  function Breadcrumb({
10
50
  ref,
11
51
  className,
@@ -15,10 +55,12 @@ function Breadcrumb({
15
55
  height: "1em",
16
56
  width: "1em"
17
57
  }),
58
+ items: itemsProp,
59
+ renderLink,
18
60
  children,
19
61
  ...props
20
62
  }) {
21
- const items = Children.toArray(children);
63
+ const items = itemsProp === undefined ? Children.toArray(children) : itemsProp.map((item, index) => renderStep(item, index === itemsProp.length - 1, renderLink));
22
64
  return /*#__PURE__*/jsx("nav", {
23
65
  "aria-label": "Breadcrumb",
24
66
  className: cn(breadcrumb({
@@ -1,3 +1,3 @@
1
- var styles = {"breadcrumb":"breadcrumb-module_breadcrumb__dW5v-","list":"breadcrumb-module_list__mLCBo","item":"breadcrumb-module_item__G0t2y","separator":"breadcrumb-module_separator__wMAks"};
1
+ var styles = {"breadcrumb":"breadcrumb-module_breadcrumb__dW5v-","list":"breadcrumb-module_list__mLCBo","item":"breadcrumb-module_item__G0t2y","separator":"breadcrumb-module_separator__wMAks","link":"breadcrumb-module_link__cclmN"};
2
2
 
3
3
  export { styles as default };
@@ -1,13 +1,60 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import * as react from 'react';
2
3
  import { ComponentProps } from 'react';
4
+ import { RenderProp } from '../../primitives/use-render.mjs';
5
+ import { TypographyProps } from '../typography/typography.mjs';
3
6
 
4
7
  type CardVariant = "elevated" | "outlined" | "filled" | "glass";
5
8
  type CardPadding = "sm" | "md" | "lg";
6
9
  interface CardProps extends ComponentProps<"div"> {
10
+ /**
11
+ * Space between the card's children. A number is read as pixels; a string is
12
+ * used as-is. Unset, the children sit flush, as before this prop existed.
13
+ */
14
+ gap?: number | string;
7
15
  padding?: CardPadding;
16
+ /**
17
+ * Render the card as another element — `render={<button type="button" />}`
18
+ * or `render={(props) => <NextLink href="…" {...props} />}`. The card's
19
+ * class names, style and children are merged onto it.
20
+ */
21
+ render?: RenderProp;
8
22
  variant?: CardVariant;
9
23
  }
10
- declare function Card({ ref, className, style, variant, padding, children, ...props }: CardProps): react_jsx_runtime.JSX.Element;
24
+ declare function CardRoot({ ref, render: renderProp, className, style: _style, variant, padding, gap, children, ...props }: CardProps): react.ReactElement<unknown, string | react.JSXElementConstructor<any>>;
25
+ type CardHeaderProps = ComponentProps<"div">;
26
+ /**
27
+ * The card's top row: a title on the inline-start side, actions on the end.
28
+ * It keeps one height whether or not an action is there, so the content below
29
+ * does not shift when a button comes and goes.
30
+ */
31
+ declare function CardHeader({ className, ...props }: CardHeaderProps): react_jsx_runtime.JSX.Element;
32
+ type HeadingTypographyProps = Extract<TypographyProps, {
33
+ type: "heading";
34
+ }>;
35
+ type CardTitleProps = Omit<HeadingTypographyProps, "type">;
36
+ /**
37
+ * The card's heading. An `h2` at the `small` heading step by default; pass
38
+ * `level` for a different rank, or `render` for another element.
39
+ */
40
+ declare function CardTitle({ className, size, weight, ...props }: CardTitleProps): react_jsx_runtime.JSX.Element;
41
+ /**
42
+ * Surface container. Compose with `Card.Header` and `Card.Title`.
43
+ *
44
+ * @example
45
+ * <Card gap={16} variant="outlined">
46
+ * <Card.Header>
47
+ * <Card.Title>Monthly revenue</Card.Title>
48
+ * <Button size="small">Export</Button>
49
+ * </Card.Header>
50
+ * …
51
+ * </Card>
52
+ */
53
+ declare const Card: typeof CardRoot & {
54
+ displayName: "Card";
55
+ Header: typeof CardHeader;
56
+ Title: typeof CardTitle;
57
+ };
11
58
 
12
59
  export { Card };
13
- export type { CardPadding, CardProps, CardVariant };
60
+ export type { CardHeaderProps, CardPadding, CardProps, CardTitleProps, CardVariant };
@@ -2,26 +2,92 @@ import { card } from '../../ecosystem/codegen/generated/card.mjs';
2
2
  import { cn } from '../../cn.mjs';
3
3
  import styles from './card.module.css.mjs';
4
4
  import { jsx } from 'react/jsx-runtime';
5
+ import { Typography } from '../typography/typography.mjs';
6
+ import { useRender } from '@base-ui/react/use-render';
7
+ import { mergeProps } from '@base-ui/react/merge-props';
5
8
 
6
- function Card({
9
+ const toLength = value => typeof value === "number" ? `${value}px` : value;
10
+ function CardRoot({
7
11
  ref,
12
+ render: renderProp,
8
13
  className,
9
- style,
14
+ style: _style,
10
15
  variant = "elevated",
11
16
  padding = "md",
17
+ gap,
12
18
  children,
13
19
  ...props
20
+ }) {
21
+ const style = {
22
+ ...(gap === undefined ? {} : {
23
+ "--cocso-card-gap": toLength(gap)
24
+ }),
25
+ ..._style
26
+ };
27
+ return useRender({
28
+ render: renderProp,
29
+ ref,
30
+ props: mergeProps({
31
+ className: cn(card({
32
+ variant,
33
+ padding
34
+ }), styles.card, variant === "elevated" && styles.elevated, variant === "glass" && styles.glass, className),
35
+ style
36
+ }, props, {
37
+ children
38
+ }),
39
+ defaultTagName: "div"
40
+ });
41
+ }
42
+ /**
43
+ * The card's top row: a title on the inline-start side, actions on the end.
44
+ * It keeps one height whether or not an action is there, so the content below
45
+ * does not shift when a button comes and goes.
46
+ */
47
+ function CardHeader({
48
+ className,
49
+ ...props
14
50
  }) {
15
51
  return /*#__PURE__*/jsx("div", {
16
- className: cn(card({
17
- variant,
18
- padding
19
- }), styles.card, variant === "elevated" && styles.elevated, variant === "glass" && styles.glass, className),
20
- ref: ref,
21
- style: style,
22
- ...props,
23
- children: children
52
+ className: cn(styles.header, className),
53
+ ...props
24
54
  });
25
55
  }
56
+ /**
57
+ * The card's heading. An `h2` at the `small` heading step by default; pass
58
+ * `level` for a different rank, or `render` for another element.
59
+ */
60
+ function CardTitle({
61
+ className,
62
+ size = "small",
63
+ weight = "bold",
64
+ ...props
65
+ }) {
66
+ return /*#__PURE__*/jsx(Typography, {
67
+ className: cn(styles.title, className),
68
+ size: size,
69
+ type: "heading",
70
+ weight: weight,
71
+ ...props
72
+ });
73
+ }
74
+
75
+ /**
76
+ * Surface container. Compose with `Card.Header` and `Card.Title`.
77
+ *
78
+ * @example
79
+ * <Card gap={16} variant="outlined">
80
+ * <Card.Header>
81
+ * <Card.Title>Monthly revenue</Card.Title>
82
+ * <Button size="small">Export</Button>
83
+ * </Card.Header>
84
+ * …
85
+ * </Card>
86
+ */
87
+ const Card = Object.assign(CardRoot, {
88
+ displayName: "Card",
89
+ Header: CardHeader,
90
+ Title: CardTitle
91
+ });
26
92
 
27
93
  export { Card };
@@ -1,3 +1,3 @@
1
- var styles = {"card":"card-module_card__ZPFTz","elevated":"card-module_elevated__Gua8s","glass":"card-module_glass__u-Nbb"};
1
+ var styles = {"card":"card-module_card__ZPFTz","elevated":"card-module_elevated__Gua8s","glass":"card-module_glass__u-Nbb","header":"card-module_header__tz-Qf","title":"card-module_title__GAX2O"};
2
2
 
3
3
  export { styles as default };
@@ -0,0 +1,29 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { ButtonProps } from '../button/button.mjs';
3
+
4
+ interface CopyButtonProps extends Omit<ButtonProps, "children" | "svgOnly"> {
5
+ /** Accessible name once the copy succeeded. Defaults to "복사됨". */
6
+ copiedLabel?: string;
7
+ /** Accessible name and tooltip of the button. Defaults to "복사". */
8
+ label?: string;
9
+ /** Called with the error when the copy fails — permission denied, insecure context. */
10
+ onCopyError?: (error: unknown) => void;
11
+ /** Called with the copied text after a successful copy. */
12
+ onCopySuccess?: (text: string) => void;
13
+ /** How long the check mark stays after a successful copy, in seconds. Defaults to 2. */
14
+ resetTimeoutSeconds?: number;
15
+ /** The text written to the clipboard. */
16
+ text: string;
17
+ }
18
+ /**
19
+ * An icon button that copies `text` to the clipboard and shows a check mark
20
+ * for a moment.
21
+ *
22
+ * It uses `navigator.clipboard.writeText`, which only works in a secure
23
+ * context (HTTPS or localhost). A failure is reported through `onCopyError`
24
+ * and nowhere else — the library does not log.
25
+ */
26
+ declare function CopyButton({ text, resetTimeoutSeconds, onCopySuccess, onCopyError, label, copiedLabel, onClick, size, variant, ...props }: CopyButtonProps): react_jsx_runtime.JSX.Element;
27
+
28
+ export { CopyButton };
29
+ export type { CopyButtonProps };
@@ -0,0 +1,65 @@
1
+ "use client";
2
+ import { CheckIcon, ContentCopyIcon } from '@cocso-ui/react-icons';
3
+ import { useState, useEffect } from 'react';
4
+ import { jsx } from 'react/jsx-runtime';
5
+ import { Button } from '../button/button.mjs';
6
+
7
+ /**
8
+ * An icon button that copies `text` to the clipboard and shows a check mark
9
+ * for a moment.
10
+ *
11
+ * It uses `navigator.clipboard.writeText`, which only works in a secure
12
+ * context (HTTPS or localhost). A failure is reported through `onCopyError`
13
+ * and nowhere else — the library does not log.
14
+ */
15
+ function CopyButton({
16
+ text,
17
+ resetTimeoutSeconds = 2,
18
+ onCopySuccess,
19
+ onCopyError,
20
+ label = "복사",
21
+ copiedLabel = "복사됨",
22
+ onClick,
23
+ size = "x-small",
24
+ variant = "ghost",
25
+ ...props
26
+ }) {
27
+ const [isCopied, setIsCopied] = useState(false);
28
+ useEffect(() => {
29
+ if (!isCopied) {
30
+ return;
31
+ }
32
+ const timer = setTimeout(() => {
33
+ setIsCopied(false);
34
+ }, resetTimeoutSeconds * 1000);
35
+ return () => clearTimeout(timer);
36
+ }, [isCopied, resetTimeoutSeconds]);
37
+ const handleClick = async event => {
38
+ onClick?.(event);
39
+ if (event.defaultPrevented) {
40
+ return;
41
+ }
42
+ try {
43
+ await navigator.clipboard.writeText(text);
44
+ setIsCopied(true);
45
+ onCopySuccess?.(text);
46
+ } catch (error) {
47
+ onCopyError?.(error);
48
+ }
49
+ };
50
+ return /*#__PURE__*/jsx(Button, {
51
+ "aria-label": isCopied ? copiedLabel : label,
52
+ "data-cocso-component": "copy-button",
53
+ "data-copied": isCopied || undefined,
54
+ size: size,
55
+ svgOnly: true,
56
+ title: label,
57
+ type: "button",
58
+ variant: variant,
59
+ ...props,
60
+ onClick: handleClick,
61
+ children: isCopied ? /*#__PURE__*/jsx(CheckIcon, {}) : /*#__PURE__*/jsx(ContentCopyIcon, {})
62
+ });
63
+ }
64
+
65
+ export { CopyButton };
@@ -0,0 +1,30 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { ComponentProps, ReactNode } from 'react';
3
+
4
+ interface EmptyStateProps extends Omit<ComponentProps<"div">, "title"> {
5
+ /** A button placed under the text. Usually a single "add" action. */
6
+ action?: ReactNode;
7
+ /**
8
+ * Rendered above the title, in the same frame — a `Spinner` while loading,
9
+ * or an illustration. Loading, failure and empty share one frame so the
10
+ * three states stand in the same place at the same size.
11
+ */
12
+ children?: ReactNode;
13
+ /** Why being empty is expected here, or what to do next. */
14
+ description?: ReactNode;
15
+ /** One bold line that says what is missing. */
16
+ title?: ReactNode;
17
+ }
18
+ /**
19
+ * The empty state of a region that is not a table.
20
+ *
21
+ * Inside a table, use the table's own empty row — it has to span the columns.
22
+ * Outside one (a list inside a card, a section of a popup), bare text floating
23
+ * in the layout reads as "something went wrong". The dashed frame marks out
24
+ * the place the content would occupy, so the screen says first that being
25
+ * empty is normal.
26
+ */
27
+ declare function EmptyState({ ref, className, title, description, action, children, ...props }: EmptyStateProps): react_jsx_runtime.JSX.Element;
28
+
29
+ export { EmptyState };
30
+ export type { EmptyStateProps };
@@ -0,0 +1,48 @@
1
+ import { cn } from '../../cn.mjs';
2
+ import styles from './empty-state.module.css.mjs';
3
+ import { jsxs, jsx } from 'react/jsx-runtime';
4
+ import { Typography } from '../typography/typography.mjs';
5
+ import { colors } from '../../token/color.mjs';
6
+
7
+ /**
8
+ * The empty state of a region that is not a table.
9
+ *
10
+ * Inside a table, use the table's own empty row — it has to span the columns.
11
+ * Outside one (a list inside a card, a section of a popup), bare text floating
12
+ * in the layout reads as "something went wrong". The dashed frame marks out
13
+ * the place the content would occupy, so the screen says first that being
14
+ * empty is normal.
15
+ */
16
+ function EmptyState({
17
+ ref,
18
+ className,
19
+ title,
20
+ description,
21
+ action,
22
+ children,
23
+ ...props
24
+ }) {
25
+ return /*#__PURE__*/jsxs("div", {
26
+ className: cn(styles.root, className),
27
+ "data-cocso-component": "empty-state",
28
+ ref: ref,
29
+ ...props,
30
+ children: [children, title && /*#__PURE__*/jsx(Typography, {
31
+ size: "small",
32
+ type: "body",
33
+ weight: "medium",
34
+ children: title
35
+ }), description && /*#__PURE__*/jsx(Typography, {
36
+ className: styles.description,
37
+ color: colors.textSecondary,
38
+ size: "x-small",
39
+ type: "body",
40
+ children: description
41
+ }), action && /*#__PURE__*/jsx("div", {
42
+ className: styles.action,
43
+ children: action
44
+ })]
45
+ });
46
+ }
47
+
48
+ export { EmptyState };
@@ -0,0 +1,3 @@
1
+ var styles = {"root":"empty-state-module_root__UNTr-","description":"empty-state-module_description__muQc4","action":"empty-state-module_action__OEm3v"};
2
+
3
+ export { styles as default };
@@ -0,0 +1,80 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { ComponentProps, ReactNode, Ref } from 'react';
3
+
4
+ /** One chosen file. The `File` is kept so the caller can upload it later. */
5
+ interface FileItem {
6
+ file: File;
7
+ name: string;
8
+ size: number;
9
+ }
10
+ /** Why a file was turned away. */
11
+ type FileUploaderRejectionReason = "type" | "size" | "count";
12
+ interface FileUploaderRejection {
13
+ /** The file that was turned away. */
14
+ file: File;
15
+ /** The message that describes it, already resolved from `messages`. */
16
+ message: string;
17
+ reason: FileUploaderRejectionReason;
18
+ }
19
+ /** Every word the component says. Each one is optional; the rest keep the default. */
20
+ interface FileUploaderMessages {
21
+ /** The prompt in the one-line (`compact`) drop zone. */
22
+ compactPrompt?: ReactNode;
23
+ /** The `(max N MB)` hint shown when no `sizeHint` is given. */
24
+ maxSizeHint?: (maxSizeMb: number) => ReactNode;
25
+ /** The prompt in the default drop zone. */
26
+ prompt?: ReactNode;
27
+ /** A file arrived after `maxFiles` was reached. */
28
+ rejectCount?: (maxFiles: number) => string;
29
+ /** A file is larger than `maxSize`. */
30
+ rejectSize?: (file: File, maxSizeMb: number) => string;
31
+ /** A file does not match `accept`. */
32
+ rejectType?: (file: File) => string;
33
+ /** Accessible name of the remove button on each row. */
34
+ remove?: (fileName: string) => string;
35
+ }
36
+ interface FileUploaderProps extends Omit<ComponentProps<"input">, "type" | "size" | "ref"> {
37
+ /**
38
+ * One-line drop zone. A table row that holds an uploader grows by the full
39
+ * zone's height otherwise; this lays the prompt out on a single line.
40
+ */
41
+ compact?: boolean;
42
+ /** The chosen files (controlled). */
43
+ files: FileItem[];
44
+ /** Most files that may be chosen in total. Default 2. */
45
+ maxFiles?: number;
46
+ /** Largest single file in bytes. Default 3 MB. */
47
+ maxSize?: number;
48
+ /** Override any of the default (Korean) words. */
49
+ messages?: FileUploaderMessages;
50
+ /** Called with the next list whenever files are added or removed. */
51
+ onFilesChange: (files: FileItem[]) => void;
52
+ /**
53
+ * Called with every file turned away by one pick or drop. When given, the
54
+ * default error toasts are not shown — the caller reports them instead.
55
+ */
56
+ onReject?: (rejections: FileUploaderRejection[]) => void;
57
+ /** Called after a row's remove button takes a file out. */
58
+ onRemove?: (fileName: string) => void;
59
+ /** Forwarded to the underlying `<input type="file">`. */
60
+ ref?: Ref<HTMLInputElement>;
61
+ /** Replaces the `(max N MB)` hint. Still shown while disabled. */
62
+ sizeHint?: ReactNode;
63
+ }
64
+ /**
65
+ * Drag-and-drop or pick files, listed underneath as `FileRow`s.
66
+ *
67
+ * The drop zone is a `<label>` around a real, visually hidden
68
+ * `<input type="file">`, so Tab reaches the input, Enter and Space open the
69
+ * picker natively, and the zone's prompt is the input's accessible name. The
70
+ * zone is drawn focused while the input is. It disappears once `maxFiles` is
71
+ * reached (or one file is chosen when `multiple` is false).
72
+ *
73
+ * Files that fail `accept`, `maxSize` or `maxFiles` are turned away and
74
+ * reported — through `onReject` when given, otherwise as error toasts (which
75
+ * need a `Toaster` mounted).
76
+ */
77
+ declare function FileUploader({ ref, className, style, files, onFilesChange, onRemove, onReject, maxFiles, maxSize, sizeHint, compact, messages: messagesProp, multiple, accept, disabled, onChange, ...props }: FileUploaderProps): react_jsx_runtime.JSX.Element;
78
+
79
+ export { FileUploader };
80
+ export type { FileItem, FileUploaderMessages, FileUploaderProps, FileUploaderRejection, FileUploaderRejectionReason };