@cerberus-design/react 0.9.1 → 0.9.2-next-dd740c8
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/build/legacy/_tsup-dts-rollup.d.cts +0 -9
- package/build/legacy/components/FileStatus.cjs +147 -46
- package/build/legacy/components/FileStatus.cjs.map +1 -1
- package/build/legacy/components/FileUploader.cjs +116 -16
- package/build/legacy/components/FileUploader.cjs.map +1 -1
- package/build/legacy/context/confirm-modal.cjs +136 -43
- package/build/legacy/context/confirm-modal.cjs.map +1 -1
- package/build/legacy/context/prompt-modal.cjs +136 -43
- package/build/legacy/context/prompt-modal.cjs.map +1 -1
- package/build/legacy/index.cjs +290 -259
- package/build/legacy/index.cjs.map +1 -1
- package/build/modern/_tsup-dts-rollup.d.ts +0 -9
- package/build/modern/{chunk-MLCVO7JP.js → chunk-DGJPW76I.js} +18 -18
- package/build/modern/chunk-DGJPW76I.js.map +1 -0
- package/build/modern/{chunk-KKJKOKP7.js → chunk-O6WHVUEW.js} +4 -4
- package/build/modern/{chunk-CZMC77YO.js → chunk-T7TOXGZT.js} +35 -10
- package/build/modern/chunk-T7TOXGZT.js.map +1 -0
- package/build/modern/{chunk-GB3SECCO.js → chunk-WWJRKSM5.js} +35 -10
- package/build/modern/chunk-WWJRKSM5.js.map +1 -0
- package/build/modern/{chunk-TUIVLIJI.js → chunk-XOVQGPIE.js} +16 -4
- package/build/modern/chunk-XOVQGPIE.js.map +1 -0
- package/build/modern/components/FileStatus.js +3 -1
- package/build/modern/components/FileUploader.js +2 -1
- package/build/modern/context/confirm-modal.js +3 -3
- package/build/modern/context/notification-center.js +2 -2
- package/build/modern/context/prompt-modal.js +3 -3
- package/build/modern/index.js +14 -18
- package/build/modern/index.js.map +1 -1
- package/package.json +2 -2
- package/src/components/FileStatus.tsx +17 -19
- package/src/components/FileUploader.tsx +12 -5
- package/src/context/confirm-modal.tsx +25 -12
- package/src/context/prompt-modal.tsx +25 -12
- package/src/index.ts +0 -1
- package/build/legacy/components/ModalIcon.cjs +0 -51
- package/build/legacy/components/ModalIcon.cjs.map +0 -1
- package/build/modern/chunk-CZMC77YO.js.map +0 -1
- package/build/modern/chunk-GB3SECCO.js.map +0 -1
- package/build/modern/chunk-MLCVO7JP.js.map +0 -1
- package/build/modern/chunk-TUIVLIJI.js.map +0 -1
- package/build/modern/chunk-VCR5C6Q3.js +0 -29
- package/build/modern/chunk-VCR5C6Q3.js.map +0 -1
- package/build/modern/components/ModalIcon.js +0 -7
- package/build/modern/components/ModalIcon.js.map +0 -1
- package/src/components/ModalIcon.tsx +0 -28
- /package/build/modern/{chunk-KKJKOKP7.js.map → chunk-O6WHVUEW.js.map} +0 -0
|
@@ -77,7 +77,6 @@ import { label } from '@cerberus/styled-system/recipes';
|
|
|
77
77
|
import { MeasuringConfiguration } from '@dnd-kit/core';
|
|
78
78
|
import { MeasuringFrequency } from '@dnd-kit/core';
|
|
79
79
|
import { MeasuringStrategy } from '@dnd-kit/core';
|
|
80
|
-
import { ModalIconVariantProps } from '@cerberus/styled-system/recipes';
|
|
81
80
|
import { Modifier } from '@dnd-kit/core';
|
|
82
81
|
import { Modifiers } from '@dnd-kit/core';
|
|
83
82
|
import { MouseEvent as MouseEvent_2 } from 'react';
|
|
@@ -808,14 +807,6 @@ declare type ModalHeadingProps = HTMLAttributes<HTMLParagraphElement>;
|
|
|
808
807
|
export { ModalHeadingProps }
|
|
809
808
|
export { ModalHeadingProps as ModalHeadingProps_alias_1 }
|
|
810
809
|
|
|
811
|
-
declare function ModalIcon(props: PropsWithChildren<ModalIconProps>): JSX_2.Element;
|
|
812
|
-
export { ModalIcon }
|
|
813
|
-
export { ModalIcon as ModalIcon_alias_1 }
|
|
814
|
-
|
|
815
|
-
declare type ModalIconProps = HTMLAttributes<HTMLDivElement> & ModalIconVariantProps;
|
|
816
|
-
export { ModalIconProps }
|
|
817
|
-
export { ModalIconProps as ModalIconProps_alias_1 }
|
|
818
|
-
|
|
819
810
|
/**
|
|
820
811
|
* This module contains the Modal root component for a customizable modal.
|
|
821
812
|
* @module
|
|
@@ -4,6 +4,9 @@ import {
|
|
|
4
4
|
import {
|
|
5
5
|
IconButton
|
|
6
6
|
} from "./chunk-SLHX5K6I.js";
|
|
7
|
+
import {
|
|
8
|
+
Avatar
|
|
9
|
+
} from "./chunk-UN3OAW56.js";
|
|
7
10
|
import {
|
|
8
11
|
FieldMessage
|
|
9
12
|
} from "./chunk-VGHVH2T3.js";
|
|
@@ -23,7 +26,7 @@ import {
|
|
|
23
26
|
fileStatus
|
|
24
27
|
} from "@cerberus/styled-system/recipes";
|
|
25
28
|
import { css, cx } from "@cerberus/styled-system/css";
|
|
26
|
-
import {
|
|
29
|
+
import { hstack, vstack } from "@cerberus/styled-system/patterns";
|
|
27
30
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
28
31
|
var processStatus = /* @__PURE__ */ ((processStatus2) => {
|
|
29
32
|
processStatus2["TODO"] = "todo";
|
|
@@ -67,15 +70,12 @@ function FileStatus(props) {
|
|
|
67
70
|
className: cx(nativeProps.className, styles.root, hstack()),
|
|
68
71
|
children: [
|
|
69
72
|
/* @__PURE__ */ jsx(
|
|
70
|
-
|
|
73
|
+
Avatar,
|
|
71
74
|
{
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
})
|
|
77
|
-
),
|
|
78
|
-
children: /* @__PURE__ */ jsx(MatchFileStatusIcon, { status })
|
|
75
|
+
ariaLabel: "",
|
|
76
|
+
gradient: modalIconPalette,
|
|
77
|
+
icon: /* @__PURE__ */ jsx(MatchFileStatusIcon, { size: 24, status }),
|
|
78
|
+
src: ""
|
|
79
79
|
}
|
|
80
80
|
),
|
|
81
81
|
/* @__PURE__ */ jsxs(
|
|
@@ -98,7 +98,7 @@ function FileStatus(props) {
|
|
|
98
98
|
}
|
|
99
99
|
),
|
|
100
100
|
/* @__PURE__ */ jsx(ProgressBar, { now, size: "sm" }),
|
|
101
|
-
/* @__PURE__ */ jsx(Field, { invalid: modalIconPalette === "
|
|
101
|
+
/* @__PURE__ */ jsx(Field, { invalid: modalIconPalette === "red", children: /* @__PURE__ */ jsx(
|
|
102
102
|
FieldMessage,
|
|
103
103
|
{
|
|
104
104
|
className: css({
|
|
@@ -134,11 +134,11 @@ function MatchFileStatusIcon(props) {
|
|
|
134
134
|
switch (props.status) {
|
|
135
135
|
case "todo" /* TODO */:
|
|
136
136
|
case "processing" /* PROCESSING */:
|
|
137
|
-
return /* @__PURE__ */ jsx(FileUploaderIcon, {});
|
|
137
|
+
return /* @__PURE__ */ jsx(FileUploaderIcon, { size: props.size });
|
|
138
138
|
case "done" /* DONE */:
|
|
139
|
-
return /* @__PURE__ */ jsx(DoneIcon, {});
|
|
139
|
+
return /* @__PURE__ */ jsx(DoneIcon, { size: props.size });
|
|
140
140
|
case "error" /* ERROR */:
|
|
141
|
-
return /* @__PURE__ */ jsx(InvalidIcon, {});
|
|
141
|
+
return /* @__PURE__ */ jsx(InvalidIcon, { size: props.size });
|
|
142
142
|
default:
|
|
143
143
|
throw new Error("Unknown status");
|
|
144
144
|
}
|
|
@@ -201,13 +201,13 @@ function getModalIconPalette(status) {
|
|
|
201
201
|
switch (status) {
|
|
202
202
|
case "todo" /* TODO */:
|
|
203
203
|
case "processing" /* PROCESSING */:
|
|
204
|
-
return "
|
|
204
|
+
return "light-purple";
|
|
205
205
|
case "error" /* ERROR */:
|
|
206
|
-
return "
|
|
206
|
+
return "red";
|
|
207
207
|
case "done" /* DONE */:
|
|
208
|
-
return "
|
|
208
|
+
return "green";
|
|
209
209
|
default:
|
|
210
|
-
return "
|
|
210
|
+
return "light-purple";
|
|
211
211
|
}
|
|
212
212
|
}
|
|
213
213
|
|
|
@@ -215,4 +215,4 @@ export {
|
|
|
215
215
|
processStatus,
|
|
216
216
|
FileStatus
|
|
217
217
|
};
|
|
218
|
-
//# sourceMappingURL=chunk-
|
|
218
|
+
//# sourceMappingURL=chunk-DGJPW76I.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/FileStatus.tsx"],"sourcesContent":["'use client'\n\nimport {\n useCallback,\n useMemo,\n type HTMLAttributes,\n type MouseEvent,\n} from 'react'\nimport { ProgressBar } from './ProgressBar'\nimport { IconButton } from './IconButton'\nimport {\n fileStatus,\n type FileStatusVariantProps,\n} from '@cerberus/styled-system/recipes'\nimport { css, cx } from '@cerberus/styled-system/css'\nimport { hstack, vstack } from '@cerberus/styled-system/patterns'\nimport { $cerberusIcons } from '../config/defineIcons'\nimport { FieldMessage } from './FieldMessage'\nimport { Field } from '../context/field'\nimport { Avatar } from './Avatar'\n\n/**\n * This module contains the FileStatus component.\n * @module\n */\n\nexport type FileStatusKey = (typeof processStatus)[keyof typeof processStatus]\nexport type FileStatusActions = 'cancel' | 'retry' | 'delete'\nexport interface FileBaseStatusProps\n extends Omit<HTMLAttributes<HTMLDivElement>, 'onClick'> {\n file: string\n now: number\n status: processStatus\n onClick: (status: FileStatusActions, e: MouseEvent<HTMLButtonElement>) => void\n}\nexport type FileStatusProps = FileBaseStatusProps & FileStatusVariantProps\n\n/**\n * A helper object to represent the status of a file.\n * @example\n * ```tsx\n * import { fileStatus } from '@cerberus/react'\n * processStatus.TODO // 'todo'\n * ```\n */\nexport const enum processStatus {\n TODO = 'todo',\n PROCESSING = 'processing',\n DONE = 'done',\n ERROR = 'error',\n}\n\n/**\n * This component displays the status of a file.\n * @param props - {\n * file: string,\n * now: number,\n * status: keyof typeof fileStatus,\n * action: (status: FileStatusActions, e: MouseEvent<HTMLButtonElement>) => void\n * }.\n * @example\n * ```tsx\n * <FileStatus file=\"file.txt\" now={0} status={processStatus.TODO} action={(status, e) => console.log(status, e)} />\n * ```\n */\nexport function FileStatus(props: FileStatusProps) {\n const { file, now, status, onClick, ...nativeProps } = props\n const actionLabel = useMemo(() => getStatusActionLabel(status), [status])\n const palette = useMemo(() => getPalette(status), [status])\n const modalIconPalette = useMemo(() => getModalIconPalette(status), [status])\n const styles = useMemo(() => {\n switch (status) {\n case processStatus.TODO:\n return fileStatus({ status: 'todo' })\n case processStatus.PROCESSING:\n return fileStatus({ status: 'processing' })\n case processStatus.DONE:\n return fileStatus({ status: 'done' })\n case processStatus.ERROR:\n return fileStatus({ status: 'error' })\n default:\n return fileStatus()\n }\n }, [status])\n\n const handleClick = useCallback(\n (e: MouseEvent<HTMLButtonElement>) => {\n const actionStatus = getStatusActionLabel(\n status,\n ).toLocaleLowerCase() as FileStatusActions\n onClick(actionStatus, e)\n },\n [onClick],\n )\n\n return (\n <div\n {...nativeProps}\n className={cx(nativeProps.className, styles.root, hstack())}\n >\n <Avatar\n ariaLabel=\"\"\n gradient={modalIconPalette}\n icon={<MatchFileStatusIcon size={24} status={status} />}\n src=\"\"\n />\n\n <div\n className={vstack({\n alignItems: 'flex-start',\n gap: '0.12rem',\n w: 'full',\n })}\n >\n <small\n className={css({\n color: 'page.text.initial',\n textStyle: 'label-sm',\n })}\n >\n {file}\n </small>\n <ProgressBar now={now} size=\"sm\" />\n <Field invalid={modalIconPalette === 'red'}>\n <FieldMessage\n className={css({\n color: 'page.text.100',\n })}\n id={`help:${file}`}\n >\n <MatchFileStatusText status={status} now={now} />\n </FieldMessage>\n </Field>\n </div>\n\n <IconButton\n ariaLabel={actionLabel}\n onClick={handleClick}\n palette={palette}\n size=\"sm\"\n >\n <MatchStatusAction status={status} />\n </IconButton>\n </div>\n )\n}\n\ninterface FileStatusElProps {\n status: FileStatusProps['status']\n size?: 16 | 20 | 24 | 32\n now?: number\n}\n\nfunction MatchFileStatusIcon(props: FileStatusElProps) {\n const {\n fileUploader: FileUploaderIcon,\n invalidAlt: InvalidIcon,\n successNotification: DoneIcon,\n } = $cerberusIcons\n\n switch (props.status) {\n case processStatus.TODO:\n case processStatus.PROCESSING:\n return <FileUploaderIcon size={props.size} />\n case processStatus.DONE:\n return <DoneIcon size={props.size} />\n case processStatus.ERROR:\n return <InvalidIcon size={props.size} />\n default:\n throw new Error('Unknown status')\n }\n}\n\nfunction MatchFileStatusText(props: FileStatusElProps) {\n switch (props.status) {\n case processStatus.TODO:\n return 'Waiting to upload'\n case processStatus.PROCESSING:\n return `${props.now}% Complete`\n case processStatus.DONE:\n return 'File uploaded successfully'\n case processStatus.ERROR:\n return 'There was an error uploading the file'\n default:\n throw new Error('Invalid status')\n }\n}\n\nfunction MatchStatusAction(props: FileStatusElProps) {\n const { close: CloseIcon, redo: RedoIcon, delete: TrashIcon } = $cerberusIcons\n switch (props.status) {\n case processStatus.TODO:\n case processStatus.PROCESSING:\n return <CloseIcon />\n case processStatus.ERROR:\n return <RedoIcon />\n case processStatus.DONE:\n return <TrashIcon />\n default:\n throw new Error('Invalid status')\n }\n}\n\nfunction getStatusActionLabel(status: FileStatusKey) {\n switch (status) {\n case processStatus.TODO:\n case processStatus.PROCESSING:\n return 'Cancel'\n case processStatus.ERROR:\n return 'Retry'\n case processStatus.DONE:\n return 'Delete'\n default:\n return ''\n }\n}\n\nfunction getPalette(status: FileStatusKey) {\n switch (status) {\n case processStatus.TODO:\n case processStatus.PROCESSING:\n return 'danger'\n case processStatus.ERROR:\n return 'action'\n case processStatus.DONE:\n return 'danger'\n default:\n return 'action'\n }\n}\n\nfunction getModalIconPalette(status: FileStatusKey) {\n switch (status) {\n case processStatus.TODO:\n case processStatus.PROCESSING:\n return 'light-purple'\n case processStatus.ERROR:\n return 'red'\n case processStatus.DONE:\n return 'green'\n default:\n return 'light-purple'\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAEA;AAAA,EACE;AAAA,EACA;AAAA,OAGK;AAGP;AAAA,EACE;AAAA,OAEK;AACP,SAAS,KAAK,UAAU;AACxB,SAAS,QAAQ,cAAc;AAwFjB,cAIR,YAJQ;AA1DP,IAAW,gBAAX,kBAAWA,mBAAX;AACL,EAAAA,eAAA,UAAO;AACP,EAAAA,eAAA,gBAAa;AACb,EAAAA,eAAA,UAAO;AACP,EAAAA,eAAA,WAAQ;AAJQ,SAAAA;AAAA,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gB;AAAA,EACpC;AACF;AAEA,SAAS,kBAAkB,OAA0B;AACnD,QAAM,EAAE,OAAO,WAAW,MAAM,UAAU,QAAQ,UAAU,IAAI;AAChE,UAAQ,MAAM,QAAQ;AAAA,IACpB,KAAK;AAAA,IACL,KAAK;AACH,aAAO,oBAAC,aAAU;AAAA,IACpB,KAAK;AACH,aAAO,oBAAC,YAAS;AAAA,IACnB,KAAK;AACH,aAAO,oBAAC,aAAU;AAAA,IACpB;AACE,YAAM,IAAI,MAAM,gBAAgB;AAAA,EACpC;AACF;AAEA,SAAS,qBAAqB,QAAuB;AACnD,UAAQ,QAAQ;AAAA,IACd,KAAK;AAAA,IACL,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT;AACE,aAAO;AAAA,EACX;AACF;AAEA,SAAS,WAAW,QAAuB;AACzC,UAAQ,QAAQ;AAAA,IACd,KAAK;AAAA,IACL,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT;AACE,aAAO;AAAA,EACX;AACF;AAEA,SAAS,oBAAoB,QAAuB;AAClD,UAAQ,QAAQ;AAAA,IACd,KAAK;AAAA,IACL,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT;AACE,aAAO;AAAA,EACX;AACF;","names":["processStatus"]}
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Portal
|
|
3
|
-
} from "./chunk-4CAT3FHV.js";
|
|
4
1
|
import {
|
|
5
2
|
Notification
|
|
6
3
|
} from "./chunk-QZ6NS6VN.js";
|
|
@@ -10,6 +7,9 @@ import {
|
|
|
10
7
|
import {
|
|
11
8
|
NotificationHeading
|
|
12
9
|
} from "./chunk-3C2DJSEE.js";
|
|
10
|
+
import {
|
|
11
|
+
Portal
|
|
12
|
+
} from "./chunk-4CAT3FHV.js";
|
|
13
13
|
import {
|
|
14
14
|
Button
|
|
15
15
|
} from "./chunk-6F34A7NZ.js";
|
|
@@ -119,4 +119,4 @@ export {
|
|
|
119
119
|
NotificationCenter,
|
|
120
120
|
useNotificationCenter
|
|
121
121
|
};
|
|
122
|
-
//# sourceMappingURL=chunk-
|
|
122
|
+
//# sourceMappingURL=chunk-O6WHVUEW.js.map
|
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Portal
|
|
3
|
-
} from "./chunk-4CAT3FHV.js";
|
|
4
1
|
import {
|
|
5
2
|
ModalHeading
|
|
6
3
|
} from "./chunk-JB7IQ2BM.js";
|
|
7
4
|
import {
|
|
8
|
-
|
|
9
|
-
} from "./chunk-
|
|
5
|
+
Portal
|
|
6
|
+
} from "./chunk-4CAT3FHV.js";
|
|
10
7
|
import {
|
|
11
8
|
Input
|
|
12
9
|
} from "./chunk-FMFKM2AB.js";
|
|
@@ -22,6 +19,9 @@ import {
|
|
|
22
19
|
import {
|
|
23
20
|
ModalHeader
|
|
24
21
|
} from "./chunk-QU7UV5DB.js";
|
|
22
|
+
import {
|
|
23
|
+
Avatar
|
|
24
|
+
} from "./chunk-UN3OAW56.js";
|
|
25
25
|
import {
|
|
26
26
|
Button
|
|
27
27
|
} from "./chunk-6F34A7NZ.js";
|
|
@@ -106,11 +106,36 @@ function PromptModal(props) {
|
|
|
106
106
|
/* @__PURE__ */ jsx(Portal, { children: /* @__PURE__ */ jsxs(Modal, { onKeyDown: focusTrap, ref: modalRef, children: [
|
|
107
107
|
/* @__PURE__ */ jsxs(ModalHeader, { children: [
|
|
108
108
|
/* @__PURE__ */ jsx(
|
|
109
|
-
|
|
109
|
+
"div",
|
|
110
110
|
{
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
111
|
+
className: hstack({
|
|
112
|
+
justify: "center",
|
|
113
|
+
w: "full"
|
|
114
|
+
}),
|
|
115
|
+
children: /* @__PURE__ */ jsx(
|
|
116
|
+
Show,
|
|
117
|
+
{
|
|
118
|
+
when: palette === "danger",
|
|
119
|
+
fallback: /* @__PURE__ */ jsx(
|
|
120
|
+
Avatar,
|
|
121
|
+
{
|
|
122
|
+
ariaLabel: "",
|
|
123
|
+
gradient: "light-purple",
|
|
124
|
+
icon: /* @__PURE__ */ jsx(PromptIcon, { size: 24 }),
|
|
125
|
+
src: ""
|
|
126
|
+
}
|
|
127
|
+
),
|
|
128
|
+
children: /* @__PURE__ */ jsx(
|
|
129
|
+
Avatar,
|
|
130
|
+
{
|
|
131
|
+
ariaLabel: "",
|
|
132
|
+
gradient: "red",
|
|
133
|
+
icon: /* @__PURE__ */ jsx(PromptIcon, { size: 24 }),
|
|
134
|
+
src: ""
|
|
135
|
+
}
|
|
136
|
+
)
|
|
137
|
+
}
|
|
138
|
+
)
|
|
114
139
|
}
|
|
115
140
|
),
|
|
116
141
|
/* @__PURE__ */ jsx(ModalHeading, { children: content?.heading }),
|
|
@@ -204,4 +229,4 @@ export {
|
|
|
204
229
|
PromptModal,
|
|
205
230
|
usePromptModal
|
|
206
231
|
};
|
|
207
|
-
//# sourceMappingURL=chunk-
|
|
232
|
+
//# sourceMappingURL=chunk-T7TOXGZT.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/context/prompt-modal.tsx"],"sourcesContent":["'use client'\n\nimport {\n createContext,\n useCallback,\n useContext,\n useMemo,\n useRef,\n useState,\n type ChangeEvent,\n type MouseEvent,\n type PropsWithChildren,\n} from 'react'\nimport { Portal } from '../components/Portal'\nimport { Button } from '../components/Button'\nimport { css } from '@cerberus/styled-system/css'\nimport { hstack, vstack } from '@cerberus/styled-system/patterns'\nimport { trapFocus } from '../aria-helpers/trap-focus.aria'\nimport { Input } from '../components/Input'\nimport { Field } from './field'\nimport { Label } from '../components/Label'\nimport { $cerberusIcons } from '../config/defineIcons'\nimport { Show } from '../components/Show'\nimport { useModal } from '../hooks/useModal'\nimport { Modal } from '../components/Modal'\nimport { ModalHeader } from '../components/ModalHeader'\nimport { ModalHeading } from '../components/ModalHeading'\nimport { ModalDescription } from '../components/ModalDescription'\nimport { Avatar } from '../components/Avatar'\n\n/**\n * This module provides a context and hook for the prompt modal.\n * @module\n */\n\nexport interface ShowPromptModalOptions {\n kind?: 'destructive' | 'non-destructive'\n heading: string\n description?: string\n key: string\n actionText: string\n cancelText: string\n}\nexport type PromptShowResult =\n | ((value: string | PromiseLike<string>) => void)\n | null\n\nexport interface PromptModalValue {\n show: (options: ShowPromptModalOptions) => Promise<string>\n}\n\nconst PromptModalContext = createContext<PromptModalValue | null>(null)\n\nexport interface PromptModalProviderProps {}\n\n/**\n * Provides a prompt modal to the app.\n * @example\n * ```tsx\n * // Wrap the Provider around the root of the feature.\n * <PromptModal>\n * <SomeFeatureSection />\n * </PromptModal>\n *\n * // Use the hook to show the prompt modal.\n * const prompt = usePromptModal()\n *\n * const handleClick = useCallback(async () => {\n * const accepted = await prompt.show({\n * kind: 'destructive',\n * heading: 'Delete channel?',\n * description:\n * 'This will permanently delete a channel on your account. There is no going back.',\n * key: CHANNEL_NAME,\n * actionText: 'Yes, delete channel',\n * cancelText: 'No, cancel',\n * })\n * // do something with accepted\n * }, [prompt])\n * ```\n */\nexport function PromptModal(\n props: PropsWithChildren<PromptModalProviderProps>,\n) {\n const { modalRef, show, close } = useModal()\n const resolveRef = useRef<PromptShowResult>(null)\n const [content, setContent] = useState<ShowPromptModalOptions | null>(null)\n const [inputValue, setInputValue] = useState<string>('')\n const focusTrap = trapFocus(modalRef)\n const PromptIcon = $cerberusIcons.promptModal\n\n const isValid = useMemo(\n () => inputValue === content?.key,\n [inputValue, content],\n )\n\n const palette = useMemo(\n () => (content?.kind === 'destructive' ? 'danger' : 'action'),\n [content],\n )\n\n const handleChange = useCallback(\n (e: ChangeEvent<HTMLInputElement>) => {\n setInputValue(e.currentTarget.value)\n },\n [content],\n )\n\n const handleChoice = useCallback(\n (e: MouseEvent<HTMLButtonElement>) => {\n const target = e.currentTarget as HTMLButtonElement\n if (target.value === 'true') {\n resolveRef.current?.(inputValue)\n }\n close()\n },\n [inputValue, close],\n )\n\n const handleShow = useCallback(\n (options: ShowPromptModalOptions) => {\n return new Promise<string>((resolve) => {\n setContent({ ...options, kind: options.kind || 'non-destructive' })\n show()\n resolveRef.current = resolve\n })\n },\n [show],\n )\n\n const value = useMemo(\n () => ({\n show: handleShow,\n }),\n [handleShow],\n )\n\n return (\n <PromptModalContext.Provider value={value}>\n {props.children}\n\n <Portal>\n <Modal onKeyDown={focusTrap} ref={modalRef}>\n <ModalHeader>\n <div\n className={hstack({\n justify: 'center',\n w: 'full',\n })}\n >\n <Show\n when={palette === 'danger'}\n fallback={\n <Avatar\n ariaLabel=\"\"\n gradient=\"light-purple\"\n icon={<PromptIcon size={24} />}\n src=\"\"\n />\n }\n >\n <Avatar\n ariaLabel=\"\"\n gradient=\"red\"\n icon={<PromptIcon size={24} />}\n src=\"\"\n />\n </Show>\n </div>\n <ModalHeading>{content?.heading}</ModalHeading>\n <ModalDescription>{content?.description}</ModalDescription>\n </ModalHeader>\n\n <div\n className={vstack({\n alignItems: 'flex-start',\n mt: '4',\n mb: '8',\n })}\n >\n <Field invalid={!isValid}>\n <Label htmlFor=\"confirm\" size=\"md\">\n Type\n <strong\n className={css({\n textTransform: 'uppercase',\n })}\n >\n {content?.key}\n </strong>\n to confirm\n </Label>\n <Input\n id=\"confirm\"\n name=\"confirm\"\n onChange={handleChange}\n type=\"text\"\n />\n </Field>\n </div>\n\n <div\n className={hstack({\n justifyContent: 'stretch',\n gap: '4',\n })}\n >\n <Button\n autoFocus\n className={css({\n w: '1/2',\n })}\n disabled={!isValid}\n name=\"confirm\"\n onClick={handleChoice}\n palette={palette}\n value=\"true\"\n >\n {content?.actionText}\n </Button>\n <Button\n className={css({\n w: '1/2',\n })}\n name=\"cancel\"\n onClick={handleChoice}\n usage=\"outlined\"\n value=\"false\"\n >\n {content?.cancelText}\n </Button>\n </div>\n </Modal>\n </Portal>\n </PromptModalContext.Provider>\n )\n}\n\nexport function usePromptModal(): PromptModalValue {\n const context = useContext(PromptModalContext)\n if (context === null) {\n throw new Error('usePromptModal must be used within a PromptModal Provider')\n }\n return context\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAIK;AAGP,SAAS,WAAW;AACpB,SAAS,QAAQ,cAAc;AA+HrB,SAagB,KAbhB;AA5FV,IAAM,qBAAqB,cAAuC,IAAI;AA8B/D,SAAS,YACd,OACA;AACA,QAAM,EAAE,UAAU,MAAM,MAAM,IAAI,SAAS;AAC3C,QAAM,aAAa,OAAyB,IAAI;AAChD,QAAM,CAAC,SAAS,UAAU,IAAI,SAAwC,IAAI;AAC1E,QAAM,CAAC,YAAY,aAAa,IAAI,SAAiB,EAAE;AACvD,QAAM,YAAY,UAAU,QAAQ;AACpC,QAAM,aAAa,eAAe;AAElC,QAAM,UAAU;AAAA,IACd,MAAM,eAAe,SAAS;AAAA,IAC9B,CAAC,YAAY,OAAO;AAAA,EACtB;AAEA,QAAM,UAAU;AAAA,IACd,MAAO,SAAS,SAAS,gBAAgB,WAAW;AAAA,IACpD,CAAC,OAAO;AAAA,EACV;AAEA,QAAM,eAAe;AAAA,IACnB,CAAC,MAAqC;AACpC,oBAAc,EAAE,cAAc,KAAK;AAAA,IACrC;AAAA,IACA,CAAC,OAAO;AAAA,EACV;AAEA,QAAM,eAAe;AAAA,IACnB,CAAC,MAAqC;AACpC,YAAM,SAAS,EAAE;AACjB,UAAI,OAAO,UAAU,QAAQ;AAC3B,mBAAW,UAAU,UAAU;AAAA,MACjC;AACA,YAAM;AAAA,IACR;AAAA,IACA,CAAC,YAAY,KAAK;AAAA,EACpB;AAEA,QAAM,aAAa;AAAA,IACjB,CAAC,YAAoC;AACnC,aAAO,IAAI,QAAgB,CAAC,YAAY;AACtC,mBAAW,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5
|
+
Portal
|
|
6
|
+
} from "./chunk-4CAT3FHV.js";
|
|
10
7
|
import {
|
|
11
8
|
Modal
|
|
12
9
|
} from "./chunk-2UFNQM55.js";
|
|
@@ -16,6 +13,9 @@ import {
|
|
|
16
13
|
import {
|
|
17
14
|
ModalHeader
|
|
18
15
|
} from "./chunk-QU7UV5DB.js";
|
|
16
|
+
import {
|
|
17
|
+
Avatar
|
|
18
|
+
} from "./chunk-UN3OAW56.js";
|
|
19
19
|
import {
|
|
20
20
|
Button
|
|
21
21
|
} from "./chunk-6F34A7NZ.js";
|
|
@@ -87,11 +87,36 @@ function ConfirmModal(props) {
|
|
|
87
87
|
/* @__PURE__ */ jsx(Portal, { children: /* @__PURE__ */ jsxs(Modal, { onKeyDown: focusTrap, ref: modalRef, children: [
|
|
88
88
|
/* @__PURE__ */ jsxs(ModalHeader, { children: [
|
|
89
89
|
/* @__PURE__ */ jsx(
|
|
90
|
-
|
|
90
|
+
"div",
|
|
91
91
|
{
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
92
|
+
className: hstack({
|
|
93
|
+
justify: "center",
|
|
94
|
+
w: "full"
|
|
95
|
+
}),
|
|
96
|
+
children: /* @__PURE__ */ jsx(
|
|
97
|
+
Show,
|
|
98
|
+
{
|
|
99
|
+
when: palette === "danger",
|
|
100
|
+
fallback: /* @__PURE__ */ jsx(
|
|
101
|
+
Avatar,
|
|
102
|
+
{
|
|
103
|
+
ariaLabel: "",
|
|
104
|
+
gradient: "light-purple",
|
|
105
|
+
icon: /* @__PURE__ */ jsx(ConfirmIcon, { size: 24 }),
|
|
106
|
+
src: ""
|
|
107
|
+
}
|
|
108
|
+
),
|
|
109
|
+
children: /* @__PURE__ */ jsx(
|
|
110
|
+
Avatar,
|
|
111
|
+
{
|
|
112
|
+
ariaLabel: "",
|
|
113
|
+
gradient: "red",
|
|
114
|
+
icon: /* @__PURE__ */ jsx(ConfirmIcon, { size: 24 }),
|
|
115
|
+
src: ""
|
|
116
|
+
}
|
|
117
|
+
)
|
|
118
|
+
}
|
|
119
|
+
)
|
|
95
120
|
}
|
|
96
121
|
),
|
|
97
122
|
/* @__PURE__ */ jsx(ModalHeading, { children: content?.heading }),
|
|
@@ -151,4 +176,4 @@ export {
|
|
|
151
176
|
ConfirmModal,
|
|
152
177
|
useConfirmModal
|
|
153
178
|
};
|
|
154
|
-
//# sourceMappingURL=chunk-
|
|
179
|
+
//# sourceMappingURL=chunk-WWJRKSM5.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/context/confirm-modal.tsx"],"sourcesContent":["'use client'\n\nimport {\n createContext,\n useCallback,\n useContext,\n useMemo,\n useRef,\n useState,\n type MouseEvent,\n type PropsWithChildren,\n} from 'react'\nimport { Portal } from '../components/Portal'\nimport { Button } from '../components/Button'\nimport { css } from '@cerberus/styled-system/css'\nimport { hstack } from '@cerberus/styled-system/patterns'\nimport { $cerberusIcons } from '../config/defineIcons'\nimport { trapFocus } from '../aria-helpers/trap-focus.aria'\nimport { Show } from '../components/Show'\nimport { Modal } from '../components/Modal'\nimport { useModal } from '../hooks/useModal'\nimport { ModalHeader } from '../components/ModalHeader'\nimport { ModalHeading } from '../components/ModalHeading'\nimport { ModalDescription } from '../components/ModalDescription'\nimport { Avatar } from '../components/Avatar'\n\n/**\n * This module provides a context and hook for the confirm modal.\n * @module\n */\n\nexport interface ShowConfirmModalOptions {\n kind?: 'destructive' | 'non-destructive'\n heading: string\n description?: string\n actionText: string\n cancelText: string\n}\nexport type ShowResult =\n | ((value: boolean | PromiseLike<boolean>) => void)\n | null\n\nexport interface ConfirmModalValue {\n show: (options: ShowConfirmModalOptions) => Promise<boolean>\n}\n\nconst ConfirmModalContext = createContext<ConfirmModalValue | null>(null)\n\nexport interface ConfirmModalProviderProps {}\n\n/**\n * Provides a confirm modal to the app.\n * @example\n * ```tsx\n * // Wrap the Provider around the root of the feature.\n * <ConfirmModal>\n * <SomeFeatureSection />\n * </ConfirmModal>\n *\n * // Use the hook to show the confirm modal.\n * const confirm = useConfirmModal()\n *\n * const handleClick = useCallback(async () => {\n * const userConsent = await confirm.show({\n * heading: 'Add new payment method?',\n * description:\n * 'This will add a new payment method to your account to be billed for future purchases.',\n * actionText: 'Yes, add payment method',\n * cancelText: 'No, cancel',\n * })\n * setConsent(userConsent)\n * }, [confirm])\n * ```\n */\nexport function ConfirmModal(\n props: PropsWithChildren<ConfirmModalProviderProps>,\n) {\n const { modalRef, show, close } = useModal()\n const resolveRef = useRef<ShowResult>(null)\n const [content, setContent] = useState<ShowConfirmModalOptions | null>(null)\n const focusTrap = trapFocus(modalRef)\n const ConfirmIcon = $cerberusIcons.confirmModal\n\n const palette = useMemo(\n () => (content?.kind === 'destructive' ? 'danger' : 'action'),\n [content],\n )\n\n const handleChoice = useCallback(\n (e: MouseEvent<HTMLButtonElement>) => {\n const target = e.currentTarget as HTMLButtonElement\n if (target.value === 'true') {\n resolveRef.current?.(true)\n }\n resolveRef.current?.(false)\n close()\n },\n [close],\n )\n\n const handleShow = useCallback(\n (options: ShowConfirmModalOptions) => {\n return new Promise<boolean>((resolve) => {\n setContent({ ...options, kind: options.kind || 'non-destructive' })\n show()\n resolveRef.current = resolve\n })\n },\n [show],\n )\n\n const value = useMemo(\n () => ({\n show: handleShow,\n }),\n [handleShow],\n )\n\n return (\n <ConfirmModalContext.Provider value={value}>\n {props.children}\n\n <Portal>\n <Modal onKeyDown={focusTrap} ref={modalRef}>\n <ModalHeader>\n <div\n className={hstack({\n justify: 'center',\n w: 'full',\n })}\n >\n <Show\n when={palette === 'danger'}\n fallback={\n <Avatar\n ariaLabel=\"\"\n gradient=\"light-purple\"\n icon={<ConfirmIcon size={24} />}\n src=\"\"\n />\n }\n >\n <Avatar\n ariaLabel=\"\"\n gradient=\"red\"\n icon={<ConfirmIcon size={24} />}\n src=\"\"\n />\n </Show>\n </div>\n <ModalHeading>{content?.heading}</ModalHeading>\n <ModalDescription>{content?.description}</ModalDescription>\n </ModalHeader>\n\n <div\n className={hstack({\n gap: '4',\n })}\n >\n <Button\n autoFocus\n className={css({\n w: '1/2',\n })}\n name=\"confirm\"\n onClick={handleChoice}\n palette={palette}\n value=\"true\"\n >\n {content?.actionText}\n </Button>\n <Button\n className={css({\n w: '1/2',\n })}\n name=\"cancel\"\n onClick={handleChoice}\n usage=\"outlined\"\n value=\"false\"\n >\n {content?.cancelText}\n </Button>\n </div>\n </Modal>\n </Portal>\n </ConfirmModalContext.Provider>\n )\n}\n\nexport function useConfirmModal(): ConfirmModalValue {\n const context = useContext(ConfirmModalContext)\n if (context === null) {\n throw new Error(\n 'useConfirmModal must be used within a ConfirmModal Provider',\n )\n }\n return context\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAGK;AAGP,SAAS,WAAW;AACpB,SAAS,cAAc;AA6Gb,SAagB,KAbhB;AA9EV,IAAM,sBAAsB,cAAwC,IAAI;AA4BjE,SAAS,aACd,OACA;AACA,QAAM,EAAE,UAAU,MAAM,MAAM,IAAI,SAAS;AAC3C,QAAM,aAAa,OAAmB,IAAI;AAC1C,QAAM,CAAC,SAAS,UAAU,IAAI,SAAyC,IAAI;AAC3E,QAAM,YAAY,UAAU,QAAQ;AACpC,QAAM,cAAc,eAAe;AAEnC,QAAM,UAAU;AAAA,IACd,MAAO,SAAS,SAAS,gBAAgB,WAAW;AAAA,IACpD,CAAC,OAAO;AAAA,EACV;AAEA,QAAM,eAAe;AAAA,IACnB,CAAC,MAAqC;AACpC,YAAM,SAAS,EAAE;AACjB,UAAI,OAAO,UAAU,QAAQ;AAC3B,mBAAW,UAAU,IAAI;AAAA,MAC3B;AACA,iBAAW,UAAU,KAAK;AAC1B,YAAM;AAAA,IACR;AAAA,IACA,CAAC,KAAK;AAAA,EACR;AAEA,QAAM,aAAa;AAAA,IACjB,CAAC,YAAqC;AACpC,aAAO,IAA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,SAAS;AAAA,gBACT;AAAA,gBACA,OAAM;AAAA,gBAEL,mBAAS;AAAA;AAAA,YACZ;AAAA,YACA;AAAA,cAAC;AAAA;AAAA,gBACC,WAAW,IAAI;AAAA,kBACb,GAAG;AAAA,gBACL,CAAC;AAAA,gBACD,MAAK;AAAA,gBACL,SAAS;AAAA,gBACT,OAAM;AAAA,gBACN,OAAM;AAAA,gBAEL,mBAAS;AAAA;AAAA,YACZ;AAAA;AAAA;AAAA,MACF;AAAA,OACF,GACF;AAAA,KACF;AAEJ;AAEO,SAAS,kBAAqC;AACnD,QAAM,UAAU,WAAW,mBAAmB;AAC9C,MAAI,YAAY,MAAM;AACpB,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AACA,SAAO;AACT;","names":[]}
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Avatar
|
|
3
|
+
} from "./chunk-UN3OAW56.js";
|
|
1
4
|
import {
|
|
2
5
|
Show
|
|
3
6
|
} from "./chunk-4O4QFF4S.js";
|
|
@@ -7,8 +10,8 @@ import {
|
|
|
7
10
|
|
|
8
11
|
// src/components/FileUploader.tsx
|
|
9
12
|
import { cx } from "@cerberus/styled-system/css";
|
|
10
|
-
import {
|
|
11
|
-
import { fileUploader
|
|
13
|
+
import { vstack } from "@cerberus/styled-system/patterns";
|
|
14
|
+
import { fileUploader } from "@cerberus/styled-system/recipes";
|
|
12
15
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
13
16
|
function FileUploader(props) {
|
|
14
17
|
const styles = fileUploader();
|
|
@@ -23,7 +26,16 @@ function FileUploader(props) {
|
|
|
23
26
|
styles.container
|
|
24
27
|
),
|
|
25
28
|
children: [
|
|
26
|
-
/* @__PURE__ */ jsx("
|
|
29
|
+
/* @__PURE__ */ jsx("div", { className: styles.icon, children: /* @__PURE__ */ jsx(
|
|
30
|
+
Avatar,
|
|
31
|
+
{
|
|
32
|
+
gradient: "light-purple",
|
|
33
|
+
ariaLabel: "",
|
|
34
|
+
icon: /* @__PURE__ */ jsx(Icon, {}),
|
|
35
|
+
size: "md",
|
|
36
|
+
src: ""
|
|
37
|
+
}
|
|
38
|
+
) }),
|
|
27
39
|
/* @__PURE__ */ jsxs(
|
|
28
40
|
"label",
|
|
29
41
|
{
|
|
@@ -59,4 +71,4 @@ function FileUploader(props) {
|
|
|
59
71
|
export {
|
|
60
72
|
FileUploader
|
|
61
73
|
};
|
|
62
|
-
//# sourceMappingURL=chunk-
|
|
74
|
+
//# sourceMappingURL=chunk-XOVQGPIE.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/FileUploader.tsx"],"sourcesContent":["'use client'\n\nimport { cx } from '@cerberus/styled-system/css'\nimport { vstack } from '@cerberus/styled-system/patterns'\nimport { type InputHTMLAttributes } from 'react'\nimport { Show } from './Show'\nimport { fileUploader } from '@cerberus/styled-system/recipes'\nimport { $cerberusIcons } from '../config/defineIcons'\nimport { Avatar } from './Avatar'\n\nexport interface FileUploaderProps\n extends InputHTMLAttributes<HTMLInputElement> {\n heading?: string\n name: string\n}\n\nexport function FileUploader(props: FileUploaderProps) {\n const styles = fileUploader()\n const Icon = $cerberusIcons.fileUploader\n\n return (\n <div\n className={cx(\n vstack({\n justify: 'center',\n }),\n styles.container,\n )}\n >\n <div className={styles.icon}>\n <Avatar\n gradient=\"light-purple\"\n ariaLabel=\"\"\n icon={<Icon />}\n size=\"md\"\n src=\"\"\n />\n </div>\n\n <label\n className={cx(\n vstack({\n justify: 'center',\n }),\n styles.label,\n )}\n htmlFor={props.name}\n >\n <Show when={Boolean(props.heading)}>\n <p className={styles.heading}>{props.heading}</p>\n </Show>\n Import {props.accept?.replace(',', ', ')} files\n <p className={styles.description}>Click to select files</p>\n <input\n {...props}\n className={cx(props.className, styles.input)}\n type=\"file\"\n />\n </label>\n </div>\n )\n}\n"],"mappings":";;;;;;;;;;;AAEA,SAAS,UAAU;AACnB,SAAS,cAAc;AAGvB,SAAS,oBAAoB;AA2Bb,cAMV,YANU;AAjBT,SAAS,aAAa,OAA0B;AACrD,QAAM,SAAS,aAAa;AAC5B,QAAM,OAAO,eAAe;AAE5B,SACE;AAAA,IAAC;AAAA;AAAA,MACC,WAAW;AAAA,QACT,OAAO;AAAA,UACL,SAAS;AAAA,QACX,CAAC;AAAA,QACD,OAAO;AAAA,MACT;AAAA,MAEA;AAAA,4BAAC,SAAI,WAAW,OAAO,MACrB;AAAA,UAAC;AAAA;AAAA,YACC,UAAS;AAAA,YACT,WAAU;AAAA,YACV,MAAM,oBAAC,QAAK;AAAA,YACZ,MAAK;AAAA,YACL,KAAI;AAAA;AAAA,QACN,GACF;AAAA,QAEA;AAAA,UAAC;AAAA;AAAA,YACC,WAAW;AAAA,cACT,OAAO;AAAA,gBACL,SAAS;AAAA,cACX,CAAC;AAAA,cACD,OAAO;AAAA,YACT;AAAA,YACA,SAAS,MAAM;AAAA,YAEf;AAAA,kCAAC,QAAK,MAAM,QAAQ,MAAM,OAAO,GAC/B,8BAAC,OAAE,WAAW,OAAO,SAAU,gBAAM,SAAQ,GAC/C;AAAA,cAAO;AAAA,cACC,MAAM,QAAQ,QAAQ,KAAK,IAAI;AAAA,cAAE;AAAA,cACzC,oBAAC,OAAE,WAAW,OAAO,aAAa,mCAAqB;AAAA,cACvD;AAAA,gBAAC;AAAA;AAAA,kBACE,GAAG;AAAA,kBACJ,WAAW,GAAG,MAAM,WAAW,OAAO,KAAK;AAAA,kBAC3C,MAAK;AAAA;AAAA,cACP;AAAA;AAAA;AAAA,QACF;AAAA;AAAA;AAAA,EACF;AAEJ;","names":[]}
|
|
@@ -2,9 +2,11 @@
|
|
|
2
2
|
import {
|
|
3
3
|
FileStatus,
|
|
4
4
|
processStatus
|
|
5
|
-
} from "../chunk-
|
|
5
|
+
} from "../chunk-DGJPW76I.js";
|
|
6
6
|
import "../chunk-TYTEREKZ.js";
|
|
7
7
|
import "../chunk-SLHX5K6I.js";
|
|
8
|
+
import "../chunk-UN3OAW56.js";
|
|
9
|
+
import "../chunk-4O4QFF4S.js";
|
|
8
10
|
import "../chunk-VGHVH2T3.js";
|
|
9
11
|
import "../chunk-ZAU4JVLL.js";
|
|
10
12
|
import "../chunk-NBG2OSYI.js";
|
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
import {
|
|
3
3
|
ConfirmModal,
|
|
4
4
|
useConfirmModal
|
|
5
|
-
} from "../chunk-
|
|
6
|
-
import "../chunk-4CAT3FHV.js";
|
|
5
|
+
} from "../chunk-WWJRKSM5.js";
|
|
7
6
|
import "../chunk-JB7IQ2BM.js";
|
|
8
|
-
import "../chunk-
|
|
7
|
+
import "../chunk-4CAT3FHV.js";
|
|
9
8
|
import "../chunk-2UFNQM55.js";
|
|
10
9
|
import "../chunk-4M4LCQ43.js";
|
|
11
10
|
import "../chunk-QU7UV5DB.js";
|
|
11
|
+
import "../chunk-UN3OAW56.js";
|
|
12
12
|
import "../chunk-6F34A7NZ.js";
|
|
13
13
|
import "../chunk-4O4QFF4S.js";
|
|
14
14
|
import "../chunk-JIZQFTW6.js";
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
import {
|
|
3
3
|
NotificationCenter,
|
|
4
4
|
useNotificationCenter
|
|
5
|
-
} from "../chunk-
|
|
6
|
-
import "../chunk-4CAT3FHV.js";
|
|
5
|
+
} from "../chunk-O6WHVUEW.js";
|
|
7
6
|
import "../chunk-QZ6NS6VN.js";
|
|
8
7
|
import "../chunk-HW76XVA3.js";
|
|
9
8
|
import "../chunk-3C2DJSEE.js";
|
|
9
|
+
import "../chunk-4CAT3FHV.js";
|
|
10
10
|
import "../chunk-6F34A7NZ.js";
|
|
11
11
|
import "../chunk-4O4QFF4S.js";
|
|
12
12
|
import "../chunk-JIZQFTW6.js";
|
|
@@ -2,15 +2,15 @@
|
|
|
2
2
|
import {
|
|
3
3
|
PromptModal,
|
|
4
4
|
usePromptModal
|
|
5
|
-
} from "../chunk-
|
|
6
|
-
import "../chunk-4CAT3FHV.js";
|
|
5
|
+
} from "../chunk-T7TOXGZT.js";
|
|
7
6
|
import "../chunk-JB7IQ2BM.js";
|
|
8
|
-
import "../chunk-
|
|
7
|
+
import "../chunk-4CAT3FHV.js";
|
|
9
8
|
import "../chunk-FMFKM2AB.js";
|
|
10
9
|
import "../chunk-2FK7NR7Y.js";
|
|
11
10
|
import "../chunk-2UFNQM55.js";
|
|
12
11
|
import "../chunk-4M4LCQ43.js";
|
|
13
12
|
import "../chunk-QU7UV5DB.js";
|
|
13
|
+
import "../chunk-UN3OAW56.js";
|
|
14
14
|
import "../chunk-6F34A7NZ.js";
|
|
15
15
|
import "../chunk-4O4QFF4S.js";
|
|
16
16
|
import "../chunk-ZAU4JVLL.js";
|
package/build/modern/index.js
CHANGED
|
@@ -1,19 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ConfirmModal,
|
|
3
|
-
useConfirmModal
|
|
4
|
-
} from "./chunk-GB3SECCO.js";
|
|
5
1
|
import {
|
|
6
2
|
NotificationCenter,
|
|
7
3
|
useNotificationCenter
|
|
8
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-O6WHVUEW.js";
|
|
9
5
|
import {
|
|
10
6
|
PromptModal,
|
|
11
7
|
usePromptModal
|
|
12
|
-
} from "./chunk-
|
|
13
|
-
import {
|
|
14
|
-
Table,
|
|
15
|
-
Tr
|
|
16
|
-
} from "./chunk-A5WYZVUR.js";
|
|
8
|
+
} from "./chunk-T7TOXGZT.js";
|
|
17
9
|
import {
|
|
18
10
|
Tag
|
|
19
11
|
} from "./chunk-Z6IWNVPN.js";
|
|
@@ -36,8 +28,9 @@ import {
|
|
|
36
28
|
Toggle
|
|
37
29
|
} from "./chunk-4YJOK7JJ.js";
|
|
38
30
|
import {
|
|
39
|
-
|
|
40
|
-
|
|
31
|
+
ConfirmModal,
|
|
32
|
+
useConfirmModal
|
|
33
|
+
} from "./chunk-WWJRKSM5.js";
|
|
41
34
|
import {
|
|
42
35
|
Radio
|
|
43
36
|
} from "./chunk-PH64POOB.js";
|
|
@@ -54,12 +47,13 @@ import {
|
|
|
54
47
|
import {
|
|
55
48
|
TabPanel
|
|
56
49
|
} from "./chunk-U72VPIZA.js";
|
|
50
|
+
import {
|
|
51
|
+
Table,
|
|
52
|
+
Tr
|
|
53
|
+
} from "./chunk-A5WYZVUR.js";
|
|
57
54
|
import {
|
|
58
55
|
ModalHeading
|
|
59
56
|
} from "./chunk-JB7IQ2BM.js";
|
|
60
|
-
import {
|
|
61
|
-
ModalIcon
|
|
62
|
-
} from "./chunk-VCR5C6Q3.js";
|
|
63
57
|
import {
|
|
64
58
|
NavMenuLink
|
|
65
59
|
} from "./chunk-6DIGPXAD.js";
|
|
@@ -83,16 +77,19 @@ import {
|
|
|
83
77
|
import {
|
|
84
78
|
NotificationHeading
|
|
85
79
|
} from "./chunk-3C2DJSEE.js";
|
|
80
|
+
import {
|
|
81
|
+
Portal
|
|
82
|
+
} from "./chunk-4CAT3FHV.js";
|
|
86
83
|
import {
|
|
87
84
|
FileStatus,
|
|
88
85
|
processStatus
|
|
89
|
-
} from "./chunk-
|
|
86
|
+
} from "./chunk-DGJPW76I.js";
|
|
90
87
|
import {
|
|
91
88
|
ProgressBar
|
|
92
89
|
} from "./chunk-TYTEREKZ.js";
|
|
93
90
|
import {
|
|
94
91
|
FileUploader
|
|
95
|
-
} from "./chunk-
|
|
92
|
+
} from "./chunk-XOVQGPIE.js";
|
|
96
93
|
import {
|
|
97
94
|
IconButton
|
|
98
95
|
} from "./chunk-SLHX5K6I.js";
|
|
@@ -198,7 +195,6 @@ export {
|
|
|
198
195
|
ModalDescription,
|
|
199
196
|
ModalHeader,
|
|
200
197
|
ModalHeading,
|
|
201
|
-
ModalIcon,
|
|
202
198
|
NavMenu,
|
|
203
199
|
NavMenuLink,
|
|
204
200
|
NavMenuList,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["/**\n * This module is the entry point for the Cerberus React package.\n * @module\n */\n\n// components\n\nexport * from './components/Avatar'\nexport * from './components/Button'\nexport * from './components/Checkbox'\nexport * from './components/Droppable'\nexport * from './components/FieldMessage'\nexport * from './components/FeatureFlag'\nexport * from './components/FileStatus'\nexport * from './components/FileUploader'\nexport * from './components/IconButton'\nexport * from './components/Input'\nexport * from './components/Label'\nexport * from './components/Modal'\nexport * from './components/ModalHeader'\nexport * from './components/ModalHeading'\nexport * from './components/ModalDescription'\nexport * from './components/
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["/**\n * This module is the entry point for the Cerberus React package.\n * @module\n */\n\n// components\n\nexport * from './components/Avatar'\nexport * from './components/Button'\nexport * from './components/Checkbox'\nexport * from './components/Droppable'\nexport * from './components/FieldMessage'\nexport * from './components/FeatureFlag'\nexport * from './components/FileStatus'\nexport * from './components/FileUploader'\nexport * from './components/IconButton'\nexport * from './components/Input'\nexport * from './components/Label'\nexport * from './components/Modal'\nexport * from './components/ModalHeader'\nexport * from './components/ModalHeading'\nexport * from './components/ModalDescription'\nexport * from './components/NavMenuTrigger'\nexport * from './components/NavMenuList'\nexport * from './components/NavMenuLink'\nexport * from './components/Notification'\nexport * from './components/NotificationHeading'\nexport * from './components/NotificationDescription'\nexport * from './components/Portal'\nexport * from './components/ProgressBar'\nexport * from './components/Radio'\nexport * from './components/Select'\nexport * from './components/Tab'\nexport * from './components/TabList'\nexport * from './components/TabPanel'\nexport * from './components/Table'\nexport * from './components/Thead'\nexport * from './components/Th'\nexport * from './components/Td'\nexport * from './components/Tbody'\nexport * from './components/Tag'\nexport * from './components/Textarea'\nexport * from './components/Toggle'\nexport * from './components/Show'\n\n// context\n\nexport * from './context/confirm-modal'\nexport * from './context/feature-flags'\nexport * from './context/field'\nexport * from './context/navMenu'\nexport * from './context/notification-center'\nexport * from './context/prompt-modal'\nexport * from './context/tabs'\nexport * from './context/theme'\n\n// hooks\n\nexport * from './hooks/useModal'\nexport * from './hooks/useTheme'\nexport * from './hooks/useToggle'\n\n// aria-helpers\n\nexport * from './aria-helpers/nav-menu.aria'\nexport * from './aria-helpers/tabs.aria'\nexport * from './aria-helpers/trap-focus.aria'\n\n// utils\n\nexport * from './config/defineIcons'\n\n// shared types\n\nexport * from './types'\n\n// 3rd party\n\nexport * from '@dnd-kit/core'\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8EA,cAAc;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cerberus-design/react",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.2-next-dd740c8",
|
|
4
4
|
"description": "The Cerberus Design React component library.",
|
|
5
5
|
"browserslist": "> 0.25%, not dead",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"react-dom": "^18",
|
|
27
27
|
"tsup": "^8.1.0",
|
|
28
28
|
"@cerberus-design/configs": "0.0.0",
|
|
29
|
-
"@cerberus-design/styled-system": "0.9.
|
|
29
|
+
"@cerberus-design/styled-system": "0.9.2-next-dd740c8"
|
|
30
30
|
},
|
|
31
31
|
"publishConfig": {
|
|
32
32
|
"access": "public"
|