@ngrok/mantle 0.26.0 → 0.27.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/alert-dialog.js +1 -1
- package/dist/button-C8eGiHOm.d.ts +166 -0
- package/dist/button.d.ts +6 -166
- package/dist/chunk-DDMTW6XB.js +2 -0
- package/dist/chunk-DDMTW6XB.js.map +1 -0
- package/dist/chunk-YAT4IMMN.js +2 -0
- package/dist/chunk-YAT4IMMN.js.map +1 -0
- package/dist/code-block.js +1 -1
- package/dist/code-block.js.map +1 -1
- package/dist/data-table.d.ts +54 -10
- package/dist/data-table.js +1 -1
- package/dist/data-table.js.map +1 -1
- package/dist/dialog.js +1 -1
- package/dist/{direction-A0wepfUT.d.ts → direction-veAOo2is.d.ts} +1 -1
- package/dist/icons.d.ts +1 -1
- package/dist/pagination.js +1 -1
- package/dist/pagination.js.map +1 -1
- package/dist/sheet.js +1 -1
- package/dist/sorting.d.ts +1 -1
- package/dist/table.js +1 -1
- package/dist/tailwind-preset.cjs +1 -1
- package/dist/tailwind-preset.cjs.map +1 -1
- package/dist/tailwind-preset.d.cts +1 -1
- package/dist/tailwind-preset.d.ts +1 -1
- package/dist/tailwind-preset.js +1 -1
- package/dist/tailwind-preset.js.map +1 -1
- package/dist/toast.js +1 -1
- package/package.json +8 -8
- package/dist/chunk-ATNIDU3M.js +0 -2
- package/dist/chunk-ATNIDU3M.js.map +0 -1
- package/dist/chunk-QMAGKYIX.js +0 -2
- package/dist/chunk-QMAGKYIX.js.map +0 -1
package/dist/alert-dialog.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as A,b as D,c as y,d as g,e as u,f as C,g as P,h as v}from"./chunk-PBARMKNJ.js";import{g as c}from"./chunk-
|
|
1
|
+
import{a as A,b as D,c as y,d as g,e as u,f as C,g as P,h as v}from"./chunk-PBARMKNJ.js";import{g as c}from"./chunk-DDMTW6XB.js";import"./chunk-DOTYPWKO.js";import"./chunk-D3XF6J5A.js";import{b as m}from"./chunk-J3NVDJIE.js";import"./chunk-4LSFAAZW.js";import"./chunk-3C5O3AQA.js";import"./chunk-72TJUKMV.js";import"./chunk-7O36LG52.js";import{a as f}from"./chunk-HDPLH5HC.js";import{a}from"./chunk-AZ56JGNY.js";import{Info as j}from"@phosphor-icons/react/Info";import{Warning as F}from"@phosphor-icons/react/Warning";import{Slot as d}from"@radix-ui/react-slot";import{createContext as H,forwardRef as n,useContext as V,useMemo as k}from"react";import M from"tiny-invariant";import{jsx as i,jsxs as G}from"react/jsx-runtime";var x=H(null);function N(){let t=V(x);return M(t,"AlertDialog child component used outside of AlertDialog parent!"),t}function R({priority:t,...e}){let o=k(()=>({priority:t}),[t]);return i(x.Provider,{value:o,children:i(A,{...e})})}R.displayName="AlertDialog";var $=D,q=y,h=n(({className:t,...e},o)=>i(u,{className:a("data-state-open:animate-in data-state-closed:animate-out data-state-closed:fade-out-0 data-state-open:fade-in-0 bg-overlay fixed inset-0 z-50 backdrop-blur-sm",t),...e,ref:o}));h.displayName="AlertDialogOverlay";var b=n(({className:t,onInteractOutside:e,onPointerDownOutside:o,preferredWidth:l="max-w-md",...r},p)=>G(q,{children:[i(h,{}),i("div",{className:"fixed inset-4 z-50 flex items-center justify-center",children:i(C,{ref:p,className:a("flex w-full flex-1 flex-col items-center gap-4 sm:flex-row sm:items-start","outline-none focus-within:outline-none","p-6","border-dialog bg-dialog rounded-xl border shadow-lg transition-transform duration-200","data-state-closed:animate-out data-state-closed:fade-out-0 data-state-closed:zoom-out-95 data-state-open:animate-in data-state-open:fade-in-0 data-state-open:zoom-in-95",l,t),onInteractOutside:s=>{c(s),e?.(s)},onPointerDownOutside:s=>{c(s),o?.(s)},...r})})]}));b.displayName="AlertDialogContent";var W=n(({asChild:t=!1,className:e,...o},l)=>i(t?d:"div",{className:a("flex-1 space-y-4",e),ref:l,...o}));W.displayName="AlertDialogBody";var O=n(({asChild:t=!1,className:e,...o},l)=>i(t?d:"div",{className:a("flex flex-col space-y-2 text-center sm:text-start",e),...o}));O.displayName="AlertDialogHeader";var w=n(({asChild:t=!1,className:e,...o},l)=>i(t?d:"div",{className:a("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...o}));w.displayName="AlertDialogFooter";var B=n(({className:t,...e},o)=>i(P,{ref:o,className:a("text-strong text-center text-lg font-medium sm:text-start",t),...e}));B.displayName="AlertDialogTitle";var I=n(({className:t,...e},o)=>i(v,{ref:o,className:a("text-body text-center text-sm font-normal sm:text-start",t),...e}));I.displayName="AlertDialogDescription";var T=n(({appearance:t="filled",...e},o)=>{let l=N(),r="default";return l.priority==="danger"&&(r="danger"),i(m,{appearance:t,priority:r,ref:o,...e})});T.displayName="AlertDialogAction";var z=n(({appearance:t="outlined",className:e,priority:o="neutral",...l},r)=>i(g,{asChild:!0,children:i(m,{appearance:t,className:a("mt-2 sm:mt-0",e),priority:o,ref:r,...l})}));z.displayName="AlertDialogCancel";var S=n(({className:t,svg:e,...o},l)=>{let r=N(),p=r.priority==="danger"?"text-danger-600":"text-accent-600",s=r.priority==="danger"?i(F,{}):i(j,{});return i(f,{ref:l,className:a("size-12 sm:size-7",p,t),svg:e??s,...o})});S.displayName="AlertDialogIcon";var E=g;export{R as AlertDialog,T as AlertDialogAction,W as AlertDialogBody,z as AlertDialogCancel,E as AlertDialogClose,b as AlertDialogContent,I as AlertDialogDescription,w as AlertDialogFooter,O as AlertDialogHeader,S as AlertDialogIcon,B as AlertDialogTitle,$ as AlertDialogTrigger};
|
|
2
2
|
//# sourceMappingURL=alert-dialog.js.map
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import { D as DeepNonNullable } from './deep-non-nullable-SmpSvoSd.js';
|
|
2
|
+
import * as class_variance_authority from 'class-variance-authority';
|
|
3
|
+
import * as react from 'react';
|
|
4
|
+
import { ButtonHTMLAttributes, ReactNode, ComponentProps } from 'react';
|
|
5
|
+
import * as class_variance_authority_types from 'class-variance-authority/types';
|
|
6
|
+
import { V as VariantProps } from './variant-props-oDo2u-We.js';
|
|
7
|
+
|
|
8
|
+
declare const buttonVariants: (props?: ({
|
|
9
|
+
appearance?: "link" | "filled" | "ghost" | "outlined" | null | undefined;
|
|
10
|
+
isLoading?: boolean | null | undefined;
|
|
11
|
+
priority?: "default" | "danger" | "neutral" | null | undefined;
|
|
12
|
+
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
13
|
+
type ButtonVariants = VariantProps<typeof buttonVariants>;
|
|
14
|
+
/**
|
|
15
|
+
* The props for the `Button` component.
|
|
16
|
+
*/
|
|
17
|
+
type ButtonProps = ComponentProps<"button"> & ButtonVariants & {
|
|
18
|
+
/**
|
|
19
|
+
* An icon to render inside the button. If the `state` is `"pending"`, then
|
|
20
|
+
* the icon will automatically be replaced with a spinner.
|
|
21
|
+
*/
|
|
22
|
+
icon?: ReactNode;
|
|
23
|
+
/**
|
|
24
|
+
* The side that the icon will render on, if one is present. If `state="pending"`,
|
|
25
|
+
* then the loading icon will also render on this side.
|
|
26
|
+
* @default "start"
|
|
27
|
+
*/
|
|
28
|
+
iconPlacement?: "start" | "end";
|
|
29
|
+
} & ({
|
|
30
|
+
/**
|
|
31
|
+
* Use the `asChild` prop to compose Radix's functionality onto alternative
|
|
32
|
+
* element types or your own React components.
|
|
33
|
+
*
|
|
34
|
+
* When `asChild` is set to `true`, mantle will not render a default DOM
|
|
35
|
+
* element, instead cloning the component's child and passing it the props and
|
|
36
|
+
* behavior required to make it functional.
|
|
37
|
+
*
|
|
38
|
+
* asChild can be used as deeply as you need to. This means it is a great way
|
|
39
|
+
* to compose multiple primitive's behavior together.
|
|
40
|
+
*
|
|
41
|
+
* @see https://www.radix-ui.com/docs/primitives/guides/composition#composition
|
|
42
|
+
*/
|
|
43
|
+
asChild: true;
|
|
44
|
+
/**
|
|
45
|
+
* The default behavior of the button. Possible values are: `"button"`, `"submit"`, and `"reset"`.
|
|
46
|
+
*
|
|
47
|
+
* if `asChild` is NOT used: Unlike the native `<button>` element, this prop is required and has no default value.
|
|
48
|
+
*
|
|
49
|
+
* If `asChild` IS used: This prop HAS NO EFFECT, is REMOVED, and has no default value. This is because we do not want the `button` `type` to automatically merge with any child anchor `type` attribute because the `anchor` `type` is _strictly different_ than the `button` type, see: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#type
|
|
50
|
+
*
|
|
51
|
+
* @enum
|
|
52
|
+
* - `"button"`: The button has no default behavior, and does nothing when pressed by default. It can have client-side scripts listen to the element's events, which are triggered when the events occur.
|
|
53
|
+
* - `"reset"`: The button resets all the controls to their initial values.
|
|
54
|
+
* - `"submit"`: The button submits the form data to the server.
|
|
55
|
+
*
|
|
56
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#type
|
|
57
|
+
*/
|
|
58
|
+
type?: ButtonHTMLAttributes<HTMLButtonElement>["type"];
|
|
59
|
+
} | {
|
|
60
|
+
asChild?: false | undefined;
|
|
61
|
+
/**
|
|
62
|
+
* The default behavior of the button. Possible values are: `"button"`, `"submit"`, and `"reset"`.
|
|
63
|
+
*
|
|
64
|
+
* if `asChild` is NOT used: Unlike the native `<button>` element, this prop is required and has no default value.
|
|
65
|
+
*
|
|
66
|
+
* If `asChild` IS used: This prop HAS NO EFFECT, is REMOVED, and has no default value. This is because we do not want the `button` `type` to automatically merge with any child anchor `type` attribute because the `anchor` `type` is _strictly different_ than the `button` type, see: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#type
|
|
67
|
+
*
|
|
68
|
+
* @enum
|
|
69
|
+
* - `"button"`: The button has no default behavior, and does nothing when pressed by default. It can have client-side scripts listen to the element's events, which are triggered when the events occur.
|
|
70
|
+
* - `"reset"`: The button resets all the controls to their initial values.
|
|
71
|
+
* - `"submit"`: The button submits the form data to the server.
|
|
72
|
+
*
|
|
73
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#type
|
|
74
|
+
*/
|
|
75
|
+
type: Exclude<ButtonHTMLAttributes<HTMLButtonElement>["type"], undefined>;
|
|
76
|
+
});
|
|
77
|
+
/**
|
|
78
|
+
* Renders a button or a component that looks like a button, an interactive
|
|
79
|
+
* element activated by a user with a mouse, keyboard, finger, voice command, or
|
|
80
|
+
* other assistive technology. Once activated, it then performs an action, such
|
|
81
|
+
* as submitting a form or opening a dialog.
|
|
82
|
+
*
|
|
83
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button
|
|
84
|
+
*/
|
|
85
|
+
declare const Button: react.ForwardRefExoticComponent<(Omit<react.ClassAttributes<HTMLButtonElement> & ButtonHTMLAttributes<HTMLButtonElement> & Partial<DeepNonNullable<class_variance_authority.VariantProps<(props?: ({
|
|
86
|
+
appearance?: "link" | "filled" | "ghost" | "outlined" | null | undefined;
|
|
87
|
+
isLoading?: boolean | null | undefined;
|
|
88
|
+
priority?: "default" | "danger" | "neutral" | null | undefined;
|
|
89
|
+
} & class_variance_authority_types.ClassProp) | undefined) => string>>> & {
|
|
90
|
+
/**
|
|
91
|
+
* An icon to render inside the button. If the `state` is `"pending"`, then
|
|
92
|
+
* the icon will automatically be replaced with a spinner.
|
|
93
|
+
*/
|
|
94
|
+
icon?: ReactNode;
|
|
95
|
+
/**
|
|
96
|
+
* The side that the icon will render on, if one is present. If `state="pending"`,
|
|
97
|
+
* then the loading icon will also render on this side.
|
|
98
|
+
* @default "start"
|
|
99
|
+
*/
|
|
100
|
+
iconPlacement?: "start" | "end";
|
|
101
|
+
} & {
|
|
102
|
+
/**
|
|
103
|
+
* Use the `asChild` prop to compose Radix's functionality onto alternative
|
|
104
|
+
* element types or your own React components.
|
|
105
|
+
*
|
|
106
|
+
* When `asChild` is set to `true`, mantle will not render a default DOM
|
|
107
|
+
* element, instead cloning the component's child and passing it the props and
|
|
108
|
+
* behavior required to make it functional.
|
|
109
|
+
*
|
|
110
|
+
* asChild can be used as deeply as you need to. This means it is a great way
|
|
111
|
+
* to compose multiple primitive's behavior together.
|
|
112
|
+
*
|
|
113
|
+
* @see https://www.radix-ui.com/docs/primitives/guides/composition#composition
|
|
114
|
+
*/
|
|
115
|
+
asChild: true;
|
|
116
|
+
/**
|
|
117
|
+
* The default behavior of the button. Possible values are: `"button"`, `"submit"`, and `"reset"`.
|
|
118
|
+
*
|
|
119
|
+
* if `asChild` is NOT used: Unlike the native `<button>` element, this prop is required and has no default value.
|
|
120
|
+
*
|
|
121
|
+
* If `asChild` IS used: This prop HAS NO EFFECT, is REMOVED, and has no default value. This is because we do not want the `button` `type` to automatically merge with any child anchor `type` attribute because the `anchor` `type` is _strictly different_ than the `button` type, see: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#type
|
|
122
|
+
*
|
|
123
|
+
* @enum
|
|
124
|
+
* - `"button"`: The button has no default behavior, and does nothing when pressed by default. It can have client-side scripts listen to the element's events, which are triggered when the events occur.
|
|
125
|
+
* - `"reset"`: The button resets all the controls to their initial values.
|
|
126
|
+
* - `"submit"`: The button submits the form data to the server.
|
|
127
|
+
*
|
|
128
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#type
|
|
129
|
+
*/
|
|
130
|
+
type?: ButtonHTMLAttributes<HTMLButtonElement>["type"];
|
|
131
|
+
}, "ref"> | Omit<react.ClassAttributes<HTMLButtonElement> & ButtonHTMLAttributes<HTMLButtonElement> & Partial<DeepNonNullable<class_variance_authority.VariantProps<(props?: ({
|
|
132
|
+
appearance?: "link" | "filled" | "ghost" | "outlined" | null | undefined;
|
|
133
|
+
isLoading?: boolean | null | undefined;
|
|
134
|
+
priority?: "default" | "danger" | "neutral" | null | undefined;
|
|
135
|
+
} & class_variance_authority_types.ClassProp) | undefined) => string>>> & {
|
|
136
|
+
/**
|
|
137
|
+
* An icon to render inside the button. If the `state` is `"pending"`, then
|
|
138
|
+
* the icon will automatically be replaced with a spinner.
|
|
139
|
+
*/
|
|
140
|
+
icon?: ReactNode;
|
|
141
|
+
/**
|
|
142
|
+
* The side that the icon will render on, if one is present. If `state="pending"`,
|
|
143
|
+
* then the loading icon will also render on this side.
|
|
144
|
+
* @default "start"
|
|
145
|
+
*/
|
|
146
|
+
iconPlacement?: "start" | "end";
|
|
147
|
+
} & {
|
|
148
|
+
asChild?: false | undefined;
|
|
149
|
+
/**
|
|
150
|
+
* The default behavior of the button. Possible values are: `"button"`, `"submit"`, and `"reset"`.
|
|
151
|
+
*
|
|
152
|
+
* if `asChild` is NOT used: Unlike the native `<button>` element, this prop is required and has no default value.
|
|
153
|
+
*
|
|
154
|
+
* If `asChild` IS used: This prop HAS NO EFFECT, is REMOVED, and has no default value. This is because we do not want the `button` `type` to automatically merge with any child anchor `type` attribute because the `anchor` `type` is _strictly different_ than the `button` type, see: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#type
|
|
155
|
+
*
|
|
156
|
+
* @enum
|
|
157
|
+
* - `"button"`: The button has no default behavior, and does nothing when pressed by default. It can have client-side scripts listen to the element's events, which are triggered when the events occur.
|
|
158
|
+
* - `"reset"`: The button resets all the controls to their initial values.
|
|
159
|
+
* - `"submit"`: The button submits the form data to the server.
|
|
160
|
+
*
|
|
161
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#type
|
|
162
|
+
*/
|
|
163
|
+
type: Exclude<ButtonHTMLAttributes<HTMLButtonElement>["type"], undefined>;
|
|
164
|
+
}, "ref">) & react.RefAttributes<HTMLButtonElement>>;
|
|
165
|
+
|
|
166
|
+
export { Button as B, type ButtonProps as a };
|
package/dist/button.d.ts
CHANGED
|
@@ -1,169 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
import * as class_variance_authority from 'class-variance-authority';
|
|
3
|
-
import * as react from 'react';
|
|
4
|
-
import { ButtonHTMLAttributes, ReactNode, ComponentProps } from 'react';
|
|
5
|
-
import * as class_variance_authority_types from 'class-variance-authority/types';
|
|
6
|
-
import { V as VariantProps } from './variant-props-oDo2u-We.js';
|
|
1
|
+
export { B as Button, a as ButtonProps } from './button-C8eGiHOm.js';
|
|
7
2
|
export { I as IconButton, a as IconButtonProps } from './icon-button-D41yiI7H.js';
|
|
8
3
|
export { B as ButtonGroup, a as ButtonGroupProps } from './button-group-CpDp0fYZ.js';
|
|
4
|
+
import './deep-non-nullable-SmpSvoSd.js';
|
|
5
|
+
import 'class-variance-authority';
|
|
6
|
+
import 'react';
|
|
7
|
+
import 'class-variance-authority/types';
|
|
8
|
+
import './variant-props-oDo2u-We.js';
|
|
9
9
|
import './as-child-DJ7x3JFV.js';
|
|
10
|
-
|
|
11
|
-
declare const buttonVariants: (props?: ({
|
|
12
|
-
appearance?: "link" | "filled" | "ghost" | "outlined" | null | undefined;
|
|
13
|
-
isLoading?: boolean | null | undefined;
|
|
14
|
-
priority?: "default" | "danger" | "neutral" | null | undefined;
|
|
15
|
-
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
16
|
-
type ButtonVariants = VariantProps<typeof buttonVariants>;
|
|
17
|
-
/**
|
|
18
|
-
* The props for the `Button` component.
|
|
19
|
-
*/
|
|
20
|
-
type ButtonProps = ComponentProps<"button"> & ButtonVariants & {
|
|
21
|
-
/**
|
|
22
|
-
* An icon to render inside the button. If the `state` is `"pending"`, then
|
|
23
|
-
* the icon will automatically be replaced with a spinner.
|
|
24
|
-
*/
|
|
25
|
-
icon?: ReactNode;
|
|
26
|
-
/**
|
|
27
|
-
* The side that the icon will render on, if one is present. If `state="pending"`,
|
|
28
|
-
* then the loading icon will also render on this side.
|
|
29
|
-
* @default "start"
|
|
30
|
-
*/
|
|
31
|
-
iconPlacement?: "start" | "end";
|
|
32
|
-
} & ({
|
|
33
|
-
/**
|
|
34
|
-
* Use the `asChild` prop to compose Radix's functionality onto alternative
|
|
35
|
-
* element types or your own React components.
|
|
36
|
-
*
|
|
37
|
-
* When `asChild` is set to `true`, mantle will not render a default DOM
|
|
38
|
-
* element, instead cloning the component's child and passing it the props and
|
|
39
|
-
* behavior required to make it functional.
|
|
40
|
-
*
|
|
41
|
-
* asChild can be used as deeply as you need to. This means it is a great way
|
|
42
|
-
* to compose multiple primitive's behavior together.
|
|
43
|
-
*
|
|
44
|
-
* @see https://www.radix-ui.com/docs/primitives/guides/composition#composition
|
|
45
|
-
*/
|
|
46
|
-
asChild: true;
|
|
47
|
-
/**
|
|
48
|
-
* The default behavior of the button. Possible values are: `"button"`, `"submit"`, and `"reset"`.
|
|
49
|
-
*
|
|
50
|
-
* if `asChild` is NOT used: Unlike the native `<button>` element, this prop is required and has no default value.
|
|
51
|
-
*
|
|
52
|
-
* If `asChild` IS used: This prop HAS NO EFFECT, is REMOVED, and has no default value. This is because we do not want the `button` `type` to automatically merge with any child anchor `type` attribute because the `anchor` `type` is _strictly different_ than the `button` type, see: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#type
|
|
53
|
-
*
|
|
54
|
-
* @enum
|
|
55
|
-
* - `"button"`: The button has no default behavior, and does nothing when pressed by default. It can have client-side scripts listen to the element's events, which are triggered when the events occur.
|
|
56
|
-
* - `"reset"`: The button resets all the controls to their initial values.
|
|
57
|
-
* - `"submit"`: The button submits the form data to the server.
|
|
58
|
-
*
|
|
59
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#type
|
|
60
|
-
*/
|
|
61
|
-
type?: ButtonHTMLAttributes<HTMLButtonElement>["type"];
|
|
62
|
-
} | {
|
|
63
|
-
asChild?: false | undefined;
|
|
64
|
-
/**
|
|
65
|
-
* The default behavior of the button. Possible values are: `"button"`, `"submit"`, and `"reset"`.
|
|
66
|
-
*
|
|
67
|
-
* if `asChild` is NOT used: Unlike the native `<button>` element, this prop is required and has no default value.
|
|
68
|
-
*
|
|
69
|
-
* If `asChild` IS used: This prop HAS NO EFFECT, is REMOVED, and has no default value. This is because we do not want the `button` `type` to automatically merge with any child anchor `type` attribute because the `anchor` `type` is _strictly different_ than the `button` type, see: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#type
|
|
70
|
-
*
|
|
71
|
-
* @enum
|
|
72
|
-
* - `"button"`: The button has no default behavior, and does nothing when pressed by default. It can have client-side scripts listen to the element's events, which are triggered when the events occur.
|
|
73
|
-
* - `"reset"`: The button resets all the controls to their initial values.
|
|
74
|
-
* - `"submit"`: The button submits the form data to the server.
|
|
75
|
-
*
|
|
76
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#type
|
|
77
|
-
*/
|
|
78
|
-
type: Exclude<ButtonHTMLAttributes<HTMLButtonElement>["type"], undefined>;
|
|
79
|
-
});
|
|
80
|
-
/**
|
|
81
|
-
* Renders a button or a component that looks like a button, an interactive
|
|
82
|
-
* element activated by a user with a mouse, keyboard, finger, voice command, or
|
|
83
|
-
* other assistive technology. Once activated, it then performs an action, such
|
|
84
|
-
* as submitting a form or opening a dialog.
|
|
85
|
-
*
|
|
86
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button
|
|
87
|
-
*/
|
|
88
|
-
declare const Button: react.ForwardRefExoticComponent<(Omit<react.ClassAttributes<HTMLButtonElement> & ButtonHTMLAttributes<HTMLButtonElement> & Partial<DeepNonNullable<class_variance_authority.VariantProps<(props?: ({
|
|
89
|
-
appearance?: "link" | "filled" | "ghost" | "outlined" | null | undefined;
|
|
90
|
-
isLoading?: boolean | null | undefined;
|
|
91
|
-
priority?: "default" | "danger" | "neutral" | null | undefined;
|
|
92
|
-
} & class_variance_authority_types.ClassProp) | undefined) => string>>> & {
|
|
93
|
-
/**
|
|
94
|
-
* An icon to render inside the button. If the `state` is `"pending"`, then
|
|
95
|
-
* the icon will automatically be replaced with a spinner.
|
|
96
|
-
*/
|
|
97
|
-
icon?: ReactNode;
|
|
98
|
-
/**
|
|
99
|
-
* The side that the icon will render on, if one is present. If `state="pending"`,
|
|
100
|
-
* then the loading icon will also render on this side.
|
|
101
|
-
* @default "start"
|
|
102
|
-
*/
|
|
103
|
-
iconPlacement?: "start" | "end";
|
|
104
|
-
} & {
|
|
105
|
-
/**
|
|
106
|
-
* Use the `asChild` prop to compose Radix's functionality onto alternative
|
|
107
|
-
* element types or your own React components.
|
|
108
|
-
*
|
|
109
|
-
* When `asChild` is set to `true`, mantle will not render a default DOM
|
|
110
|
-
* element, instead cloning the component's child and passing it the props and
|
|
111
|
-
* behavior required to make it functional.
|
|
112
|
-
*
|
|
113
|
-
* asChild can be used as deeply as you need to. This means it is a great way
|
|
114
|
-
* to compose multiple primitive's behavior together.
|
|
115
|
-
*
|
|
116
|
-
* @see https://www.radix-ui.com/docs/primitives/guides/composition#composition
|
|
117
|
-
*/
|
|
118
|
-
asChild: true;
|
|
119
|
-
/**
|
|
120
|
-
* The default behavior of the button. Possible values are: `"button"`, `"submit"`, and `"reset"`.
|
|
121
|
-
*
|
|
122
|
-
* if `asChild` is NOT used: Unlike the native `<button>` element, this prop is required and has no default value.
|
|
123
|
-
*
|
|
124
|
-
* If `asChild` IS used: This prop HAS NO EFFECT, is REMOVED, and has no default value. This is because we do not want the `button` `type` to automatically merge with any child anchor `type` attribute because the `anchor` `type` is _strictly different_ than the `button` type, see: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#type
|
|
125
|
-
*
|
|
126
|
-
* @enum
|
|
127
|
-
* - `"button"`: The button has no default behavior, and does nothing when pressed by default. It can have client-side scripts listen to the element's events, which are triggered when the events occur.
|
|
128
|
-
* - `"reset"`: The button resets all the controls to their initial values.
|
|
129
|
-
* - `"submit"`: The button submits the form data to the server.
|
|
130
|
-
*
|
|
131
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#type
|
|
132
|
-
*/
|
|
133
|
-
type?: ButtonHTMLAttributes<HTMLButtonElement>["type"];
|
|
134
|
-
}, "ref"> | Omit<react.ClassAttributes<HTMLButtonElement> & ButtonHTMLAttributes<HTMLButtonElement> & Partial<DeepNonNullable<class_variance_authority.VariantProps<(props?: ({
|
|
135
|
-
appearance?: "link" | "filled" | "ghost" | "outlined" | null | undefined;
|
|
136
|
-
isLoading?: boolean | null | undefined;
|
|
137
|
-
priority?: "default" | "danger" | "neutral" | null | undefined;
|
|
138
|
-
} & class_variance_authority_types.ClassProp) | undefined) => string>>> & {
|
|
139
|
-
/**
|
|
140
|
-
* An icon to render inside the button. If the `state` is `"pending"`, then
|
|
141
|
-
* the icon will automatically be replaced with a spinner.
|
|
142
|
-
*/
|
|
143
|
-
icon?: ReactNode;
|
|
144
|
-
/**
|
|
145
|
-
* The side that the icon will render on, if one is present. If `state="pending"`,
|
|
146
|
-
* then the loading icon will also render on this side.
|
|
147
|
-
* @default "start"
|
|
148
|
-
*/
|
|
149
|
-
iconPlacement?: "start" | "end";
|
|
150
|
-
} & {
|
|
151
|
-
asChild?: false | undefined;
|
|
152
|
-
/**
|
|
153
|
-
* The default behavior of the button. Possible values are: `"button"`, `"submit"`, and `"reset"`.
|
|
154
|
-
*
|
|
155
|
-
* if `asChild` is NOT used: Unlike the native `<button>` element, this prop is required and has no default value.
|
|
156
|
-
*
|
|
157
|
-
* If `asChild` IS used: This prop HAS NO EFFECT, is REMOVED, and has no default value. This is because we do not want the `button` `type` to automatically merge with any child anchor `type` attribute because the `anchor` `type` is _strictly different_ than the `button` type, see: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#type
|
|
158
|
-
*
|
|
159
|
-
* @enum
|
|
160
|
-
* - `"button"`: The button has no default behavior, and does nothing when pressed by default. It can have client-side scripts listen to the element's events, which are triggered when the events occur.
|
|
161
|
-
* - `"reset"`: The button resets all the controls to their initial values.
|
|
162
|
-
* - `"submit"`: The button submits the form data to the server.
|
|
163
|
-
*
|
|
164
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#type
|
|
165
|
-
*/
|
|
166
|
-
type: Exclude<ButtonHTMLAttributes<HTMLButtonElement>["type"], undefined>;
|
|
167
|
-
}, "ref">) & react.RefAttributes<HTMLButtonElement>>;
|
|
168
|
-
|
|
169
|
-
export { Button, type ButtonProps };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{l as P}from"./chunk-DOTYPWKO.js";import{a as p}from"./chunk-7O36LG52.js";import{a as i}from"./chunk-AZ56JGNY.js";import{CheckCircle as v}from"@phosphor-icons/react/CheckCircle";import{Info as h}from"@phosphor-icons/react/Info";import{Warning as C}from"@phosphor-icons/react/Warning";import{WarningDiamond as b}from"@phosphor-icons/react/WarningDiamond";import{Slot as u}from"@radix-ui/react-slot";import{createContext as y,forwardRef as d,useContext as f}from"react";import*as m from"sonner";import{jsx as r,jsxs as A}from"react/jsx-runtime";var B=({className:t,containerAriaLabel:o,dir:e,duration_ms:s=4e3,position:n="top-center",style:a})=>{let c=P();return r(m.Toaster,{className:i("toaster overlay-prompt pointer-events-auto font-sans *:duration-200",t),containerAriaLabel:o,dir:e,duration:s,gap:12,position:n??"top-center",style:a,theme:c,toastOptions:{unstyled:!0}})},g=y("");function _(t,o){return m.toast.custom(e=>r(g.Provider,{value:e,children:t}),{duration:o?.duration_ms,...o?.id?{id:o.id}:{},unstyled:!0})}var T=y({priority:"info"}),j=d(({asChild:t,children:o,className:e,priority:s,...n},a)=>{let c=t?u:"div";return r(T.Provider,{value:{priority:s},children:A(c,{className:i("relative flex items-start gap-2 text-sm","p-3 pl-[0.9375rem]","bg-popover high-contrast:border-popover rounded rounded-r-[0.3125rem] border border-gray-500/35 shadow-lg",e),ref:a,...n,children:[r(w,{priority:s}),o]})})}),D=d(({className:t,svg:o,...e},s)=>{let n=f(T);switch(n.priority){case"danger":return r(p,{className:i("text-danger-600",t),ref:s,svg:o??r(C,{weight:"fill"}),...e});case"warning":return r(p,{className:i("text-warning-600",t),ref:s,svg:o??r(b,{weight:"fill"}),...e});case"success":return r(p,{className:i("text-success-600",t),ref:s,svg:o??r(v,{weight:"fill"}),...e});case"info":return r(p,{className:i("text-accent-600",t),ref:s,svg:r(h,{weight:"fill"}),...e});default:throw new Error(`Unreachable Case: ${n.priority}`)}}),L=d(({asChild:t,className:o,onClick:e,...s},n)=>{let a=f(g);return r(t?u:"button",{className:i("shrink-0","data-[icon-button]:-mr-0.5 data-[icon-button]:-mt-0.5 data-[icon-button]:rounded-sm",o),onClick:l=>{e?.(l),!l.defaultPrevented&&m.toast.dismiss(a)},ref:n,...s})}),z=d(({asChild:t,className:o,...e},s)=>r(t?u:"p",{className:i("text-strong flex-1 text-sm",o),ref:s,...e}));function F(t){t.target instanceof Element&&t.target.closest(".overlay-prompt")&&t.preventDefault()}var x={info:"bg-accent-600",warning:"bg-warning-600",success:"bg-success-600",danger:"bg-danger-600"};function w({className:t,priority:o,...e}){return r("div",{"aria-hidden":!0,className:i("z-1 absolute -inset-px right-auto w-1.5 rounded-l",x[o],t),...e})}export{B as a,_ as b,j as c,D as d,L as e,z as f,F as g};
|
|
2
|
+
//# sourceMappingURL=chunk-DDMTW6XB.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/toast/toast.tsx"],"sourcesContent":["\"use client\";\n\nimport { CheckCircle } from \"@phosphor-icons/react/CheckCircle\";\nimport { Info } from \"@phosphor-icons/react/Info\";\nimport { Warning } from \"@phosphor-icons/react/Warning\";\nimport { WarningDiamond } from \"@phosphor-icons/react/WarningDiamond\";\nimport { Slot } from \"@radix-ui/react-slot\";\nimport {\n\ttype ComponentProps,\n\ttype ComponentRef,\n\ttype ReactNode,\n\tcreateContext,\n\tforwardRef,\n\tuseContext,\n} from \"react\";\nimport * as ToastPrimitive from \"sonner\";\nimport type { WithAsChild } from \"../../types/as-child.js\";\nimport type { WithStyleProps } from \"../../types/with-style-props.js\";\nimport { cx } from \"../../utils/cx/cx.js\";\nimport { Icon } from \"../icon/icon.js\";\nimport type { SvgOnlyProps } from \"../icon/svg-only.js\";\nimport { useAppliedTheme } from \"../theme-provider/theme-provider.js\";\n\ntype ToasterPrimitiveProps = ComponentProps<typeof ToastPrimitive.Toaster>;\ntype ToasterPrimitiveTheme = ToasterPrimitiveProps[\"theme\"];\n\ntype ToasterProps = WithStyleProps &\n\tPick<ToasterPrimitiveProps, \"containerAriaLabel\" | \"dir\" | \"position\"> & {\n\t\t/**\n\t\t * Time in milliseconds that should elapse before automatically dismissing toasts.\n\t\t * When set here, this will be the default duration for all toasts.\n\t\t * @default 4000\n\t\t */\n\t\tduration_ms?: number;\n\t};\n\n/**\n * A container for displaying all toasts.\n *\n * Only one `<Toaster />` should be rendered in an app a time, preferably at the\n * root level of the app.\n */\nconst Toaster = ({\n\t//,\n\tclassName,\n\tcontainerAriaLabel,\n\tdir,\n\tduration_ms = 4000,\n\tposition = \"top-center\",\n\tstyle,\n}: ToasterProps) => {\n\tconst theme = useAppliedTheme();\n\n\treturn (\n\t\t<ToastPrimitive.Toaster\n\t\t\tclassName={cx(\n\t\t\t\t\"toaster overlay-prompt pointer-events-auto font-sans *:duration-200\",\n\t\t\t\tclassName,\n\t\t\t)}\n\t\t\tcontainerAriaLabel={containerAriaLabel}\n\t\t\tdir={dir}\n\t\t\tduration={duration_ms}\n\t\t\tgap={12}\n\t\t\tposition={position ?? \"top-center\"}\n\t\t\tstyle={style}\n\t\t\ttheme={theme as ToasterPrimitiveTheme} // we have additional themes that are not in the sonner types, so we need to cast for now\n\t\t\ttoastOptions={{\n\t\t\t\tunstyled: true,\n\t\t\t}}\n\t\t/>\n\t);\n};\n\nconst ToastIdContext = createContext<string | number>(\"\");\n\ntype MakeToastOptions = {\n\t/**\n\t * Time in milliseconds that should elapse before automatically closing the toast.\n\t * Will default to the `<Toaster />`'s `duration_ms` if not provided.\n\t */\n\tduration_ms?: number;\n\t/**\n\t * An optional custom ID for this toast. If not given, a unique ID is provided for you.\n\t */\n\tid?: string;\n};\n\n/**\n * Create a toast. Provide a `<Toast>` component as the `children` to be rendered\n * inside the `<Toaster />` section.\n */\nfunction makeToast(children: ReactNode, options?: MakeToastOptions) {\n\treturn ToastPrimitive.toast.custom(\n\t\t(toastId) => (\n\t\t\t<ToastIdContext.Provider value={toastId}>\n\t\t\t\t{children}\n\t\t\t</ToastIdContext.Provider>\n\t\t),\n\t\t{\n\t\t\t//\n\t\t\tduration: options?.duration_ms,\n\t\t\t// If a custom ID is provided, use it, else use the toastId provided by the sonner library\n\t\t\t// don't set an ID to `undefined` as it breaks the sonner library\n\t\t\t...(options?.id ? { id: options.id } : {}),\n\t\t\tunstyled: true,\n\t\t},\n\t);\n}\n\nconst priorities = [\n\t//,\n\t\"danger\",\n\t\"info\",\n\t\"success\",\n\t\"warning\",\n] as const;\ntype Priority = (typeof priorities)[number];\n\ntype ToastState = {\n\tpriority: Priority;\n};\n\nconst ToastStateContext = createContext<ToastState>({\n\tpriority: \"info\",\n});\n\ntype ToastProps = ComponentProps<\"div\"> &\n\tWithAsChild & {\n\t\tpriority: Priority;\n\t};\n\n/**\n * A succinct message with a priority that is displayed temporarily.\n * Toasts are used to provide feedback to the user without interrupting their workflow.\n */\nconst Toast = forwardRef<ComponentRef<\"div\">, ToastProps>(\n\t({ asChild, children, className, priority, ...props }, ref) => {\n\t\tconst Component = asChild ? Slot : \"div\";\n\n\t\treturn (\n\t\t\t<ToastStateContext.Provider value={{ priority }}>\n\t\t\t\t<Component\n\t\t\t\t\tclassName={cx(\n\t\t\t\t\t\t\"relative flex items-start gap-2 text-sm\",\n\t\t\t\t\t\t\"p-3 pl-[0.9375rem]\",\n\t\t\t\t\t\t\"bg-popover high-contrast:border-popover rounded rounded-r-[0.3125rem] border border-gray-500/35 shadow-lg\",\n\t\t\t\t\t\t/**\n\t\t\t\t\t\t * Do not apply overflow-hidden because we want the priority bar accent\n\t\t\t\t\t\t * to overlap the toast border, else the border flows over the\n\t\t\t\t\t\t * priority bar.\n\t\t\t\t\t\t */\n\t\t\t\t\t\tclassName,\n\t\t\t\t\t)}\n\t\t\t\t\tref={ref}\n\t\t\t\t\t{...props}\n\t\t\t\t>\n\t\t\t\t\t<PriorityBarAccent priority={priority} />\n\t\t\t\t\t{children}\n\t\t\t\t</Component>\n\t\t\t</ToastStateContext.Provider>\n\t\t);\n\t},\n);\n\ntype ToastIconProps = Partial<SvgOnlyProps>;\n\n/**\n * An icon that visually represents the priority of the toast.\n * If you do not provide an icon, the default icon and color for the priority is used.\n */\nconst ToastIcon = forwardRef<ComponentRef<\"svg\">, ToastIconProps>(\n\t({ className, svg, ...props }, ref) => {\n\t\tconst ctx = useContext(ToastStateContext);\n\n\t\tswitch (ctx.priority) {\n\t\t\tcase \"danger\":\n\t\t\t\treturn (\n\t\t\t\t\t<Icon\n\t\t\t\t\t\tclassName={cx(\"text-danger-600\", className)}\n\t\t\t\t\t\tref={ref}\n\t\t\t\t\t\tsvg={svg ?? <Warning weight=\"fill\" />}\n\t\t\t\t\t\t{...props}\n\t\t\t\t\t/>\n\t\t\t\t);\n\t\t\tcase \"warning\":\n\t\t\t\treturn (\n\t\t\t\t\t<Icon\n\t\t\t\t\t\tclassName={cx(\"text-warning-600\", className)}\n\t\t\t\t\t\tref={ref}\n\t\t\t\t\t\tsvg={svg ?? <WarningDiamond weight=\"fill\" />}\n\t\t\t\t\t\t{...props}\n\t\t\t\t\t/>\n\t\t\t\t);\n\t\t\tcase \"success\":\n\t\t\t\treturn (\n\t\t\t\t\t<Icon\n\t\t\t\t\t\tclassName={cx(\"text-success-600\", className)}\n\t\t\t\t\t\tref={ref}\n\t\t\t\t\t\tsvg={svg ?? <CheckCircle weight=\"fill\" />}\n\t\t\t\t\t\t{...props}\n\t\t\t\t\t/>\n\t\t\t\t);\n\t\t\tcase \"info\":\n\t\t\t\treturn (\n\t\t\t\t\t<Icon\n\t\t\t\t\t\t//\n\t\t\t\t\t\tclassName={cx(\"text-accent-600\", className)}\n\t\t\t\t\t\tref={ref}\n\t\t\t\t\t\tsvg={<Info weight=\"fill\" />}\n\t\t\t\t\t\t{...props}\n\t\t\t\t\t/>\n\t\t\t\t);\n\t\t\tdefault:\n\t\t\t\tthrow new Error(`Unreachable Case: ${ctx.priority}`);\n\t\t}\n\t},\n);\n\ntype ToastActionProps = ComponentProps<\"button\"> & WithAsChild;\n\n/**\n * A button that dismisses the toast when clicked.\n * You can prevent the toast from being dismissed `onClick` by calling `event.preventDefault()`\n */\nconst ToastAction = forwardRef<ComponentRef<\"button\">, ToastActionProps>(\n\t({ asChild, className, onClick, ...props }, ref) => {\n\t\tconst ctx = useContext(ToastIdContext);\n\n\t\tconst Component = asChild ? Slot : \"button\";\n\n\t\treturn (\n\t\t\t<Component\n\t\t\t\tclassName={cx(\n\t\t\t\t\t//,\n\t\t\t\t\t\"shrink-0\",\n\t\t\t\t\t// 👇 wiggle the bits so that icon buttons toast actions are aligned with the toast icon\n\t\t\t\t\t\"data-[icon-button]:-mr-0.5 data-[icon-button]:-mt-0.5 data-[icon-button]:rounded-sm\",\n\t\t\t\t\tclassName,\n\t\t\t\t)}\n\t\t\t\tonClick={(event) => {\n\t\t\t\t\tonClick?.(event);\n\t\t\t\t\tif (event.defaultPrevented) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tToastPrimitive.toast.dismiss(ctx);\n\t\t\t\t}}\n\t\t\t\tref={ref}\n\t\t\t\t{...props}\n\t\t\t/>\n\t\t);\n\t},\n);\n\ntype ToastMessageProps = ComponentProps<\"p\"> & WithAsChild;\n\n/**\n * The message content of the toast.\n */\nconst ToastMessage = forwardRef<ComponentRef<\"p\">, ToastMessageProps>(\n\t({ asChild, className, ...props }, ref) => {\n\t\tconst Component = asChild ? Slot : \"p\";\n\n\t\treturn (\n\t\t\t<Component\n\t\t\t\t//\n\t\t\t\tclassName={cx(\"text-strong flex-1 text-sm\", className)}\n\t\t\t\tref={ref}\n\t\t\t\t{...props}\n\t\t\t/>\n\t\t);\n\t},\n);\n\nexport {\n\t//,\n\tmakeToast,\n\tToast,\n\tToastAction,\n\tToaster,\n\tToastIcon,\n\tToastMessage,\n};\n\nexport type {\n\t//,\n\tPriority,\n};\n\n/**\n * @private\n *\n * Allows any mantle floating prompt (e.g. toasts and notifications) to be interacted with\n * even when a modaled view (e.g. dialog, sheet, etc) is open and a focus trap is active.\n *\n * Without this, interacting with the prompt would close the modaled view.\n */\nexport function preventCloseOnPromptInteraction(\n\tevent: CustomEvent | PointerEvent | MouseEvent | TouchEvent | FocusEvent,\n) {\n\tif (!(event.target instanceof Element)) {\n\t\treturn;\n\t}\n\n\tif (event.target.closest(\".overlay-prompt\")) {\n\t\tevent.preventDefault();\n\t}\n}\n\nconst priorityBackgroundColor = {\n\tinfo: \"bg-accent-600\",\n\twarning: \"bg-warning-600\",\n\tsuccess: \"bg-success-600\",\n\tdanger: \"bg-danger-600\",\n} as const satisfies Record<Priority, string>;\n\ntype PriorityBarAccentProps = Omit<ComponentProps<\"div\">, \"children\"> & {\n\tpriority: Priority;\n};\n\n/**\n * @private\n *\n * A colored bar that visually represents the priority of the toast.\n */\nfunction PriorityBarAccent({\n\tclassName,\n\tpriority,\n\t...props\n}: PriorityBarAccentProps) {\n\treturn (\n\t\t<div\n\t\t\taria-hidden\n\t\t\tclassName={cx(\n\t\t\t\t//\n\t\t\t\t\"z-1 absolute -inset-px right-auto w-1.5 rounded-l\",\n\t\t\t\tpriorityBackgroundColor[priority],\n\t\t\t\tclassName,\n\t\t\t)}\n\t\t\t{...props}\n\t\t/>\n\t);\n}\n"],"mappings":"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","names":["CheckCircle","Info","Warning","WarningDiamond","Slot","createContext","forwardRef","useContext","ToastPrimitive","jsx","jsxs","Toaster","className","containerAriaLabel","dir","duration_ms","position","style","theme","useAppliedTheme","cx","ToastIdContext","createContext","makeToast","children","options","toastId","ToastStateContext","createContext","Toast","forwardRef","asChild","children","className","priority","props","ref","Component","Slot","jsx","jsxs","cx","PriorityBarAccent","ToastIcon","svg","ctx","useContext","Icon","Warning","WarningDiamond","CheckCircle","Info","ToastAction","onClick","ToastIdContext","event","ToastMessage","preventCloseOnPromptInteraction","event","priorityBackgroundColor","PriorityBarAccent","className","priority","props","jsx","cx"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{a as s}from"./chunk-AZ56JGNY.js";import{forwardRef as l,useEffect as p,useMemo as h,useRef as y,useState as u}from"react";import{jsx as n}from"react/jsx-runtime";var v=l(({children:e,className:t,style:o,...r},d)=>{let a=x();return n("div",{className:s("group/table scrollbar overflow-auto rounded-lg border border-gray-300 bg-white dark:bg-gray-100 relative",t),"data-sticky-active":a.state.hasOverflow&&!a.state.scrolledToEnd||void 0,"data-x-overflow":a.state.hasOverflow,"data-x-scroll-end":a.state.hasOverflow&&a.state.scrolledToEnd,ref:a.ref,children:n("table",{ref:d,className:"table-auto border-separate caption-bottom border-spacing-0 w-full text-left",...r,children:e})})});v.displayName="Table";var i=l(({className:e,...t},o)=>n("thead",{ref:o,className:s("text-strong bg-base [&_tr]:border-b",e),...t}));i.displayName="TableHead";var T=l(({children:e,className:t,...o},r)=>n("tbody",{className:s("text-body",t),ref:r,...o,children:e}));T.displayName="TableBody";var C=l(({className:e,...t},o)=>n("tfoot",{ref:o,className:s("bg-gray-50/50 font-medium [&>tr:first-child>td]:border-t text-body",e),...t}));C.displayName="TableFoot";var g=l(({className:e,...t},o)=>n("tr",{ref:o,className:s("[&>td]:border-b [&>td]:border-gray-300 [&>td]:last:border-b-0 [&>td]:bg-card [&>td]:hover:bg-gray-200/50",e),...t}));g.displayName="TableRow";var E=l(({className:e,...t},o)=>n("th",{ref:o,className:s("h-12 px-4 text-left align-middle text-sm font-medium [&:has([role=checkbox])]:pr-0",e),...t}));i.displayName="TableHead";var w=l(({className:e,...t},o)=>n("td",{ref:o,className:s("p-4 align-middle [&:has([role=checkbox])]:pr-0 font-mono text-size-mono",e),...t}));w.displayName="TableCell";var N=l(({className:e,...t},o)=>n("caption",{ref:o,className:s("border-t border-gray-300 py-4 text-sm text-gray-500",e),...t}));N.displayName="TableCaption";function x(){let e=y(null),[t,o]=u({hasOverflow:!1,scrolledToEnd:!1});return p(()=>{let r=e.current;if(!r)return;let d=()=>{let m=r.scrollWidth>r.clientWidth,f=Math.abs(r.scrollWidth-r.scrollLeft-r.clientWidth)<1;o(c=>c.hasOverflow!==m||c.scrolledToEnd!==f?{hasOverflow:m,scrolledToEnd:f}:c)},a=new ResizeObserver(d);a.observe(r);let b=new MutationObserver(d);return b.observe(r,{childList:!0,subtree:!0}),r.addEventListener("scroll",d,{passive:!0}),d(),()=>{a.disconnect(),b.disconnect(),r.removeEventListener("scroll",d)}},[]),h(()=>({ref:e,state:t}),[t])}export{v as a,i as b,T as c,C as d,g as e,E as f,w as g,N as h};
|
|
2
|
+
//# sourceMappingURL=chunk-YAT4IMMN.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/table/table.tsx"],"sourcesContent":["import type { ComponentProps, ComponentRef } from \"react\";\nimport { forwardRef, useEffect, useMemo, useRef, useState } from \"react\";\nimport { cx } from \"../../utils/cx/cx.js\";\n\n/**\n * The `<Table>` is a structured way to display data in rows and columns. The API\n * matches the HTML `<table>` element 1:1.\n *\n * Permitted content in this order:\n * 1. optional: `<TableCaption>`\n * 2. 0 or more: `<colgroup>` elements\n * 3. optional: `<TableHead>`\n * 4. either one of the following:\n * - 0 or more: `<TableBody>`\n * - 0 or more: `<TableRow>`\n * 5. optional: `<TableFoot>`\n *\n * @description\n * Establishes a table formatting context. Elements inside the `<Table>`\n * generate rectangular boxes. Each box occupies a number of table cells\n * according to the following rules:\n * 1. The row boxes fill the table in the source code order from top to bottom.\n * Each row box occupies one row of cells.\n * 2. A row group box occupies one or more row boxes.\n * 3. Column boxes are placed next to each other in source code order.\n * Depending on the value of the dir attribute, the columns are laid in\n * left-to-right or right-to-left direction. A column box occupies one or\n * more columns of table cells.\n * 4. A column group box occupies one or more column boxes.\n * 5. A cell box may span over multiple rows and columns. User agents trim\n * cells to fit in the available number of rows and columns.\n * Table cells do have padding. Boxes that make up a table do not have margins.\n * For more in depth information, see the [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/table).\n *\n * @example\n * ```tsx\n * <Table>\n * <TableCaption>A list of your recent invoices.</TableCaption>\n * <TableHead>\n * <TableRow>\n * <TableHeader className=\"w-[100px]\">Invoice</TableHeader>\n * <TableHeader>Status</TableHeader>\n * <TableHeader>Method</TableHeader>\n * <TableHeader className=\"text-right\">Amount</TableHeader>\n * </TableRow>\n * </TableHead>\n * <TableBody>\n * {invoices.map((invoice) => (\n * <TableRow key={invoice.invoice}>\n * <TableCell className=\"font-medium\">{invoice.invoice}</TableCell>\n * <TableCell>{invoice.paymentStatus}</TableCell>\n * <TableCell>{invoice.paymentMethod}</TableCell>\n * <TableCell className=\"text-right\">{invoice.totalAmount}</TableCell>\n * </TableRow>\n * ))}\n * </TableBody>\n * <TableFoot>\n * <TableRow>\n * <TableCell colSpan={3}>Total</TableCell>\n * <TableCell className=\"text-right\">$2,500.00</TableCell>\n * </TableRow>\n * </TableFoot>\n * </Table>\n * ```\n *\n * @see https://mantle.ngrok.com/components/table#api-table\n */\nconst Table = forwardRef<ComponentRef<\"table\">, ComponentProps<\"table\">>(\n\t({ children, className, style, ...props }, ref) => {\n\t\tconst horizontalOverflow =\n\t\t\tuseHorizontalOverflowObserver<ComponentRef<\"div\">>();\n\n\t\treturn (\n\t\t\t<div\n\t\t\t\tclassName={cx(\n\t\t\t\t\t\"group/table scrollbar overflow-auto rounded-lg border border-gray-300 bg-white dark:bg-gray-100 relative\",\n\t\t\t\t\tclassName,\n\t\t\t\t)}\n\t\t\t\tdata-sticky-active={\n\t\t\t\t\t(horizontalOverflow.state.hasOverflow &&\n\t\t\t\t\t\t!horizontalOverflow.state.scrolledToEnd) ||\n\t\t\t\t\tundefined\n\t\t\t\t}\n\t\t\t\tdata-x-overflow={horizontalOverflow.state.hasOverflow}\n\t\t\t\tdata-x-scroll-end={\n\t\t\t\t\thorizontalOverflow.state.hasOverflow &&\n\t\t\t\t\thorizontalOverflow.state.scrolledToEnd\n\t\t\t\t}\n\t\t\t\tref={horizontalOverflow.ref}\n\t\t\t>\n\t\t\t\t<table\n\t\t\t\t\tref={ref}\n\t\t\t\t\tclassName=\"table-auto border-separate caption-bottom border-spacing-0 w-full text-left\"\n\t\t\t\t\t{...props}\n\t\t\t\t>\n\t\t\t\t\t{children}\n\t\t\t\t</table>\n\t\t\t</div>\n\t\t);\n\t},\n);\nTable.displayName = \"Table\";\n\n/**\n * The `<TableHead>` is a container for the table's column headers.\n * Encapsulates a set of `<TableRow>`s, indicating that they comprise the head\n * of a table with information about the table's columns. This is usually in the\n * form of column headers (`<TableHeader>`).\n *\n * Must be used as a child of a `<Table>`. It should only come after any\n * `<TableCaption>` or `<colgroup>` and before any `<TableBody>` or `<TableFoot>`.\n *\n * Permitted Content:\n * 1. 0 or more: `<TableRow>`\n *\n * @example\n * ```tsx\n * <Table>\n * <TableCaption>A list of your recent invoices.</TableCaption>\n * <TableHead>\n * <TableRow>\n * <TableHeader className=\"w-[100px]\">Invoice</TableHeader>\n * <TableHeader>Status</TableHeader>\n * <TableHeader>Method</TableHeader>\n * <TableHeader className=\"text-right\">Amount</TableHeader>\n * </TableRow>\n * </TableHead>\n * <TableBody>\n * {invoices.map((invoice) => (\n * <TableRow key={invoice.invoice}>\n * <TableCell className=\"font-medium\">{invoice.invoice}</TableCell>\n * <TableCell>{invoice.paymentStatus}</TableCell>\n * <TableCell>{invoice.paymentMethod}</TableCell>\n * <TableCell className=\"text-right\">{invoice.totalAmount}</TableCell>\n * </TableRow>\n * ))}\n * </TableBody>\n * <TableFoot>\n * <TableRow>\n * <TableCell colSpan={3}>Total</TableCell>\n * <TableCell className=\"text-right\">$2,500.00</TableCell>\n * </TableRow>\n * </TableFoot>\n * </Table>\n * ```\n *\n * @see https://mantle.ngrok.com/components/table#api-table-header\n */\nconst TableHead = forwardRef<ComponentRef<\"thead\">, ComponentProps<\"thead\">>(\n\t({ className, ...props }, ref) => (\n\t\t<thead\n\t\t\tref={ref}\n\t\t\tclassName={cx(\"text-strong bg-base [&_tr]:border-b\", className)}\n\t\t\t{...props}\n\t\t/>\n\t),\n);\nTableHead.displayName = \"TableHead\";\n\n/**\n * The `<TableBody>` encapsulates a set of `<TableRow>`s, indicating that they\n * comprise the body of a table's (main) data.\n *\n * Must be used as a child of a `<Table>` and only come after any\n * `<TableCaption>`, `<colgroup>`, or `<TableHead>`.\n *\n * Permitted Content:\n * 1. 0 or more: `<TableRow>`\n *\n * @example\n * ```tsx\n * <Table>\n * <TableCaption>A list of your recent invoices.</TableCaption>\n * <TableHead>\n * <TableRow>\n * <TableHeader className=\"w-[100px]\">Invoice</TableHeader>\n * <TableHeader>Status</TableHeader>\n * <TableHeader>Method</TableHeader>\n * <TableHeader className=\"text-right\">Amount</TableHeader>\n * </TableRow>\n * </TableHead>\n * <TableBody>\n * {invoices.map((invoice) => (\n * <TableRow key={invoice.invoice}>\n * <TableCell className=\"font-medium\">{invoice.invoice}</TableCell>\n * <TableCell>{invoice.paymentStatus}</TableCell>\n * <TableCell>{invoice.paymentMethod}</TableCell>\n * <TableCell className=\"text-right\">{invoice.totalAmount}</TableCell>\n * </TableRow>\n * ))}\n * </TableBody>\n * <TableFoot>\n * <TableRow>\n * <TableCell colSpan={3}>Total</TableCell>\n * <TableCell className=\"text-right\">$2,500.00</TableCell>\n * </TableRow>\n * </TableFoot>\n * </Table>\n * ```\n *\n * @see https://mantle.ngrok.com/components/table#api-table-body\n */\nconst TableBody = forwardRef<ComponentRef<\"tbody\">, ComponentProps<\"tbody\">>(\n\t({ children, className, ...props }, ref) => (\n\t\t<tbody className={cx(\"text-body\", className)} ref={ref} {...props}>\n\t\t\t{children}\n\t\t</tbody>\n\t),\n);\nTableBody.displayName = \"TableBody\";\n\n/**\n * The `<TableFoot>` encapsulates a set of `<TableRow>`s, indicating that they\n * comprise the foot of a table with information about the table's columns. This\n * is usually a summary of the columns, e.g., a sum of the given numbers in a\n * column.\n *\n * Must be used as a child of a `<Table>` and only come after any\n * `<TableCaption>`, `<colgroup>`, `<TableHead>`, and `<TableBody>`.\n *\n * Permitted Content:\n * 1. 0 or more: `<TableRow>` elements\n *\n * @example\n * ```tsx\n * <Table>\n * <TableCaption>A list of your recent invoices.</TableCaption>\n * <TableHead>\n * <TableRow>\n * <TableHeader className=\"w-[100px]\">Invoice</TableHeader>\n * <TableHeader>Status</TableHeader>\n * <TableHeader>Method</TableHeader>\n * <TableHeader className=\"text-right\">Amount</TableHeader>\n * </TableRow>\n * </TableHead>\n * <TableBody>\n * {invoices.map((invoice) => (\n * <TableRow key={invoice.invoice}>\n * <TableCell className=\"font-medium\">{invoice.invoice}</TableCell>\n * <TableCell>{invoice.paymentStatus}</TableCell>\n * <TableCell>{invoice.paymentMethod}</TableCell>\n * <TableCell className=\"text-right\">{invoice.totalAmount}</TableCell>\n * </TableRow>\n * ))}\n * </TableBody>\n * <TableFoot>\n * <TableRow>\n * <TableCell colSpan={3}>Total</TableCell>\n * <TableCell className=\"text-right\">$2,500.00</TableCell>\n * </TableRow>\n * </TableFoot>\n * </Table>\n * ```\n *\n * @see https://mantle.ngrok.com/components/table#api-table-foot\n */\nconst TableFoot = forwardRef<ComponentRef<\"tfoot\">, ComponentProps<\"tfoot\">>(\n\t({ className, ...props }, ref) => (\n\t\t<tfoot\n\t\t\tref={ref}\n\t\t\tclassName={cx(\n\t\t\t\t\"bg-gray-50/50 font-medium [&>tr:first-child>td]:border-t text-body\",\n\t\t\t\tclassName,\n\t\t\t)}\n\t\t\t{...props}\n\t\t/>\n\t),\n);\nTableFoot.displayName = \"TableFoot\";\n\n/**\n * The `<TableRow>` defines a row of cells in a table. The row's cells can then\n * be established using a mix of `<TableCell>` and `<TableHeader>` components.\n *\n * Must be used as a child of a `<TableHead>`, `<TableBody>`, or `<TableFoot>`.\n *\n * Permitted Content:\n * 1. 0 or more: `<TableHeader>` or `<TableCell>`\n *\n * @example\n * ```tsx\n * <Table>\n * <TableCaption>A list of your recent invoices.</TableCaption>\n * <TableHead>\n * <TableRow>\n * <TableHeader className=\"w-[100px]\">Invoice</TableHeader>\n * <TableHeader>Status</TableHeader>\n * <TableHeader>Method</TableHeader>\n * <TableHeader className=\"text-right\">Amount</TableHeader>\n * </TableRow>\n * </TableHead>\n * <TableBody>\n * {invoices.map((invoice) => (\n * <TableRow key={invoice.invoice}>\n * <TableCell className=\"font-medium\">{invoice.invoice}</TableCell>\n * <TableCell>{invoice.paymentStatus}</TableCell>\n * <TableCell>{invoice.paymentMethod}</TableCell>\n * <TableCell className=\"text-right\">{invoice.totalAmount}</TableCell>\n * </TableRow>\n * ))}\n * </TableBody>\n * <TableFoot>\n * <TableRow>\n * <TableCell colSpan={3}>Total</TableCell>\n * <TableCell className=\"text-right\">$2,500.00</TableCell>\n * </TableRow>\n * </TableFoot>\n * </Table>\n * ```\n *\n * @see https://mantle.ngrok.com/components/table#api-table-row\n */\nconst TableRow = forwardRef<ComponentRef<\"tr\">, ComponentProps<\"tr\">>(\n\t({ className, ...props }, ref) => (\n\t\t<tr\n\t\t\tref={ref}\n\t\t\tclassName={cx(\n\t\t\t\t// \"data-state-selected:bg-gray-200\",\n\t\t\t\t\"[&>td]:border-b [&>td]:border-gray-300 [&>td]:last:border-b-0 [&>td]:bg-card [&>td]:hover:bg-gray-200/50\",\n\t\t\t\tclassName,\n\t\t\t)}\n\t\t\t{...props}\n\t\t/>\n\t),\n);\nTableRow.displayName = \"TableRow\";\n\n/**\n * The `<TableHeader>` defines a cell as the header of a group of table cells\n * and may be used as a child of a `<TableRow>`. The exact nature of this group\n * is defined by the scope and headers attributes.\n *\n * Must be used as a child of a `<TableRow>`.\n *\n * Permitted Content:\n * 1. Flow content, but with no header, footer, sectioning content, or heading\n * content descendants.\n *\n * @example\n * ```tsx\n * <Table>\n * <TableCaption>A list of your recent invoices.</TableCaption>\n * <TableHead>\n * <TableRow>\n * <TableHeader className=\"w-[100px]\">Invoice</TableHeader>\n * <TableHeader>Status</TableHeader>\n * <TableHeader>Method</TableHeader>\n * <TableHeader className=\"text-right\">Amount</TableHeader>\n * </TableRow>\n * </TableHead>\n * <TableBody>\n * {invoices.map((invoice) => (\n * <TableRow key={invoice.invoice}>\n * <TableCell className=\"font-medium\">{invoice.invoice}</TableCell>\n * <TableCell>{invoice.paymentStatus}</TableCell>\n * <TableCell>{invoice.paymentMethod}</TableCell>\n * <TableCell className=\"text-right\">{invoice.totalAmount}</TableCell>\n * </TableRow>\n * ))}\n * </TableBody>\n * <TableFoot>\n * <TableRow>\n * <TableCell colSpan={3}>Total</TableCell>\n * <TableCell className=\"text-right\">$2,500.00</TableCell>\n * </TableRow>\n * </TableFoot>\n * </Table>\n * ```\n *\n * @see https://mantle.ngrok.com/components/table#api-table-header\n */\nconst TableHeader = forwardRef<ComponentRef<\"th\">, ComponentProps<\"th\">>(\n\t({ className, ...props }, ref) => (\n\t\t<th\n\t\t\tref={ref}\n\t\t\tclassName={cx(\n\t\t\t\t\"h-12 px-4 text-left align-middle text-sm font-medium [&:has([role=checkbox])]:pr-0\",\n\t\t\t\tclassName,\n\t\t\t)}\n\t\t\t{...props}\n\t\t/>\n\t),\n);\nTableHead.displayName = \"TableHead\";\n\n/**\n * The `<TableCell>` defines a cell of a table that contains data and may be\n * used as a child of a `<TableRow>`.\n *\n * Must be used as a child of a `<TableRow>`.\n *\n * Permitted Content:\n * 1. Flow content\n *\n * @example\n * ```tsx\n * <Table>\n * <TableCaption>A list of your recent invoices.</TableCaption>\n * <TableHead>\n * <TableRow>\n * <TableHeader className=\"w-[100px]\">Invoice</TableHeader>\n * <TableHeader>Status</TableHeader>\n * <TableHeader>Method</TableHeader>\n * <TableHeader className=\"text-right\">Amount</TableHeader>\n * </TableRow>\n * </TableHead>\n * <TableBody>\n * {invoices.map((invoice) => (\n * <TableRow key={invoice.invoice}>\n * <TableCell className=\"font-medium\">{invoice.invoice}</TableCell>\n * <TableCell>{invoice.paymentStatus}</TableCell>\n * <TableCell>{invoice.paymentMethod}</TableCell>\n * <TableCell className=\"text-right\">{invoice.totalAmount}</TableCell>\n * </TableRow>\n * ))}\n * </TableBody>\n * <TableFoot>\n * <TableRow>\n * <TableCell colSpan={3}>Total</TableCell>\n * <TableCell className=\"text-right\">$2,500.00</TableCell>\n * </TableRow>\n * </TableFoot>\n * </Table>\n * ```\n *\n * @see https://mantle.ngrok.com/components/table#api-table-cell\n */\nconst TableCell = forwardRef<ComponentRef<\"td\">, ComponentProps<\"td\">>(\n\t({ className, ...props }, ref) => (\n\t\t<td\n\t\t\tref={ref}\n\t\t\tclassName={cx(\n\t\t\t\t\"p-4 align-middle [&:has([role=checkbox])]:pr-0 font-mono text-size-mono\",\n\t\t\t\tclassName,\n\t\t\t)}\n\t\t\t{...props}\n\t\t/>\n\t),\n);\nTableCell.displayName = \"TableCell\";\n\n/**\n * The optional `<TableCaption>` specifies the caption (or title) of a table,\n * providing the table an accessible description.\n *\n * If used, must be the first child of a `<Table>`.\n *\n * Permitted Content:\n * 1. Flow content\n *\n * @example\n * ```tsx\n * <Table>\n * <TableCaption>A list of your recent invoices.</TableCaption>\n * <TableHead>\n * <TableRow>\n * <TableHeader className=\"w-[100px]\">Invoice</TableHeader>\n * <TableHeader>Status</TableHeader>\n * <TableHeader>Method</TableHeader>\n * <TableHeader className=\"text-right\">Amount</TableHeader>\n * </TableRow>\n * </TableHead>\n * <TableBody>\n * {invoices.map((invoice) => (\n * <TableRow key={invoice.invoice}>\n * <TableCell className=\"font-medium\">{invoice.invoice}</TableCell>\n * <TableCell>{invoice.paymentStatus}</TableCell>\n * <TableCell>{invoice.paymentMethod}</TableCell>\n * <TableCell className=\"text-right\">{invoice.totalAmount}</TableCell>\n * </TableRow>\n * ))}\n * </TableBody>\n * <TableFoot>\n * <TableRow>\n * <TableCell colSpan={3}>Total</TableCell>\n * <TableCell className=\"text-right\">$2,500.00</TableCell>\n * </TableRow>\n * </TableFoot>\n * </Table>\n * ```\n *\n * @see https://mantle.ngrok.com/components/table#api-table-caption\n */\nconst TableCaption = forwardRef<\n\tComponentRef<\"caption\">,\n\tComponentProps<\"caption\">\n>(({ className, ...props }, ref) => (\n\t<caption\n\t\tref={ref}\n\t\tclassName={cx(\n\t\t\t\"border-t border-gray-300 py-4 text-sm text-gray-500\",\n\t\t\tclassName,\n\t\t)}\n\t\t{...props}\n\t/>\n));\nTableCaption.displayName = \"TableCaption\";\n\nexport {\n\t//,\n\tTable,\n\tTableBody,\n\tTableCaption,\n\tTableCell,\n\tTableFoot,\n\tTableHead,\n\tTableHeader,\n\tTableRow,\n};\n\n/**\n * A custom hook that observes the horizontal overflow of an element and determines\n * if it has overflow and if it is scrolled to the end.\n *\n * @private\n */\nfunction useHorizontalOverflowObserver<T extends HTMLElement>() {\n\tconst ref = useRef<T | null>(null);\n\tconst [state, setState] = useState({\n\t\thasOverflow: false,\n\t\tscrolledToEnd: false,\n\t});\n\n\tuseEffect(() => {\n\t\tconst element = ref.current;\n\t\tif (!element) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst checkState = () => {\n\t\t\tconst hasOverflow = element.scrollWidth > element.clientWidth;\n\t\t\tconst scrolledToEnd =\n\t\t\t\tMath.abs(\n\t\t\t\t\telement.scrollWidth - element.scrollLeft - element.clientWidth,\n\t\t\t\t) < 1;\n\n\t\t\tsetState((previous) => {\n\t\t\t\tif (\n\t\t\t\t\tprevious.hasOverflow !== hasOverflow ||\n\t\t\t\t\tprevious.scrolledToEnd !== scrolledToEnd\n\t\t\t\t) {\n\t\t\t\t\treturn { hasOverflow, scrolledToEnd };\n\t\t\t\t}\n\t\t\t\treturn previous; // No state change\n\t\t\t});\n\t\t};\n\n\t\tconst resizeObserver = new ResizeObserver(checkState);\n\t\tresizeObserver.observe(element);\n\n\t\tconst mutationObserver = new MutationObserver(checkState);\n\t\tmutationObserver.observe(element, { childList: true, subtree: true });\n\n\t\telement.addEventListener(\"scroll\", checkState, { passive: true });\n\n\t\tcheckState();\n\n\t\treturn () => {\n\t\t\tresizeObserver.disconnect();\n\t\t\tmutationObserver.disconnect();\n\t\t\telement.removeEventListener(\"scroll\", checkState);\n\t\t};\n\t}, []);\n\n\treturn useMemo(() => ({ ref, state }), [state]);\n}\n"],"mappings":"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","names":["forwardRef","useEffect","useMemo","useRef","useState","jsx","Table","forwardRef","children","className","style","props","ref","horizontalOverflow","useHorizontalOverflowObserver","cx","TableHead","TableBody","TableFoot","TableRow","TableHeader","TableCell","TableCaption","useHorizontalOverflowObserver","ref","useRef","state","setState","useState","useEffect","element","checkState","hasOverflow","scrolledToEnd","previous","resizeObserver","mutationObserver","useMemo"]}
|
package/dist/code-block.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as _}from"./chunk-IWKI4XHM.js";import{a as O}from"./chunk-GOXG4BVJ.js";import{a as R}from"./chunk-7O36LG52.js";import"./chunk-HDPLH5HC.js";import{a as c}from"./chunk-AZ56JGNY.js";import{CaretDown as ae}from"@phosphor-icons/react/CaretDown";import{Check as se}from"@phosphor-icons/react/Check";import{Copy as ie}from"@phosphor-icons/react/Copy";import{FileText as de}from"@phosphor-icons/react/FileText";import{Terminal as pe}from"@phosphor-icons/react/Terminal";import{Slot as b}from"@radix-ui/react-slot";import le from"clsx";import{createContext as ue,forwardRef as C,useContext as P,useEffect as B,useId as ce,useMemo as F,useRef as me,useState as h}from"react";import H from"tiny-invariant";function M(e){let t="";for(let n of e)switch(n){case"&":t+="&";break;case"<":t+="<";break;case">":t+=">";break;case'"':t+=""";break;case"'":t+="'";break;default:t+=n}return t}import E from"prismjs";import"prismjs/components/prism-bash.js";import"prismjs/components/prism-csharp.js";import"prismjs/components/prism-css.js";import"prismjs/components/prism-go.js";import"prismjs/components/prism-java.js";import"prismjs/components/prism-javascript.js";import"prismjs/components/prism-json.js";import"prismjs/components/prism-jsx.js";import"prismjs/components/prism-markup.js";import"prismjs/components/prism-python.js";import"prismjs/components/prism-ruby.js";import"prismjs/components/prism-rust.js";import"prismjs/components/prism-tsx.js";import"prismjs/components/prism-typescript.js";import"prismjs/components/prism-yaml.js";var W=["tabs","spaces"];function $(e,t){return t||(oe(e)?"tabs":(ne(e),"spaces"))}var ee=["csharp","css","go","html","java","javascript","js","jsx","ts","tsx","typescript","xml"],te=["python","py","yaml","yml","ruby","rb"];function oe(e){return ee.includes(e)}function ne(e){return te.includes(e)}function L(e,t){let{indentation:n="spaces"}=t||{};return e.trim().replace(/^[ \t]*(?=\S)/gm,o=>n==="spaces"?o.replace(/\t/g," "):o.replace(/ {2}/g," "))}var v=["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 re(e){if(!e)return"sh";let t=e.trim().slice(e.indexOf("-")+1);return D(t)?t:"sh"}var D=e=>typeof e=="string"&&v.includes(e);function N(e="sh"){return`language-${e??"sh"}`}import{Fragment as fe,jsx as s,jsxs as j}from"react/jsx-runtime";var S=ue({codeId:void 0,copyText:"",hasCodeExpander:!1,isCodeExpanded:!1,registerCodeId:()=>{},setCopyText:()=>{},setHasCodeExpander:()=>{},setIsCodeExpanded:()=>{},unregisterCodeId:()=>{}}),V=C(({asChild:e=!1,className:t,...n},o)=>{let[r,a]=h(""),[i,d]=h(!1),[l,g]=h(!1),[p,u]=h(void 0),k=F(()=>({codeId:p,copyText:r,hasCodeExpander:i,isCodeExpanded:l,registerCodeId:m=>{u(y=>(H(y==null,"You can only render a single CodeBlockCode within a CodeBlock."),m))},setCopyText:a,setHasCodeExpander:d,setIsCodeExpanded:g,unregisterCodeId:m=>{u(y=>{H(y===m,"You can only render a single CodeBlockCode within a CodeBlock.")})}}),[p,r,i,l]),f=e?b:"div";return s(S.Provider,{value:k,children:s(f,{className:c("text-mono overflow-hidden rounded-md border border-gray-300 bg-gray-50 font-mono","[&_svg]:shrink-0",t),ref:o,...n})})});V.displayName="CodeBlock";var Y=C(({asChild:e=!1,className:t,...n},o)=>s(e?b:"div",{className:c("relative",t),ref:o,...n}));Y.displayName="CodeBlockBody";var q=C(({className:e,highlightLines:t,indentation:n,language:o="text",showLineNumbers:r,style:a,tabIndex:i,value:d,...l},g)=>{let p=ce(),{hasCodeExpander:u,isCodeExpanded:k,registerCodeId:f,setCopyText:m,unregisterCodeId:y}=P(S),T=$(o,n),I=F(()=>L(d,{indentation:T}),[d,T]),[U,X]=h(M(L(d,{indentation:T})));B(()=>{let
|
|
1
|
+
import{a as _}from"./chunk-IWKI4XHM.js";import{a as O}from"./chunk-GOXG4BVJ.js";import{a as R}from"./chunk-7O36LG52.js";import"./chunk-HDPLH5HC.js";import{a as c}from"./chunk-AZ56JGNY.js";import{CaretDown as ae}from"@phosphor-icons/react/CaretDown";import{Check as se}from"@phosphor-icons/react/Check";import{Copy as ie}from"@phosphor-icons/react/Copy";import{FileText as de}from"@phosphor-icons/react/FileText";import{Terminal as pe}from"@phosphor-icons/react/Terminal";import{Slot as b}from"@radix-ui/react-slot";import le from"clsx";import{createContext as ue,forwardRef as C,useContext as P,useEffect as B,useId as ce,useMemo as F,useRef as me,useState as h}from"react";import H from"tiny-invariant";function M(e){let t="";for(let n of e)switch(n){case"&":t+="&";break;case"<":t+="<";break;case">":t+=">";break;case'"':t+=""";break;case"'":t+="'";break;default:t+=n}return t}import E from"prismjs";import"prismjs/components/prism-bash.js";import"prismjs/components/prism-csharp.js";import"prismjs/components/prism-css.js";import"prismjs/components/prism-go.js";import"prismjs/components/prism-java.js";import"prismjs/components/prism-javascript.js";import"prismjs/components/prism-json.js";import"prismjs/components/prism-jsx.js";import"prismjs/components/prism-markup.js";import"prismjs/components/prism-python.js";import"prismjs/components/prism-ruby.js";import"prismjs/components/prism-rust.js";import"prismjs/components/prism-tsx.js";import"prismjs/components/prism-typescript.js";import"prismjs/components/prism-yaml.js";var W=["tabs","spaces"];function $(e,t){return t||(oe(e)?"tabs":(ne(e),"spaces"))}var ee=["csharp","css","go","html","java","javascript","js","jsx","ts","tsx","typescript","xml"],te=["python","py","yaml","yml","ruby","rb"];function oe(e){return ee.includes(e)}function ne(e){return te.includes(e)}function L(e,t){let{indentation:n="spaces"}=t||{};return e.trim().replace(/^[ \t]*(?=\S)/gm,o=>n==="spaces"?o.replace(/\t/g," "):o.replace(/ {2}/g," "))}var v=["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 re(e){if(!e)return"sh";let t=e.trim().slice(e.indexOf("-")+1);return D(t)?t:"sh"}var D=e=>typeof e=="string"&&v.includes(e);function N(e="sh"){return`language-${e??"sh"}`}import{Fragment as fe,jsx as s,jsxs as j}from"react/jsx-runtime";var S=ue({codeId:void 0,copyText:"",hasCodeExpander:!1,isCodeExpanded:!1,registerCodeId:()=>{},setCopyText:()=>{},setHasCodeExpander:()=>{},setIsCodeExpanded:()=>{},unregisterCodeId:()=>{}}),V=C(({asChild:e=!1,className:t,...n},o)=>{let[r,a]=h(""),[i,d]=h(!1),[l,g]=h(!1),[p,u]=h(void 0),k=F(()=>({codeId:p,copyText:r,hasCodeExpander:i,isCodeExpanded:l,registerCodeId:m=>{u(y=>(H(y==null,"You can only render a single CodeBlockCode within a CodeBlock."),m))},setCopyText:a,setHasCodeExpander:d,setIsCodeExpanded:g,unregisterCodeId:m=>{u(y=>{H(y===m,"You can only render a single CodeBlockCode within a CodeBlock.")})}}),[p,r,i,l]),f=e?b:"div";return s(S.Provider,{value:k,children:s(f,{className:c("text-size-mono overflow-hidden rounded-md border border-gray-300 bg-gray-50 font-mono","[&_svg]:shrink-0",t),ref:o,...n})})});V.displayName="CodeBlock";var Y=C(({asChild:e=!1,className:t,...n},o)=>s(e?b:"div",{className:c("relative",t),ref:o,...n}));Y.displayName="CodeBlockBody";var q=C(({className:e,highlightLines:t,indentation:n,language:o="text",showLineNumbers:r,style:a,tabIndex:i,value:d,...l},g)=>{let p=ce(),{hasCodeExpander:u,isCodeExpanded:k,registerCodeId:f,setCopyText:m,unregisterCodeId:y}=P(S),T=$(o,n),I=F(()=>L(d,{indentation:T}),[d,T]),[U,X]=h(M(L(d,{indentation:T})));B(()=>{let A=E.languages[o];H(A,`CodeBlock does not support the language "${o}". The syntax highlighter does not have a grammar for this language. The supported languages are: ${v.join(", ")}.`);let Z=E.highlight(I,A,o);X(Z)},[I,o]),B(()=>{m(I)},[I,m]),B(()=>(f(p),()=>{y(p)}),[p,f,y]);let z=N(o);return s("pre",{"aria-expanded":u?k:void 0,className:c("scrollbar firefox:after:mr-[3.375rem] firefox:after:inline-block firefox:after:content-[''] overflow-x-auto overflow-y-hidden p-4 pr-14","text-size-inherit text-size-mono m-0 font-mono","aria-collapsed:max-h-[13.6rem]",z,e),"data-lang":o,id:p,ref:g,style:{...a,tabSize:2,MozTabSize:2},tabIndex:i??-1,...l,children:s("code",{className:le("text-size-inherit",z),dangerouslySetInnerHTML:{__html:U},suppressHydrationWarning:!0})})});q.displayName="CodeBlockCode";var J=C(({asChild:e=!1,className:t,...n},o)=>s(e?b:"div",{className:c("flex items-center gap-1 border-b border-gray-300 bg-gray-100 px-4 py-2 text-gray-700",t),ref:o,...n}));J.displayName="CodeBlockHeader";var Q=C(({asChild:e=!1,className:t,...n},o)=>s(e?b:"h3",{ref:o,className:c("text-size-mono m-0 font-mono font-normal",t),...n}));Q.displayName="CodeBlockTitle";var G=C(({asChild:e=!1,className:t,onCopy:n,onCopyError:o,onClick:r,...a},i)=>{let{copyText:d}=P(S),[,l]=_(),[g,p]=h(!1),u=me(0);return j(e?b:"button",{type:"button",className:c("focus-visible:border-accent-600 focus-visible:ring-focus-accent absolute right-2.5 top-2.5 z-10 flex size-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:outline-none focus-visible:ring-4",g&&"bg-filled-success text-on-filled hover:bg-filled-success focus:bg-filled-success focus-visible:border-success-600 focus-visible:ring-focus-success w-auto gap-1 border-transparent pl-2 pr-1.5 hover:border-transparent",t),ref:i,onClick:async f=>{try{if(r?.(f),f.defaultPrevented){window.clearTimeout(u.current);return}await l(d),n?.(d),p(!0),window.clearTimeout(u.current),u.current=window.setTimeout(()=>{p(!1)},2e3)}catch(m){o?.(m)}},...a,children:[s("span",{className:"sr-only",children:"Copy code"}),g?j(fe,{children:["Copied",s(se,{className:"size-4 shrink-0",weight:"bold"})]}):s(ie,{className:"-ml-px size-5 shrink-0"})]})});G.displayName="CodeBlockCopyButton";var K=C(({asChild:e=!1,className:t,onClick:n,...o},r)=>{let{codeId:a,isCodeExpanded:i,setIsCodeExpanded:d,setHasCodeExpander:l}=P(S);return B(()=>(l(!0),()=>{l(!1)}),[l]),j(e?b:"button",{...o,"aria-controls":a,"aria-expanded":i,className:c("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",t),ref:r,type:"button",onClick:p=>{d(u=>!u),n?.(p)},children:[i?"Show less":"Show more"," ",s(ae,{className:c("size-4 shrink-0",i&&"rotate-180","transition-all duration-150"),weight:"bold"})]})});K.displayName="CodeBlockExpanderButton";function ge({className:e,preset:t,svg:n,...o}){let r=n;if(t!=null)switch(t){case"file":r=s(de,{weight:"fill"});break;case"cli":r=s(pe,{weight:"fill"});break;case"traffic-policy":r=s(O,{});break}return s(R,{className:e,svg:r,...o})}function Ce(e,...t){if(!he(e)||!Array.isArray(t))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 n=String.raw({raw:e},...t),o=ye(n);return n.trim().split(`
|
|
2
2
|
`).map(a=>/^\S+/.test(a)?a:a.slice(o)).join(`
|
|
3
3
|
`)}function ye(e){let t=e.match(/^[ \t]*(?=\S)/gm);return t?t.reduce((n,o)=>Math.min(n,o.length),Number.POSITIVE_INFINITY):0}function he(e){return Array.isArray(e)&&"raw"in e&&Array.isArray(e.raw)}import{z as x}from"zod";var be=["cli","file","traffic-policy"],xe=x.object({collapsible:x.boolean().default(!1),disableCopy:x.boolean().default(!1),mode:x.enum(be).optional(),title:x.string().trim().optional(),indentation:x.enum(W).optional()}),w={collapsible:!1,disableCopy:!1,mode:void 0,title:void 0,indentation:void 0};function ke(e){let t=e?.trim()??"";if(!t)return w;let n=Le(t).reduce((o,r)=>{let[a,i]=r.split("=");if(!a)return o;let d=Ie(i);return o[a]=d??!0,o},{});try{let o=xe.parse(n);return{...w,...o}}catch{return w}}function Ie(e){return e?.trim().replace(/^"(.*)"$/,"$1")}function Le(e){let t=e?.trim()??"",n=[],o="",r=!1;for(let a of t)a===" "&&!r?o&&(n.push(o),o=""):(a==='"'&&(r=!r),o+=a);return o&&n.push(o),n}export{V as CodeBlock,Y as CodeBlockBody,q as CodeBlockCode,G as CodeBlockCopyButton,K as CodeBlockExpanderButton,J as CodeBlockHeader,ge as CodeBlockIcon,Q as CodeBlockTitle,w as defaultMeta,M as escapeHtml,Ce as fmtCode,N as formatLanguageClassName,D as isSupportedLanguage,L as normalizeIndentation,re as parseLanguage,ke as parseMetastring,v as supportedLanguages};
|
|
4
4
|
//# sourceMappingURL=code-block.js.map
|