@atlaskit/editor-common 78.34.0 → 78.36.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.
Files changed (50) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/cjs/monitoring/error.js +1 -1
  3. package/dist/cjs/portal/PortalBucket.js +44 -0
  4. package/dist/cjs/portal/PortalManager.js +209 -0
  5. package/dist/cjs/portal/index.js +26 -0
  6. package/dist/cjs/portal/usePortalProvider.js +80 -0
  7. package/dist/cjs/table/SortingIcon.js +144 -0
  8. package/dist/cjs/table/consts.js +7 -0
  9. package/dist/cjs/table/index.js +28 -0
  10. package/dist/cjs/table/messages.js +56 -0
  11. package/dist/cjs/ui/DropList/index.js +1 -1
  12. package/dist/es2019/monitoring/error.js +1 -1
  13. package/dist/es2019/portal/PortalBucket.js +29 -0
  14. package/dist/es2019/portal/PortalManager.js +157 -0
  15. package/dist/es2019/portal/index.js +3 -0
  16. package/dist/es2019/portal/usePortalProvider.js +58 -0
  17. package/dist/es2019/table/SortingIcon.js +183 -0
  18. package/dist/es2019/table/consts.js +1 -0
  19. package/dist/es2019/table/index.js +2 -0
  20. package/dist/es2019/table/messages.js +50 -0
  21. package/dist/es2019/ui/DropList/index.js +1 -1
  22. package/dist/esm/monitoring/error.js +1 -1
  23. package/dist/esm/portal/PortalBucket.js +34 -0
  24. package/dist/esm/portal/PortalManager.js +202 -0
  25. package/dist/esm/portal/index.js +3 -0
  26. package/dist/esm/portal/usePortalProvider.js +70 -0
  27. package/dist/esm/table/SortingIcon.js +139 -0
  28. package/dist/esm/table/consts.js +1 -0
  29. package/dist/esm/table/index.js +2 -0
  30. package/dist/esm/table/messages.js +50 -0
  31. package/dist/esm/ui/DropList/index.js +1 -1
  32. package/dist/types/portal/PortalBucket.d.ts +18 -0
  33. package/dist/types/portal/PortalManager.d.ts +53 -0
  34. package/dist/types/portal/index.d.ts +3 -0
  35. package/dist/types/portal/usePortalProvider.d.ts +18 -0
  36. package/dist/types/table/SortingIcon.d.ts +23 -0
  37. package/dist/types/table/consts.d.ts +1 -0
  38. package/dist/types/table/index.d.ts +2 -0
  39. package/dist/types/table/messages.d.ts +49 -0
  40. package/dist/types-ts4.5/portal/PortalBucket.d.ts +18 -0
  41. package/dist/types-ts4.5/portal/PortalManager.d.ts +53 -0
  42. package/dist/types-ts4.5/portal/index.d.ts +3 -0
  43. package/dist/types-ts4.5/portal/usePortalProvider.d.ts +21 -0
  44. package/dist/types-ts4.5/table/SortingIcon.d.ts +23 -0
  45. package/dist/types-ts4.5/table/consts.d.ts +1 -0
  46. package/dist/types-ts4.5/table/index.d.ts +2 -0
  47. package/dist/types-ts4.5/table/messages.d.ts +49 -0
  48. package/package.json +4 -2
  49. package/portal/package.json +15 -0
  50. package/table/package.json +15 -0
