@commercetools-uikit/rich-text-input 13.0.2 → 14.0.0

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.
@@ -0,0 +1,29 @@
1
+ import { type ReactNode, type ReactElement } from 'react';
2
+ import type { TEditor } from './editor.types';
3
+ export declare type TEditorProps = {
4
+ editor: TEditor;
5
+ id?: string;
6
+ name?: string;
7
+ placeholder?: string;
8
+ disabled?: boolean;
9
+ readOnly?: boolean;
10
+ horizontalConstraint?: 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 'scale' | 'auto';
11
+ children?: ReactNode;
12
+ isDisabled?: boolean;
13
+ isReadOnly?: boolean;
14
+ showExpandIcon: boolean;
15
+ onClickExpand?: () => boolean;
16
+ hasWarning?: boolean;
17
+ hasError?: boolean;
18
+ defaultExpandMultilineText?: boolean;
19
+ };
20
+ declare const Editor: {
21
+ (props: TEditorProps): import("@emotion/react/jsx-runtime").JSX.Element;
22
+ displayName: string;
23
+ };
24
+ export declare type TEditorOptions = Pick<TEditorProps, 'hasWarning' | 'hasError' | 'showExpandIcon' | 'horizontalConstraint' | 'defaultExpandMultilineText' | 'onClickExpand'>;
25
+ export declare type TRenderEditor = (props: TEditorProps & {
26
+ options: TEditorOptions;
27
+ }, editor: TEditor, next: () => ReactElement) => ReturnType<typeof Editor>;
28
+ declare const renderEditor: TRenderEditor;
29
+ export default renderEditor;
@@ -0,0 +1,8 @@
1
+ /// <reference types="react" />
2
+ import type { TEditorProps } from './editor';
3
+ declare type TEditorWrapperProps = Pick<TEditorProps, 'isDisabled' | 'isReadOnly'>;
4
+ declare const EditorWrapper: import("@emotion/styled").StyledComponent<{
5
+ theme?: import("@emotion/react").Theme | undefined;
6
+ as?: import("react").ElementType<any> | undefined;
7
+ } & TEditorWrapperProps, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
8
+ export { EditorWrapper };
@@ -0,0 +1,100 @@
1
+ import type { ReactNode } from 'react';
2
+ declare type TNodes = {
3
+ map: (node: ReactNode) => {
4
+ toArray: () => string[];
5
+ };
6
+ };
7
+ declare type TDocument = {
8
+ getClosest: (block: {
9
+ key: unknown;
10
+ }, closest: (parent: {
11
+ type: string;
12
+ }) => boolean) => boolean;
13
+ getParent?: (parentParam: string) => {
14
+ type: string;
15
+ };
16
+ text?: string;
17
+ nodes?: TNodes;
18
+ };
19
+ declare type TBlocks = {
20
+ size?: number;
21
+ some: (block: unknown) => boolean | void;
22
+ first: () => {
23
+ key: string;
24
+ type: string;
25
+ };
26
+ map: (node: ReactNode) => {
27
+ toArray: () => string[];
28
+ };
29
+ };
30
+ declare type TValue = {
31
+ blocks: TBlocks;
32
+ document: TDocument;
33
+ selection: {
34
+ isFocused: boolean;
35
+ };
36
+ activeMarks: {
37
+ some: (ascertMarkType: (mark: TMark) => boolean) => void;
38
+ } | TMark[];
39
+ data: TData;
40
+ };
41
+ declare type TMark = {
42
+ type: string;
43
+ };
44
+ declare type TData = {
45
+ get: (key: string) => TSize;
46
+ };
47
+ declare type TSize = {
48
+ size: number;
49
+ };
50
+ declare type TWrapBlock = {
51
+ wrapBlock: (blockTag: string) => void;
52
+ };
53
+ declare type TNode = {
54
+ texts: (nodeParam?: Record<string, string>) => TNodeTextsResult[];
55
+ };
56
+ declare type TNodeTextsResult = [{
57
+ key: string;
58
+ text: string;
59
+ }, string];
60
+ export declare type TEditor = {
61
+ focus: () => void;
62
+ value: TValue;
63
+ setBlocks: (blockTag: string) => {
64
+ unwrapBlock: (blockTag: string) => {
65
+ unwrapBlock: (blockTag: string) => void;
66
+ };
67
+ wrapBlock: (blockTag: string) => void;
68
+ };
69
+ unwrapBlock: (blockTag: string) => TWrapBlock;
70
+ hasPlaceholder?: boolean;
71
+ query?: (when: string | (() => void), node: TNode) => {
72
+ next: () => void;
73
+ };
74
+ props: {
75
+ options: {
76
+ placeholder: string;
77
+ };
78
+ };
79
+ undo?: () => void;
80
+ redo?: () => void;
81
+ toggleRedo?: () => void;
82
+ selection: {
83
+ isFocused: boolean;
84
+ };
85
+ hasUndos: () => boolean;
86
+ hasRedos: () => boolean;
87
+ toggleMark?: (value: unknown) => void;
88
+ hasBoldMark: () => boolean;
89
+ toggleBoldMark: () => void;
90
+ hasItalicMark: () => boolean;
91
+ toggleItalicMark: () => boolean;
92
+ hasUnderlinedMark: () => boolean;
93
+ toggleUnderlinedMark: () => void;
94
+ hasNumberedListBlock: () => boolean;
95
+ toggleNumberedListBlock: () => void;
96
+ hasBulletedListBlock: () => boolean;
97
+ toggleBulletedListBlock: () => void;
98
+ toggleUndo: () => void;
99
+ };
100
+ export {};
@@ -0,0 +1,2 @@
1
+ export { default } from './rich-text-input';
2
+ export { default as version } from './version';
@@ -0,0 +1,68 @@
1
+ import { PureComponent, type FocusEvent } from 'react';
2
+ import { richTextPlugins, html } from '@commercetools-uikit/rich-text-utils';
3
+ import { type TEditorProps, type TRenderEditor, type TEditorOptions } from './editor';
4
+ declare type TSlateReactEditorProps = {
5
+ autoFocus?: TRichTextInputProps['isAutofocussed'];
6
+ id?: TRichTextInputProps['id'];
7
+ name?: TRichTextInputProps['name'];
8
+ onFocus?: TEventHook<FocusEvent>;
9
+ onBlur?: TEventHook<FocusEvent>;
10
+ disabled?: TRichTextInputProps['isDisabled'];
11
+ readOnly?: TRichTextInputProps['isReadOnly'];
12
+ value: ReturnType<typeof html.deserialize>;
13
+ options: TEditorOptions;
14
+ onChange?: TOnChangeFn;
15
+ plugins: typeof richTextPlugins;
16
+ renderEditor: TRenderEditor;
17
+ };
18
+ declare const Editor: (props: TSlateReactEditorProps) => import("@emotion/react/jsx-runtime").JSX.Element;
19
+ declare type TBaseEvent = {
20
+ target: {
21
+ id?: string;
22
+ name?: string;
23
+ };
24
+ };
25
+ declare type TChangeEvent = {
26
+ target: TBaseEvent['target'] & {
27
+ value: string;
28
+ };
29
+ };
30
+ declare type TFocusEvent = TBaseEvent;
31
+ declare type TEventHook<T = Event> = (event: T, editor: typeof Editor, next: () => unknown) => unknown;
32
+ declare type TOnChangeParam = {
33
+ operations: unknown;
34
+ value: ReturnType<typeof html.deserialize>;
35
+ };
36
+ declare type TOnChangeFn = (change: TOnChangeParam) => unknown;
37
+ export declare type TRichTextInputProps = {
38
+ isAutofocussed?: boolean;
39
+ defaultExpandMultilineText?: TEditorProps['defaultExpandMultilineText'];
40
+ hasError?: TEditorProps['hasError'];
41
+ hasWarning?: TEditorProps['hasWarning'];
42
+ id?: string;
43
+ name?: string;
44
+ placeholder: string;
45
+ isDisabled?: TEditorProps['isDisabled'];
46
+ isReadOnly?: TEditorProps['isReadOnly'];
47
+ horizontalConstraint?: TEditorProps['horizontalConstraint'];
48
+ onChange?: (event: TChangeEvent) => void;
49
+ onFocus?: (event: TFocusEvent) => void;
50
+ onBlur?: (event: TFocusEvent) => void;
51
+ value?: string;
52
+ showExpandIcon: TEditorProps['showExpandIcon'];
53
+ onClickExpand?: TEditorProps['onClickExpand'];
54
+ };
55
+ declare class RichTextInput extends PureComponent<TRichTextInputProps> {
56
+ static defaultProps: Pick<TRichTextInputProps, 'defaultExpandMultilineText' | 'horizontalConstraint' | 'placeholder' | 'showExpandIcon'>;
57
+ static displayName: string;
58
+ static isEmpty: (rawValue: string) => boolean;
59
+ static isTouched: (touched: boolean | unknown[]) => boolean;
60
+ serializedValue: string | undefined;
61
+ internalSlateValue: import("slate").Value;
62
+ componentDidUpdate(): void;
63
+ onValueChange: TOnChangeFn;
64
+ onBlur: TEventHook<FocusEvent>;
65
+ onFocus: TEventHook<FocusEvent>;
66
+ render(): import("@emotion/react/jsx-runtime").JSX.Element;
67
+ }
68
+ export default RichTextInput;
@@ -0,0 +1,2 @@
1
+ declare const _default: "__@UI_KIT_PACKAGE/VERSION_OF_RELEASE__";
2
+ export default _default;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@commercetools-uikit/rich-text-input",
3
3
  "description": "A controlled rich text input component for rich text with validation states.",
