@atlaskit/editor-common 74.57.0 → 74.58.1

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.
Files changed (111) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/cjs/element-browser/ElementBrowser.js +152 -0
  3. package/dist/cjs/element-browser/ViewMore.js +39 -0
  4. package/dist/cjs/element-browser/components/CategoryList.js +115 -0
  5. package/dist/cjs/element-browser/components/ElementBrowserLoader.js +36 -0
  6. package/dist/cjs/element-browser/components/ElementList/ElementList.js +256 -0
  7. package/dist/cjs/element-browser/components/ElementList/EmptyState.js +47 -0
  8. package/dist/cjs/element-browser/components/ElementList/NotFoundIllustration.js +70 -0
  9. package/dist/cjs/element-browser/components/ElementList/cellSizeAndPositionGetter.js +42 -0
  10. package/dist/cjs/element-browser/components/ElementList/utils.js +54 -0
  11. package/dist/cjs/element-browser/components/ElementSearch.js +88 -0
  12. package/dist/cjs/element-browser/components/StatelessElementBrowser.js +269 -0
  13. package/dist/cjs/element-browser/constants.js +41 -0
  14. package/dist/cjs/element-browser/hooks/use-container-width.js +70 -0
  15. package/dist/cjs/element-browser/hooks/use-focus.js +51 -0
  16. package/dist/cjs/element-browser/hooks/use-select-and-focus-on-arrow-navigation.js +286 -0
  17. package/dist/cjs/element-browser/index.js +20 -0
  18. package/dist/cjs/element-browser/types.js +12 -0
  19. package/dist/cjs/monitoring/error.js +1 -1
  20. package/dist/cjs/ui/DropList/index.js +1 -1
  21. package/dist/cjs/utils/performance/measure-render.js +4 -3
  22. package/dist/cjs/utils/performance/measure-tti.js +9 -3
  23. package/dist/cjs/utils/validator.js +7 -0
  24. package/dist/es2019/element-browser/ElementBrowser.js +117 -0
  25. package/dist/es2019/element-browser/ViewMore.js +40 -0
  26. package/dist/es2019/element-browser/components/CategoryList.js +106 -0
  27. package/dist/es2019/element-browser/components/ElementBrowserLoader.js +21 -0
  28. package/dist/es2019/element-browser/components/ElementList/ElementList.js +320 -0
  29. package/dist/es2019/element-browser/components/ElementList/EmptyState.js +58 -0
  30. package/dist/es2019/element-browser/components/ElementList/NotFoundIllustration.js +65 -0
  31. package/dist/es2019/element-browser/components/ElementList/cellSizeAndPositionGetter.js +39 -0
  32. package/dist/es2019/element-browser/components/ElementList/utils.js +50 -0
  33. package/dist/es2019/element-browser/components/ElementSearch.js +117 -0
  34. package/dist/es2019/element-browser/components/StatelessElementBrowser.js +339 -0
  35. package/dist/es2019/element-browser/constants.js +23 -0
  36. package/dist/es2019/element-browser/hooks/use-container-width.js +59 -0
  37. package/dist/es2019/element-browser/hooks/use-focus.js +48 -0
  38. package/dist/es2019/element-browser/hooks/use-select-and-focus-on-arrow-navigation.js +284 -0
  39. package/dist/es2019/element-browser/index.js +2 -0
  40. package/dist/es2019/element-browser/types.js +5 -0
  41. package/dist/es2019/monitoring/error.js +1 -1
  42. package/dist/es2019/ui/DropList/index.js +1 -1
  43. package/dist/es2019/utils/performance/measure-render.js +2 -3
  44. package/dist/es2019/utils/performance/measure-tti.js +9 -3
  45. package/dist/es2019/utils/validator.js +7 -0
  46. package/dist/esm/element-browser/ElementBrowser.js +142 -0
  47. package/dist/esm/element-browser/ViewMore.js +31 -0
  48. package/dist/esm/element-browser/components/CategoryList.js +105 -0
  49. package/dist/esm/element-browser/components/ElementBrowserLoader.js +23 -0
  50. package/dist/esm/element-browser/components/ElementList/ElementList.js +241 -0
  51. package/dist/esm/element-browser/components/ElementList/EmptyState.js +40 -0
  52. package/dist/esm/element-browser/components/ElementList/NotFoundIllustration.js +63 -0
  53. package/dist/esm/element-browser/components/ElementList/cellSizeAndPositionGetter.js +37 -0
  54. package/dist/esm/element-browser/components/ElementList/utils.js +46 -0
  55. package/dist/esm/element-browser/components/ElementSearch.js +77 -0
  56. package/dist/esm/element-browser/components/StatelessElementBrowser.js +258 -0
  57. package/dist/esm/element-browser/constants.js +23 -0
  58. package/dist/esm/element-browser/hooks/use-container-width.js +61 -0
  59. package/dist/esm/element-browser/hooks/use-focus.js +46 -0
  60. package/dist/esm/element-browser/hooks/use-select-and-focus-on-arrow-navigation.js +278 -0
  61. package/dist/esm/element-browser/index.js +2 -0
  62. package/dist/esm/element-browser/types.js +5 -0
  63. package/dist/esm/monitoring/error.js +1 -1
  64. package/dist/esm/ui/DropList/index.js +1 -1
  65. package/dist/esm/utils/performance/measure-render.js +2 -3
  66. package/dist/esm/utils/performance/measure-tti.js +9 -3
  67. package/dist/esm/utils/validator.js +7 -0
  68. package/dist/types/analytics/types/general-events.d.ts +2 -1
  69. package/dist/types/element-browser/ElementBrowser.d.ts +37 -0
  70. package/dist/types/element-browser/ViewMore.d.ts +6 -0
  71. package/dist/types/element-browser/components/CategoryList.d.ts +10 -0
  72. package/dist/types/element-browser/components/ElementBrowserLoader.d.ts +6 -0
  73. package/dist/types/element-browser/components/ElementList/ElementList.d.ts +33 -0
  74. package/dist/types/element-browser/components/ElementList/EmptyState.d.ts +6 -0
  75. package/dist/types/element-browser/components/ElementList/NotFoundIllustration.d.ts +2 -0
  76. package/dist/types/element-browser/components/ElementList/cellSizeAndPositionGetter.d.ts +7 -0
  77. package/dist/types/element-browser/components/ElementList/utils.d.ts +12 -0
  78. package/dist/types/element-browser/components/ElementSearch.d.ts +18 -0
  79. package/dist/types/element-browser/components/StatelessElementBrowser.d.ts +23 -0
  80. package/dist/types/element-browser/constants.d.ts +19 -0
  81. package/dist/types/element-browser/hooks/use-container-width.d.ts +33 -0
  82. package/dist/types/element-browser/hooks/use-focus.d.ts +35 -0
  83. package/dist/types/element-browser/hooks/use-select-and-focus-on-arrow-navigation.d.ts +72 -0
  84. package/dist/types/element-browser/index.d.ts +2 -0
  85. package/dist/types/element-browser/types.d.ts +12 -0
  86. package/dist/types/types/quick-insert.d.ts +1 -0
  87. package/dist/types/utils/performance/measure-render.d.ts +6 -4
  88. package/dist/types/utils/performance/measure-tti.d.ts +1 -1
  89. package/dist/types-ts4.5/analytics/types/general-events.d.ts +2 -1
  90. package/dist/types-ts4.5/element-browser/ElementBrowser.d.ts +37 -0
  91. package/dist/types-ts4.5/element-browser/ViewMore.d.ts +6 -0
  92. package/dist/types-ts4.5/element-browser/components/CategoryList.d.ts +10 -0
  93. package/dist/types-ts4.5/element-browser/components/ElementBrowserLoader.d.ts +6 -0
  94. package/dist/types-ts4.5/element-browser/components/ElementList/ElementList.d.ts +33 -0
  95. package/dist/types-ts4.5/element-browser/components/ElementList/EmptyState.d.ts +6 -0
  96. package/dist/types-ts4.5/element-browser/components/ElementList/NotFoundIllustration.d.ts +2 -0
  97. package/dist/types-ts4.5/element-browser/components/ElementList/cellSizeAndPositionGetter.d.ts +7 -0
  98. package/dist/types-ts4.5/element-browser/components/ElementList/utils.d.ts +12 -0
  99. package/dist/types-ts4.5/element-browser/components/ElementSearch.d.ts +18 -0
  100. package/dist/types-ts4.5/element-browser/components/StatelessElementBrowser.d.ts +23 -0
  101. package/dist/types-ts4.5/element-browser/constants.d.ts +19 -0
  102. package/dist/types-ts4.5/element-browser/hooks/use-container-width.d.ts +33 -0
  103. package/dist/types-ts4.5/element-browser/hooks/use-focus.d.ts +35 -0
  104. package/dist/types-ts4.5/element-browser/hooks/use-select-and-focus-on-arrow-navigation.d.ts +72 -0
  105. package/dist/types-ts4.5/element-browser/index.d.ts +2 -0
  106. package/dist/types-ts4.5/element-browser/types.d.ts +12 -0
  107. package/dist/types-ts4.5/types/quick-insert.d.ts +1 -0
  108. package/dist/types-ts4.5/utils/performance/measure-render.d.ts +6 -4
  109. package/dist/types-ts4.5/utils/performance/measure-tti.d.ts +1 -1
  110. package/element-browser/package.json +15 -0
  111. package/package.json +6 -2