@@ -0,0 +1,18 @@
1
+ /// <reference types="react" />
2
+ import type { PortalManager } from './PortalManager';
3
+ type PortalBucketProps = {
4
+ id: number;
5
+ portalManager: PortalManager;
6
+ };
7
+ /**
8
+ * A component for rendering portals managed by a `PortalManager`.
9
+ * It subscribes to a `PortalManager` instance to listen for changes in the portal content
10
+ * and renders the content of its assigned portal bucket.
11
+ *
12
+ * @param {PortalBucketProps} props The component props.
13
+ * @param {number} props.id The ID for the portal bucket. This ID is used by the `PortalManager` to manage the content of this bucket.
14
+ * @param {PortalManager} props.portalManager An instance of `PortalManager` which manages the registration and unregistration of portal buckets and their content.
15
+ * @returns {React.ReactElement} The React element(s) that are currently registered to this portal bucket.
16
+ */
17
+ export declare function PortalBucket({ id, portalManager }: PortalBucketProps): JSX.Element;
18
+ export {};
@@ -0,0 +1,53 @@
1
+ /// <reference types="react" />
2
+ type PortalsBucketUpdater = React.Dispatch<React.SetStateAction<Record<React.Key, React.ReactPortal>>>;
3
+ type PortalRendererUpdater = React.Dispatch<React.SetStateAction<Array<PortalBucketType>>>;
4
+ type PortalBucketType = {
5
+ portals: Record<React.Key, React.ReactPortal>;
6
+ capacity: number;
7
+ updater: PortalsBucketUpdater | null;
8
+ };
9
+ /**
10
+ * A utility class to manage and dynamically scale React portals across multiple buckets.
11
+ * It allows for efficient rendering of large numbers of React portals by distributing them
12
+ * across "buckets" and updating these buckets as necessary to balance load and performance.
13
+ *
14
+ * @class PortalManager
15
+ * @typedef {Object} PortalManager
16
+ *
17
+ * @property {number} maxBucketCapacity - The maximum capacity of each bucket before a new bucket is created.
18
+ * @property {number} scaleRatio - The ratio to determine the number of new buckets to add when scaling up.
19
+ * @property {Array<PortalBucketType>} buckets - An array of bucket objects where each bucket holds a record of React portals.
20
+ * @property {Set<number>} availableBuckets - A set of indices representing buckets that have available capacity.
21
+ * @property {Map<React.Key, number>} portalToBucketMap - A map of React portal keys to their corresponding bucket indices.
22
+ * @property {PortalRendererUpdater|null} portalRendererUpdater - A function to trigger updates to the rendering of portals.
23
+ * @property {number} scaleCapacityThreshold - The threshold at which the buckets are scaled up to accommodate more portals.
24
+ *
25
+ * @param {number} [initialBuckets=DEFAULT_INITIAL_BUCKETS] - The initial number of buckets to create.
26
+ * @param {number} [maxBucketCapacity=DEFAULT_MAX_BUCKET_CAPACITY] - The maximum number of portals a single bucket can hold.
27
+ * @param {number} [scaleRatio=DEFAULT_SCALE_RATIO] - The ratio used to calculate the number of new buckets to add when scaling.
28
+ */
29
+ export declare class PortalManager {
30
+ private maxBucketCapacity;
31
+ private scaleRatio;
32
+ private buckets;
33
+ private availableBuckets;
34
+ private portalToBucketMap;
35
+ private portalRendererUpdater;
36
+ private scaleCapacityThreshold;
37
+ constructor(initialBuckets?: number, maxBucketCapacity?: number, scaleRatio?: number);
38
+ private getCurrentBucket;
39
+ private createBucket;
40
+ getBuckets(): PortalBucketType[];
41
+ registerBucket(id: number, updater: PortalsBucketUpdater): void;
42
+ unregisterBucket(id: number): void;
43
+ updateBuckets(id: number): void;
44
+ registerPortal(key: React.Key, portal: React.ReactPortal): () => void;
45
+ registerPortalRenderer(updater: PortalRendererUpdater): void;
46
+ unregisterPortalRenderer(): void;
47
+ /**
48
+ * Cleans up resources used by the PortalManager. This includes clearing all portals,
49
+ * unregistering all buckets, and resetting internal state.
50
+ */
51
+ destroy(): void;
52
+ }
53
+ export {};
@@ -0,0 +1,3 @@
1
+ export { PortalManager } from './PortalManager';
2
+ export { PortalBucket } from './PortalBucket';
3
+ export { usePortalProvider } from './usePortalProvider';
@@ -0,0 +1,21 @@
1
+ import React from 'react';
2
+ type RenderFn = (key: string, children: () => React.ReactChild | JSX.Element | null, container: HTMLElement) => void;
3
+ type RemoveFn = (key: string) => void;
4
+ interface PortalProviderAPI {
5
+ render: RenderFn;
6
+ remove: RemoveFn;
7
+ destroy: () => void;
8
+ }
9
+ type PortalRendererComponent = () => JSX.Element;
10
+ type UsePortalProviderReturnType = [
11
+ PortalProviderAPI,
12
+ PortalRendererComponent
13
+ ];
14
+ /**
15
+ * Initializes PortalManager and creates PortalRendererComponent. Offers an API (portalProviderAPI) for managing portals.
16
+ * @returns {[PortalProviderAPI, PortalRendererComponent]} An array containing two elements:
17
+ * 1. portalProviderAPI: An object providing an API for rendering and removing portals.
18
+ * 2. PortalRenderer: A React component responsible for rendering the portal content.
19
+ */
20
+ export declare function usePortalProvider(): UsePortalProviderReturnType;
21
+ export {};
@@ -0,0 +1,23 @@
1
+ /// <reference types="react" />
2
+ import type { WrappedComponentProps } from 'react-intl-next';
3
+ import { SortOrder } from '../types';
4
+ export declare enum StatusClassNames {
5
+ ASC = "sorting-icon-svg__asc",
6
+ DESC = "sorting-icon-svg__desc",
7
+ NO_ORDER = "sorting-icon-svg__no_order",
8
+ SORTING_NOT_ALLOWED = "sorting-icon-svg__not-allowed"
9
+ }
10
+ declare const _default: import("react").FC<import("react-intl-next").WithIntlProps<{
11
+ isSortingAllowed: boolean;
12
+ sortOrdered?: SortOrder | undefined;
13
+ onClick: () => void;
14
+ onKeyDown: (event: import("react").KeyboardEvent<HTMLElement>) => void;
15
+ } & WrappedComponentProps>> & {
16
+ WrappedComponent: import("react").ComponentType<{
17
+ isSortingAllowed: boolean;
18
+ sortOrdered?: SortOrder | undefined;
19
+ onClick: () => void;
20
+ onKeyDown: (event: import("react").KeyboardEvent<HTMLElement>) => void;
21
+ } & WrappedComponentProps>;
22
+ };
23
+ export default _default;
@@ -0,0 +1 @@
1
+ export declare const SORTABLE_COLUMN_ICON_CLASSNAME = "ak-renderer-tableHeader-sorting-icon";
@@ -0,0 +1,2 @@
1
+ export { SORTABLE_COLUMN_ICON_CLASSNAME } from './consts';
2
+ export { default as SortingIcon, StatusClassNames } from './SortingIcon';
@@ -0,0 +1,49 @@
1
+ export declare const sortingIconMessages: {
2
+ noOrderLabel: {
3
+ id: string;
4
+ defaultMessage: string;
5
+ description: string;
6
+ };
7
+ ascOrderLabel: {
8
+ id: string;
9
+ defaultMessage: string;
10
+ description: string;
11
+ };
12
+ descOrderLabel: {
13
+ id: string;
14
+ defaultMessage: string;
15
+ description: string;
16
+ };
17
+ invalidLabel: {
18
+ id: string;
19
+ defaultMessage: string;
20
+ description: string;
21
+ };
22
+ };
23
+ export declare const sortingAriaLabelMessages: {
24
+ noOrderLabel: {
25
+ id: string;
26
+ defaultMessage: string;
27
+ description: string;
28
+ };
29
+ ascOrderLabel: {
30
+ id: string;
31
+ defaultMessage: string;
32
+ description: string;
33
+ };
34
+ descOrderLabel: {
35
+ id: string;
36
+ defaultMessage: string;
37
+ description: string;
38
+ };
39
+ invalidLabel: {
40
+ id: string;
41
+ defaultMessage: string;
42
+ description: string;
43
+ };
44
+ defaultLabel: {
45
+ id: string;
46
+ defaultMessage: string;
47
+ description: string;
48
+ };
49
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-common",
3
- "version": "78.34.0",
3
+ "version": "78.36.0",
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/"
@@ -49,6 +49,7 @@
49
49
  "./collab": "./src/collab/index.ts",
50
50
  "./emoji": "./src/emoji.ts",
51
51
  "./mention": "./src/mention.ts",
52
+ "./portal": "./src/portal/index.ts",
52
53
  "./provider-helpers": "./src/provider-helpers/index.ts",
53
54
  "./icons": "./src/icons/index.ts",
54
55
  "./safe-plugin": "./src/safe-plugin/index.ts",
@@ -91,7 +92,8 @@
91
92
  "./annotation": "./src/annotation/index.ts",
92
93
  "./constants": "./src/link/constants.ts",
93
94
  "./doc-utils": "./src/doc-utils/index.ts",
94
- "./expand": "./src/expand/index.ts"
95
+ "./expand": "./src/expand/index.ts",
96
+ "./table": "./src/table/index.ts"
95
97
  },
