@cratis/components 1.1.3 → 1.1.5
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/cjs/CommandDialog/CommandDialog.js +4 -25
- package/dist/cjs/CommandDialog/CommandDialog.js.map +1 -1
- package/dist/cjs/CommandDialog/index.js +0 -1
- package/dist/cjs/CommandDialog/index.js.map +1 -1
- package/dist/cjs/CommandForm/fields/CheckboxField.js +1 -1
- package/dist/cjs/CommandForm/fields/CheckboxField.js.map +1 -1
- package/dist/cjs/CommandForm/fields/DropdownField.js +1 -1
- package/dist/cjs/CommandForm/fields/DropdownField.js.map +1 -1
- package/dist/cjs/CommandForm/fields/InputTextField.js +1 -1
- package/dist/cjs/CommandForm/fields/InputTextField.js.map +1 -1
- package/dist/cjs/CommandForm/fields/NumberField.js +1 -1
- package/dist/cjs/CommandForm/fields/NumberField.js.map +1 -1
- package/dist/cjs/CommandForm/fields/SliderField.js +1 -1
- package/dist/cjs/CommandForm/fields/SliderField.js.map +1 -1
- package/dist/cjs/CommandForm/fields/TextAreaField.js +1 -1
- package/dist/cjs/CommandForm/fields/TextAreaField.js.map +1 -1
- package/dist/cjs/Common/Page.js +1 -1
- package/dist/cjs/Common/Page.js.map +1 -1
- package/dist/cjs/Dialogs/Dialog.js +10 -6
- package/dist/cjs/Dialogs/Dialog.js.map +1 -1
- package/dist/esm/CommandDialog/CommandDialog.d.ts +3 -42
- package/dist/esm/CommandDialog/CommandDialog.d.ts.map +1 -1
- package/dist/esm/CommandDialog/CommandDialog.js +6 -26
- package/dist/esm/CommandDialog/CommandDialog.js.map +1 -1
- package/dist/esm/CommandDialog/CommandDialog.stories.d.ts +1 -0
- package/dist/esm/CommandDialog/CommandDialog.stories.d.ts.map +1 -1
- package/dist/esm/CommandDialog/CommandDialog.stories.js +67 -14
- package/dist/esm/CommandDialog/CommandDialog.stories.js.map +1 -1
- package/dist/esm/CommandDialog/index.js +1 -1
- package/dist/esm/CommandForm/fields/CheckboxField.d.ts.map +1 -1
- package/dist/esm/CommandForm/fields/CheckboxField.js +1 -1
- package/dist/esm/CommandForm/fields/CheckboxField.js.map +1 -1
- package/dist/esm/CommandForm/fields/DropdownField.d.ts.map +1 -1
- package/dist/esm/CommandForm/fields/DropdownField.js +1 -1
- package/dist/esm/CommandForm/fields/DropdownField.js.map +1 -1
- package/dist/esm/CommandForm/fields/InputTextField.d.ts.map +1 -1
- package/dist/esm/CommandForm/fields/InputTextField.js +1 -1
- package/dist/esm/CommandForm/fields/InputTextField.js.map +1 -1
- package/dist/esm/CommandForm/fields/NumberField.d.ts.map +1 -1
- package/dist/esm/CommandForm/fields/NumberField.js +1 -1
- package/dist/esm/CommandForm/fields/NumberField.js.map +1 -1
- package/dist/esm/CommandForm/fields/SliderField.js +1 -1
- package/dist/esm/CommandForm/fields/SliderField.js.map +1 -1
- package/dist/esm/CommandForm/fields/TextAreaField.d.ts.map +1 -1
- package/dist/esm/CommandForm/fields/TextAreaField.js +1 -1
- package/dist/esm/CommandForm/fields/TextAreaField.js.map +1 -1
- package/dist/esm/Common/Page.js +1 -1
- package/dist/esm/Common/Page.js.map +1 -1
- package/dist/esm/Dialogs/Dialog.d.ts.map +1 -1
- package/dist/esm/Dialogs/Dialog.js +10 -6
- package/dist/esm/Dialogs/Dialog.js.map +1 -1
- package/dist/esm/Dialogs/Dialog.stories.d.ts.map +1 -1
- package/dist/esm/Dialogs/Dialog.stories.js +32 -8
- package/dist/esm/Dialogs/Dialog.stories.js.map +1 -1
- package/dist/esm/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Dialog.js","sources":["../../../Dialogs/Dialog.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { Dialog as PrimeDialog } from 'primereact/dialog';\nimport { Button } from 'primereact/button';\nimport { DialogResult, DialogButtons, useDialogContext } from '@cratis/arc.react/dialogs';\nimport { ReactNode } from 'react';\n\nexport type CloseDialog = (result: DialogResult) => boolean | void | Promise<boolean> | Promise<void>;\nexport type ConfirmCallback = () => boolean | void | Promise<boolean> | Promise<void>;\nexport type CancelCallback = () => boolean | void | Promise<boolean> | Promise<void>;\n\nexport interface DialogProps {\n title: string;\n visible?: boolean;\n onClose?: CloseDialog;\n onConfirm?: ConfirmCallback;\n onCancel?: CancelCallback;\n buttons?: DialogButtons | ReactNode;\n children: ReactNode;\n width?: string;\n resizable?: boolean;\n isValid?: boolean;\n okLabel?: string;\n cancelLabel?: string;\n yesLabel?: string;\n noLabel?: string;\n}\n\nexport const Dialog = ({ \n title, \n visible = true, \n onClose, \n onConfirm,\n onCancel,\n buttons = DialogButtons.OkCancel, \n children, \n width = '450px', \n resizable = false, \n isValid,\n okLabel = 'Ok',\n cancelLabel = 'Cancel',\n yesLabel = 'Yes',\n noLabel = 'No'\n}: DialogProps) => {\n // Try to get dialog context, but allow it to be undefined for standalone usage\n let contextCloseDialog: ((result: DialogResult) => void) | undefined;\n try {\n const context = useDialogContext();\n contextCloseDialog = context?.closeDialog;\n } catch {\n // No context available - dialog is being used standalone\n contextCloseDialog = undefined;\n }\n \n const isDialogValid = isValid !== false;\n const headerElement = (\n <div className=\"inline-flex align-items-center justify-content-center gap-2\">\n <span className=\"font-bold white-space-nowrap\">{title}</span>\n </div>\n );\n\n const handleClose = async (result: DialogResult) => {\n
|
|
1
|
+
{"version":3,"file":"Dialog.js","sources":["../../../Dialogs/Dialog.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { Dialog as PrimeDialog } from 'primereact/dialog';\nimport { Button } from 'primereact/button';\nimport { DialogResult, DialogButtons, useDialogContext } from '@cratis/arc.react/dialogs';\nimport { ReactNode } from 'react';\n\nexport type CloseDialog = (result: DialogResult) => boolean | void | Promise<boolean> | Promise<void>;\nexport type ConfirmCallback = () => boolean | void | Promise<boolean> | Promise<void>;\nexport type CancelCallback = () => boolean | void | Promise<boolean> | Promise<void>;\n\nexport interface DialogProps {\n title: string;\n visible?: boolean;\n onClose?: CloseDialog;\n onConfirm?: ConfirmCallback;\n onCancel?: CancelCallback;\n buttons?: DialogButtons | ReactNode;\n children: ReactNode;\n width?: string;\n resizable?: boolean;\n isValid?: boolean;\n okLabel?: string;\n cancelLabel?: string;\n yesLabel?: string;\n noLabel?: string;\n}\n\nexport const Dialog = ({ \n title, \n visible = true, \n onClose, \n onConfirm,\n onCancel,\n buttons = DialogButtons.OkCancel, \n children, \n width = '450px', \n resizable = false, \n isValid,\n okLabel = 'Ok',\n cancelLabel = 'Cancel',\n yesLabel = 'Yes',\n noLabel = 'No'\n}: DialogProps) => {\n // Try to get dialog context, but allow it to be undefined for standalone usage\n let contextCloseDialog: ((result: DialogResult) => void) | undefined;\n try {\n const context = useDialogContext();\n contextCloseDialog = context?.closeDialog;\n } catch {\n // No context available - dialog is being used standalone\n contextCloseDialog = undefined;\n }\n \n const isDialogValid = isValid !== false;\n const headerElement = (\n <div className=\"inline-flex align-items-center justify-content-center gap-2\">\n <span className=\"font-bold white-space-nowrap\">{title}</span>\n </div>\n );\n\n const handleClose = async (result: DialogResult) => {\n let shouldCloseThroughContext = true;\n\n if (result === DialogResult.Ok || result === DialogResult.Yes) {\n if (onConfirm) {\n const closeResult = await onConfirm();\n shouldCloseThroughContext = closeResult === true;\n } else if (onClose) {\n const closeResult = await onClose(result);\n shouldCloseThroughContext = closeResult !== false;\n }\n } else {\n if (onCancel) {\n const closeResult = await onCancel();\n shouldCloseThroughContext = closeResult === true;\n } else if (onClose) {\n const closeResult = await onClose(result);\n shouldCloseThroughContext = closeResult !== false;\n }\n }\n\n if (shouldCloseThroughContext) {\n contextCloseDialog?.(result);\n }\n };\n\n const okFooter = (\n <>\n <Button label={okLabel} icon=\"pi pi-check\" onClick={() => handleClose(DialogResult.Ok)} disabled={!isDialogValid} autoFocus />\n </>\n );\n\n const okCancelFooter = (\n <>\n <Button label={okLabel} icon=\"pi pi-check\" onClick={() => handleClose(DialogResult.Ok)} disabled={!isDialogValid} autoFocus />\n <Button label={cancelLabel} icon=\"pi pi-times\" outlined onClick={() => handleClose(DialogResult.Cancelled)} />\n </>\n );\n\n const yesNoFooter = (\n <>\n <Button label={yesLabel} icon=\"pi pi-check\" onClick={() => handleClose(DialogResult.Yes)} disabled={!isDialogValid} autoFocus />\n <Button label={noLabel} icon=\"pi pi-times\" outlined onClick={() => handleClose(DialogResult.No)} />\n </>\n );\n\n const yesNoCancelFooter = (\n <>\n <Button label={yesLabel} icon=\"pi pi-check\" onClick={() => handleClose(DialogResult.Yes)} disabled={!isDialogValid} autoFocus />\n <Button label={noLabel} icon=\"pi pi-times\" outlined onClick={() => handleClose(DialogResult.No)} />\n <Button label={cancelLabel} icon=\"pi pi-times\" outlined onClick={() => handleClose(DialogResult.Cancelled)} />\n </>\n );\n\n const getFooterInterior = () => {\n // If buttons is a ReactNode (custom buttons), use it directly\n if (typeof buttons !== 'number') {\n return buttons;\n }\n\n // Otherwise, use predefined buttons based on DialogButtons enum\n switch (buttons) {\n case DialogButtons.Ok:\n return okFooter;\n case DialogButtons.OkCancel:\n return okCancelFooter;\n case DialogButtons.YesNo:\n return yesNoFooter;\n case DialogButtons.YesNoCancel:\n return yesNoCancelFooter;\n }\n\n return (<></>);\n };\n\n const footer = (\n <div className=\"flex flex-wrap justify-content-start gap-3\">\n {getFooterInterior()}\n </div>\n );\n\n return (\n <PrimeDialog\n header={headerElement}\n modal\n footer={footer}\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n onHide={typeof buttons === 'number' ? () => handleClose(DialogResult.Cancelled) : () => {}}\n visible={visible}\n style={{ width }}\n resizable={resizable}\n closable={typeof buttons === 'number'}>\n {children}\n </PrimeDialog>\n );\n};\n"],"names":["_jsx","_Fragment","_jsxs","PrimeDialog"],"mappings":";;;;;AA6BO,MAAM,MAAM,GAAG,CAAC,EACnB,KAAK,EACL,OAA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AC1B,gBAAA,OAAO,iBAAiB;;QAGhC,QAAQA,GAAA,CAAAC,QAAA,EAAA,EAAA,CAAK;AACjB,IAAA,CAAC;AAED,IAAA,MAAM,MAAM,IACRD,GAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAC,4CAA4C,EAAA,QAAA,EACtD,iBAAiB,EAAE,EAAA,CAClB,CACT;AAED,IAAA,QACIA,GAAA,CAACG,QAAW,EAAA,EACR,MAAM,EAAE,aAAa,EACrB,KAAK,EAAA,IAAA,EACL,MAAM,EAAE,MAAM,EAEd,MAAM,EAAE,OAAO,OAAO,KAAK,QAAQ,GAAG,MAAM,WAAW,CAAC,YAAY,CAAC,SAAS,CAAC,GAAG,MAAK,EAAE,CAAC,EAC1F,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,EAAE,KAAK,EAAE,EAChB,SAAS,EAAE,SAAS,EACpB,QAAQ,EAAE,OAAO,OAAO,KAAK,QAAQ,EAAA,QAAA,EACpC,QAAQ,EAAA,CACC;AAEtB;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Dialog.stories.d.ts","sourceRoot":"","sources":["../../../Dialogs/Dialog.stories.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAKlC,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,OAAO,MAAM,CAM7B,CAAC;AAEF,eAAe,IAAI,CAAC;AACpB,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,MAAM,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"Dialog.stories.d.ts","sourceRoot":"","sources":["../../../Dialogs/Dialog.stories.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAKlC,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,OAAO,MAAM,CAM7B,CAAC;AAEF,eAAe,IAAI,CAAC;AACpB,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,MAAM,CAAC,CAAC;AA6BrC,eAAO,MAAM,QAAQ,EAAE,KAMtB,CAAC;AAEF,eAAO,MAAM,KAAK,EAAE,KAMnB,CAAC;AAEF,eAAO,MAAM,WAAW,EAAE,KAMzB,CAAC;AAEF,eAAO,MAAM,EAAE,EAAE,KAMhB,CAAC;AAEF,eAAO,MAAM,QAAQ,EAAE,KAmDtB,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE,KAmD3B,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useState } from 'react';
|
|
3
3
|
import { Dialog } from './Dialog';
|
|
4
|
-
import { DialogButtons } from '@cratis/arc.react/dialogs';
|
|
4
|
+
import { DialogButtons, DialogResult, useDialog, useDialogContext } from '@cratis/arc.react/dialogs';
|
|
5
5
|
import { Button } from 'primereact/button';
|
|
6
6
|
import { InputText } from 'primereact/inputtext';
|
|
7
7
|
const meta = {
|
|
@@ -13,8 +13,12 @@ const meta = {
|
|
|
13
13
|
};
|
|
14
14
|
export default meta;
|
|
15
15
|
const DialogWrapper = ({ buttons, title, children, isValid }) => {
|
|
16
|
-
const
|
|
17
|
-
|
|
16
|
+
const ResultDialog = () => {
|
|
17
|
+
const { closeDialog } = useDialogContext();
|
|
18
|
+
return (_jsx(Dialog, { title: title, buttons: buttons, onConfirm: () => closeDialog(DialogResult.Ok), onCancel: () => closeDialog(DialogResult.Cancelled), isValid: isValid, children: children }));
|
|
19
|
+
};
|
|
20
|
+
const [DialogComponent, showDialog] = useDialog(ResultDialog);
|
|
21
|
+
return (_jsxs(_Fragment, { children: [_jsx(Button, { label: "Open Dialog", onClick: async () => await showDialog() }), _jsx(DialogComponent, {})] }));
|
|
18
22
|
};
|
|
19
23
|
export const OkCancel = {
|
|
20
24
|
render: () => (_jsx(DialogWrapper, { title: "Confirm Action", buttons: DialogButtons.OkCancel, children: _jsx("p", { children: "Are you sure you want to perform this action?" }) }))
|
|
@@ -30,15 +34,35 @@ export const Ok = {
|
|
|
30
34
|
};
|
|
31
35
|
export const WithForm = {
|
|
32
36
|
render: () => {
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
|
|
37
|
+
const AddNameDialog = () => {
|
|
38
|
+
const { closeDialog } = useDialogContext();
|
|
39
|
+
const [name, setName] = useState('');
|
|
40
|
+
return (_jsx(Dialog, { title: "Edit Name", buttons: DialogButtons.OkCancel, onConfirm: () => closeDialog(DialogResult.Ok, { name }), onCancel: () => closeDialog(DialogResult.Cancelled), isValid: name.trim().length > 0, children: _jsxs("div", { className: "flex flex-column gap-2", children: [_jsx("label", { htmlFor: "name", children: "Name" }), _jsx(InputText, { id: "name", value: name, onChange: (e) => setName(e.target.value), placeholder: "Enter name..." }), name.trim().length === 0 && (_jsx("small", { className: "p-error", children: "Name is required" }))] }) }));
|
|
41
|
+
};
|
|
42
|
+
const [AddNameDialogComponent, showAddNameDialog] = useDialog(AddNameDialog);
|
|
43
|
+
const [result, setResult] = useState('');
|
|
44
|
+
return (_jsxs(_Fragment, { children: [_jsx(Button, { label: "Open Form Dialog", onClick: async () => {
|
|
45
|
+
const [dialogResult, value] = await showAddNameDialog();
|
|
46
|
+
if (dialogResult === DialogResult.Ok && value) {
|
|
47
|
+
setResult(value.name);
|
|
48
|
+
}
|
|
49
|
+
} }), result && _jsxs("p", { children: ["Last saved name: ", result] }), _jsx(AddNameDialogComponent, {})] }));
|
|
36
50
|
}
|
|
37
51
|
};
|
|
38
52
|
export const CustomButtons = {
|
|
39
53
|
render: () => {
|
|
40
|
-
const
|
|
41
|
-
|
|
54
|
+
const CustomActionsDialog = () => {
|
|
55
|
+
const { closeDialog } = useDialogContext();
|
|
56
|
+
return (_jsx(Dialog, { title: "Custom Actions", buttons: _jsxs(_Fragment, { children: [_jsx(Button, { label: "Save Draft", icon: "pi pi-save", severity: "secondary", onClick: () => closeDialog(DialogResult.Ok, { action: 'draft' }) }), _jsx(Button, { label: "Publish", icon: "pi pi-send", onClick: () => closeDialog(DialogResult.Ok, { action: 'publish' }) })] }), onCancel: () => closeDialog(DialogResult.Cancelled), children: _jsx("p", { children: "Choose what to do with your changes." }) }));
|
|
57
|
+
};
|
|
58
|
+
const [CustomActionsDialogComponent, showCustomActionsDialog] = useDialog(CustomActionsDialog);
|
|
59
|
+
const [result, setResult] = useState('');
|
|
60
|
+
return (_jsxs(_Fragment, { children: [_jsx(Button, { label: "Open Custom Dialog", onClick: async () => {
|
|
61
|
+
const [dialogResult, value] = await showCustomActionsDialog();
|
|
62
|
+
if (dialogResult === DialogResult.Ok && value) {
|
|
63
|
+
setResult(value.action);
|
|
64
|
+
}
|
|
65
|
+
} }), result && _jsxs("p", { children: ["Last action: ", result] }), _jsx(CustomActionsDialogComponent, {})] }));
|
|
42
66
|
}
|
|
43
67
|
};
|
|
44
68
|
//# sourceMappingURL=Dialog.stories.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Dialog.stories.js","sourceRoot":"","sources":["../../../Dialogs/Dialog.stories.tsx"],"names":[],"mappings":";AAGA,OAAc,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAExC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"Dialog.stories.js","sourceRoot":"","sources":["../../../Dialogs/Dialog.stories.tsx"],"names":[],"mappings":";AAGA,OAAc,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAExC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,C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