/** * @module * Primitive and base data types for component props. */ import type { ReactNode, FC } from 'react' import type { Link } from './links' import type { Image } from './image' import type { Video } from './video' import type { VectorArt } from './vectorArt' import type { A11y } from './a11y' import type { Audio } from './audio' /** * A plain text string. * * @example * ```tsx * import type { Text } from '@wix/editor-react-types'; * * interface MyComponentProps { * label?: Text; * } * ``` */ export type Text = string /** * The value selected by the Wix user from a predefined set of options. * * @example * ```tsx * import type { TextEnum } from '@wix/editor-react-types'; * * interface MyComponentProps { * alignment?: TextEnum; // e.g. 'left' | 'center' | 'right' * } * ``` */ export type TextEnum = string /** * Any numeric value. * * @example * ```tsx * import type { NumberType } from '@wix/editor-react-types'; * * interface MyComponentProps { * rating?: NumberType; * } * ``` */ export type NumberType = number /** * A boolean `true` or `false` value. * * @example * ```tsx * import type { BooleanValue } from '@wix/editor-react-types'; * * interface MyComponentProps { * showLabel?: BooleanValue; * } * ``` */ export type BooleanValue = boolean /** * A JSON Schema definition. * * @example * ```tsx * import type { Schema } from '@wix/editor-react-types'; * * interface MyComponentProps { * schema?: Schema; * } * ``` */ export type Schema = Record /** * A local date string in ISO-8601 extended format (`YYYY-MM-DD`). * * @example * ```tsx * import type { LocalDate } from '@wix/editor-react-types'; * * interface MyComponentProps { * startDate?: LocalDate; // e.g. '2024-03-15' * } * ``` */ export type LocalDate = string /** * A local time string in ISO-8601 extended format (`hh:mm[:ss][.sss]`). * * @example * ```tsx * import type { LocalTime } from '@wix/editor-react-types'; * * interface MyComponentProps { * openingTime?: LocalTime; // e.g. '09:00' * } * ``` */ export type LocalTime = string /** * A local date-time string in ISO-8601 extended format (`YYYY-MM-DDThh:mm[:ss][.sss]`). * * @example * ```tsx * import type { LocalDateTime } from '@wix/editor-react-types'; * * interface MyComponentProps { * eventStart?: LocalDateTime; // e.g. '2024-03-15T09:00' * } * ``` */ export type LocalDateTime = string /** * A URL with an `http` or `https` scheme. * * @example * ```tsx * import type { WebUrl } from '@wix/editor-react-types'; * * interface MyComponentProps { * website?: WebUrl; * } * ``` */ export type WebUrl = string /** * A standard email address according to RFC 5321, section 4.1.2. * * @example * ```tsx * import type { Email } from '@wix/editor-react-types'; * * interface MyComponentProps { * contactEmail?: Email; * } * ``` */ export type Email = string /** * A phone number string, accepting common phone number characters. * * @example * ```tsx * import type { Phone } from '@wix/editor-react-types'; * * interface MyComponentProps { * phoneNumber?: Phone; * } * ``` */ export type Phone = string /** * A hostname according to IANA standards. * * @example * ```tsx * import type { Hostname } from '@wix/editor-react-types'; * * interface MyComponentProps { * host?: Hostname; // e.g. 'www.example.com' * } * ``` */ export type Hostname = string /** * A valid regular expression pattern provided by the Wix user. * * @example * ```tsx * import type { Regex } from '@wix/editor-react-types'; * * interface MyComponentProps { * validationPattern?: Regex; // e.g. '^[a-z]+$' * } * ``` */ export type Regex = string /** * A unique identifier (UUID). * * @example * ```tsx * import type { Guid } from '@wix/editor-react-types'; * * interface MyComponentProps { * itemId?: Guid; * } * ``` */ export type Guid = string /** * Rich text content with resolved links. * * @example * ```tsx * import type { RichText } from '@wix/editor-react-types'; * * interface MyComponentProps { * description?: RichText; * } * * const MyComponent = ({ description }: MyComponentProps) => ( *
* {description?.html} * {description?.linkList.map((link) => ( * {link.href} * ))} *
* ); * ``` */ export type RichText = { /** The original rich text content. */ text: string /** The HTML content with all links resolved. */ html: string /** All links present in the rich text content. */ linkList: Array } /** * A container slot in the component. * * Can be either a `ReactNode` passed as `children`, or a function component * used as a render prop. * * @example * ```tsx * import type { Container } from '@wix/editor-react-types'; * * interface MyComponentProps { * content?: Container; * } * * const MyComponent = ({ content }: MyComponentProps) => ( *
* {typeof content === 'function' ? content({}) : content} *
* ); * ``` */ export type Container = ReactNode | FC> export type Data = Record /** * An array of data values or data records. * * @example * ```tsx * import type { ArrayItems } from '@wix/editor-react-types'; * * interface MyComponentProps { * items?: ArrayItems; * } * ``` */ export type ArrayItems = Array /** * The text direction of the component. * Maps to the HTML `dir` attribute. * - `'ltr'` — left to right. * - `'rtl'` — right to left. * - `'auto'` — determined by content. * * @example * ```tsx * import type { Direction } from '@wix/editor-react-types'; * * interface MyComponentProps { * direction?: Direction; * } * * const MyComponent = ({ direction = 'ltr' }: MyComponentProps) => ( *
...
* ); * ``` */ export type Direction = 'rtl' | 'ltr' | 'auto' /** A union of all supported data types that can be used as component props. */ export type DataType = | Text | TextEnum | NumberType | BooleanValue | Schema | LocalDate | LocalTime | LocalDateTime | WebUrl | Email | Phone | Hostname | Regex | Guid | RichText | Container | ArrayItems | Direction | A11y | Image | Video | VectorArt | Audio | Link