@ngrok/mantle 0.1.2 → 0.1.4

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 (90) hide show
  1. package/dist/alert.cjs +2 -0
  2. package/dist/alert.cjs.map +1 -0
  3. package/dist/alert.d.cts +26 -0
  4. package/dist/anchor.cjs +2 -0
  5. package/dist/anchor.cjs.map +1 -0
  6. package/dist/anchor.d.cts +17 -0
  7. package/dist/as-child-BjnPZ1DU.d.cts +22 -0
  8. package/dist/button.cjs +2 -0
  9. package/dist/button.cjs.map +1 -0
  10. package/dist/button.d.cts +92 -0
  11. package/dist/card.cjs +2 -0
  12. package/dist/card.cjs.map +1 -0
  13. package/dist/card.d.cts +29 -0
  14. package/dist/checkbox.cjs +2 -0
  15. package/dist/checkbox.cjs.map +1 -0
  16. package/dist/checkbox.d.cts +6 -0
  17. package/dist/chunk-D3F6KERE.cjs +2 -0
  18. package/dist/chunk-D3F6KERE.cjs.map +1 -0
  19. package/dist/chunk-IN6SIXF2.cjs +2 -0
  20. package/dist/chunk-IN6SIXF2.cjs.map +1 -0
  21. package/dist/chunk-JGNAMNKZ.cjs +2 -0
  22. package/dist/chunk-JGNAMNKZ.cjs.map +1 -0
  23. package/dist/chunk-K4UKFOMI.cjs +2 -0
  24. package/dist/chunk-K4UKFOMI.cjs.map +1 -0
  25. package/dist/chunk-ROHPZJ5N.cjs +2 -0
  26. package/dist/chunk-ROHPZJ5N.cjs.map +1 -0
  27. package/dist/code-block.cjs +4 -0
  28. package/dist/code-block.cjs.map +1 -0
  29. package/dist/code-block.d.cts +108 -0
  30. package/dist/cx.cjs +2 -0
  31. package/dist/cx.cjs.map +1 -0
  32. package/dist/cx.d.cts +10 -0
  33. package/dist/deep-non-nullable-SmpSvoSd.d.cts +8 -0
  34. package/dist/dialog.cjs +2 -0
  35. package/dist/dialog.cjs.map +1 -0
  36. package/dist/dialog.d.cts +26 -0
  37. package/dist/dropdown-menu.cjs +2 -0
  38. package/dist/dropdown-menu.cjs.map +1 -0
  39. package/dist/dropdown-menu.d.cts +37 -0
  40. package/dist/hooks.cjs +2 -0
  41. package/dist/hooks.cjs.map +1 -0
  42. package/dist/hooks.d.cts +15 -0
  43. package/dist/icon.cjs +2 -0
  44. package/dist/icon.cjs.map +1 -0
  45. package/dist/icon.d.cts +23 -0
  46. package/dist/inline-code.cjs +2 -0
  47. package/dist/inline-code.cjs.map +1 -0
  48. package/dist/inline-code.d.cts +9 -0
  49. package/dist/input.cjs +2 -0
  50. package/dist/input.cjs.map +1 -0
  51. package/dist/input.d.cts +75 -0
  52. package/dist/media-object.cjs +2 -0
  53. package/dist/media-object.cjs.map +1 -0
  54. package/dist/media-object.d.cts +26 -0
  55. package/dist/popover.cjs +2 -0
  56. package/dist/popover.cjs.map +1 -0
  57. package/dist/popover.d.cts +8 -0
  58. package/dist/select.cjs +2 -0
  59. package/dist/select.cjs.map +1 -0
  60. package/dist/select.d.cts +19 -0
  61. package/dist/separator.cjs +2 -0
  62. package/dist/separator.cjs.map +1 -0
  63. package/dist/separator.d.cts +9 -0
  64. package/dist/sheet.cjs +2 -0
  65. package/dist/sheet.cjs.map +1 -0
  66. package/dist/sheet.d.cts +22 -0
  67. package/dist/skeleton.cjs +2 -0
  68. package/dist/skeleton.cjs.map +1 -0
  69. package/dist/skeleton.d.cts +14 -0
  70. package/dist/table.cjs +2 -0
  71. package/dist/table.cjs.map +1 -0
  72. package/dist/table.d.cts +13 -0
  73. package/dist/tailwind-preset.cjs +2 -0
  74. package/dist/tailwind-preset.cjs.map +1 -0
  75. package/dist/tailwind-preset.d.cts +475 -0
  76. package/dist/text-area.cjs +2 -0
  77. package/dist/text-area.cjs.map +1 -0
  78. package/dist/text-area.d.cts +19 -0
  79. package/dist/theme-provider.cjs +29 -0
  80. package/dist/theme-provider.cjs.map +1 -0
  81. package/dist/theme-provider.d.cts +75 -0
  82. package/dist/tooltip.cjs +2 -0
  83. package/dist/tooltip.cjs.map +1 -0
  84. package/dist/tooltip.d.cts +15 -0
  85. package/dist/types.cjs +1 -0
  86. package/dist/types.cjs.map +1 -0
  87. package/dist/types.d.cts +6 -0
  88. package/dist/variant-props-DnYnbC7s.d.cts +11 -0
  89. package/dist/with-style-props-VnLWm0Yd.d.cts +27 -0
  90. package/package.json +25 -1