96
98
  "dependencies": {
97
99
  "@atlaskit/activity-provider": "^2.4.0",
@@ -0,0 +1,15 @@
1
+ {
2
+ "name": "@atlaskit/editor-common/portal",
3
+ "main": "../dist/cjs/portal/index.js",
4
+ "module": "../dist/esm/portal/index.js",
5
+ "module:es2019": "../dist/es2019/portal/index.js",
6
+ "sideEffects": false,
7
+ "types": "../dist/types/portal/index.d.ts",
8
+ "typesVersions": {
9
+ ">=4.5 <5.4": {
10
+ "*": [
11
+ "../dist/types-ts4.5/portal/index.d.ts"
12
+ ]
13
+ }
14
+ }
15
+ }
@@ -0,0 +1,15 @@
1
+ {
2
+ "name": "@atlaskit/editor-common/table",
3
+ "main": "../dist/cjs/table/index.js",
4
+ "module": "../dist/esm/table/index.js",
5
+ "module:es2019": "../dist/es2019/table/index.js",
6
+ "sideEffects": false,
7
+ "types": "../dist/types/table/index.d.ts",
8
+ "typesVersions": {
9
+ ">=4.5 <5.4": {
10
+ "*": [
11
+ "../dist/types-ts4.5/table/index.d.ts"
12
+ ]
13
+ }
14
+ }
15
+ }