4
- "version": "13.0.2",
4
+ "version": "14.0.0",
5
5
  "bugs": "https://github.com/commercetools/ui-kit/issues",
6
6
  "repository": {
7
7
  "type": "git",
@@ -9,7 +9,7 @@
9
9
  "directory": "packages/components/inputs/rich-text-input"
10
10
  },
11
11
  "homepage": "https://uikit.commercetools.com",
12
- "keywords": ["javascript", "design system", "react", "uikit"],
12
+ "keywords": ["javascript", "typescript", "design-system", "react", "uikit"],
13
13
  "license": "MIT",
14
14
  "publishConfig": {
15
15
  "access": "public"
@@ -19,20 +19,20 @@
19
19
  "module": "dist/commercetools-uikit-rich-text-input.esm.js",
20
20
  "files": ["dist"],
21
21
  "dependencies": {
22
- "@babel/runtime": "7.17.2",
23
- "@babel/runtime-corejs3": "7.17.2",
24
- "@commercetools-uikit/collapsible-motion": "13.0.2",
25
- "@commercetools-uikit/constraints": "13.0.2",
26
- "@commercetools-uikit/design-system": "13.0.0",
27
- "@commercetools-uikit/flat-button": "13.0.2",
28
- "@commercetools-uikit/hooks": "13.0.2",
29
- "@commercetools-uikit/icons": "13.0.2",
30
- "@commercetools-uikit/input-utils": "13.0.2",
31
- "@commercetools-uikit/rich-text-utils": "13.0.2",
32
- "@commercetools-uikit/spacings-inline": "13.0.2",
33
- "@commercetools-uikit/spacings-stack": "13.0.2",
34
- "@commercetools-uikit/tooltip": "13.0.2",
35
- "@commercetools-uikit/utils": "13.0.2",
22
+ "@babel/runtime": "^7.17.2",
23
+ "@babel/runtime-corejs3": "^7.17.2",
24
+ "@commercetools-uikit/collapsible-motion": "14.0.0",
25
+ "@commercetools-uikit/constraints": "14.0.0",
26
+ "@commercetools-uikit/design-system": "14.0.0",
27
+ "@commercetools-uikit/flat-button": "14.0.0",
28
+ "@commercetools-uikit/hooks": "14.0.0",
29
+ "@commercetools-uikit/icons": "14.0.0",
30
+ "@commercetools-uikit/input-utils": "14.0.0",
31
+ "@commercetools-uikit/rich-text-utils": "14.0.0",
32
+ "@commercetools-uikit/spacings-inline": "14.0.0",
33
+ "@commercetools-uikit/spacings-stack": "14.0.0",
34
+ "@commercetools-uikit/tooltip": "14.0.0",
35
+ "@commercetools-uikit/utils": "14.0.0",
36
36
  "@emotion/react": "^11.4.0",
37
37
  "@emotion/styled": "^11.3.0",
38
38
  "downshift": "6.1.7",
@@ -40,14 +40,13 @@
40
40
  "is-hotkey": "0.2.0",
41
41
  "lodash": "4.17.21",
42
42
  "prop-types": "15.8.1",
43
- "react-required-if": "1.0.3",
44
43
  "slate": "0.47.9",
45
44
  "slate-html-serializer": "0.8.13",
46
45
  "slate-react": "0.22.10"
47
46
  },
48
47
  "devDependencies": {
49
48
  "react": "17.0.2",
50
- "react-intl": "5.24.6"
49
+ "react-intl": "^5.24.6"
51
50
  },
52
51
  "peerDependencies": {
53
52
  "react": "17.x",