@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
@@ -1,14 +1,35 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import { ComponentProps, ReactNode } from 'react';
3
+ import { RenderProp } from '../../primitives/use-render.js';
3
4
 
4
5
  /** Inline type aliases — codegen is a devDependency and must not leak into published .d.ts */
5
6
  type BreadcrumbSize = "sm" | "md" | "lg";
7
+ /** One step of the path. The last step is the current page and never links. */
8
+ interface BreadcrumbItem {
9
+ /** Where the step leads. A step without one renders as text. */
10
+ href?: string;
11
+ label: ReactNode;
12
+ }
6
13
  interface BreadcrumbProps extends ComponentProps<"nav"> {
14
+ /**
15
+ * The path from the root to the current page. When given, it is rendered
16
+ * instead of `children`.
17
+ */
18
+ items?: readonly BreadcrumbItem[];
19
+ /**
20
+ * Element each linked step renders as — the router's link, for example
21
+ * `renderLink={(props) => <NextLink {...props} href={props.href ?? ""} />}`.
22
+ * It receives `href`, `className` and `children`. Defaults to `<a>`.
23
+ */
24
+ renderLink?: RenderProp;
7
25
  separator?: ReactNode;
8
26
  size?: BreadcrumbSize;
9
27
  }
10
- /** Navigation hierarchy indicator with configurable separator. */
11
- declare function Breadcrumb({ ref, className, style, size, separator, children, ...props }: BreadcrumbProps): react_jsx_runtime.JSX.Element;
28
+ /**
29
+ * Navigation hierarchy indicator with configurable separator. Pass the path as
30
+ * `items`, or compose the steps yourself as `children`.
31
+ */
32
+ declare function Breadcrumb({ ref, className, style, size, separator, items: itemsProp, renderLink, children, ...props }: BreadcrumbProps): react_jsx_runtime.JSX.Element;
12
33
 
13
34
  export { Breadcrumb };
14
- export type { BreadcrumbProps, BreadcrumbSize };
35
+ export type { BreadcrumbItem, BreadcrumbProps, BreadcrumbSize };
@@ -7,8 +7,48 @@ var react = require('react');
7
7
  var cn = require('../../cn.js');
8
8
  var breadcrumb_module = require('./breadcrumb.module.css.js');
9
9
  var jsxRuntime = require('react/jsx-runtime');
10
+ var useRender = require('@base-ui/react/use-render');
11
+ var mergeProps = require('@base-ui/react/merge-props');
10
12
 
