Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Documentation/CommandDialog/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ function MyComponent() {
- `onFieldChange`: Callback when field values change
- `onBeforeExecute`: Transform command values before execution
- `style`: Custom CSS styles
- `contentStyle`: Custom CSS styles for the dialog content area
- `width`: Dialog width

## Callback Behavior
Expand Down
1 change: 1 addition & 0 deletions Documentation/Dialogs/dialog.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ const MyComponent = () => {
- `buttons`: Predefined `DialogButtons` or custom footer content
- `width`: Dialog width
- `style`: Custom dialog style forwarded to PrimeReact `Dialog`
- `contentStyle`: Custom content area style forwarded to PrimeReact `Dialog`
- `resizable`: Enables resize
- `isValid`: Enables or disables confirm actions
- `isBusy`: When `true`, disables all buttons and shows a loading spinner on the primary action button
Expand Down
1 change: 1 addition & 0 deletions Documentation/StepperCommandDialog/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ function MyComponent() {
- `width`: Dialog width (default: `'600px'`)
- `resizable`: Whether the dialog can be resized
- `style`: Custom CSS styles
- `contentStyle`: Custom CSS styles for the dialog content area
- `onFieldValidate`: Custom validation function for fields
- `onFieldChange`: Callback when field values change
- `onBeforeExecute`: Transform command values before execution
Expand Down
5 changes: 5 additions & 0 deletions Source/CommandDialog/CommandDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const CommandDialogWrapper = <TCommand extends object>({
visible,
width,
style,
contentStyle,
resizable,
buttons,
okLabel,
Expand All @@ -41,6 +42,7 @@ const CommandDialogWrapper = <TCommand extends object>({
visible?: boolean;
width?: string;
style?: DialogProps['style'];
contentStyle?: DialogProps['contentStyle'];
resizable?: boolean;
buttons?: DialogProps['buttons'];
okLabel?: string;
Expand Down Expand Up @@ -120,6 +122,7 @@ const CommandDialogWrapper = <TCommand extends object>({
visible={visible}
width={width}
style={style}
contentStyle={contentStyle}
resizable={resizable}
buttons={buttons}
onClose={onClose}
Expand All @@ -145,6 +148,7 @@ const CommandDialogComponent = <TCommand extends object = object>(props: Command
visible,
width,
style,
contentStyle,
resizable,
buttons = DialogButtons.OkCancel,
okLabel,
Expand All @@ -166,6 +170,7 @@ const CommandDialogComponent = <TCommand extends object = object>(props: Command
visible={visible}
width={width}
style={style}
contentStyle={contentStyle}
resizable={resizable}
buttons={buttons}
okLabel={okLabel}
Expand Down
14 changes: 10 additions & 4 deletions Source/CommandDialog/StepperCommandDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import { ICommandResult } from '@cratis/arc/commands';
import { DialogResult, useDialogContext } from '@cratis/arc.react/dialogs';
import { Dialog as PrimeDialog } from 'primereact/dialog';
import { Dialog as PrimeDialog, type DialogProps as PrimeDialogProps } from 'primereact/dialog';
import { Stepper as PrimeStepper, type StepperProps } from 'primereact/stepper';
import { Button } from 'primereact/button';
import React, { useMemo, useState } from 'react';
Expand All @@ -15,7 +15,6 @@ import {
type CommandFormProps
} from '@cratis/arc.react/commands';
import type { CloseDialog, ConfirmCallback, CancelCallback } from '../Dialogs/Dialog';
import { CSSProperties } from 'react';
import './StepperCommandDialog.css';

/** Extracts the property name from an accessor function like `c => c.name`. */
Expand Down Expand Up @@ -63,7 +62,9 @@ export interface StepperCommandDialogProps<TCommand extends object>
/** Dialog width. */
width?: string;
/** Custom CSS styles applied to the dialog. */
style?: CSSProperties;
style?: PrimeDialogProps['style'];
/** Custom CSS styles applied to the dialog content area. */
contentStyle?: PrimeDialogProps['contentStyle'];
/** Whether the dialog can be resized. Defaults to `false`. */
resizable?: boolean;
/** Additional validity gate combined with command form validity. */
Expand All @@ -89,6 +90,7 @@ const StepperCommandDialogWrapper = <TCommand extends object>({
visible = true,
width = '600px',
style,
contentStyle,
resizable = false,
isValid,
onClose,
Expand All @@ -112,7 +114,8 @@ const StepperCommandDialogWrapper = <TCommand extends object>({
title: string;
visible?: boolean;
width?: string;
style?: CSSProperties;
style?: PrimeDialogProps['style'];
contentStyle?: PrimeDialogProps['contentStyle'];
resizable?: boolean;
isValid?: boolean;
onClose?: CloseDialog;
Expand Down Expand Up @@ -324,6 +327,7 @@ const StepperCommandDialogWrapper = <TCommand extends object>({
onHide={() => handleClose(DialogResult.Cancelled)}
visible={visible}
style={{ width, ...style }}
contentStyle={contentStyle}
resizable={resizable}
closable
>
Expand Down Expand Up @@ -353,6 +357,7 @@ const StepperCommandDialogComponent = <TCommand extends object = object>(
visible,
width,
style,
contentStyle,
resizable,
isValid,
onClose,
Expand Down Expand Up @@ -381,6 +386,7 @@ const StepperCommandDialogComponent = <TCommand extends object = object>(
visible={visible}
width={width}
style={style}
contentStyle={contentStyle}
resizable={resizable}
isValid={isValid}
onClose={onClose}
Expand Down
9 changes: 6 additions & 3 deletions Source/Dialogs/Dialog.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// Copyright (c) Cratis. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

import { Dialog as PrimeDialog } from 'primereact/dialog';
import { Dialog as PrimeDialog, type DialogProps as PrimeDialogProps } from 'primereact/dialog';
import { Button } from 'primereact/button';
import { DialogResult, DialogButtons, useDialogContext } from '@cratis/arc.react/dialogs';
import { CSSProperties, ReactNode } from 'react';
import { ReactNode } from 'react';

export type CloseDialog = (result: DialogResult) => boolean | void | Promise<boolean> | Promise<void>;
export type ConfirmCallback = () => boolean | void | Promise<boolean> | Promise<void>;
Expand All @@ -19,7 +19,8 @@ export interface DialogProps {
buttons?: DialogButtons | ReactNode;
children: ReactNode;
width?: string;
style?: CSSProperties;
style?: PrimeDialogProps['style'];
contentStyle?: PrimeDialogProps['contentStyle'];
resizable?: boolean;
isValid?: boolean;
isBusy?: boolean;
Expand All @@ -39,6 +40,7 @@ export const Dialog = ({
children,
width = '450px',
style,
contentStyle,
resizable = false,
isValid,
isBusy = false,
Expand Down Expand Up @@ -154,6 +156,7 @@ export const Dialog = ({
onHide={typeof buttons === 'number' ? () => handleClose(DialogResult.Cancelled) : () => {}}
visible={visible}
style={{ width, ...style }}
contentStyle={contentStyle}
resizable={resizable}
closable={typeof buttons === 'number'}>
{children}
Expand Down
Loading