From 6374290ec9a0c79a90f4218b40f49462328263bd Mon Sep 17 00:00:00 2001 From: Akmal Isomadinov Date: Thu, 21 Dec 2023 16:12:45 +0500 Subject: [PATCH] Shared:Components:Cron Added README --- packages/shared/components/cron/Cron.props.ts | 3 ++ packages/shared/components/cron/README.md | 53 +++++++++++++++++++ packages/shared/components/index.ts | 3 ++ 3 files changed, 59 insertions(+) create mode 100644 packages/shared/components/cron/README.md diff --git a/packages/shared/components/cron/Cron.props.ts b/packages/shared/components/cron/Cron.props.ts index 358d53fd30..06b3629c2a 100644 --- a/packages/shared/components/cron/Cron.props.ts +++ b/packages/shared/components/cron/Cron.props.ts @@ -1,6 +1,9 @@ interface CronProps { + /** Cron value */ value?: string; + /** Set the cron value, similar to onChange. */ setValue: (value: string) => void; + /** Triggered when the cron component detects an error with the value. */ onError?: (error?: Error) => void; } diff --git a/packages/shared/components/cron/README.md b/packages/shared/components/cron/README.md new file mode 100644 index 0000000000..f2f7ff79e9 --- /dev/null +++ b/packages/shared/components/cron/README.md @@ -0,0 +1,53 @@ +# Cron + +The `Cron` component provides an interface for working with cron expressions. + +## Properties + +| Property | Type | Required | Default | Description | +| ---------- | ------------------------- | -------- | ------------- | --------------------------------------------------------------------- | +| `value` | `string` | No | `"* * * * *"` | Current cron expression value. | +| `setValue` | `(value: string) => void` | Yes | - | Function to set a new cron expression value, similar to `onChange`. | +| `onError` | `(error?: Error) => void` | No | - | Callback function triggered when an error is detected with the value. | + +### Property `value` + +- Type: `string` +- Description: The current cron expression value. If not specified, the component will display the default value. + +### Property `setValue` + +- Type: `(value: string) => void` +- Description: Function to set a new cron expression value. Called when the component's value changes, similar to the `onChange` event. + +### Property `onError` + +- Type: `(error?: Error) => void` +- Description: Callback function triggered when an error is detected with the cron expression value. If specified, the component will pass error information to this function. + +## Usage Example + +```jsx +import React from "react"; +import Cron from "@docspace/shared/components"; + +const Component = () => { + const handleCronChange = (newCronValue) => { + console.log("New cron value:", newCronValue); + }; + + const handleCronError = (error) => { + console.error("Cron error:", error); + }; + + return ( + + ); +}; + +export default Component; +``` diff --git a/packages/shared/components/index.ts b/packages/shared/components/index.ts index 5aed7901d6..f8e383359f 100644 --- a/packages/shared/components/index.ts +++ b/packages/shared/components/index.ts @@ -30,6 +30,7 @@ import { SeparatorType, } from "./context-menu"; import { Checkbox } from "./checkbox"; +import { Cron, getNextSynchronization } from "./cron"; import { Toast, toastr, ToastType } from "./toast"; import { Textarea } from "./textarea"; import { TextInput, InputSize, InputType } from "./text-input"; @@ -109,6 +110,8 @@ export { ComboBox, ComboBoxDisplayType, ComboBoxSize, + Cron, + getNextSynchronization, DropDown, DropDownItem, ModalDialog,