package/dist/alert.cjs ADDED
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkD3F6KEREcjs = require('./chunk-D3F6KERE.cjs');var _classvarianceauthority = require('class-variance-authority');var _react = require('react');var _jsxruntime = require('react/jsx-runtime');var d=_classvarianceauthority.cva.call(void 0, "relative flex w-full gap-1.5 rounded-md border p-2.5 text-sm",{variants:{priority:{danger:"border-danger-500/50 bg-danger-500/10 text-danger-700",default:"border-neutral-500/50 bg-neutral-500/10 text-neutral-700",info:"border-accent-500/50 bg-accent-500/10 text-accent-700",success:"border-success-500/50 bg-success-500/10 text-success-700",warning:"border-warning-500/50 bg-warning-500/10 text-warning-700"}},defaultVariants:{priority:"default"}}),l= exports.Alert =_react.forwardRef.call(void 0, ({className:e,priority:t="default",...r},c)=>_jsxruntime.jsx.call(void 0, "div",{ref:c,className:_chunkD3F6KEREcjs.a.call(void 0, d({priority:t}),e),...r}));l.displayName="Alert";var s=_react.forwardRef.call(void 0, ({className:e,...t},r)=>_jsxruntime.jsx.call(void 0, "div",{ref:r,className:_chunkD3F6KEREcjs.a.call(void 0, "min-w-0 flex-1",e),...t}));s.displayName="AlertContent";var o=_react.forwardRef.call(void 0, ({className:e,...t},r)=>_jsxruntime.jsx.call(void 0, "h5",{ref:r,className:_chunkD3F6KEREcjs.a.call(void 0, "font-medium",e),...t}));o.displayName="AlertTitle";var m=_react.forwardRef.call(void 0, ({className:e,...t},r)=>_jsxruntime.jsx.call(void 0, "div",{ref:r,className:_chunkD3F6KEREcjs.a.call(void 0, "text-sm",e),...t}));m.displayName="AlertDescription";exports.Alert = l; exports.AlertContent = s; exports.AlertDescription = m; exports.AlertTitle = o;
2
+ //# sourceMappingURL=alert.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../packages/alert/src/alert.tsx"],"names":["cva","forwardRef","jsx","alertVariants","Alert","className","priority","props","ref","cx","AlertContent","AlertTitle","AlertDescription"],"mappings":"oCAAA,OAAS,OAAAA,MAAW,2BACpB,OAAS,cAAAC,MAAkB,QAgCzB,cAAAC,MAAA,oBA3BF,IAAMC,EAAgBH,EAAI,+DAAgE,CACzF,SAAU,CAMT,SAAU,CACT,OAAQ,wDACR,QAAS,2DACT,KAAM,wDACN,QAAS,2DACT,QAAS,0DACV,CACD,EACA,gBAAiB,CAChB,SAAU,SACX,CACD,CAAC,EAOKI,EAAQH,EACb,CAAC,CAAE,UAAAI,EAAW,SAAAC,EAAW,UAAW,GAAGC,CAAM,EAAGC,IAC/CN,EAAC,OAAI,IAAKM,EAAK,UAAWC,EAAGN,EAAc,CAAE,SAAAG,CAAS,CAAC,EAAGD,CAAS,EAAI,GAAGE,EAAO,CAEnF,EACAH,EAAM,YAAc,QAKpB,IAAMM,EAAeT,EAA2D,CAAC,CAAE,UAAAI,EAAW,GAAGE,CAAM,EAAGC,IACzGN,EAAC,OAAI,IAAKM,EAAK,UAAWC,EAAG,iBAAkBJ,CAAS,EAAI,GAAGE,EAAO,CACtE,EACDG,EAAa,YAAc,eAK3B,IAAMC,EAAaV,EAClB,CAAC,CAAE,UAAAI,EAAW,GAAGE,CAAM,EAAGC,IAAQN,EAAC,MAAG,IAAKM,EAAK,UAAWC,EAAG,cAAeJ,CAAS,EAAI,GAAGE,EAAO,CACrG,EACAI,EAAW,YAAc,aAKzB,IAAMC,EAAmBX,EACxB,CAAC,CAAE,UAAAI,EAAW,GAAGE,CAAM,EAAGC,IAAQN,EAAC,OAAI,IAAKM,EAAK,UAAWC,EAAG,UAAWJ,CAAS,EAAI,GAAGE,EAAO,CAClG,EACAK,EAAiB,YAAc","sourcesContent":["import { cva } from \"class-variance-authority\";\nimport { forwardRef } from \"react\";\nimport type { HTMLAttributes } from \"react\";\nimport { cx } from \"../../cx\";\nimport type { VariantProps } from \"../../types\";\n\nconst alertVariants = cva(\"relative flex w-full gap-1.5 rounded-md border p-2.5 text-sm\", {\n\tvariants: {\n\t\t/**\n\t\t * The priority of the Alert. Indicates the importance or impact level of the Alert,\n\t\t * affecting its color and styling to communicate its purpose to the user.\n\t\t * @default \"default\"\n\t\t */\n\t\tpriority: {\n\t\t\tdanger: \"border-danger-500/50 bg-danger-500/10 text-danger-700\",\n\t\t\tdefault: \"border-neutral-500/50 bg-neutral-500/10 text-neutral-700\",\n\t\t\tinfo: \"border-accent-500/50 bg-accent-500/10 text-accent-700\",\n\t\t\tsuccess: \"border-success-500/50 bg-success-500/10 text-success-700\",\n\t\t\twarning: \"border-warning-500/50 bg-warning-500/10 text-warning-700\",\n\t\t},\n\t},\n\tdefaultVariants: {\n\t\tpriority: \"default\",\n\t},\n});\n\ntype AlertVariants = VariantProps<typeof alertVariants>;\n\n/**\n * Displays a callout for user attention.\n */\nconst Alert = forwardRef<HTMLDivElement, HTMLAttributes<HTMLDivElement> & AlertVariants>(\n\t({ className, priority = \"default\", ...props }, ref) => (\n\t\t<div ref={ref} className={cx(alertVariants({ priority }), className)} {...props} />\n\t),\n);\nAlert.displayName = \"Alert\";\n\n/**\n * The container for the content slot of an alert. Place the title and description as direct children.\n */\nconst AlertContent = forwardRef<HTMLDivElement, HTMLAttributes<HTMLDivElement>>(({ className, ...props }, ref) => (\n\t<div ref={ref} className={cx(\"min-w-0 flex-1\", className)} {...props} />\n));\nAlertContent.displayName = \"AlertContent\";\n\n/**\n * The title of an alert.\n */\nconst AlertTitle = forwardRef<HTMLParagraphElement, HTMLAttributes<HTMLHeadingElement>>(\n\t({ className, ...props }, ref) => <h5 ref={ref} className={cx(\"font-medium\", className)} {...props} />,\n);\nAlertTitle.displayName = \"AlertTitle\";\n\n/**\n * The description of an alert.\n */\nconst AlertDescription = forwardRef<HTMLParagraphElement, HTMLAttributes<HTMLParagraphElement>>(\n\t({ className, ...props }, ref) => <div ref={ref} className={cx(\"text-sm\", className)} {...props} />,\n);\nAlertDescription.displayName = \"AlertDescription\";\n\nexport { Alert, AlertContent, AlertTitle, AlertDescription };\n"]}
@@ -0,0 +1,26 @@
1
+ import * as react from 'react';
2
+ import { HTMLAttributes } from 'react';
3
+ import * as class_variance_authority from 'class-variance-authority';
4
+ import { D as DeepNonNullable } from './deep-non-nullable-SmpSvoSd.cjs';
5
+ import * as class_variance_authority_types from 'class-variance-authority/types';
6
+
7
+ /**
8
+ * Displays a callout for user attention.
9
+ */
10
+ declare const Alert: react.ForwardRefExoticComponent<HTMLAttributes<HTMLDivElement> & Partial<DeepNonNullable<class_variance_authority.VariantProps<(props?: ({
11
+ priority?: "danger" | "default" | "info" | "success" | "warning" | null | undefined;
12
+ } & class_variance_authority_types.ClassProp) | undefined) => string>>> & react.RefAttributes<HTMLDivElement>>;
13
+ /**
14
+ * The container for the content slot of an alert. Place the title and description as direct children.
15
+ */
16
+ declare const AlertContent: react.ForwardRefExoticComponent<HTMLAttributes<HTMLDivElement> & react.RefAttributes<HTMLDivElement>>;
17
+ /**
18
+ * The title of an alert.
19
+ */
20
+ declare const AlertTitle: react.ForwardRefExoticComponent<HTMLAttributes<HTMLHeadingElement> & react.RefAttributes<HTMLParagraphElement>>;
21
+ /**
22
+ * The description of an alert.
23
+ */
24
+ declare const AlertDescription: react.ForwardRefExoticComponent<HTMLAttributes<HTMLParagraphElement> & react.RefAttributes<HTMLParagraphElement>>;
25
+
26
+ export { Alert, AlertContent, AlertDescription, AlertTitle };
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkD3F6KEREcjs = require('./chunk-D3F6KERE.cjs');var _reactslot = require('@radix-ui/react-slot');var _react = require('react');var _jsxruntime = require('react/jsx-runtime');var n=o=>_chunkD3F6KEREcjs.a.call(void 0, "cursor-pointer rounded bg-transparent text-accent-600 hover:underline focus:outline-none focus-visible:ring focus-visible:ring-focus-accent",o),e= exports.Anchor =_react.forwardRef.call(void 0, ({asChild:o,className:t,...s},c)=>_jsxruntime.jsx.call(void 0, o?_reactslot.Slot:"a",{className:n(t),ref:c,...s}));e.displayName="Anchor";exports.Anchor = e; exports.anchorClassNames = n;
2
+ //# sourceMappingURL=anchor.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../packages/anchor/src/anchor.tsx"],"names":["Slot","forwardRef","jsx","anchorClassNames","className","cx","Anchor","asChild","props","ref"],"mappings":"yCAAA,OAAS,QAAAA,MAAY,uBACrB,OAA+B,cAAAC,MAAkB,QAwBzC,cAAAC,MAAA,oBApBR,IAAMC,EAAoBC,GACzBC,EACC,8IACAD,CACD,EAaKE,EAASL,EAA2C,CAAC,CAAE,QAAAM,EAAS,UAAAH,EAAW,GAAGI,CAAM,EAAGC,IAGrFP,EAFWK,EAAUP,EAAO,IAE3B,CAAU,UAAWG,EAAiBC,CAAS,EAAG,IAAKK,EAAM,GAAGD,EAAO,CAC/E,EACDF,EAAO,YAAc","sourcesContent":["import { Slot } from \"@radix-ui/react-slot\";\nimport { AnchorHTMLAttributes, forwardRef } from \"react\";\nimport { cx } from \"../../cx\";\nimport { WithAsChild } from \"../../types/src/as-child\";\n\nconst anchorClassNames = (className: string | undefined) =>\n\tcx(\n\t\t\"cursor-pointer rounded bg-transparent text-accent-600 hover:underline focus:outline-none focus-visible:ring focus-visible:ring-focus-accent\",\n\t\tclassName,\n\t);\n\ntype AnchorProps = AnchorHTMLAttributes<HTMLAnchorElement> & WithAsChild;\n\n/**\n * Fundamental component for rendering links to external addresses.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a\n *\n * @note If you need to link to an internal application route, prefer using the\n * [`react-router-dom` `<Link>`](https://reactrouter.com/en/main/components/link) or the\n * [`@remix-run/react` `<Link>`](https://remix.run/docs/en/main/components/link).\n */\nconst Anchor = forwardRef<HTMLAnchorElement, AnchorProps>(({ asChild, className, ...props }, ref) => {\n\tconst Component = asChild ? Slot : \"a\";\n\n\treturn <Component className={anchorClassNames(className)} ref={ref} {...props} />;\n});\nAnchor.displayName = \"Anchor\";\n\nexport { Anchor, anchorClassNames };\n"]}
@@ -0,0 +1,17 @@
1
+ import * as react from 'react';
2
+ import { AnchorHTMLAttributes } from 'react';
3
+ import { W as WithAsChild } from './as-child-BjnPZ1DU.cjs';
4
+
5
+ declare const anchorClassNames: (className: string | undefined) => string;
6
+ /**
7
+ * Fundamental component for rendering links to external addresses.
8
+ *
9
+ * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a
10
+ *
11
+ * @note If you need to link to an internal application route, prefer using the
12
+ * [`react-router-dom` `<Link>`](https://reactrouter.com/en/main/components/link) or the
13
+ * [`@remix-run/react` `<Link>`](https://remix.run/docs/en/main/components/link).
14
+ */
15
+ declare const Anchor: react.ForwardRefExoticComponent<AnchorHTMLAttributes<HTMLAnchorElement> & WithAsChild & react.RefAttributes<HTMLAnchorElement>>;
16
+
17
+ export { Anchor, anchorClassNames };
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Utility type for adding the `asChild` boolean prop to a component.
3
+ */
4
+ type WithAsChild = {
5
+ /**
6
+ * Use the `asChild` prop to compose Radix's functionality onto alternative
7
+ * element types or your own React components.
8
+ *
9
+ * All Radix primitive parts that render a DOM element accept an `asChild`
10
+ * prop. When `asChild` is set to `true`, Radix will not render a default DOM
11
+ * element, instead cloning the part's child and passing it the props and
12
+ * behavior required to make it functional.
13
+ *
14
+ * asChild can be used as deeply as you need to. This means it is a great way
15
+ * to compose multiple primitive's behavior together.
16
+ *
17
+ * @see https://www.radix-ui.com/docs/primitives/guides/composition#composition
18
+ */
19
+ asChild?: boolean;
20
+ };
21
+
22
+ export type { WithAsChild as W };
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkK4UKFOMIcjs = require('./chunk-K4UKFOMI.cjs');require('./chunk-JGNAMNKZ.cjs');require('./chunk-D3F6KERE.cjs');exports.Button = _chunkK4UKFOMIcjs.a; exports.IconButton = _chunkK4UKFOMIcjs.b;
2
+ //# sourceMappingURL=button.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":""}
@@ -0,0 +1,92 @@
1
+ import * as react from 'react';
2
+ import { ButtonHTMLAttributes, ReactNode } from 'react';
3
+ import { W as WithAsChild } from './as-child-BjnPZ1DU.cjs';
4
+ import { V as VariantProps } from './variant-props-DnYnbC7s.cjs';
5
+ import { D as DeepNonNullable } from './deep-non-nullable-SmpSvoSd.cjs';
6
+ import * as class_variance_authority from 'class-variance-authority';
7
+ import * as class_variance_authority_types from 'class-variance-authority/types';
8
+
9
+ declare const buttonVariants: (props?: ({
10
+ appearance?: "link" | "filled" | "ghost" | "outlined" | null | undefined;
11
+ iconPlacement?: "end" | "start" | null | undefined;
12
+ isLoading?: boolean | null | undefined;
13
+ priority?: "default" | "danger" | "neutral" | null | undefined;
14
+ } & class_variance_authority_types.ClassProp) | undefined) => string;
15
+ type ButtonVariants = VariantProps<typeof buttonVariants>;
16
+ /**
17
+ * The props for the `Button` component.
18
+ */
19
+ type ButtonProps = ButtonHTMLAttributes<HTMLButtonElement> & WithAsChild & ButtonVariants & {
20
+ /**
21
+ * An icon to render inside the button. If the `state` is `"pending"`, then
22
+ * the icon will automatically be replaced with a spinner.
23
+ */
24
+ icon?: ReactNode;
25
+ };
26
+ /**
27
+ * Renders a button or a component that looks like a button, an interactive
28
+ * element activated by a user with a mouse, keyboard, finger, voice command, or
29
+ * other assistive technology. Once activated, it then performs an action, such
30
+ * as submitting a form or opening a dialog.
31
+ *
32
+ * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button
33
+ */
34
+ declare const Button: react.ForwardRefExoticComponent<ButtonHTMLAttributes<HTMLButtonElement> & WithAsChild & Partial<DeepNonNullable<class_variance_authority.VariantProps<(props?: ({
35
+ appearance?: "link" | "filled" | "ghost" | "outlined" | null | undefined;
36
+ iconPlacement?: "end" | "start" | null | undefined;
37
+ isLoading?: boolean | null | undefined;
38
+ priority?: "default" | "danger" | "neutral" | null | undefined;
39
+ } & class_variance_authority_types.ClassProp) | undefined) => string>>> & {
40
+ /**
41
+ * An icon to render inside the button. If the `state` is `"pending"`, then
42
+ * the icon will automatically be replaced with a spinner.
43
+ */
44
+ icon?: ReactNode;
45
+ } & react.RefAttributes<HTMLButtonElement>>;
46
+
47
+ declare const iconButtonVariants: (props?: ({
48
+ appearance?: "ghost" | "outlined" | null | undefined;
49
+ isLoading?: boolean | null | undefined;
50
+ size?: "xs" | "sm" | "md" | null | undefined;
51
+ } & class_variance_authority_types.ClassProp) | undefined) => string;
52
+ type IconButtonVariants = VariantProps<typeof iconButtonVariants>;
53
+ /**
54
+ * The props for the `Button` component.
55
+ */
56
+ type IconButtonProps = ButtonHTMLAttributes<HTMLButtonElement> & WithAsChild & IconButtonVariants & {
57
+ /**
58
+ * The accessible label for the icon. This label will be visually hidden but announced to screen reader users, similar to alt text for img tags.
59
+ */
60
+ label: string;
61
+ /**
62
+ * An icon to render inside the button. If the `state` is `"pending"`, then
63
+ * the icon will automatically be replaced with a spinner.
64
+ */
65
+ icon: ReactNode;
66
+ };
67
+ /**
68
+ * Renders a button or a component that looks like a button, an interactive
69
+ * element activated by a user with a mouse, keyboard, finger, voice command, or
70
+ * other assistive technology. Once activated, it then performs an action, such
71
+ * as submitting a form or opening a dialog.
72
+ * Renders only a single icon as children with an accessible, screen-reader-only label.
73
+ *
74
+ * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button
75
+ */
76
+ declare const IconButton: react.ForwardRefExoticComponent<ButtonHTMLAttributes<HTMLButtonElement> & WithAsChild & Partial<DeepNonNullable<class_variance_authority.VariantProps<(props?: ({
77
+ appearance?: "ghost" | "outlined" | null | undefined;
78
+ isLoading?: boolean | null | undefined;
79
+ size?: "xs" | "sm" | "md" | null | undefined;
80
+ } & class_variance_authority_types.ClassProp) | undefined) => string>>> & {
81
+ /**
82
+ * The accessible label for the icon. This label will be visually hidden but announced to screen reader users, similar to alt text for img tags.
83
+ */
84
+ label: string;
85
+ /**
86
+ * An icon to render inside the button. If the `state` is `"pending"`, then
87
+ * the icon will automatically be replaced with a spinner.
88
+ */
89
+ icon: ReactNode;
90
+ } & react.RefAttributes<HTMLButtonElement>>;
91
+
92
+ export { Button, type ButtonProps, IconButton, type IconButtonProps };
package/dist/card.cjs ADDED
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkD3F6KEREcjs = require('./chunk-D3F6KERE.cjs');var _reactslot = require('@radix-ui/react-slot');var _react = require('react');var _jsxruntime = require('react/jsx-runtime');var p=_react.forwardRef.call(void 0, ({className:r,children:e,...d},a)=>_jsxruntime.jsx.call(void 0, "div",{ref:a,className:_chunkD3F6KEREcjs.a.call(void 0, "relative divide-y divide-card-muted rounded-md border border-card bg-card",r),...d,children:e}));p.displayName="Card";var s=_react.forwardRef.call(void 0, ({className:r,children:e,...d},a)=>_jsxruntime.jsx.call(void 0, "div",{ref:a,className:_chunkD3F6KEREcjs.a.call(void 0, "p-6",r),...d,children:e}));s.displayName="CardBody";var m=_react.forwardRef.call(void 0, ({className:r,children:e,...d},a)=>_jsxruntime.jsx.call(void 0, "div",{ref:a,className:_chunkD3F6KEREcjs.a.call(void 0, "px-6 py-3",r),...d,children:e}));m.displayName="CardFooter";var l=_react.forwardRef.call(void 0, ({className:r,children:e,...d},a)=>_jsxruntime.jsx.call(void 0, "div",{ref:a,className:_chunkD3F6KEREcjs.a.call(void 0, "px-6 py-3",r),...d,children:e}));l.displayName="CardHeader";var C=_react.forwardRef.call(void 0, ({className:r,asChild:e,...d},a)=>_jsxruntime.jsx.call(void 0, e?_reactslot.Slot:"h3",{ref:a,className:_chunkD3F6KEREcjs.a.call(void 0, "font-semibold leading-none tracking-tight",r),...d}));C.displayName="CardTitle";exports.Card = p; exports.CardBody = s; exports.CardFooter = m; exports.CardHeader = l; exports.CardTitle = C;
2
+ //# sourceMappingURL=card.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../packages/card/src/card.tsx"],"names":["Slot","forwardRef","jsx","Card","className","children","rest","ref","cx","CardBody","CardFooter","CardHeader","CardTitle","asChild","props"],"mappings":"yCAAA,OAAS,QAAAA,MAAY,uBAErB,OAAS,cAAAC,MAAkB,QAW1B,cAAAC,MAAA,oBADM,IAAMC,EAAOF,EAAsC,CAAC,CAAE,UAAAG,EAAW,SAAAC,EAAU,GAAGC,CAAK,EAAGC,IAC5FL,EAAC,OACA,IAAKK,EACL,UAAWC,EAAG,4EAA6EJ,CAAS,EACnG,GAAGE,EAEH,SAAAD,EACF,CACA,EACDF,EAAK,YAAc,OAKZ,IAAMM,EAAWR,EAAsC,CAAC,CAAE,UAAAG,EAAW,SAAAC,EAAU,GAAGC,CAAK,EAAGC,IAChGL,EAAC,OAAI,IAAKK,EAAK,UAAWC,EAAG,MAAOJ,CAAS,EAAI,GAAGE,EAClD,SAAAD,EACF,CACA,EACDI,EAAS,YAAc,WAKhB,IAAMC,EAAaT,EAAsC,CAAC,CAAE,UAAAG,EAAW,SAAAC,EAAU,GAAGC,CAAK,EAAGC,IAClGL,EAAC,OAAI,IAAKK,EAAK,UAAWC,EAAG,YAAaJ,CAAS,EAAI,GAAGE,EACxD,SAAAD,EACF,CACA,EACDK,EAAW,YAAc,aAKlB,IAAMC,EAAaV,EAAsC,CAAC,CAAE,UAAAG,EAAW,SAAAC,EAAU,GAAGC,CAAK,EAAGC,IAClGL,EAAC,OAAI,IAAKK,EAAK,UAAWC,EAAG,YAAaJ,CAAS,EAAI,GAAGE,EACxD,SAAAD,EACF,CACA,EACDM,EAAW,YAAc,aAOlB,IAAMC,EAAYX,EAAiD,CAAC,CAAE,UAAAG,EAAW,QAAAS,EAAS,GAAGC,CAAM,EAAGP,IAErGL,EADMW,EAAUb,EAAO,KACtB,CAAK,IAAKO,EAAK,UAAWC,EAAG,4CAA6CJ,CAAS,EAAI,GAAGU,EAAO,CACzG,EACDF,EAAU,YAAc","sourcesContent":["import { Slot } from \"@radix-ui/react-slot\";\nimport type { HTMLAttributes } from \"react\";\nimport { forwardRef } from \"react\";\nimport { cx } from \"../../cx\";\nimport type { WithAsChild } from \"../../types/src/as-child\";\n\nexport type CardProps = HTMLAttributes<HTMLDivElement>;\n\n/**\n * A container that can be used to display content in a box resembling a playing\n * card.\n */\nexport const Card = forwardRef<HTMLDivElement, CardProps>(({ className, children, ...rest }, ref) => (\n\t<div\n\t\tref={ref}\n\t\tclassName={cx(\"relative divide-y divide-card-muted rounded-md border border-card bg-card\", className)}\n\t\t{...rest}\n\t>\n\t\t{children}\n\t</div>\n));\nCard.displayName = \"Card\";\n\n/**\n * The main content of a card. Usually composed as a direct child of a `Card` component.\n */\nexport const CardBody = forwardRef<HTMLDivElement, CardProps>(({ className, children, ...rest }, ref) => (\n\t<div ref={ref} className={cx(\"p-6\", className)} {...rest}>\n\t\t{children}\n\t</div>\n));\nCardBody.displayName = \"CardBody\";\n\n/**\n * The footer container of a card. Usually composed as a direct child of a `Card` component.\n */\nexport const CardFooter = forwardRef<HTMLDivElement, CardProps>(({ className, children, ...rest }, ref) => (\n\t<div ref={ref} className={cx(\"px-6 py-3\", className)} {...rest}>\n\t\t{children}\n\t</div>\n));\nCardFooter.displayName = \"CardFooter\";\n\n/**\n * The header container of a card. Usually composed as a direct child of a `Card` component.\n */\nexport const CardHeader = forwardRef<HTMLDivElement, CardProps>(({ className, children, ...rest }, ref) => (\n\t<div ref={ref} className={cx(\"px-6 py-3\", className)} {...rest}>\n\t\t{children}\n\t</div>\n));\nCardHeader.displayName = \"CardHeader\";\n\nexport type CardTitleProps = HTMLAttributes<HTMLHeadingElement> & WithAsChild;\n\n/**\n * The title of a card. Usually composed as a direct child of a `CardHeader` component.\n */\nexport const CardTitle = forwardRef<HTMLParagraphElement, CardTitleProps>(({ className, asChild, ...props }, ref) => {\n\tconst Comp = asChild ? Slot : \"h3\";\n\treturn <Comp ref={ref} className={cx(\"font-semibold leading-none tracking-tight\", className)} {...props} />;\n});\nCardTitle.displayName = \"CardTitle\";\n"]}
@@ -0,0 +1,29 @@
1
+ import * as react from 'react';
2
+ import { HTMLAttributes } from 'react';
3
+ import { W as WithAsChild } from './as-child-BjnPZ1DU.cjs';
4
+
5
+ type CardProps = HTMLAttributes<HTMLDivElement>;
6
+ /**
7
+ * A container that can be used to display content in a box resembling a playing
8
+ * card.
9
+ */
10
+ declare const Card: react.ForwardRefExoticComponent<CardProps & react.RefAttributes<HTMLDivElement>>;
11
+ /**
12
+ * The main content of a card. Usually composed as a direct child of a `Card` component.
13
+ */
14
+ declare const CardBody: react.ForwardRefExoticComponent<CardProps & react.RefAttributes<HTMLDivElement>>;
15
+ /**
16
+ * The footer container of a card. Usually composed as a direct child of a `Card` component.
17
+ */
18
+ declare const CardFooter: react.ForwardRefExoticComponent<CardProps & react.RefAttributes<HTMLDivElement>>;
19
+ /**
20
+ * The header container of a card. Usually composed as a direct child of a `Card` component.
21
+ */
22
+ declare const CardHeader: react.ForwardRefExoticComponent<CardProps & react.RefAttributes<HTMLDivElement>>;
23
+ type CardTitleProps = HTMLAttributes<HTMLHeadingElement> & WithAsChild;
24
+ /**
25
+ * The title of a card. Usually composed as a direct child of a `CardHeader` component.
26
+ */
27
+ declare const CardTitle: react.ForwardRefExoticComponent<HTMLAttributes<HTMLHeadingElement> & WithAsChild & react.RefAttributes<HTMLParagraphElement>>;
28
+
29
+ export { Card, CardBody, CardFooter, CardHeader, type CardProps, CardTitle, type CardTitleProps };
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } }var _chunkD3F6KEREcjs = require('./chunk-D3F6KERE.cjs');var _reactcheckbox = require('@radix-ui/react-checkbox'); var t = _interopRequireWildcard(_reactcheckbox);var _react = require('react');var _jsxruntime = require('react/jsx-runtime');var a=_react.forwardRef.call(void 0, ({className:o,...i},s)=>_jsxruntime.jsxs.call(void 0, t.Root,{ref:s,className:_chunkD3F6KEREcjs.a.call(void 0, "size-4 shrink-0 appearance-none rounded border border-form bg-form focus:border-accent-600 focus-visible:outline-none focus-visible:ring-4 focus-visible:ring-focus-accent disabled:cursor-not-allowed disabled:opacity-50 data-state-checked:border-transparent data-state-checked:bg-filled-accent data-state-indeterminate:border-transparent data-state-indeterminate:bg-filled-accent",o),...i,children:[_jsxruntime.jsx.call(void 0, t.Indicator,{className:"hidden items-center justify-center leading-none text-on-filled data-state-checked:flex",children:_jsxruntime.jsx.call(void 0, c,{className:"size-3"})}),_jsxruntime.jsx.call(void 0, t.Indicator,{className:"hidden items-center justify-center text-on-filled data-state-indeterminate:flex",children:_jsxruntime.jsx.call(void 0, l,{className:"size-3"})}),_jsxruntime.jsx.call(void 0, t.Indicator,{})]}));a.displayName="Checkbox";var c=({className:o,style:i})=>_jsxruntime.jsx.call(void 0, "svg",{className:o,style:i,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:_jsxruntime.jsx.call(void 0, "path",{d:"M12.7071 4.29289C13.0976 4.68342 13.0976 5.31658 12.7071 5.70711L6.70711 11.7071C6.31658 12.0976 5.68342 12.0976 5.29289 11.7071L3.29289 9.70711C2.90237 9.31658 2.90237 8.68342 3.29289 8.29289C3.68342 7.90237 4.31658 7.90237 4.70711 8.29289L6 9.58579L11.2929 4.29289C11.6834 3.90237 12.3166 3.90237 12.7071 4.29289Z",fill:"currentColor"})}),l=({className:o,style:i})=>_jsxruntime.jsx.call(void 0, "svg",{className:o,style:i,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:_jsxruntime.jsx.call(void 0, "path",{d:"M4 8C4 7.44772 4.44772 7 5 7H11C11.5523 7 12 7.44772 12 8C12 8.55228 11.5523 9 11 9H5C4.44772 9 4 8.55228 4 8Z",fill:"currentColor"})});exports.Checkbox = a;
2
+ //# sourceMappingURL=checkbox.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../packages/checkbox/src/checkbox.tsx"],"names":["CheckboxPrimitive","forwardRef","jsx","jsxs","Checkbox","className","props","ref","cx","CheckedIcon","IndeterminateIcon","style"],"mappings":"yCAAA,UAAYA,MAAuB,2BACnC,OAAS,cAAAC,MAAkB,QAQ1B,OASE,OAAAC,EATF,QAAAC,MAAA,oBADD,IAAMC,EAAWH,EAA6D,CAAC,CAAE,UAAAI,EAAW,GAAGC,CAAM,EAAGC,IACvGJ,EAAmB,OAAlB,CACA,IAAKI,EACL,UAAWC,EACV,6XACAH,CACD,EACC,GAAGC,EAEJ,UAAAJ,EAAmB,YAAlB,CAA4B,UAAU,yFACtC,SAAAA,EAACO,EAAA,CAAY,UAAU,SAAS,EACjC,EACAP,EAAmB,YAAlB,CAA4B,UAAU,kFACtC,SAAAA,EAACQ,EAAA,CAAkB,UAAU,SAAS,EACvC,EACAR,EAAmB,YAAlB,EAA4B,GAC9B,CACA,EACDE,EAAS,YAAc,WAIvB,IAAMK,EAAc,CAAC,CAAE,UAAAJ,EAAW,MAAAM,CAAM,IACvCT,EAAC,OAAI,UAAWG,EAAW,MAAOM,EAAO,QAAQ,YAAY,KAAK,OAAO,MAAM,6BAC9E,SAAAT,EAAC,QACA,EAAE,8TACF,KAAK,eACN,EACD,EAGKQ,EAAoB,CAAC,CAAE,UAAAL,EAAW,MAAAM,CAAM,IAC7CT,EAAC,OAAI,UAAWG,EAAW,MAAOM,EAAO,QAAQ,YAAY,KAAK,OAAO,MAAM,6BAC9E,SAAAT,EAAC,QACA,EAAE,iHACF,KAAK,eACN,EACD","sourcesContent":["import * as CheckboxPrimitive from \"@radix-ui/react-checkbox\";\nimport { forwardRef } from \"react\";\nimport type { ComponentPropsWithoutRef, ElementRef } from \"react\";\nimport { cx } from \"../../cx\";\nimport { WithStyleProps } from \"../../types\";\n\ntype Props = ComponentPropsWithoutRef<typeof CheckboxPrimitive.Root>;\n\nconst Checkbox = forwardRef<ElementRef<typeof CheckboxPrimitive.Root>, Props>(({ className, ...props }, ref) => (\n\t<CheckboxPrimitive.Root\n\t\tref={ref}\n\t\tclassName={cx(\n\t\t\t\"size-4 shrink-0 appearance-none rounded border border-form bg-form focus:border-accent-600 focus-visible:outline-none focus-visible:ring-4 focus-visible:ring-focus-accent disabled:cursor-not-allowed disabled:opacity-50 data-state-checked:border-transparent data-state-checked:bg-filled-accent data-state-indeterminate:border-transparent data-state-indeterminate:bg-filled-accent\",\n\t\t\tclassName,\n\t\t)}\n\t\t{...props}\n\t>\n\t\t<CheckboxPrimitive.Indicator className=\"hidden items-center justify-center leading-none text-on-filled data-state-checked:flex\">\n\t\t\t<CheckedIcon className=\"size-3\" />\n\t\t</CheckboxPrimitive.Indicator>\n\t\t<CheckboxPrimitive.Indicator className=\"hidden items-center justify-center text-on-filled data-state-indeterminate:flex\">\n\t\t\t<IndeterminateIcon className=\"size-3\" />\n\t\t</CheckboxPrimitive.Indicator>\n\t\t<CheckboxPrimitive.Indicator />\n\t</CheckboxPrimitive.Root>\n));\nCheckbox.displayName = \"Checkbox\";\n\nexport { Checkbox };\n\nconst CheckedIcon = ({ className, style }: WithStyleProps) => (\n\t<svg className={className} style={style} viewBox=\"0 0 16 16\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n\t\t<path\n\t\t\td=\"M12.7071 4.29289C13.0976 4.68342 13.0976 5.31658 12.7071 5.70711L6.70711 11.7071C6.31658 12.0976 5.68342 12.0976 5.29289 11.7071L3.29289 9.70711C2.90237 9.31658 2.90237 8.68342 3.29289 8.29289C3.68342 7.90237 4.31658 7.90237 4.70711 8.29289L6 9.58579L11.2929 4.29289C11.6834 3.90237 12.3166 3.90237 12.7071 4.29289Z\"\n\t\t\tfill=\"currentColor\"\n\t\t/>\n\t</svg>\n);\n\nconst IndeterminateIcon = ({ className, style }: WithStyleProps) => (\n\t<svg className={className} style={style} viewBox=\"0 0 16 16\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n\t\t<path\n\t\t\td=\"M4 8C4 7.44772 4.44772 7 5 7H11C11.5523 7 12 7.44772 12 8C12 8.55228 11.5523 9 11 9H5C4.44772 9 4 8.55228 4 8Z\"\n\t\t\tfill=\"currentColor\"\n\t\t/>\n\t</svg>\n);\n"]}
@@ -0,0 +1,6 @@
1
+ import * as react from 'react';
2
+ import * as CheckboxPrimitive from '@radix-ui/react-checkbox';
3
+
4
+ declare const Checkbox: react.ForwardRefExoticComponent<Omit<CheckboxPrimitive.CheckboxProps & react.RefAttributes<HTMLButtonElement>, "ref"> & react.RefAttributes<HTMLButtonElement>>;
5
+
6
+ export { Checkbox };
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _clsx = require('clsx');var _tailwindmerge = require('tailwind-merge');function t(...r){return _tailwindmerge.twMerge.call(void 0, _clsx.clsx.call(void 0, r))}exports.a = t;
2
+ //# sourceMappingURL=chunk-D3F6KERE.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../packages/cx/src/cx.ts"],"names":["clsx","twMerge","cx","inputs"],"mappings":"AAAA,OAAS,QAAAA,MAA6B,OACtC,OAAS,WAAAC,MAAe,iBAOjB,SAASC,KAAMC,EAAsB,CAC3C,OAAOF,EAAQD,EAAKG,CAAM,CAAC,CAC5B","sourcesContent":["import { clsx, type ClassValue } from \"clsx\";\nimport { twMerge } from \"tailwind-merge\";\n\n/**\n * Conditionally add Tailwind (and other) CSS classes.\n *\n * Allows for tailwind overrides in LTR-specificity-like order of applied classes.\n */\nexport function cx(...inputs: ClassValue[]) {\n\treturn twMerge(clsx(inputs));\n}\n"]}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _react = require('react');function c(e){let r=_react.useCallback.call(void 0, t=>{let n=window.matchMedia(e);return n.addEventListener("change",t),()=>{n.removeEventListener("change",t)}},[e]);return _react.useSyncExternalStore.call(void 0, r,()=>window.matchMedia(e).matches,()=>!1)}exports.a = c;
2
+ //# sourceMappingURL=chunk-IN6SIXF2.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../packages/hooks/src/use-matches-media-query.tsx"],"names":["useCallback","useSyncExternalStore","useMatchesMediaQuery","query","subscribe","callback","matchMedia"],"mappings":"AAAA,OAAS,eAAAA,EAAa,wBAAAC,MAA4B,QAE3C,SAASC,EAAqBC,EAAe,CACnD,IAAMC,EAAYJ,EAChBK,GAAyB,CACzB,IAAMC,EAAa,OAAO,WAAWH,CAAK,EAE1C,OAAAG,EAAW,iBAAiB,SAAUD,CAAQ,EACvC,IAAM,CACZC,EAAW,oBAAoB,SAAUD,CAAQ,CAClD,CACD,EACA,CAACF,CAAK,CACP,EAEA,OAAOF,EACNG,EACA,IACQ,OAAO,WAAWD,CAAK,EAAE,QAEjC,IAAM,EACP,CACD","sourcesContent":["import { useCallback, useSyncExternalStore } from \"react\";\n\nexport function useMatchesMediaQuery(query: string) {\n\tconst subscribe = useCallback(\n\t\t(callback: () => void) => {\n\t\t\tconst matchMedia = window.matchMedia(query);\n\n\t\t\tmatchMedia.addEventListener(\"change\", callback);\n\t\t\treturn () => {\n\t\t\t\tmatchMedia.removeEventListener(\"change\", callback);\n\t\t\t};\n\t\t},\n\t\t[query],\n\t);\n\n\treturn useSyncExternalStore(\n\t\tsubscribe,\n\t\t() => {\n\t\t\treturn window.matchMedia(query).matches;\n\t\t},\n\t\t() => false,\n\t);\n}\n"]}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var _chunkD3F6KEREcjs = require('./chunk-D3F6KERE.cjs');var _react = require('react');var _tinyinvariant = require('tiny-invariant'); var _tinyinvariant2 = _interopRequireDefault(_tinyinvariant);var _jsxruntime = require('react/jsx-runtime');var a=({className:o,style:s,svg:r})=>{let t=_react.Children.only(r);return _tinyinvariant2.default.call(void 0, _react.isValidElement.call(void 0, t),"Icon must be passed a single SVG icon as a JSX tag."),_jsxruntime.jsx.call(void 0, _jsxruntime.Fragment,{children:_react.cloneElement.call(void 0, t,{className:_chunkD3F6KEREcjs.a.call(void 0, "size-6 sm:size-5 shrink-0",t.props.className,o),style:{...t.props.style,...s}})})};exports.a = a;
2
+ //# sourceMappingURL=chunk-JGNAMNKZ.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../packages/icon/src/icon.tsx"],"names":["Children","cloneElement","isValidElement","invariant","Fragment","jsx","Icon","className","style","svg","icon","cx"],"mappings":"yCAAA,OAAS,YAAAA,EAAU,gBAAAC,EAA8B,kBAAAC,MAA+C,QAChG,OAAOC,MAAe,iBA2BpB,mBAAAC,EAAA,OAAAC,MAAA,oBALF,IAAMC,EAAO,CAAC,CAAE,UAAAC,EAAW,MAAAC,EAAO,IAAAC,CAAI,IAAiB,CACtD,IAAMC,EAAOV,EAAS,KAAKS,CAAG,EAC9B,OAAAN,EAAUD,EAA8BQ,CAAI,EAAG,qDAAqD,EAGnGL,EAAAD,EAAA,CACE,SAAAH,EAAaS,EAAM,CACnB,UAAWC,EAAG,4BAA6BD,EAAK,MAAM,UAAWH,CAAS,EAC1E,MAAO,CAAE,GAAGG,EAAK,MAAM,MAAO,GAAGF,CAAM,CACxC,CAAC,EACF,CAEF","sourcesContent":["import { Children, cloneElement, HTMLAttributes, isValidElement, ReactElement, ReactNode } from \"react\";\nimport invariant from \"tiny-invariant\";\nimport { cx } from \"../../cx\";\nimport { WithStyleProps } from \"../../types\";\n\ntype IconProps = WithStyleProps & {\n\t/**\n\t * A single SVG icon element.\n\t */\n\tsvg: ReactNode;\n};\n\ntype SvgAttributes = HTMLAttributes<SVGElement> & {\n\tfocusable?: \"true\" | \"false\";\n};\n\n/**\n * Decorates an svg icon with automatic sizing styles.\n * Merges `className` selectors with the following order of precedence (last one wins):\n * 1. Icon base classes\n * 2. svg className\n * 3. Icon className\n */\nconst Icon = ({ className, style, svg }: IconProps) => {\n\tconst icon = Children.only(svg) as ReactElement;\n\tinvariant(isValidElement<SvgAttributes>(icon), \"Icon must be passed a single SVG icon as a JSX tag.\");\n\n\treturn (\n\t\t<>\n\t\t\t{cloneElement(icon, {\n\t\t\t\tclassName: cx(\"size-6 sm:size-5 shrink-0\", icon.props.className, className),\n\t\t\t\tstyle: { ...icon.props.style, ...style },\n\t\t\t})}\n\t\t</>\n\t);\n};\n\nexport { Icon };\nexport type { IconProps, SvgAttributes };\n"]}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var _chunkJGNAMNKZcjs = require('./chunk-JGNAMNKZ.cjs');var _chunkD3F6KEREcjs = require('./chunk-D3F6KERE.cjs');var _CircleNotch = require('@phosphor-icons/react/CircleNotch');var _reactslot = require('@radix-ui/react-slot');var _classvarianceauthority = require('class-variance-authority');var _clsx = require('clsx'); var _clsx2 = _interopRequireDefault(_clsx);var _react = require('react');var _tinyinvariant = require('tiny-invariant'); var _tinyinvariant2 = _interopRequireDefault(_tinyinvariant);var _jsxruntime = require('react/jsx-runtime');var W=_classvarianceauthority.cva.call(void 0, "items-center justify-center gap-1.5 whitespace-nowrap rounded-md focus-within:outline-none focus-visible:ring-4 disabled:pointer-events-none disabled:opacity-50 aria-disabled:opacity-50 sm:text-sm [&>*]:focus-within:outline-none",{variants:{appearance:{filled:"inline-flex h-11 border border-transparent bg-filled-accent px-3 font-medium text-on-filled hover:bg-filled-accent-hover focus-visible:border-accent-600 focus-visible:ring-focus-accent active:bg-filled-accent-active sm:h-9",ghost:"inline-flex h-11 border border-transparent px-3 font-medium text-accent-600 hover:bg-accent-500/10 hover:text-accent-700 focus-visible:ring-focus-accent active:bg-accent-500/15 active:text-accent-700 sm:h-9",outlined:"inline-flex h-11 border border-accent-600 bg-form px-3 font-medium text-accent-600 hover:border-accent-700 hover:bg-accent-500/10 hover:text-accent-700 focus-visible:ring-focus-accent active:border-accent-700 active:bg-accent-500/15 active:text-accent-700 sm:h-9",link:"group inline cursor-pointer border-transparent text-accent-600 hover:underline focus-visible:ring-focus-accent"},iconPlacement:{end:"pe-2.5",start:"ps-2.5"},isLoading:{false:"",true:"opacity-50"},priority:{danger:"",default:"",neutral:""}},defaultVariants:{appearance:"outlined",isLoading:!1,priority:"default"},compoundVariants:[{appearance:"ghost",priority:"danger",class:"border-transparent text-danger-600 hover:bg-danger-500/10 hover:text-danger-700 focus-visible:ring-focus-danger active:bg-danger-500/15 active:text-danger-700"},{appearance:"outlined",priority:"danger",class:"border-danger-600 bg-form text-danger-600 hover:border-danger-700 hover:bg-danger-500/10 hover:text-danger-700 focus-visible:ring-focus-danger active:border-danger-700 active:bg-danger-500/15 active:text-danger-700"},{appearance:"filled",priority:"danger",class:"border-transparent bg-filled-danger hover:bg-filled-danger-hover focus-visible:border-danger-600 focus-visible:ring-focus-danger active:bg-filled-danger-active"},{appearance:"link",priority:"danger",class:"text-danger-600 focus-visible:ring-focus-danger"},{appearance:"ghost",priority:"neutral",class:"border-transparent text-strong hover:bg-neutral-500/10 hover:text-strong focus-visible:ring-focus-accent active:bg-neutral-500/15 active:text-strong"},{appearance:"outlined",priority:"neutral",class:"border-form bg-form text-strong hover:border-neutral-400 hover:bg-form-hover hover:text-strong focus-visible:border-accent-600 focus-visible:ring-focus-accent active:border-neutral-400 active:bg-neutral-500/10 active:text-strong focus-visible:active:border-accent-600"},{appearance:"filled",priority:"neutral",class:"border-transparent bg-filled-neutral hover:bg-filled-neutral-hover focus-visible:border-neutral-600 focus-visible:ring-focus-neutral active:bg-filled-neutral-active"},{appearance:"link",priority:"neutral",class:"text-strong focus-visible:ring-focus-accent"}]}),V= exports.a =_react.forwardRef.call(void 0, ({"aria-disabled":l,appearance:r="outlined",asChild:o=!1,children:a,className:b,icon:t,iconPlacement:i="start",isLoading:n=!1,onClickCapture:g,priority:m="default",...v},h)=>{let x=_nullishCoalesce(l, () => (n)),u=n?_jsxruntime.jsx.call(void 0, _CircleNotch.CircleNotch,{className:"animate-spin"}):t,d=e=>{n&&(e.preventDefault(),e.stopPropagation()),_optionalChain([g, 'optionalCall', _2 => _2(e)])},y={"aria-disabled":x,className:_chunkD3F6KEREcjs.a.call(void 0, W({appearance:r,priority:m,isLoading:n,iconPlacement:u?i:void 0}),b),"data-loading":n,onClickCapture:d,ref:h,...v};if(o){let e=_react.Children.only(a);_tinyinvariant2.default.call(void 0, _react.isValidElement.call(void 0, e),"When using `asChild`, Button must be passed a single child as a JSX tag.");let B=_optionalChain([e, 'access', _3 => _3.props, 'optionalAccess', _4 => _4.children]);return _jsxruntime.jsx.call(void 0, _reactslot.Slot,{...y,children:_react.cloneElement.call(void 0, e,{},_jsxruntime.jsx.call(void 0, P,{appearance:r,icon:u,iconPlacement:i,children:B}))})}return _jsxruntime.jsx.call(void 0, "button",{...y,children:_jsxruntime.jsx.call(void 0, P,{appearance:r,icon:u,iconPlacement:i,children:a})})});V.displayName="Button";var P=({appearance:l,children:r,icon:o,iconPlacement:a})=>_jsxruntime.jsxs.call(void 0, "span",{className:_clsx2.default.call(void 0, "inline-flex items-center gap-1.5 focus-within:outline-none focus-visible:outline-none",l==="link"&&"group-hover:underline"),children:[o&&_jsxruntime.jsx.call(void 0, _chunkJGNAMNKZcjs.a,{svg:o,className:_clsx2.default.call(void 0, a==="end"&&"order-last")}),r]});var j=_classvarianceauthority.cva.call(void 0, "inline-flex items-center justify-center rounded-md border focus-within:outline-none focus-visible:ring-4 disabled:pointer-events-none disabled:opacity-50 aria-disabled:opacity-50",{variants:{appearance:{ghost:"border-transparent text-strong hover:bg-neutral-500/10 hover:text-strong focus-visible:ring-focus-accent active:bg-neutral-500/15 active:text-strong",outlined:"border-form bg-form text-strong hover:border-neutral-400 hover:bg-form-hover hover:text-strong focus-visible:border-accent-600 focus-visible:ring-focus-accent active:border-neutral-400 active:bg-neutral-500/10 active:text-strong focus-visible:active:border-accent-600"},isLoading:{false:"",true:"opacity-50"},size:{xs:"size-7 sm:size-6",sm:"size-9 sm:size-7",md:"size-11 sm:size-9"}},defaultVariants:{appearance:"outlined",size:"md"}}),I= exports.b =_react.forwardRef.call(void 0, ({"aria-disabled":l,appearance:r,asChild:o=!1,children:a,className:b,isLoading:t=!1,icon:i,label:n,onClickCapture:g,size:m,...v},h)=>{let x=_nullishCoalesce(l, () => (t)),u=e=>{t&&(e.preventDefault(),e.stopPropagation()),_optionalChain([g, 'optionalCall', _5 => _5(e)])},d={"aria-disabled":x,className:_chunkD3F6KEREcjs.a.call(void 0, j({appearance:r,isLoading:t,size:m}),b),"data-loading":t,onClickCapture:u,ref:h,...v};if(o){let e=_react.Children.only(a),B=_react.isValidElement.call(void 0, e);return _jsxruntime.jsx.call(void 0, _reactslot.Slot,{...d,children:B&&_react.cloneElement.call(void 0, e,{},_jsxruntime.jsx.call(void 0, _chunkJGNAMNKZcjs.a,{svg:t?_jsxruntime.jsx.call(void 0, _CircleNotch.CircleNotch,{className:"animate-spin"}):i}))})}return _jsxruntime.jsxs.call(void 0, "button",{...d,children:[_jsxruntime.jsx.call(void 0, "span",{className:"sr-only",children:n}),_jsxruntime.jsx.call(void 0, _chunkJGNAMNKZcjs.a,{svg:t?_jsxruntime.jsx.call(void 0, _CircleNotch.CircleNotch,{className:"animate-spin"}):i})]})});I.displayName="IconButton";exports.a = V; exports.b = I;
2
+ //# sourceMappingURL=chunk-K4UKFOMI.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../packages/button/src/button.tsx","../packages/button/src/icon-button.tsx"],"names":["CircleNotch","Slot","cva","clsx","Children","cloneElement","forwardRef","isValidElement","invariant","jsx","jsxs","buttonVariants","Button","_ariaDisabled","appearance","asChild","children","className","propIcon","iconPlacement","isLoading","onClickCapture","priority","props","ref","ariaDisabled","icon","_onClickCapture","event","buttonProps","cx","singleChild","grandchildren","InnerContent","Icon","iconButtonVariants","IconButton","label","size","isValidChild"],"mappings":"kFAAA,OAAS,eAAAA,MAAmB,oCAC5B,OAAS,QAAAC,MAAY,uBACrB,OAAS,OAAAC,MAAW,2BACpB,OAAOC,MAAU,OACjB,OAAS,YAAAC,EAAU,gBAAAC,EAAc,cAAAC,EAAY,kBAAAC,MAAsB,QAEnE,OAAOC,MAAe,iBAkJK,cAAAC,EA4D1B,QAAAC,MA5D0B,oBA5I3B,IAAMC,EAAiBT,EACtB,uOACA,CACC,SAAU,CAIT,WAAY,CACX,OACC,iOACD,MACC,iNACD,SACC,yQACD,KAAM,gHACP,EAKA,cAAe,CACd,IAAK,SACL,MAAO,QACR,EAMA,UAAW,CACV,MAAO,GACP,KAAM,YACP,EAKA,SAAU,CACT,OAAQ,GACR,QAAS,GACT,QAAS,EACV,CACD,EACA,gBAAiB,CAChB,WAAY,WACZ,UAAW,GACX,SAAU,SACX,EACA,iBAAkB,CACjB,CACC,WAAY,QACZ,SAAU,SACV,MACC,gKACF,EACA,CACC,WAAY,WACZ,SAAU,SACV,MACC,wNACF,EACA,CACC,WAAY,SACZ,SAAU,SACV,MACC,iKACF,EACA,CACC,WAAY,OACZ,SAAU,SACV,MAAO,iDACR,EACA,CACC,WAAY,QACZ,SAAU,UACV,MACC,sJACF,EACA,CACC,WAAY,WACZ,SAAU,UACV,MACC,6QACF,EACA,CACC,WAAY,SACZ,SAAU,UACV,MACC,sKACF,EACA,CACC,WAAY,OACZ,SAAU,UACV,MAAO,6CACR,CACD,CACD,CACD,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EAAA,CAAK,IAFtEd,EAAYX,EAACT,EAAA,CAAY,UAAU,eAAe,EAAKkB,EAE0B,CAAE,EAAE,CACnG,CAIA,OACCR,EAAC,UAAQ,GAAGmB,EACX,UAAApB,EAAC,QAAK,UAAU,UAAW,SAAA4B,EAAM,EACjC5B,EAACyB,EAAA,CAAK,IALKd,EAAYX,EAACT,EAAA,CAAY,UAAU,eAAe,EAAKkB,EAKjD,GAClB,CAEF,CACD,EACAkB,EAAW,YAAc","sourcesContent":["import { CircleNotch } from \"@phosphor-icons/react/CircleNotch\";\nimport { Slot } from \"@radix-ui/react-slot\";\nimport { cva } from \"class-variance-authority\";\nimport clsx from \"clsx\";\nimport { Children, cloneElement, forwardRef, isValidElement } from \"react\";\nimport type { ButtonHTMLAttributes, MouseEvent, PropsWithChildren, ReactNode } from \"react\";\nimport invariant from \"tiny-invariant\";\nimport { cx } from \"../../cx\";\nimport { Icon } from \"../../icon\";\nimport type { WithAsChild } from \"../../types/src/as-child\";\nimport type { VariantProps } from \"../../types/src/variant-props\";\n\nconst buttonVariants = cva(\n\t\"items-center justify-center gap-1.5 whitespace-nowrap rounded-md focus-within:outline-none focus-visible:ring-4 disabled:pointer-events-none disabled:opacity-50 aria-disabled:opacity-50 sm:text-sm [&>*]:focus-within:outline-none\",\n\t{\n\t\tvariants: {\n\t\t\t/**\n\t\t\t * Defines the visual style of the Button.\n\t\t\t */\n\t\t\tappearance: {\n\t\t\t\tfilled:\n\t\t\t\t\t\"inline-flex h-11 border border-transparent bg-filled-accent px-3 font-medium text-on-filled hover:bg-filled-accent-hover focus-visible:border-accent-600 focus-visible:ring-focus-accent active:bg-filled-accent-active sm:h-9\",\n\t\t\t\tghost:\n\t\t\t\t\t\"inline-flex h-11 border border-transparent px-3 font-medium text-accent-600 hover:bg-accent-500/10 hover:text-accent-700 focus-visible:ring-focus-accent active:bg-accent-500/15 active:text-accent-700 sm:h-9\",\n\t\t\t\toutlined:\n\t\t\t\t\t\"inline-flex h-11 border border-accent-600 bg-form px-3 font-medium text-accent-600 hover:border-accent-700 hover:bg-accent-500/10 hover:text-accent-700 focus-visible:ring-focus-accent active:border-accent-700 active:bg-accent-500/15 active:text-accent-700 sm:h-9\",\n\t\t\t\tlink: \"group inline cursor-pointer border-transparent text-accent-600 hover:underline focus-visible:ring-focus-accent\",\n\t\t\t},\n\t\t\t/**\n\t\t\t * The side that the icon will render on, if one is present. If `state=\"pending\"`,\n\t\t\t * then the loading icon will also render on this side.\n\t\t\t */\n\t\t\ticonPlacement: {\n\t\t\t\tend: \"pe-2.5\",\n\t\t\t\tstart: \"ps-2.5\",\n\t\t\t},\n\t\t\t/**\n\t\t\t * Whether or not the button is in a loading state, default `false`. Setting `isLoading` will\n\t\t\t * replace any `icon` with a spinner, or add one if an icon wasn't given.\n\t\t\t * It will also disable user interaction with the button and set `aria-disabled`.\n\t\t\t */\n\t\t\tisLoading: {\n\t\t\t\tfalse: \"\",\n\t\t\t\ttrue: \"opacity-50\",\n\t\t\t},\n\t\t\t/**\n\t\t\t * Indicates the importance or impact level of the button, affecting its\n\t\t\t * color and styling to communicate its purpose to the user\n\t\t\t */\n\t\t\tpriority: {\n\t\t\t\tdanger: \"\",\n\t\t\t\tdefault: \"\",\n\t\t\t\tneutral: \"\",\n\t\t\t},\n\t\t},\n\t\tdefaultVariants: {\n\t\t\tappearance: \"outlined\",\n\t\t\tisLoading: false,\n\t\t\tpriority: \"default\",\n\t\t},\n\t\tcompoundVariants: [\n\t\t\t{\n\t\t\t\tappearance: \"ghost\",\n\t\t\t\tpriority: \"danger\",\n\t\t\t\tclass:\n\t\t\t\t\t\"border-transparent text-danger-600 hover:bg-danger-500/10 hover:text-danger-700 focus-visible:ring-focus-danger active:bg-danger-500/15 active:text-danger-700\",\n\t\t\t},\n\t\t\t{\n\t\t\t\tappearance: \"outlined\",\n\t\t\t\tpriority: \"danger\",\n\t\t\t\tclass:\n\t\t\t\t\t\"border-danger-600 bg-form text-danger-600 hover:border-danger-700 hover:bg-danger-500/10 hover:text-danger-700 focus-visible:ring-focus-danger active:border-danger-700 active:bg-danger-500/15 active:text-danger-700\",\n\t\t\t},\n\t\t\t{\n\t\t\t\tappearance: \"filled\",\n\t\t\t\tpriority: \"danger\",\n\t\t\t\tclass:\n\t\t\t\t\t\"border-transparent bg-filled-danger hover:bg-filled-danger-hover focus-visible:border-danger-600 focus-visible:ring-focus-danger active:bg-filled-danger-active\",\n\t\t\t},\n\t\t\t{\n\t\t\t\tappearance: \"link\",\n\t\t\t\tpriority: \"danger\",\n\t\t\t\tclass: \"text-danger-600 focus-visible:ring-focus-danger\",\n\t\t\t},\n\t\t\t{\n\t\t\t\tappearance: \"ghost\",\n\t\t\t\tpriority: \"neutral\",\n\t\t\t\tclass:\n\t\t\t\t\t\"border-transparent text-strong hover:bg-neutral-500/10 hover:text-strong focus-visible:ring-focus-accent active:bg-neutral-500/15 active:text-strong\",\n\t\t\t},\n\t\t\t{\n\t\t\t\tappearance: \"outlined\",\n\t\t\t\tpriority: \"neutral\",\n\t\t\t\tclass:\n\t\t\t\t\t\"border-form bg-form text-strong hover:border-neutral-400 hover:bg-form-hover hover:text-strong focus-visible:border-accent-600 focus-visible:ring-focus-accent active:border-neutral-400 active:bg-neutral-500/10 active:text-strong focus-visible:active:border-accent-600\",\n\t\t\t},\n\t\t\t{\n\t\t\t\tappearance: \"filled\",\n\t\t\t\tpriority: \"neutral\",\n\t\t\t\tclass:\n\t\t\t\t\t\"border-transparent bg-filled-neutral hover:bg-filled-neutral-hover focus-visible:border-neutral-600 focus-visible:ring-focus-neutral active:bg-filled-neutral-active\",\n\t\t\t},\n\t\t\t{\n\t\t\t\tappearance: \"link\",\n\t\t\t\tpriority: \"neutral\",\n\t\t\t\tclass: \"text-strong focus-visible:ring-focus-accent\",\n\t\t\t},\n\t\t],\n\t},\n);\n\ntype ButtonVariants = VariantProps<typeof buttonVariants>;\n\n/**\n * The props for the `Button` component.\n */\ntype ButtonProps = ButtonHTMLAttributes<HTMLButtonElement> &\n\tWithAsChild &\n\tButtonVariants & {\n\t\t/**\n\t\t * An icon to render inside the button. If the `state` is `\"pending\"`, then\n\t\t * the icon will automatically be replaced with a spinner.\n\t\t */\n\t\ticon?: ReactNode;\n\t};\n\n/**\n * Renders a button or a component that looks like a button, an interactive\n * element activated by a user with a mouse, keyboard, finger, voice command, or\n * other assistive technology. Once activated, it then performs an action, such\n * as submitting a form or opening a dialog.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button\n */\nconst Button = forwardRef<HTMLButtonElement, ButtonProps>(\n\t(\n\t\t{\n\t\t\t\"aria-disabled\": _ariaDisabled,\n\t\t\tappearance = \"outlined\",\n\t\t\tasChild = false,\n\t\t\tchildren,\n\t\t\tclassName,\n\t\t\ticon: propIcon,\n\t\t\ticonPlacement = \"start\",\n\t\t\tisLoading = false,\n\t\t\tonClickCapture,\n\t\t\tpriority = \"default\",\n\t\t\t...props\n\t\t},\n\t\tref,\n\t) => {\n\t\tconst ariaDisabled = _ariaDisabled ?? isLoading;\n\t\tconst icon = isLoading ? <CircleNotch className=\"animate-spin\" /> : propIcon;\n\n\t\tconst _onClickCapture = (event: MouseEvent<HTMLButtonElement>) => {\n\t\t\tif (isLoading) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tevent.stopPropagation();\n\t\t\t}\n\t\t\tonClickCapture?.(event);\n\t\t};\n\n\t\tconst buttonProps = {\n\t\t\t\"aria-disabled\": ariaDisabled,\n\t\t\tclassName: cx(\n\t\t\t\tbuttonVariants({ appearance, priority, isLoading, iconPlacement: icon ? iconPlacement : undefined }),\n\t\t\t\tclassName,\n\t\t\t),\n\t\t\t\"data-loading\": isLoading,\n\t\t\tonClickCapture: _onClickCapture,\n\t\t\tref,\n\t\t\t...props,\n\t\t};\n\n\t\tif (asChild) {\n\t\t\tconst singleChild = Children.only(children);\n\t\t\tinvariant(\n\t\t\t\tisValidElement<ButtonProps>(singleChild),\n\t\t\t\t\"When using `asChild`, Button must be passed a single child as a JSX tag.\",\n\t\t\t);\n\t\t\tconst grandchildren = singleChild.props?.children;\n\n\t\t\treturn (\n\t\t\t\t<Slot {...buttonProps}>\n\t\t\t\t\t{cloneElement(\n\t\t\t\t\t\tsingleChild,\n\t\t\t\t\t\t{},\n\t\t\t\t\t\t<InnerContent appearance={appearance} icon={icon} iconPlacement={iconPlacement}>\n\t\t\t\t\t\t\t{grandchildren}\n\t\t\t\t\t\t</InnerContent>,\n\t\t\t\t\t)}\n\t\t\t\t</Slot>\n\t\t\t);\n\t\t}\n\n\t\treturn (\n\t\t\t<button {...buttonProps}>\n\t\t\t\t<InnerContent appearance={appearance} icon={icon} iconPlacement={iconPlacement}>\n\t\t\t\t\t{children}\n\t\t\t\t</InnerContent>\n\t\t\t</button>\n\t\t);\n\t},\n);\nButton.displayName = \"Button\";\n\nexport { Button, buttonVariants };\nexport type { ButtonProps };\n\ntype InnerContentProps = PropsWithChildren & Pick<ButtonProps, \"appearance\" | \"icon\" | \"iconPlacement\">;\n\nconst InnerContent = ({ appearance, children, icon, iconPlacement }: InnerContentProps) => (\n\t<span\n\t\tclassName={clsx(\n\t\t\t\"inline-flex items-center gap-1.5 focus-within:outline-none focus-visible:outline-none\",\n\t\t\tappearance === \"link\" && \"group-hover:underline\",\n\t\t)}\n\t>\n\t\t{icon && <Icon svg={icon} className={clsx(iconPlacement === \"end\" && \"order-last\")} />}\n\t\t{children}\n\t</span>\n);\n","import { CircleNotch } from \"@phosphor-icons/react/CircleNotch\";\nimport { Slot } from \"@radix-ui/react-slot\";\nimport { cva } from \"class-variance-authority\";\nimport { ButtonHTMLAttributes, Children, cloneElement, forwardRef, isValidElement, MouseEvent, ReactNode } from \"react\";\nimport { cx } from \"../../cx\";\nimport { Icon } from \"../../icon\";\nimport type { VariantProps, WithAsChild } from \"../../types\";\n\nconst iconButtonVariants = cva(\n\t\"inline-flex items-center justify-center rounded-md border focus-within:outline-none focus-visible:ring-4 disabled:pointer-events-none disabled:opacity-50 aria-disabled:opacity-50\",\n\t{\n\t\tvariants: {\n\t\t\t/**\n\t\t\t * Defines the visual style of the Button.\n\t\t\t */\n\t\t\tappearance: {\n\t\t\t\tghost:\n\t\t\t\t\t\"border-transparent text-strong hover:bg-neutral-500/10 hover:text-strong focus-visible:ring-focus-accent active:bg-neutral-500/15 active:text-strong\",\n\t\t\t\toutlined:\n\t\t\t\t\t\"border-form bg-form text-strong hover:border-neutral-400 hover:bg-form-hover hover:text-strong focus-visible:border-accent-600 focus-visible:ring-focus-accent active:border-neutral-400 active:bg-neutral-500/10 active:text-strong focus-visible:active:border-accent-600\",\n\t\t\t},\n\t\t\t/**\n\t\t\t * Whether or not the button is in a loading state, default `false`. Setting `isLoading` will\n\t\t\t * replace the `icon` with a spinner.\n\t\t\t * It will also disable user interaction with the button and set `aria-disabled`.\n\t\t\t */\n\t\t\tisLoading: {\n\t\t\t\tfalse: \"\",\n\t\t\t\ttrue: \"opacity-50\",\n\t\t\t},\n\t\t\t/**\n\t\t\t * The size of the IconButton.\n\t\t\t */\n\t\t\tsize: {\n\t\t\t\txs: \"size-7 sm:size-6\",\n\t\t\t\tsm: \"size-9 sm:size-7\",\n\t\t\t\tmd: \"size-11 sm:size-9\",\n\t\t\t},\n\t\t},\n\t\tdefaultVariants: {\n\t\t\tappearance: \"outlined\",\n\t\t\tsize: \"md\",\n\t\t},\n\t},\n);\n\ntype IconButtonVariants = VariantProps<typeof iconButtonVariants>;\n\n/**\n * The props for the `Button` component.\n */\ntype IconButtonProps = ButtonHTMLAttributes<HTMLButtonElement> &\n\tWithAsChild &\n\tIconButtonVariants & {\n\t\t/**\n\t\t * The accessible label for the icon. This label will be visually hidden but announced to screen reader users, similar to alt text for img tags.\n\t\t */\n\t\tlabel: string;\n\t\t/**\n\t\t * An icon to render inside the button. If the `state` is `\"pending\"`, then\n\t\t * the icon will automatically be replaced with a spinner.\n\t\t */\n\t\ticon: ReactNode;\n\t};\n\n/**\n * Renders a button or a component that looks like a button, an interactive\n * element activated by a user with a mouse, keyboard, finger, voice command, or\n * other assistive technology. Once activated, it then performs an action, such\n * as submitting a form or opening a dialog.\n * Renders only a single icon as children with an accessible, screen-reader-only label.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button\n */\nconst IconButton = forwardRef<HTMLButtonElement, IconButtonProps>(\n\t(\n\t\t{\n\t\t\t\"aria-disabled\": _ariaDisabled,\n\t\t\tappearance,\n\t\t\tasChild = false,\n\t\t\tchildren,\n\t\t\tclassName,\n\t\t\tisLoading = false,\n\t\t\ticon: propIcon,\n\t\t\tlabel,\n\t\t\tonClickCapture,\n\t\t\tsize,\n\t\t\t...props\n\t\t},\n\t\tref,\n\t) => {\n\t\tconst ariaDisabled = _ariaDisabled ?? isLoading;\n\n\t\tconst _onClickCapture = (event: MouseEvent<HTMLButtonElement>) => {\n\t\t\tif (isLoading) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tevent.stopPropagation();\n\t\t\t}\n\t\t\tonClickCapture?.(event);\n\t\t};\n\n\t\tconst buttonProps = {\n\t\t\t\"aria-disabled\": ariaDisabled,\n\t\t\tclassName: cx(iconButtonVariants({ appearance, isLoading, size }), className),\n\t\t\t\"data-loading\": isLoading,\n\t\t\tonClickCapture: _onClickCapture,\n\t\t\tref,\n\t\t\t...props,\n\t\t};\n\n\t\tif (asChild) {\n\t\t\tconst singleChild = Children.only(children);\n\t\t\tconst isValidChild = isValidElement(singleChild);\n\t\t\tconst icon = isLoading ? <CircleNotch className=\"animate-spin\" /> : propIcon;\n\n\t\t\treturn <Slot {...buttonProps}>{isValidChild && cloneElement(singleChild, {}, <Icon svg={icon} />)}</Slot>;\n\t\t}\n\n\t\tconst icon = isLoading ? <CircleNotch className=\"animate-spin\" /> : propIcon;\n\n\t\treturn (\n\t\t\t<button {...buttonProps}>\n\t\t\t\t<span className=\"sr-only\">{label}</span>\n\t\t\t\t<Icon svg={icon} />\n\t\t\t</button>\n\t\t);\n\t},\n);\nIconButton.displayName = \"IconButton\";\n\nexport { IconButton };\nexport type { IconButtonProps };\n"]}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } }var _chunkD3F6KEREcjs = require('./chunk-D3F6KERE.cjs');var _reactseparator = require('@radix-ui/react-separator'); var a = _interopRequireWildcard(_reactseparator);var _react = require('react');var _jsxruntime = require('react/jsx-runtime');var e=_react.forwardRef.call(void 0, ({className:i,orientation:r="horizontal",decorative:o=!0,...p},m)=>_jsxruntime.jsx.call(void 0, a.Root,{ref:m,"aria-orientation":o?void 0:r,decorative:o,orientation:r,className:_chunkD3F6KEREcjs.a.call(void 0, "shrink-0 bg-gray-500/20 dark-high-contrast:bg-black high-contrast:bg-black dark:bg-gray-600/20",r==="horizontal"?"h-px w-full":"h-full w-px",i),...p}));e.displayName="Separator";exports.a = e;
2
+ //# sourceMappingURL=chunk-ROHPZJ5N.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../packages/separator/src/separator.tsx"],"names":["SeparatorPrimitive","forwardRef","jsx","Separator","className","orientation","decorative","props","ref","cx"],"mappings":"yCAAA,UAAYA,MAAwB,4BACpC,OAAS,cAAAC,MAAkB,QAW1B,cAAAC,MAAA,oBAJD,IAAMC,EAAYF,EAGhB,CAAC,CAAE,UAAAG,EAAW,YAAAC,EAAc,aAAc,WAAAC,EAAa,GAAM,GAAGC,CAAM,EAAGC,IAC1EN,EAAoB,OAAnB,CACA,IAAKM,EACL,mBAAkBF,EAAa,OAAYD,EAC3C,WAAYC,EACZ,YAAaD,EACb,UAAWI,EACV,iGACAJ,IAAgB,aAAe,cAAgB,cAC/CD,CACD,EACC,GAAGG,EACL,CACA,EACDJ,EAAU,YAAc","sourcesContent":["import * as SeparatorPrimitive from \"@radix-ui/react-separator\";\nimport { forwardRef } from \"react\";\nimport type { ComponentPropsWithoutRef, ElementRef } from \"react\";\nimport { cx } from \"../../cx\";\n\n/**\n * Visually or semantically separates content.\n */\nconst Separator = forwardRef<\n\tElementRef<typeof SeparatorPrimitive.Root>,\n\tComponentPropsWithoutRef<typeof SeparatorPrimitive.Root>\n>(({ className, orientation = \"horizontal\", decorative = true, ...props }, ref) => (\n\t<SeparatorPrimitive.Root\n\t\tref={ref}\n\t\taria-orientation={decorative ? undefined : orientation}\n\t\tdecorative={decorative}\n\t\torientation={orientation}\n\t\tclassName={cx(\n\t\t\t\"shrink-0 bg-gray-500/20 dark-high-contrast:bg-black high-contrast:bg-black dark:bg-gray-600/20\",\n\t\t\torientation === \"horizontal\" ? \"h-px w-full\" : \"h-full w-px\",\n\t\t\tclassName,\n\t\t)}\n\t\t{...props}\n\t/>\n));\nSeparator.displayName = \"Separator\";\n\nexport { Separator };\n"]}
@@ -0,0 +1,4 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var _chunkD3F6KEREcjs = require('./chunk-D3F6KERE.cjs');var _reactslot = require('@radix-ui/react-slot');var _prismjs = require('prismjs'); var _prismjs2 = _interopRequireDefault(_prismjs);var _react = require('react');require('prismjs/components/prism-bash.js');require('prismjs/components/prism-csharp.js');require('prismjs/components/prism-css.js');require('prismjs/components/prism-go.js');require('prismjs/components/prism-java.js');require('prismjs/components/prism-javascript.js');require('prismjs/components/prism-json.js');require('prismjs/components/prism-jsx.js');require('prismjs/components/prism-markup.js');require('prismjs/components/prism-python.js');require('prismjs/components/prism-ruby.js');require('prismjs/components/prism-rust.js');require('prismjs/components/prism-tsx.js');require('prismjs/components/prism-typescript.js');require('prismjs/components/prism-yaml.js');var _CaretDown = require('@phosphor-icons/react/CaretDown');var _Check = require('@phosphor-icons/react/Check');var _Copy = require('@phosphor-icons/react/Copy');var _usehooks = require('@uidotdev/usehooks');var _tinyinvariant = require('tiny-invariant'); var _tinyinvariant2 = _interopRequireDefault(_tinyinvariant);var b=["bash","cs","csharp","css","dotnet","go","html","java","javascript","js","json","jsx","markup","plain","plaintext","py","python","rb","ruby","rust","sh","shell","text","ts","tsx","txt","typescript","xml","yaml","yml"];function $(e){if(!e)return"sh";let o=e.trim().slice(e.indexOf("-")+1);return S(o)?o:"sh"}var S=e=>typeof e=="string"&&b.includes(e);function L(e="sh"){return`language-${_nullishCoalesce(e, () => ("sh"))}`}var _jsxruntime = require('react/jsx-runtime');var B=_react.createContext.call(void 0, {codeId:void 0,copyText:"",hasCodeExpander:!1,isCodeExpanded:!1,registerCodeId:()=>{},setCopyText:()=>{},setHasCodeExpander:()=>{},setIsCodeExpanded:()=>{},unregisterCodeId:()=>{}}),H= exports.CodeBlock =_react.forwardRef.call(void 0, ({className:e,...o},r)=>{let[t,a]=_react.useState.call(void 0, ""),[n,i]=_react.useState.call(void 0, !1),[s,c]=_react.useState.call(void 0, !1),[d,f]=_react.useState.call(void 0, void 0),h=_react.useMemo.call(void 0, ()=>({codeId:d,copyText:t,hasCodeExpander:n,isCodeExpanded:s,registerCodeId:p=>{f(C=>(_tinyinvariant2.default.call(void 0, C==null,"You can only render a single CodeBlockCode within a CodeBlock."),p))},setCopyText:a,setHasCodeExpander:i,setIsCodeExpanded:c,unregisterCodeId:p=>{f(C=>{_tinyinvariant2.default.call(void 0, C===p,"You can only render a single CodeBlockCode within a CodeBlock.")})}}),[d,t,n,s]);return _jsxruntime.jsx.call(void 0, B.Provider,{value:h,children:_jsxruntime.jsx.call(void 0, "div",{className:_chunkD3F6KEREcjs.a.call(void 0, "overflow-hidden rounded-md border border-gray-300 bg-gray-50 font-mono text-[0.8125rem]",e),ref:r,...o})})});H.displayName="CodeBlock";var I=_react.forwardRef.call(void 0, ({className:e,...o},r)=>_jsxruntime.jsx.call(void 0, "div",{className:_chunkD3F6KEREcjs.a.call(void 0, "relative",e),ref:r,...o}));I.displayName="CodeBlockBody";var N=_react.forwardRef.call(void 0, (e,o)=>{let{className:r,language:t="text",style:a,value:n}=e,i=_react.useId.call(void 0, ),{hasCodeExpander:s,isCodeExpanded:c,registerCodeId:d,setCopyText:f,unregisterCodeId:h}=_react.useContext.call(void 0, B),p=_nullishCoalesce(_optionalChain([n, 'optionalAccess', _2 => _2.trim, 'call', _3 => _3()]), () => ("")),[C,j]=_react.useState.call(void 0, p);return _react.useEffect.call(void 0, ()=>{let E=_prismjs2.default.languages[t];_tinyinvariant2.default.call(void 0, E,`CodeBlock does not support the language "${t}". The syntax highlighter does not have a grammar for this language. The supported languages are: ${b.join(", ")}.`);let z=_prismjs2.default.highlight(p,E,t);j(z)},[p,t]),_react.useEffect.call(void 0, ()=>{f(p)},[p,f]),_react.useEffect.call(void 0, ()=>(d(i),()=>{h(i)}),[i,d,h]),_jsxruntime.jsx.call(void 0, "pre",{"aria-expanded":s?c:void 0,className:_chunkD3F6KEREcjs.a.call(void 0, L(t),"scrollbar overflow-x-auto overflow-y-hidden p-4 pr-[3.375rem] firefox:after:mr-[3.375rem] firefox:after:inline-block firefox:after:content-['']","aria-collapsed:max-h-[13.6rem]",r),"data-lang":t,id:i,ref:o,style:{...a,tabSize:2,MozTabSize:2},children:_jsxruntime.jsx.call(void 0, "code",{dangerouslySetInnerHTML:{__html:C}})})});N.displayName="CodeBlockCode";var A=_react.forwardRef.call(void 0, ({className:e,...o},r)=>_jsxruntime.jsx.call(void 0, "div",{className:_chunkD3F6KEREcjs.a.call(void 0, "flex items-center gap-1 border-b border-gray-300 bg-gray-100 px-4 py-2 text-gray-700",e),ref:r,...o}));A.displayName="CodeBlockHeader";var P=_react.forwardRef.call(void 0, ({asChild:e=!1,className:o,...r},t)=>_jsxruntime.jsx.call(void 0, e?_reactslot.Slot:"h3",{ref:t,className:_chunkD3F6KEREcjs.a.call(void 0, "font-mono text-[0.8125rem] font-normal",o),...r}));P.displayName="CodeBlockTitle";var D=_react.forwardRef.call(void 0, ({className:e,onCopy:o,onCopyError:r,style:t},a)=>{let{copyText:n}=_react.useContext.call(void 0, B),[,i]=_usehooks.useCopyToClipboard.call(void 0, ),[s,c]=_react.useState.call(void 0, !1);return _react.useEffect.call(void 0, ()=>{if(s){let d=window.setTimeout(()=>{c(!1)},2e3);return()=>{clearTimeout(d)}}},[s]),_jsxruntime.jsxs.call(void 0, "button",{type:"button",className:_chunkD3F6KEREcjs.a.call(void 0, "absolute right-3 top-3 z-10 flex h-7 w-7 items-center justify-center rounded border border-gray-300 bg-gray-50 shadow-[-1rem_0_0.75rem_-0.375rem_hsl(var(--gray-50)),1rem_0_0_-0.25rem_hsl(var(--gray-50))] hover:border-gray-400 hover:bg-gray-200 focus-visible:border-accent-600 focus-visible:outline-none focus-visible:ring-4 focus-visible:ring-focus-accent",s&&"w-auto gap-1 border-transparent bg-filled-success pl-2 pr-1.5 text-on-filled hover:border-transparent hover:bg-filled-success focus:bg-filled-success focus-visible:border-success-600 focus-visible:ring-focus-success",e),ref:a,style:t,onClick:async()=>{try{await i(n),_optionalChain([o, 'optionalCall', _4 => _4(n)]),c(!0)}catch(d){_optionalChain([r, 'optionalCall', _5 => _5(d)])}},children:[_jsxruntime.jsx.call(void 0, "span",{className:"sr-only",children:"Copy code"}),s?_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:["Copied",_jsxruntime.jsx.call(void 0, _Check.Check,{className:"h-4 w-4",weight:"bold"})]}):_jsxruntime.jsx.call(void 0, _Copy.Copy,{className:"-ml-px h-5 w-5"})]})});D.displayName="CodeBlockCopyButton";var _=_react.forwardRef.call(void 0, ({className:e,onClick:o,...r},t)=>{let{codeId:a,isCodeExpanded:n,setIsCodeExpanded:i,setHasCodeExpander:s}=_react.useContext.call(void 0, B);return _react.useEffect.call(void 0, ()=>(s(!0),()=>{s(!1)}),[s]),_jsxruntime.jsxs.call(void 0, "button",{...r,"aria-controls":a,"aria-expanded":n,className:_chunkD3F6KEREcjs.a.call(void 0, "flex w-full items-center justify-center gap-0.5 border-t border-gray-300 bg-gray-50 px-4 py-2 font-sans text-gray-700 hover:bg-gray-100",e),ref:t,type:"button",onClick:c=>{i(d=>!d),_optionalChain([o, 'optionalCall', _6 => _6(c)])},children:[n?"Show less":"Show more"," ",_jsxruntime.jsx.call(void 0, _CaretDown.CaretDown,{className:_chunkD3F6KEREcjs.a.call(void 0, "h-4 w-4",n&&"rotate-180","transition-all duration-150"),weight:"bold"})]})});_.displayName="CodeBlockExpanderButton";function G(e,...o){if(!U(e)||!Array.isArray(o))throw new Error("It looks like you tried to call `fmtCode` as a function. Make sure to use it as a tagged template.\n Example: fmtCode`SELECT * FROM users`, not fmtCode('SELECT * FROM users')");let r=String.raw({raw:e},...o),t=K(r);return r.trim().split(`
2
+ `).map(n=>/^\S+/.test(n)?n:n.slice(t)).join(`
3
+ `)}function K(e){let o=e.match(/^[ \t]*(?=\S)/gm);return o?o.reduce((r,t)=>Math.min(r,t.length),1/0):0}function U(e){return Array.isArray(e)&&"raw"in e&&Array.isArray(e.raw)}var _zod = require('zod');var X=["file","cli"],Z=_zod.z.object({collapsible:_zod.z.boolean().default(!1),disableCopy:_zod.z.boolean().default(!1),mode:_zod.z.enum(X).optional(),title:_zod.z.string().trim().optional()}),k= exports.defaultMeta ={collapsible:!1,disableCopy:!1,mode:void 0,title:void 0};function ee(e){let o=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _7 => _7.trim, 'call', _8 => _8()]), () => (""));if(!o)return k;let r=oe(o).reduce((t,a)=>{let[n,i]=a.split("=");if(!n)return t;let s=te(i);return t[n]=_nullishCoalesce(s, () => (!0)),t},{});try{let t=Z.parse(r);return{...k,...t}}catch (e2){return k}}function te(e){return _optionalChain([e, 'optionalAccess', _9 => _9.trim, 'call', _10 => _10(), 'access', _11 => _11.replace, 'call', _12 => _12(/^"(.*)"$/,"$1")])}function oe(e){let o=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _13 => _13.trim, 'call', _14 => _14()]), () => ("")),r=[],t="",a=!1;for(let n of o)n===" "&&!a?t&&(r.push(t),t=""):(n==='"'&&(a=!a),t+=n);return t&&r.push(t),r}exports.CodeBlock = H; exports.CodeBlockBody = I; exports.CodeBlockCode = N; exports.CodeBlockCopyButton = D; exports.CodeBlockExpanderButton = _; exports.CodeBlockHeader = A; exports.CodeBlockTitle = P; exports.defaultMeta = k; exports.fmtCode = G; exports.formatLanguageClassName = L; exports.isSupportedLanguage = S; exports.parseLanguage = $; exports.parseMetastring = ee; exports.supportedLanguages = b;
4
+ //# sourceMappingURL=code-block.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../packages/code-block/src/code-block.tsx","../packages/code-block/src/supported-languages.ts","../packages/code-block/src/fmt-code.ts","../packages/code-block/src/parse-metastring.ts"],"names":["Slot","Prism","createContext","forwardRef","useContext","useEffect","useId","useMemo","useState","CaretDown","Check","Copy","useCopyToClipboard","assert","supportedLanguages","parseLanguage","value","maybeLanguage","isSupportedLanguage","formatLanguageClassName","language","Fragment","jsx","jsxs","CodeBlockContext","CodeBlock","className","props","ref","copyText","setCopyText","hasCodeExpander","setHasCodeExpander","isCodeExpanded","setIsCodeExpanded","codeId","setCodeId","context","id","old","cx","CodeBlockBody","CodeBlockCode","style","registerCodeId","unregisterCodeId","trimmedCode","highlightedCodeInnerHtml","setHighlightedCodeInnerHtml","grammar","newHighlightedCodeInnerHtml","CodeBlockHeader","CodeBlockTitle","asChild","CodeBlockCopyButton","onCopy","onCopyError","copyToClipboard","copied","setCopied","timeoutId","error","CodeBlockExpanderButton","onClick","event","prev","fmtCode","strings","values","isTemplateStringsArray","text","minIndent","findMinIndent","line","match","acc","curr","z","modes","metaSchema","defaultMeta","parseMetastring","metastring","metaJson","tokenizeMetastring","token","key","_value","normalizeValue","parsed","input","result","currentString","inQuotes","char"],"mappings":"yCAAA,OAAS,QAAAA,MAAY,uBACrB,OAAOC,MAAW,UAClB,OACC,iBAAAC,EAEA,cAAAC,EAGA,cAAAC,EACA,aAAAC,EACA,SAAAC,EACA,WAAAC,EACA,YAAAC,MACM,QACP,MAAO,mCACP,MAAO,mCACP,MAAO,qCACP,MAAO,kCACP,MAAO,iCACP,MAAO,mCACP,MAAO,yCACP,MAAO,mCACP,MAAO,kCACP,MAAO,qCACP,MAAO,qCACP,MAAO,mCACP,MAAO,mCACP,MAAO,kCACP,MAAO,yCACP,MAAO,mCACP,OAAS,aAAAC,MAAiB,kCAC1B,OAAS,SAAAC,MAAa,8BACtB,OAAS,QAAAC,MAAY,6BACrB,OAAS,sBAAAC,MAA0B,qBACnC,OAAOC,MAAY,iBC9BZ,IAAMC,EAAqB,CACjC,OACA,KACA,SACA,MACA,SACA,KACA,OACA,OACA,aACA,KACA,OACA,MACA,SACA,QACA,YACA,KACA,SACA,KACA,OACA,OACA,KACA,QACA,OACA,KACA,MACA,MACA,aACA,MACA,OACA,KACD,EAWA,SAASC,EAAcC,EAA+F,CACrH,GAAI,CAACA,EACJ,MAAO,KAKR,IAAMC,EAAgBD,EAAM,KAAK,EAAE,MAAMA,EAAM,QAAQ,GAAG,EAAI,CAAC,EAE/D,OAAOE,EAAoBD,CAAa,EAAIA,EAAgB,IAC7D,CAKA,IAAMC,EAAuBF,GACrB,OAAOA,GAAU,UAAYF,EAAmB,SAASE,CAA0B,EAY3F,SAASG,EAAwBC,EAA0C,KAAM,CAGhF,MADiC,YADpBA,GAAY,IACwB,EAElD,CD4BG,OAkKE,YAAAC,EAlKF,OAAAC,EAkKE,QAAAC,MAlKF,oBA9CH,IAAMC,EAAmBtB,EAAoC,CAC5D,OAAQ,OACR,S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HD,EAAO,KAAKC,CAAa,EAGnBD,CACR","sourcesContent":["import { Slot } from \"@radix-ui/react-slot\";\nimport Prism from \"prismjs\";\nimport {\n\tcreateContext,\n\tDispatch,\n\tforwardRef,\n\tHTMLAttributes,\n\tSetStateAction,\n\tuseContext,\n\tuseEffect,\n\tuseId,\n\tuseMemo,\n\tuseState,\n} from \"react\";\nimport \"prismjs/components/prism-bash.js\";\nimport \"prismjs/components/prism-bash.js\";\nimport \"prismjs/components/prism-csharp.js\";\nimport \"prismjs/components/prism-css.js\";\nimport \"prismjs/components/prism-go.js\";\nimport \"prismjs/components/prism-java.js\";\nimport \"prismjs/components/prism-javascript.js\";\nimport \"prismjs/components/prism-json.js\";\nimport \"prismjs/components/prism-jsx.js\";\nimport \"prismjs/components/prism-markup.js\";\nimport \"prismjs/components/prism-python.js\";\nimport \"prismjs/components/prism-ruby.js\";\nimport \"prismjs/components/prism-rust.js\";\nimport \"prismjs/components/prism-tsx.js\";\nimport \"prismjs/components/prism-typescript.js\";\nimport \"prismjs/components/prism-yaml.js\";\nimport { CaretDown } from \"@phosphor-icons/react/CaretDown\";\nimport { Check } from \"@phosphor-icons/react/Check\";\nimport { Copy } from \"@phosphor-icons/react/Copy\";\nimport { useCopyToClipboard } from \"@uidotdev/usehooks\";\nimport assert from \"tiny-invariant\";\nimport { cx } from \"../../cx\";\nimport type { WithStyleProps } from \"../../types/src/with-style-props\";\nimport { LineRange } from \"./line-numbers\";\nimport { formatLanguageClassName, supportedLanguages } from \"./supported-languages\";\nimport type { SupportedLanguage } from \"./supported-languages\";\n\n/**\n * TODO(cody):\n * - fix line numbers, maybe try grid instead of :before and flex?\n * - fix line hightlighting\n * - fix line wrapping? horizontal scrolling has problems w/ line highlighting :(\n */\n\ntype CodeBlockContextType = {\n\tcodeId: string | undefined;\n\tcopyText: string;\n\thasCodeExpander: boolean;\n\tisCodeExpanded: boolean;\n\tregisterCodeId: (id: string) => void;\n\tsetCopyText: (newCopyText: string) => void;\n\tsetHasCodeExpander: (value: boolean) => void;\n\tsetIsCodeExpanded: Dispatch<SetStateAction<boolean>>;\n\tunregisterCodeId: (id: string) => void;\n};\n\nconst CodeBlockContext = createContext<CodeBlockContextType>({\n\tcodeId: undefined,\n\tcopyText: \"\",\n\thasCodeExpander: false,\n\tisCodeExpanded: false,\n\tregisterCodeId: () => {},\n\tsetCopyText: () => {},\n\tsetHasCodeExpander: () => {},\n\tsetIsCodeExpanded: () => {},\n\tunregisterCodeId: () => {},\n});\n\nconst CodeBlock = forwardRef<HTMLDivElement, HTMLAttributes<HTMLDivElement>>(({ className, ...props }, ref) => {\n\tconst [copyText, setCopyText] = useState(\"\");\n\tconst [hasCodeExpander, setHasCodeExpander] = useState(false);\n\tconst [isCodeExpanded, setIsCodeExpanded] = useState(false);\n\tconst [codeId, setCodeId] = useState<string | undefined>(undefined);\n\n\tconst context: CodeBlockContextType = useMemo(\n\t\t() =>\n\t\t\t({\n\t\t\t\tcodeId,\n\t\t\t\tcopyText,\n\t\t\t\thasCodeExpander,\n\t\t\t\tisCodeExpanded,\n\t\t\t\tregisterCodeId: (id) => {\n\t\t\t\t\tsetCodeId((old) => {\n\t\t\t\t\t\tassert(old == null, \"You can only render a single CodeBlockCode within a CodeBlock.\");\n\t\t\t\t\t\treturn id;\n\t\t\t\t\t});\n\t\t\t\t},\n\t\t\t\tsetCopyText,\n\t\t\t\tsetHasCodeExpander,\n\t\t\t\tsetIsCodeExpanded,\n\t\t\t\tunregisterCodeId: (id) => {\n\t\t\t\t\tsetCodeId((old) => {\n\t\t\t\t\t\tassert(old === id, \"You can only render a single CodeBlockCode within a CodeBlock.\");\n\t\t\t\t\t\treturn undefined;\n\t\t\t\t\t});\n\t\t\t\t},\n\t\t\t}) as const,\n\t\t[codeId, copyText, hasCodeExpander, isCodeExpanded],\n\t);\n\n\treturn (\n\t\t<CodeBlockContext.Provider value={context}>\n\t\t\t<div\n\t\t\t\tclassName={cx(\n\t\t\t\t\t\"overflow-hidden rounded-md border border-gray-300 bg-gray-50 font-mono text-[0.8125rem]\",\n\t\t\t\t\tclassName,\n\t\t\t\t)}\n\t\t\t\tref={ref}\n\t\t\t\t{...props}\n\t\t\t/>\n\t\t</CodeBlockContext.Provider>\n\t);\n});\nCodeBlock.displayName = \"CodeBlock\";\n\nconst CodeBlockBody = forwardRef<HTMLDivElement, HTMLAttributes<HTMLDivElement>>(({ className, ...props }, ref) => (\n\t<div className={cx(\"relative\", className)} ref={ref} {...props} />\n));\nCodeBlockBody.displayName = \"CodeBlockBody\";\n\ntype CodeBlockCodeProps = WithStyleProps & {\n\t/**\n\t * The code to display in the code block. Should be code formatted as a string. This code will be passed to our syntax highlighter.\n\t */\n\tvalue: string;\n\t/**\n\t * @todo not implemented yet\n\t */\n\thighlightLines?: (LineRange | number)[];\n\t/**\n\t * The language of the code block. This will be used to determine how to syntax highlight the code. @default `\"text\"`.\n\t */\n\tlanguage?: SupportedLanguage;\n\t/**\n\t * @todo not implemented yet\n\t */\n\tshowLineNumbers?: boolean;\n};\n\nconst CodeBlockCode = forwardRef<HTMLPreElement, CodeBlockCodeProps>((props, ref) => {\n\tconst { className, language = \"text\", style, value } = props;\n\tconst id = useId();\n\tconst { hasCodeExpander, isCodeExpanded, registerCodeId, setCopyText, unregisterCodeId } =\n\t\tuseContext(CodeBlockContext);\n\n\t// trim any leading and trailing whitespace/empty lines\n\tconst trimmedCode = value?.trim() ?? \"\";\n\tconst [highlightedCodeInnerHtml, setHighlightedCodeInnerHtml] = useState(trimmedCode);\n\n\tuseEffect(() => {\n\t\tconst grammar = Prism.languages[language];\n\t\tassert(\n\t\t\tgrammar,\n\t\t\t`CodeBlock does not support the language \"${language}\". The syntax highlighter does not have a grammar for this language. The supported languages are: ${supportedLanguages.join(\", \")}.`,\n\t\t);\n\t\tconst newHighlightedCodeInnerHtml = Prism.highlight(trimmedCode, grammar, language);\n\t\tsetHighlightedCodeInnerHtml(newHighlightedCodeInnerHtml);\n\t}, [trimmedCode, language]);\n\n\tuseEffect(() => {\n\t\tsetCopyText(trimmedCode);\n\t}, [trimmedCode, setCopyText]);\n\n\tuseEffect(() => {\n\t\tregisterCodeId(id);\n\n\t\treturn () => {\n\t\t\tunregisterCodeId(id);\n\t\t};\n\t}, [id, registerCodeId, unregisterCodeId]);\n\n\treturn (\n\t\t<pre\n\t\t\taria-expanded={hasCodeExpander ? isCodeExpanded : undefined}\n\t\t\tclassName={cx(\n\t\t\t\tformatLanguageClassName(language),\n\t\t\t\t\"scrollbar overflow-x-auto overflow-y-hidden p-4 pr-[3.375rem] firefox:after:mr-[3.375rem] firefox:after:inline-block firefox:after:content-['']\",\n\t\t\t\t\"aria-collapsed:max-h-[13.6rem]\",\n\t\t\t\tclassName,\n\t\t\t)}\n\t\t\tdata-lang={language}\n\t\t\tid={id}\n\t\t\tref={ref}\n\t\t\tstyle={{\n\t\t\t\t...style,\n\t\t\t\ttabSize: 2,\n\t\t\t\tMozTabSize: 2,\n\t\t\t}}\n\t\t>\n\t\t\t<code dangerouslySetInnerHTML={{ __html: highlightedCodeInnerHtml }} />\n\t\t</pre>\n\t);\n});\nCodeBlockCode.displayName = \"CodeBlockCode\";\n\nconst CodeBlockHeader = forwardRef<HTMLDivElement, HTMLAttributes<HTMLDivElement>>(({ className, ...props }, ref) => (\n\t<div\n\t\tclassName={cx(\"flex items-center gap-1 border-b border-gray-300 bg-gray-100 px-4 py-2 text-gray-700\", className)}\n\t\tref={ref}\n\t\t{...props}\n\t/>\n));\nCodeBlockHeader.displayName = \"CodeBlockHeader\";\n\nconst CodeBlockTitle = forwardRef<HTMLHeadingElement, HTMLAttributes<HTMLHeadingElement> & { asChild?: boolean }>(\n\t({ asChild = false, className, ...props }, ref) => {\n\t\tconst Comp = asChild ? Slot : \"h3\";\n\t\treturn <Comp ref={ref} className={cx(\"font-mono text-[0.8125rem] font-normal\", className)} {...props} />;\n\t},\n);\nCodeBlockTitle.displayName = \"CodeBlockTitle\";\n\ntype CodeBlockCopyButtonProps = WithStyleProps & {\n\t/**\n\t * Callback fired when the copy button is clicked, passes the copied text as an argument.\n\t */\n\tonCopy?: (value: string) => void;\n\t/**\n\t * Callback fired when an error occurs during copying.\n\t */\n\tonCopyError?: (error: unknown) => void;\n};\n\nconst CodeBlockCopyButton = forwardRef<HTMLButtonElement, CodeBlockCopyButtonProps>(\n\t({ className, onCopy, onCopyError, style }, ref) => {\n\t\tconst { copyText } = useContext(CodeBlockContext);\n\t\tconst [, copyToClipboard] = useCopyToClipboard();\n\t\tconst [copied, setCopied] = useState(false);\n\n\t\tuseEffect(() => {\n\t\t\tif (copied) {\n\t\t\t\tconst timeoutId = window.setTimeout(() => {\n\t\t\t\t\tsetCopied(false);\n\t\t\t\t}, 2000);\n\n\t\t\t\treturn () => {\n\t\t\t\t\tclearTimeout(timeoutId);\n\t\t\t\t};\n\t\t\t}\n\t\t}, [copied]);\n\n\t\treturn (\n\t\t\t<button\n\t\t\t\ttype=\"button\"\n\t\t\t\tclassName={cx(\n\t\t\t\t\t\"absolute right-3 top-3 z-10 flex h-7 w-7 items-center justify-center rounded border border-gray-300 bg-gray-50 shadow-[-1rem_0_0.75rem_-0.375rem_hsl(var(--gray-50)),1rem_0_0_-0.25rem_hsl(var(--gray-50))] hover:border-gray-400 hover:bg-gray-200 focus-visible:border-accent-600 focus-visible:outline-none focus-visible:ring-4 focus-visible:ring-focus-accent\",\n\t\t\t\t\tcopied &&\n\t\t\t\t\t\t\"w-auto gap-1 border-transparent bg-filled-success pl-2 pr-1.5 text-on-filled hover:border-transparent hover:bg-filled-success focus:bg-filled-success focus-visible:border-success-600 focus-visible:ring-focus-success\",\n\t\t\t\t\tclassName,\n\t\t\t\t)}\n\t\t\t\tref={ref}\n\t\t\t\tstyle={style}\n\t\t\t\tonClick={async () => {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait copyToClipboard(copyText);\n\t\t\t\t\t\tonCopy?.(copyText);\n\t\t\t\t\t\tsetCopied(true);\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tonCopyError?.(error);\n\t\t\t\t\t}\n\t\t\t\t}}\n\t\t\t>\n\t\t\t\t<span className=\"sr-only\">Copy code</span>\n\t\t\t\t{copied ? (\n\t\t\t\t\t<>\n\t\t\t\t\t\tCopied\n\t\t\t\t\t\t<Check className=\"h-4 w-4\" weight=\"bold\" />\n\t\t\t\t\t</>\n\t\t\t\t) : (\n\t\t\t\t\t<Copy className=\"-ml-px h-5 w-5\" />\n\t\t\t\t)}\n\t\t\t</button>\n\t\t);\n\t},\n);\nCodeBlockCopyButton.displayName = \"CodeBlockCopyButton\";\n\ntype CodeBlockExpanderButtonProps = Omit<\n\tHTMLAttributes<HTMLButtonElement>,\n\t\"children\" | \"aria-controls\" | \"aria-expanded\"\n>;\n\nconst CodeBlockExpanderButton = forwardRef<HTMLButtonElement, CodeBlockExpanderButtonProps>(\n\t({ className, onClick, ...props }, ref) => {\n\t\tconst { codeId, isCodeExpanded, setIsCodeExpanded, setHasCodeExpander } = useContext(CodeBlockContext);\n\n\t\tuseEffect(() => {\n\t\t\tsetHasCodeExpander(true);\n\n\t\t\treturn () => {\n\t\t\t\tsetHasCodeExpander(false);\n\t\t\t};\n\t\t}, [setHasCodeExpander]);\n\n\t\treturn (\n\t\t\t<button\n\t\t\t\t{...props}\n\t\t\t\taria-controls={codeId}\n\t\t\t\taria-expanded={isCodeExpanded}\n\t\t\t\tclassName={cx(\n\t\t\t\t\t\"flex w-full items-center justify-center gap-0.5 border-t border-gray-300 bg-gray-50 px-4 py-2 font-sans text-gray-700 hover:bg-gray-100\",\n\t\t\t\t\tclassName,\n\t\t\t\t)}\n\t\t\t\tref={ref}\n\t\t\t\ttype=\"button\"\n\t\t\t\tonClick={(event) => {\n\t\t\t\t\tsetIsCodeExpanded((prev) => !prev);\n\t\t\t\t\tonClick?.(event);\n\t\t\t\t}}\n\t\t\t>\n\t\t\t\t{isCodeExpanded ? \"Show less\" : \"Show more\"}{\" \"}\n\t\t\t\t<CaretDown\n\t\t\t\t\tclassName={cx(\"h-4 w-4\", isCodeExpanded && \"rotate-180\", \"transition-all duration-150\")}\n\t\t\t\t\tweight=\"bold\"\n\t\t\t\t/>\n\t\t\t</button>\n\t\t);\n\t},\n);\nCodeBlockExpanderButton.displayName = \"CodeBlockExpanderButton\";\n\nexport {\n\tCodeBlock,\n\tCodeBlockBody,\n\tCodeBlockCode,\n\tCodeBlockCopyButton,\n\tCodeBlockExpanderButton,\n\tCodeBlockHeader,\n\tCodeBlockTitle,\n};\n","/**\n * List of supported languages for syntax highlighting.\n * @private\n */\nexport const supportedLanguages = [\n\t\"bash\",\n\t\"cs\",\n\t\"csharp\",\n\t\"css\",\n\t\"dotnet\",\n\t\"go\",\n\t\"html\",\n\t\"java\",\n\t\"javascript\",\n\t\"js\",\n\t\"json\",\n\t\"jsx\",\n\t\"markup\",\n\t\"plain\",\n\t\"plaintext\",\n\t\"py\",\n\t\"python\",\n\t\"rb\",\n\t\"ruby\",\n\t\"rust\",\n\t\"sh\",\n\t\"shell\",\n\t\"text\",\n\t\"ts\",\n\t\"tsx\",\n\t\"txt\",\n\t\"typescript\",\n\t\"xml\",\n\t\"yaml\",\n\t\"yml\",\n] as const;\n\n/**\n * Supported languages for syntax highlighting.\n */\ntype SupportedLanguage = (typeof supportedLanguages)[number];\n\n/**\n * Parses a markdown code block (```) language class into a SupportedLanguage.\n * Defaults to \"sh\" if no supported language is found.\n */\nfunction parseLanguage(value: `language-${string}` | `lang-${string}` | (string & {}) | undefined): SupportedLanguage {\n\tif (!value) {\n\t\treturn \"sh\";\n\t}\n\n\t// remove leading \"language-\" and \"lang-\" prefixes\n\t// find first '-' and slice from there\n\tconst maybeLanguage = value.trim().slice(value.indexOf(\"-\") + 1);\n\n\treturn isSupportedLanguage(maybeLanguage) ? maybeLanguage : \"sh\";\n}\n\n/**\n * Type Predicate: checks if an arbitrary value is a supported syntax highlighting language.\n */\nconst isSupportedLanguage = (value: unknown): value is SupportedLanguage => {\n\treturn typeof value === \"string\" && supportedLanguages.includes(value as SupportedLanguage);\n};\n\n/**\n * A class name for a language that Prism.js can understand.\n */\ntype LanguageClass = `language-${SupportedLanguage}`;\n\n/**\n * Formats a language name into a class name that Prism.js can understand.\n * @default \"language-sh\"\n */\nfunction formatLanguageClassName(language: SupportedLanguage | undefined = \"sh\") {\n\tconst lang = language ?? \"sh\";\n\tconst className: LanguageClass = `language-${lang}`;\n\treturn className;\n}\n\nexport { isSupportedLanguage, parseLanguage, formatLanguageClassName };\nexport type { SupportedLanguage };\n","type Primitive = string | number | boolean | undefined | null;\n\n/**\n * Tagged template literal to format code blocks and normalize leading indentation\n */\nexport function fmtCode(strings: TemplateStringsArray, ...values: Primitive[]): string {\n\tif (!isTemplateStringsArray(strings) || !Array.isArray(values)) {\n\t\tthrow new Error(\n\t\t\t\"It looks like you tried to call `fmtCode` as a function. Make sure to use it as a tagged template.\\n\\tExample: fmtCode`SELECT * FROM users`, not fmtCode('SELECT * FROM users')\",\n\t\t);\n\t}\n\n\tconst text = String.raw({ raw: strings }, ...values);\n\n\t// fine the minimum indentation of the code block\n\tconst minIndent = findMinIndent(text);\n\tconst lines = text.trim().split(\"\\n\");\n\n\treturn lines\n\t\t.map((line) => {\n\t\t\t// remove nothing if the line doesn't start with indentation\n\t\t\tif (/^\\S+/.test(line)) {\n\t\t\t\treturn line;\n\t\t\t}\n\t\t\treturn line.slice(minIndent);\n\t\t})\n\t\t.join(\"\\n\");\n\t// replace all tabs with 2 spaces\n\t// .replace(/\\t/g, \" \")\n}\n\n/**\n * Find the shortest indentation of a multiline string\n */\nfunction findMinIndent(value: string): number {\n\tconst match = value.match(/^[ \\t]*(?=\\S)/gm);\n\n\tif (!match) {\n\t\treturn 0;\n\t}\n\n\treturn match.reduce((acc, curr) => Math.min(acc, curr.length), Infinity);\n}\n\n/**\n * Type guard to check if a value is a `TemplateStringsArray`\n */\nfunction isTemplateStringsArray(strings: unknown): strings is TemplateStringsArray {\n\treturn Array.isArray(strings) && \"raw\" in strings && Array.isArray(strings.raw);\n}\n","import { z } from \"zod\";\n\nconst modes = [\"file\", \"cli\"] as const;\ntype Mode = (typeof modes)[number];\n\nconst metaSchema = z.object({\n\tcollapsible: z.boolean().default(false),\n\tdisableCopy: z.boolean().default(false),\n\tmode: z.enum(modes).optional(),\n\ttitle: z.string().trim().optional(),\n});\n\ntype MetaInput = z.input<typeof metaSchema>;\n\ntype Meta = z.infer<typeof metaSchema>;\n\nconst defaultMeta = {\n\tcollapsible: false,\n\tdisableCopy: false,\n\tmode: undefined,\n\ttitle: undefined,\n} as const satisfies Meta;\n\ntype DefaultMeta = typeof defaultMeta;\n\n/**\n * Parses a markdown code block (```) metastring into a meta object.\n * Defaults to DefaultMeta if no metastring given or if metastring is invalid.\n * Useful for parsing the metastring from a markdown code block to pass into the\n * CodeBlock components as props.\n */\nfunction parseMetastring(value: string | undefined): Meta {\n\tconst metastring = value?.trim() ?? \"\";\n\tif (!metastring) {\n\t\treturn defaultMeta;\n\t}\n\n\tconst metaJson = tokenizeMetastring(metastring).reduce<Record<string, unknown>>((acc, token) => {\n\t\tconst [key, _value] = token.split(\"=\");\n\t\tif (!key) {\n\t\t\treturn acc;\n\t\t}\n\t\tconst value = normalizeValue(_value);\n\t\tacc[key] = value ?? true;\n\t\treturn acc;\n\t}, {});\n\n\ttry {\n\t\tconst parsed = metaSchema.parse(metaJson);\n\n\t\t// return the parsed meta object, with default values filled in\n\t\treturn {\n\t\t\t...defaultMeta,\n\t\t\t...parsed,\n\t\t};\n\t} catch (_) {\n\t\treturn defaultMeta;\n\t}\n}\n\nexport { defaultMeta, parseMetastring };\nexport type { Meta, MetaInput, Mode, DefaultMeta };\n\n/**\n * Remove leading and trailing `\"` quotes around value\n * @private\n */\nexport function normalizeValue(value: string | undefined) {\n\treturn value?.trim().replace(/^\"(.*)\"$/, \"$1\");\n}\n\n/**\n * Splits a metastring into an array of tokens that can be parsed into a meta object.\n * Should allow for quotes and spaces in tokens\n * @private\n */\nexport function tokenizeMetastring(value: string | undefined): string[] {\n\tconst input = value?.trim() ?? \"\";\n\tconst result: string[] = [];\n\n\tlet currentString = \"\";\n\tlet inQuotes = false;\n\n\tfor (const char of input) {\n\t\tif (char === \" \" && !inQuotes) {\n\t\t\tif (currentString) {\n\t\t\t\tresult.push(currentString);\n\t\t\t\tcurrentString = \"\";\n\t\t\t}\n\t\t} else if (char === '\"') {\n\t\t\tinQuotes = !inQuotes;\n\t\t\tcurrentString += char;\n\t\t} else {\n\t\t\tcurrentString += char;\n\t\t}\n\t}\n\n\tif (currentString) {\n\t\tresult.push(currentString);\n\t}\n\n\treturn result;\n}\n"]}