@@ -0,0 +1,12 @@
1
+ export declare function getColumnCount(clientWidth: number): number;
2
+ type DatumReturnType = {
3
+ availableWidth: number;
4
+ columnCount: number;
5
+ };
6
+ type Options = {
7
+ gutterSize: number;
8
+ scrollbarWidth: number;
9
+ };
10
+ export declare function generateVirtualizedContainerDatum(containerWidth: number, options: Options): DatumReturnType;
11
+ export declare function getScrollbarWidth(): number;
12
+ export {};
@@ -0,0 +1,18 @@
1
+ /** @jsx jsx */
2
+ import React from 'react';
3
+ import type { WrappedComponentProps } from 'react-intl-next';
4
+ import { Modes } from '../types';
5
+ interface Props {
6
+ onSearch: (value: string) => void;
7
+ mode: keyof typeof Modes;
8
+ focus: boolean;
9
+ onClick: (e: React.MouseEvent) => void;
10
+ onKeyDown: (e: React.KeyboardEvent) => void;
11
+ searchTerm?: string;
12
+ }
13
+ declare const MemoizedElementSearchWithAnalytics: React.MemoExoticComponent<React.ForwardRefExoticComponent<Omit<Props & WrappedComponentProps<"intl">, "intl"> & {
14
+ forwardedRef?: React.Ref<any> | undefined;
15
+ } & {
16
+ children?: React.ReactNode;
17
+ } & import("@atlaskit/analytics-next").WithContextProps & React.RefAttributes<any>>>;
18
+ export default MemoizedElementSearchWithAnalytics;
@@ -0,0 +1,23 @@
1
+ /** @jsx jsx */
2
+ import React from 'react';
3
+ import type { WithAnalyticsEventsProps } from '@atlaskit/analytics-next';
4
+ import type { QuickInsertItem } from '../../provider-factory';
5
+ import type { EmptyStateHandler } from '../../types';
6
+ import type { Category, Modes } from '../types';
7
+ export type StatelessElementBrowserProps = {
8
+ categories?: Category[];
9
+ items: QuickInsertItem[];
10
+ onSearch: (searchTerm: string) => void;
11
+ onSelectCategory: (category: Category) => void;
12
+ onSelectItem?: (item: QuickInsertItem) => void;
13
+ onInsertItem: (item: QuickInsertItem) => void;
14
+ selectedCategory?: string;
15
+ showSearch: boolean;
16
+ showCategories: boolean;
17
+ mode: keyof typeof Modes;
18
+ searchTerm?: string;
19
+ emptyStateHandler?: EmptyStateHandler;
20
+ viewMoreItem?: QuickInsertItem;
21
+ } & WithAnalyticsEventsProps;
22
+ declare const MemoizedElementBrowser: React.MemoExoticComponent<React.ForwardRefExoticComponent<Pick<Omit<StatelessElementBrowserProps, keyof WithAnalyticsEventsProps> & React.RefAttributes<any> & import("@atlaskit/analytics-next").WithContextProps, "key" | "mode" | "analyticsContext" | "categories" | "onSelectCategory" | "selectedCategory" | "items" | "emptyStateHandler" | "searchTerm" | "onInsertItem" | "onSearch" | "onSelectItem" | "viewMoreItem" | "showCategories" | "showSearch"> & React.RefAttributes<any>>>;
23
+ export default MemoizedElementBrowser;
@@ -0,0 +1,19 @@
1
+ export declare const GRID_SIZE: number;
2
+ export declare const DEVICE_BREAKPOINT_NUMBERS: {
3
+ small: number;
4
+ medium: number;
5
+ large: number;
6
+ };
7
+ export declare const FLEX_ITEMS_CONTAINER_BREAKPOINT_NUMBERS: {
8
+ small: number;
9
+ medium: number;
10
+ large: number;
11
+ };
12
+ export declare const SIDEBAR_WIDTH: string;
13
+ export declare const SIDEBAR_HEADING_WRAPPER_HEIGHT: string;
14
+ export declare const SIDEBAR_HEADING_PADDING_LEFT = "12px";
15
+ export declare const INLINE_SIDEBAR_HEIGHT = "54px";
16
+ export declare const SEARCH_ITEM_HEIGHT_WIDTH = "20px";
17
+ export declare const SCROLLBAR_WIDTH = 15;
18
+ export declare const ELEMENT_LIST_PADDING = 2;
19
+ export declare const ELEMENT_ITEM_HEIGHT = 75;
@@ -0,0 +1,33 @@
1
+ /** @jsx jsx */
2
+ import React from 'react';
3
+ /**
4
+ *
5
+ * Problem:
6
+ * While using WidthObserver, there's no initial width.
7
+ * That may cause problems, but not limited to, something like a lag between
8
+ * renders for conditionally rendered components.
9
+ *
10
+ * solution:
11
+ * useContainerWidth() hook
12
+ * it pre-measures the width of a parent container on initial mount
13
+ * and gives you back the containerWidth.
14
+ *
15
+ *
16
+ * Example hook usage:
17
+ *
18
+ * const { containerWidth, ContainerWidthMonitor } = useContainerWidth();
19
+ *
20
+ * return (
21
+ * <>
22
+ * <ContainerWidthMonitor />
23
+ * {containerWidth < 600 ? <MobileComponent /> : <DesktopComponent />}
24
+ * </>
25
+ * );
26
+ *
27
+ */
28
+ type useContainerWidthReturnType = {
29
+ containerWidth: number;
30
+ ContainerWidthMonitor: React.ElementType;
31
+ };
32
+ export default function useContainerWidth(): useContainerWidthReturnType;
33
+ export {};
@@ -0,0 +1,35 @@
1
+ /// <reference types="react" />
2
+ /**
3
+ * A custom hook that handles focus on a DOM element.
4
+ * Takes in a boolean value and calls element.focus
5
+ *
6
+ * @param {boolean} focus
7
+ *
8
+ * Example usage:
9
+ *******************************************************************************
10
+ * const SearchBar = ({ focus }) => {
11
+ * const ref = useFocus(focus);
12
+ * return <input ref={ref} />
13
+ * }
14
+ *******************************************************************************
15
+ * const ItemList = ({ items, focus }) => (
16
+ * <ul>
17
+ * {items.map((item, index) => (
18
+ * <Item key={item.uuid} item={item} focus={focus} />
19
+ * ))}
20
+ * </ul>
21
+ * );
22
+ *
23
+ * const Item = ({ item, focus }) => {
24
+ * const ref = useFocus(focus);
25
+ * return (
26
+ * <li ref={ref}>
27
+ * {item.name}
28
+ * </li>
29
+ * )
30
+ * }
31
+ *******************************************************************************
32
+ */
33
+ type RefType = null | HTMLInputElement | HTMLDivElement;
34
+ export default function useFocus(focus: boolean): import("react").MutableRefObject<RefType>;
35
+ export {};
@@ -0,0 +1,72 @@
1
+ import type React from 'react';
2
+ /**
3
+ * a custom hook that handles keyboard navigation for Arrow keys based on a
4
+ * given listSize, and a step (for up and down arrows).
5
+ *
6
+ * @param {number} listSize
7
+ * @param {number} upDownStep
8
+ *
9
+ * Example usage:
10
+ * const list = ['Confluence','Jira','Atlaskit'];
11
+ * const {
12
+ * selectedItemIndex,
13
+ * focusedItemIndex,
14
+ * focusOnSearch,
15
+ * focusOnViewMore,
16
+ * setFocusedItemIndex,
17
+ * onKeyDown
18
+ * } = useSelectAndFocusOnArrowNavigation(list.length - 1, 1);
19
+ *
20
+ * return (
21
+ * <div onKeyDown={onKeyDown}>
22
+ * <SearchBar onClick={() => setFocusedItemIndex(undefined)} focus={focusOnSearch} />
23
+ * {list.map((item, index) => (
24
+ * <ListItem
25
+ * title={item}
26
+ * style={{ ..., color: selected ? 'selectedStateColor' : defaultColor }}
27
+ * onClick={() => {
28
+ * setFocusedItemIndex(index);
29
+ * }
30
+ * />
31
+ * )}
32
+ * </div>
33
+ * );
34
+ *
35
+ * const SearchBar = ({ focus }) => {
36
+ * const ref = useRefToFocusOrScroll(focus);
37
+ * return <input ref={ref} />
38
+ * }
39
+ *
40
+ */
41
+ type ReducerState = {
42
+ focusOnSearch: boolean;
43
+ focusOnViewMore: boolean;
44
+ selectedItemIndex?: number;
45
+ focusedItemIndex?: number;
46
+ listSize: number;
47
+ canFocusViewMore?: boolean;
48
+ };
49
+ export declare enum ACTIONS {
50
+ FOCUS_SEARCH = "focusOnSearch",
51
+ UPDATE_STATE = "updateState",
52
+ MOVE = "move"
53
+ }
54
+ export type ReducerAction = {
55
+ type: ACTIONS;
56
+ payload: Partial<ReducerState> & {
57
+ positions?: number;
58
+ step?: number;
59
+ };
60
+ };
61
+ export type useSelectAndFocusReturnType = {
62
+ selectedItemIndex?: number;
63
+ onKeyDown: (e: React.KeyboardEvent<HTMLDivElement>) => void;
64
+ focusOnSearch: boolean;
65
+ focusOnViewMore: boolean;
66
+ focusedItemIndex?: number;
67
+ setFocusedItemIndex: (index?: number) => void;
68
+ setFocusOnSearch: () => void;
69
+ };
70
+ declare function useSelectAndFocusOnArrowNavigation(listSize: number, step: number, canFocusViewMore: boolean): useSelectAndFocusReturnType;
71
+ export declare const ensureSafeIndex: (index: number, listSize: number) => number;
72
+ export default useSelectAndFocusOnArrowNavigation;
@@ -0,0 +1,2 @@
1
+ export { default as ElementBrowser } from './components/ElementBrowserLoader';
2
+ export { ELEMENT_ITEM_HEIGHT } from './constants';
@@ -0,0 +1,12 @@
1
+ export type Category = {
2
+ title: string;
3
+ name: string;
4
+ };
5
+ export declare enum Modes {
6
+ full = "full",
7
+ inline = "inline"
8
+ }
9
+ export type SelectedItemProps = {
10
+ selectedItemIndex?: number;
11
+ focusedItemIndex?: number;
12
+ };
@@ -34,4 +34,5 @@ export type QuickInsertSharedState = {
34
34
  lazyDefaultItems: () => QuickInsertItem[];
35
35
  emptyStateHandler?: EmptyStateHandler;
36
36
  providedItems?: QuickInsertItem[];
37
+ isElementBrowserModalOpen: boolean;
37
38
  };