11
- /** Navigation hierarchy indicator with configurable separator. */
13
+ function BreadcrumbLink({
14
+ href,
15
+ render,
16
+ children
17
+ }) {
18
+ return useRender.useRender({
19
+ render,
20
+ props: mergeProps.mergeProps({
21
+ className: breadcrumb_module.link,
22
+ href
23
+ }, {
24
+ children
25
+ }),
26
+ defaultTagName: "a"
27
+ });
28
+ }
29
+ function renderStep(item, isCurrent, renderLink) {
30
+ if (isCurrent) {
31
+ return /*#__PURE__*/jsxRuntime.jsx("span", {
32
+ "aria-current": "page",
33
+ children: item.label
34
+ });
35
+ }
36
+ if (item.href === undefined) {
37
+ return /*#__PURE__*/jsxRuntime.jsx("span", {
38
+ children: item.label
39
+ });
40
+ }
41
+ return /*#__PURE__*/jsxRuntime.jsx(BreadcrumbLink, {
42
+ href: item.href,
43
+ render: renderLink,
44
+ children: item.label
45
+ });
46
+ }
47
+
48
+ /**
49
+ * Navigation hierarchy indicator with configurable separator. Pass the path as
50
+ * `items`, or compose the steps yourself as `children`.
51
+ */
12
52
  function Breadcrumb({
13
53
  ref,
14
54
  className,
@@ -18,10 +58,12 @@ function Breadcrumb({
18
58
  height: "1em",
19
59
  width: "1em"
20
60
  }),
61
+ items: itemsProp,
62
+ renderLink,
21
63
  children,
22
64
  ...props
23
65
  }) {
24
- const items = react.Children.toArray(children);
66
+ const items = itemsProp === undefined ? react.Children.toArray(children) : itemsProp.map((item, index) => renderStep(item, index === itemsProp.length - 1, renderLink));
25
67
  return /*#__PURE__*/jsxRuntime.jsx("nav", {
26
68
  "aria-label": "Breadcrumb",
27
69
  className: cn.cn(breadcrumb.breadcrumb({
@@ -2,8 +2,8 @@
2
2
 
3
3
  var styleInject_es = require('../../node_modules/.pnpm/style-inject@0.3.0/node_modules/style-inject/dist/style-inject.es.js');
4
4
 
5
- var css_248z = "@layer components{.breadcrumb-module_breadcrumb__dW5v-{color:var(--cocso-breadcrumb-font-color);font-size:var(--cocso-breadcrumb-font-size)}.breadcrumb-module_list__mLCBo{align-items:center;display:flex;flex-wrap:wrap;gap:var(--cocso-spacing-2);list-style:none;margin:0;padding:0}.breadcrumb-module_item__G0t2y{align-items:center;display:inline-flex;gap:var(--cocso-spacing-2)}.breadcrumb-module_item__G0t2y:last-child{color:var(--cocso-color-text-primary);font-weight:500}.breadcrumb-module_separator__wMAks{color:var(--cocso-color-text-tertiary);user-select:none}}";
6
- var styles = {"breadcrumb":"breadcrumb-module_breadcrumb__dW5v-","list":"breadcrumb-module_list__mLCBo","item":"breadcrumb-module_item__G0t2y","separator":"breadcrumb-module_separator__wMAks"};
5
+ var css_248z = "@layer components{.breadcrumb-module_breadcrumb__dW5v-{color:var(--cocso-breadcrumb-font-color);font-size:var(--cocso-breadcrumb-font-size)}.breadcrumb-module_list__mLCBo{align-items:center;display:flex;flex-wrap:wrap;gap:var(--cocso-spacing-2);list-style:none;margin:0;padding:0}.breadcrumb-module_item__G0t2y{align-items:center;display:inline-flex;gap:var(--cocso-spacing-2)}.breadcrumb-module_item__G0t2y:last-child{color:var(--cocso-color-text-primary);font-weight:500}.breadcrumb-module_separator__wMAks{color:var(--cocso-color-text-tertiary);user-select:none}.breadcrumb-module_link__cclmN{color:var(--cocso-breadcrumb-font-color);text-decoration:underline;text-underline-offset:2px}.breadcrumb-module_link__cclmN:hover{color:var(--cocso-color-text-primary)}}";
6
+ 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"};
7
7
  styleInject_es(css_248z);
8
8
 
9
9
  module.exports = styles;
@@ -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.js';
5
+ import { TypographyProps } from '../typography/typography.js';
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 };
@@ -5,26 +5,92 @@ require('../../ecosystem/codegen/generated/card.css.js');
5
5
  var cn = require('../../cn.js');
6
6
  var card_module = require('./card.module.css.js');
7
7
  var jsxRuntime = require('react/jsx-runtime');
8
+ var typography = require('../typography/typography.js');
9
+ var useRender = require('@base-ui/react/use-render');
10
+ var mergeProps = require('@base-ui/react/merge-props');
8
11
 
9
- function Card({
12
+ const toLength = value => typeof value === "number" ? `${value}px` : value;
13
+ function CardRoot({
10
14
  ref,
15
+ render: renderProp,
11
16
  className,
12
- style,
17
+ style: _style,
13
18
  variant = "elevated",
14
19
  padding = "md",
20
+ gap,
15
21
  children,
16
22
  ...props
23
+ }) {
24
+ const style = {
25
+ ...(gap === undefined ? {} : {
26
+ "--cocso-card-gap": toLength(gap)
27
+ }),
28
+ ..._style
29
+ };
30
+ return useRender.useRender({
31
+ render: renderProp,
32
+ ref,
33
+ props: mergeProps.mergeProps({
34
+ className: cn.cn(card.card({
35
+ variant,
36
+ padding
37
+ }), card_module.card, variant === "elevated" && card_module.elevated, variant === "glass" && card_module.glass, className),
38
+ style
39
+ }, props, {
40
+ children
41
+ }),
42
+ defaultTagName: "div"
43
+ });
44
+ }
45
+ /**
46
+ * The card's top row: a title on the inline-start side, actions on the end.
47
+ * It keeps one height whether or not an action is there, so the content below
48
+ * does not shift when a button comes and goes.
49
+ */
50
+ function CardHeader({
51
+ className,
52
+ ...props
17
53
  }) {
18
54
  return /*#__PURE__*/jsxRuntime.jsx("div", {
19
- className: cn.cn(card.card({
20
- variant,
21
- padding
22
- }), card_module.card, variant === "elevated" && card_module.elevated, variant === "glass" && card_module.glass, className),
23
- ref: ref,
24
- style: style,
25
- ...props,
26
- children: children
55
+ className: cn.cn(card_module.header, className),
56
+ ...props
27
57
  });
28
58
  }
59
+ /**
60
+ * The card's heading. An `h2` at the `small` heading step by default; pass
61
+ * `level` for a different rank, or `render` for another element.
62
+ */
63
+ function CardTitle({
64
+ className,
65
+ size = "small",
66
+ weight = "bold",
67
+ ...props
68
+ }) {
69
+ return /*#__PURE__*/jsxRuntime.jsx(typography.Typography, {
70
+ className: cn.cn(card_module.title, className),
71
+ size: size,
72
+ type: "heading",
73
+ weight: weight,
74
+ ...props
75
+ });
76
+ }
77
+
78
+ /**
79
+ * Surface container. Compose with `Card.Header` and `Card.Title`.
80
+ *
81
+ * @example
82
+ * <Card gap={16} variant="outlined">
83
+ * <Card.Header>
84
+ * <Card.Title>Monthly revenue</Card.Title>
85
+ * <Button size="small">Export</Button>
86
+ * </Card.Header>
87
+ * …
88
+ * </Card>
89
+ */
90
+ const Card = Object.assign(CardRoot, {
91
+ displayName: "Card",
92
+ Header: CardHeader,
93
+ Title: CardTitle
94
+ });
29
95
 
30
96
  exports.Card = Card;
@@ -2,8 +2,8 @@
2
2
 
3
3
  var styleInject_es = require('../../node_modules/.pnpm/style-inject@0.3.0/node_modules/style-inject/dist/style-inject.es.js');
4
4
 
5
- var css_248z = "@layer components{.card-module_card__ZPFTz{background-color:var(--cocso-card-bg-color);border:var(--cocso-card-border,none);border-radius:var(--cocso-card-border-radius);display:flex;flex-direction:column;padding:var(--cocso-card-padding)}.card-module_elevated__Gua8s{box-shadow:var(--cocso-shadow-card)}.card-module_glass__u-Nbb{backdrop-filter:blur(16px)}}";
6
- var styles = {"card":"card-module_card__ZPFTz","elevated":"card-module_elevated__Gua8s","glass":"card-module_glass__u-Nbb"};
5
+ var css_248z = "@layer components{.card-module_card__ZPFTz{background-color:var(--cocso-card-bg-color);border:var(--cocso-card-border,none);border-radius:var(--cocso-card-border-radius);display:flex;flex-direction:column;gap:var(--cocso-card-gap);padding:var(--cocso-card-padding)}.card-module_elevated__Gua8s{box-shadow:var(--cocso-shadow-card)}.card-module_glass__u-Nbb{backdrop-filter:blur(16px)}.card-module_header__tz-Qf{align-items:center;display:flex;gap:var(--cocso-spacing-5);justify-content:space-between;min-block-size:32px}.card-module_header__tz-Qf>:first-child{flex:1;min-inline-size:0}.card-module_title__GAX2O{margin:0;word-break:keep-all}}";
6
+ 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"};
7
7
  styleInject_es(css_248z);
8
8
 
9
9
  module.exports = styles;
@@ -0,0 +1,29 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { ButtonProps } from '../button/button.js';
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,67 @@
1
+ "use client";
2
+ 'use strict';
3
+
4
+ var reactIcons = require('@cocso-ui/react-icons');
5
+ var react = require('react');
6
+ var jsxRuntime = require('react/jsx-runtime');
7
+ var button = require('../button/button.js');
8
+
9
+ /**
10
+ * An icon button that copies `text` to the clipboard and shows a check mark
11
+ * for a moment.
12
+ *
13
+ * It uses `navigator.clipboard.writeText`, which only works in a secure
14
+ * context (HTTPS or localhost). A failure is reported through `onCopyError`
15
+ * and nowhere else — the library does not log.
16
+ */
17
+ function CopyButton({
18
+ text,
19
+ resetTimeoutSeconds = 2,
20
+ onCopySuccess,
21
+ onCopyError,
22
+ label = "복사",
23
+ copiedLabel = "복사됨",
24
+ onClick,
25
+ size = "x-small",
26
+ variant = "ghost",
27
+ ...props
28
+ }) {
29
+ const [isCopied, setIsCopied] = react.useState(false);
30
+ react.useEffect(() => {
31
+ if (!isCopied) {
32
+ return;
33
+ }
34
+ const timer = setTimeout(() => {
35
+ setIsCopied(false);
36
+ }, resetTimeoutSeconds * 1000);
37
+ return () => clearTimeout(timer);
38
+ }, [isCopied, resetTimeoutSeconds]);
39
+ const handleClick = async event => {
40
+ onClick?.(event);
41
+ if (event.defaultPrevented) {
42
+ return;
43
+ }
44
+ try {
45
+ await navigator.clipboard.writeText(text);
46
+ setIsCopied(true);
47
+ onCopySuccess?.(text);
48
+ } catch (error) {
49
+ onCopyError?.(error);
50
+ }
51
+ };
52
+ return /*#__PURE__*/jsxRuntime.jsx(button.Button, {
53
+ "aria-label": isCopied ? copiedLabel : label,
54
+ "data-cocso-component": "copy-button",
55
+ "data-copied": isCopied || undefined,
56
+ size: size,
57
+ svgOnly: true,
58
+ title: label,
59
+ type: "button",
60
+ variant: variant,
61
+ ...props,
62
+ onClick: handleClick,
63
+ children: isCopied ? /*#__PURE__*/jsxRuntime.jsx(reactIcons.CheckIcon, {}) : /*#__PURE__*/jsxRuntime.jsx(reactIcons.ContentCopyIcon, {})
64
+ });
65
+ }
66
+
67
+ exports.CopyButton = 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,50 @@
1
+ 'use strict';
2
+
3
+ var cn = require('../../cn.js');
4
+ var emptyState_module = require('./empty-state.module.css.js');
5
+ var jsxRuntime = require('react/jsx-runtime');
6
+ var typography = require('../typography/typography.js');
7
+ var color = require('../../token/color.js');
8
+
9
+ /**
10
+ * The empty state of a region that is not a table.
11
+ *
12
+ * Inside a table, use the table's own empty row — it has to span the columns.
13
+ * Outside one (a list inside a card, a section of a popup), bare text floating
14
+ * in the layout reads as "something went wrong". The dashed frame marks out
15
+ * the place the content would occupy, so the screen says first that being
16
+ * empty is normal.
17
+ */
18
+ function EmptyState({
19
+ ref,
20
+ className,
21
+ title,
22
+ description,
23
+ action,
24
+ children,
25
+ ...props
26
+ }) {
27
+ return /*#__PURE__*/jsxRuntime.jsxs("div", {
28
+ className: cn.cn(emptyState_module.root, className),
29
+ "data-cocso-component": "empty-state",
30
+ ref: ref,
31
+ ...props,
32
+ children: [children, title && /*#__PURE__*/jsxRuntime.jsx(typography.Typography, {
33
+ size: "small",
34
+ type: "body",
35
+ weight: "medium",
36
+ children: title
37
+ }), description && /*#__PURE__*/jsxRuntime.jsx(typography.Typography, {
38
+ className: emptyState_module.description,
39
+ color: color.colors.textSecondary,
40
+ size: "x-small",
41
+ type: "body",
42
+ children: description
43
+ }), action && /*#__PURE__*/jsxRuntime.jsx("div", {
44
+ className: emptyState_module.action,
45
+ children: action
46
+ })]
47
+ });
48
+ }
49
+
50
+ exports.EmptyState = EmptyState;
@@ -0,0 +1,9 @@
1
+ 'use strict';
2
+
3
+ var styleInject_es = require('../../node_modules/.pnpm/style-inject@0.3.0/node_modules/style-inject/dist/style-inject.es.js');
4
+
5
+ var css_248z = "@layer components{.empty-state-module_root__UNTr-{align-items:center;border:1px dashed var(--cocso-color-border-secondary);border-radius:var(--cocso-radius-4);display:flex;flex-direction:column;gap:var(--cocso-spacing-4);justify-content:center;padding-block:var(--cocso-spacing-10);padding-inline:var(--cocso-spacing-8);text-align:center}.empty-state-module_description__muQc4{max-inline-size:28rem}.empty-state-module_action__OEm3v{margin-block-start:var(--cocso-spacing-3)}}";
6
+ var styles = {"root":"empty-state-module_root__UNTr-","description":"empty-state-module_description__muQc4","action":"empty-state-module_action__OEm3v"};
7
+ styleInject_es(css_248z);
8
+
9
+ module.exports = styles;
@@ -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 };