@@ -1,12 +1,13 @@
1
+ type DistortedDurationMonitor = {
2
+ distortedDuration: boolean;
3
+ cleanup: () => void;
4
+ };
1
5
  /**
2
6
  * Monitors if a pages enters a visibility state which will lead to
3
7
  * distorted duration measurements (where the measurement uses the
4
8
  * requestAnimationFrame api).
5
9
  */
6
- export declare function getDistortedDurationMonitor(): {
7
- distortedDuration: boolean;
8
- cleanup(): void;
9
- };
10
+ export declare const getDistortedDurationMonitor: () => DistortedDurationMonitor;
10
11
  /**
11
12
  * Measures time it takes to render a frame including -> style, paint, layout and composition.
12
13
  *
@@ -48,3 +49,4 @@ onMeasureComplete: ({ duration, startTime, distortedDuration, }: {
48
49
  */
49
50
  distortedDuration: boolean;
50
51
  }) => void): void;
52
+ export {};
@@ -1,5 +1,5 @@
1
1
  import { SEVERITY } from '../analytics';
2
- export declare function measureTTI(onMeasureComplete: (tti: number, ttiFromInvocation: number, canceled: boolean) => void, idleThreshold?: number, cancelAfter?: number, PerfObserver?: typeof window.PerformanceObserver): void;
2
+ export declare function measureTTI(onMeasureComplete: (tti: number, ttiFromInvocation: number, canceled: boolean, distortedDuration: boolean) => void, idleThreshold?: number, cancelAfter?: number, PerfObserver?: typeof window.PerformanceObserver): void;
3
3
  export declare const TTI_SEVERITY_THRESHOLD_DEFAULTS: {
4
4
  NORMAL: number;
5
5
  DEGRADED: number;
@@ -0,0 +1,15 @@
1
+ {
2
+ "name": "@atlaskit/editor-common/element-browser",
3
+ "main": "../dist/cjs/element-browser/index.js",
4
+ "module": "../dist/esm/element-browser/index.js",
5
+ "module:es2019": "../dist/es2019/element-browser/index.js",
6
+ "sideEffects": false,
7
+ "types": "../dist/types/element-browser/index.d.ts",
8
+ "typesVersions": {
9
+ ">=4.5 <4.9": {
10
+ "*": [
11
+ "../dist/types-ts4.5/element-browser/index.d.ts"
12
+ ]
13
+ }
14
+ }
15
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-common",
3
- "version": "74.57.0",
3
+ "version": "74.58.1",
4
4
  "description": "A package that contains common classes and components for editor and renderer",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -77,7 +77,8 @@
77
77
  "./link": "./src/link/index.ts",
78
78
  "./mark": "./src/mark/index.ts",
79
79
  "./commands": "./src/commands/index.ts",
80
- "./lists": "./src/lists/index.ts"
80
+ "./lists": "./src/lists/index.ts",
81
+ "./element-browser": "./src/element-browser/index.ts"
81
82
  },
82
83
  "dependencies": {
83
84
  "@atlaskit/activity-provider": "^2.4.0",
@@ -111,6 +112,7 @@
111
112
  "@atlaskit/smart-user-picker": "^6.3.0",
112
113
  "@atlaskit/spinner": "^15.5.0",
113
114
  "@atlaskit/task-decision": "^17.8.0",
115
+ "@atlaskit/textfield": "^5.6.0",
114
116
  "@atlaskit/theme": "^12.6.0",
115
117
  "@atlaskit/tokens": "^1.21.0",
116
118
  "@atlaskit/tooltip": "^17.8.0",
@@ -134,6 +136,7 @@
134
136
  "raf-schd": "^4.0.3",
135
137
  "re-resizable": "6.0.0",
136
138
  "react-loadable": "^5.1.0",
139
+ "react-virtualized": "^9.8.0",
137
140
  "rusha": "^0.8.13",
138
141
  "w3c-keyname": "^2.1.0"
139
142
  },
@@ -158,6 +161,7 @@
158
161
  "@testing-library/react-hooks": "^8.0.1",
159
162
  "@testing-library/user-event": "^14.4.3",
160
163
  "@types/raf-schd": "^4.0.1",
164
+ "@types/react-virtualized": "^9.18.12",
161
165
  "enzyme": "^3.10.0",
162
166
  "raf-stub": "^2.0.1",
163
167
  "react": "^16.8.0",