@atlaskit/link-picker 0.0.2 → 0.8.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 (66) hide show
  1. package/CHANGELOG.md +152 -0
  2. package/README.md +27 -5
  3. package/dist/cjs/browser.js +39 -0
  4. package/dist/cjs/index.js +2 -2
  5. package/dist/cjs/messages.js +102 -0
  6. package/dist/cjs/styles.js +90 -0
  7. package/dist/cjs/transformTimeStamp.js +55 -0
  8. package/dist/cjs/types.js +5 -0
  9. package/dist/cjs/ui/LinkSearchList.js +112 -0
  10. package/dist/cjs/ui/LinkSearchListItem.js +101 -0
  11. package/dist/cjs/ui/PanelTextInput.js +119 -0
  12. package/dist/cjs/ui/announcer.js +64 -0
  13. package/dist/cjs/ui/link-picker.js +582 -0
  14. package/dist/cjs/url.js +104 -0
  15. package/dist/cjs/utils.js +40 -0
  16. package/dist/cjs/version.json +1 -1
  17. package/dist/es2019/browser.js +34 -0
  18. package/dist/es2019/index.js +1 -1
  19. package/dist/es2019/messages.js +93 -0
  20. package/dist/es2019/styles.js +93 -0
  21. package/dist/es2019/transformTimeStamp.js +41 -0
  22. package/dist/es2019/types.js +1 -0
  23. package/dist/es2019/ui/LinkSearchList.js +65 -0
  24. package/dist/es2019/ui/LinkSearchListItem.js +88 -0
  25. package/dist/es2019/ui/PanelTextInput.js +93 -0
  26. package/dist/es2019/ui/announcer.js +38 -0
  27. package/dist/es2019/ui/link-picker.js +481 -0
  28. package/dist/es2019/url.js +88 -0
  29. package/dist/es2019/utils.js +24 -0
  30. package/dist/es2019/version.json +1 -1
  31. package/dist/esm/browser.js +34 -0
  32. package/dist/esm/index.js +1 -1
  33. package/dist/esm/messages.js +93 -0
  34. package/dist/esm/styles.js +46 -0
  35. package/dist/esm/transformTimeStamp.js +41 -0
  36. package/dist/esm/types.js +1 -0
  37. package/dist/esm/ui/LinkSearchList.js +87 -0
  38. package/dist/esm/ui/LinkSearchListItem.js +88 -0
  39. package/dist/esm/ui/PanelTextInput.js +93 -0
  40. package/dist/esm/ui/announcer.js +51 -0
  41. package/dist/esm/ui/link-picker.js +560 -0
  42. package/dist/esm/url.js +90 -0
  43. package/dist/esm/utils.js +24 -0
  44. package/dist/esm/version.json +1 -1
  45. package/dist/types/browser.d.ts +15 -0
  46. package/dist/types/index.d.ts +3 -1
  47. package/dist/types/messages.d.ts +92 -0
  48. package/dist/types/styles.d.ts +18 -0
  49. package/dist/types/transformTimeStamp.d.ts +3 -0
  50. package/dist/types/types.d.ts +37 -0
  51. package/dist/types/ui/LinkSearchList.d.ts +20 -0
  52. package/dist/types/ui/LinkSearchListItem.d.ts +17 -0
  53. package/dist/types/ui/PanelTextInput.d.ts +17 -0
  54. package/dist/types/ui/announcer.d.ts +22 -0
  55. package/dist/types/ui/link-picker.d.ts +51 -0
  56. package/dist/types/url.d.ts +5 -0
  57. package/dist/types/utils.d.ts +4 -0
  58. package/example-helpers/flight-deck/_manifest.json +9 -0
  59. package/example-helpers/flight-deck/mockFDResponse.json +133 -0
  60. package/example-helpers/mock-data.ts +316 -0
  61. package/example-helpers/providers.ts +39 -0
  62. package/package.json +35 -6
  63. package/dist/cjs/link-picker.js +0 -12
  64. package/dist/es2019/link-picker.js +0 -3
  65. package/dist/esm/link-picker.js +0 -3
  66. package/dist/types/link-picker.d.ts +0 -1
@@ -1 +1,3 @@
1
- export { LinkPicker } from './link-picker';
1
+ export type { LinkPickerProps } from './ui/link-picker';
2
+ export { LinkPickerWithIntl as LinkPicker } from './ui/link-picker';
3
+ export type { LinkInputType, LinkPickerPlugin, LinkPickerState, LinkSearchListItemData, } from './types';
@@ -0,0 +1,92 @@
1
+ export declare const messages: {
2
+ placeholder: {
3
+ id: string;
4
+ defaultMessage: string;
5
+ description: string;
6
+ };
7
+ linkPlaceholder: {
8
+ id: string;
9
+ defaultMessage: string;
10
+ description: string;
11
+ };
12
+ linkTextPlaceholder: {
13
+ id: string;
14
+ defaultMessage: string;
15
+ description: string;
16
+ };
17
+ linkLabel: {
18
+ id: string;
19
+ defaultMessage: string;
20
+ description: string;
21
+ };
22
+ linkInvalid: {
23
+ id: string;
24
+ defaultMessage: string;
25
+ description: string;
26
+ };
27
+ linkTextLabel: {
28
+ id: string;
29
+ defaultMessage: string;
30
+ description: string;
31
+ };
32
+ clearText: {
33
+ id: string;
34
+ defaultMessage: string;
35
+ description: string;
36
+ };
37
+ clearLink: {
38
+ id: string;
39
+ defaultMessage: string;
40
+ description: string;
41
+ };
42
+ searchLinkAriaDescription: {
43
+ id: string;
44
+ defaultMessage: string;
45
+ description: string;
46
+ };
47
+ searchLinkResults: {
48
+ id: string;
49
+ defaultMessage: string;
50
+ description: string;
51
+ };
52
+ linkAriaLabel: {
53
+ id: string;
54
+ defaultMessage: string;
55
+ description: string;
56
+ };
57
+ timeUpdated: {
58
+ id: string;
59
+ defaultMessage: string;
60
+ description: string;
61
+ };
62
+ timeViewed: {
63
+ id: string;
64
+ defaultMessage: string;
65
+ description: string;
66
+ };
67
+ timeAgo: {
68
+ id: string;
69
+ defaultMessage: string;
70
+ description: string;
71
+ };
72
+ titleRecentlyViewed: {
73
+ id: string;
74
+ defaultMessage: string;
75
+ description: string;
76
+ };
77
+ titleResults: {
78
+ id: string;
79
+ defaultMessage: string;
80
+ description: string;
81
+ };
82
+ cancelButton: {
83
+ id: string;
84
+ defaultMessage: string;
85
+ description: string;
86
+ };
87
+ insertButton: {
88
+ id: string;
89
+ defaultMessage: string;
90
+ description: string;
91
+ };
92
+ };
@@ -0,0 +1,18 @@
1
+ /// <reference types="react" />
2
+ export declare const recentListStyles: import("@emotion/utils").SerializedStyles;
3
+ export declare const Container: import("styled-components").StyledComponentClass<import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement>, any, import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement>>;
4
+ export declare const ClearText: import("styled-components").StyledComponentClass<import("react").ClassAttributes<HTMLButtonElement> & import("react").ButtonHTMLAttributes<HTMLButtonElement>, any, import("react").ClassAttributes<HTMLButtonElement> & import("react").ButtonHTMLAttributes<HTMLButtonElement>>;
5
+ export declare const FieldWrapper: import("styled-components").StyledComponentClass<import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement>, any, import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement>>;
6
+ export declare const SearchIconWrapper: import("styled-components").StyledComponentClass<import("react").ClassAttributes<HTMLSpanElement> & import("react").HTMLAttributes<HTMLSpanElement>, any, import("react").ClassAttributes<HTMLSpanElement> & import("react").HTMLAttributes<HTMLSpanElement>>;
7
+ export declare const ListTitleStyles: import("@emotion/utils").SerializedStyles;
8
+ interface ListItemProps {
9
+ active: boolean;
10
+ selected: boolean;
11
+ }
12
+ export declare const ListItemWrapper: import("styled-components").StyledComponentClass<import("react").ClassAttributes<HTMLLIElement> & import("react").LiHTMLAttributes<HTMLLIElement> & ListItemProps, any, import("react").ClassAttributes<HTMLLIElement> & import("react").LiHTMLAttributes<HTMLLIElement> & ListItemProps>;
13
+ export declare const ItemNameWrapper: import("styled-components").StyledComponentClass<import("react").ClassAttributes<HTMLSpanElement> & import("react").HTMLAttributes<HTMLSpanElement>, any, import("react").ClassAttributes<HTMLSpanElement> & import("react").HTMLAttributes<HTMLSpanElement>>;
14
+ export declare const ListItemName: import("styled-components").StyledComponentClass<import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement>, any, import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement>>;
15
+ export declare const ListItemContext: import("styled-components").StyledComponentClass<import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement>, any, import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement>>;
16
+ export declare const ItemIconWrapper: import("styled-components").StyledComponentClass<import("react").ClassAttributes<HTMLSpanElement> & import("react").HTMLAttributes<HTMLSpanElement>, any, import("react").ClassAttributes<HTMLSpanElement> & import("react").HTMLAttributes<HTMLSpanElement>>;
17
+ export declare const ImgStyles: import("@emotion/utils").SerializedStyles;
18
+ export {};
@@ -0,0 +1,3 @@
1
+ import { IntlShape } from 'react-intl-next';
2
+ import { ListItemTimeStamp } from './types';
3
+ export declare const transformTimeStamp: (intl: IntlShape, lastViewedDate?: Date | undefined, lastUpdatedDate?: Date | undefined) => ListItemTimeStamp | undefined;
@@ -0,0 +1,37 @@
1
+ /// <reference types="react" />
2
+ import { MessageDescriptor } from 'react-intl-next';
3
+ export declare type LinkInputType = 'manual' | 'typeAhead';
4
+ export interface LinkSearchListItemData {
5
+ /** Unique identifiable attribute for the item */
6
+ objectId: string;
7
+ /** Name / title / display text of the link */
8
+ name: string;
9
+ /** URL of the resource being linked to */
10
+ url: string;
11
+ /** Context to display in link result */
12
+ container: string;
13
+ /** Icon to display in link result */
14
+ icon: string | React.ComponentType<{
15
+ alt: string;
16
+ }>;
17
+ /** Alt text describing the icon */
18
+ iconAlt: string | MessageDescriptor;
19
+ /** Optional last view date to display in link result */
20
+ lastViewedDate?: Date;
21
+ /** Optional last updated date to display in link result */
22
+ lastUpdatedDate?: Date;
23
+ /** Whether the result is pre-fetched from activity provider */
24
+ prefetch?: boolean;
25
+ }
26
+ export declare type ListItemTimeStamp = {
27
+ pageAction: string;
28
+ dateString: string;
29
+ timeSince?: string | undefined;
30
+ };
31
+ export interface LinkPickerState {
32
+ /** Current query string / URL input field value */
33
+ query: string;
34
+ }
35
+ export interface LinkPickerPlugin {
36
+ resolve: (state: LinkPickerState) => AsyncGenerator<LinkSearchListItemData[], LinkSearchListItemData[]>;
37
+ }
@@ -0,0 +1,20 @@
1
+ import React from 'react';
2
+ import { PureComponent } from 'react';
3
+ import { LinkSearchListItemData } from '../types';
4
+ export declare const List: import("styled-components").StyledComponentClass<React.ClassAttributes<HTMLUListElement> & React.HTMLAttributes<HTMLUListElement>, any, React.ClassAttributes<HTMLUListElement> & React.HTMLAttributes<HTMLUListElement>>;
5
+ export interface Props {
6
+ items?: LinkSearchListItemData[];
7
+ isLoading: boolean;
8
+ selectedIndex: number;
9
+ activeIndex: number;
10
+ onSelect: (objectId: string) => void;
11
+ onMouseEnter: (objectId: string) => void;
12
+ onMouseLeave: (objectId: string) => void;
13
+ ariaControls?: string;
14
+ ariaLabelledBy?: string;
15
+ role?: string;
16
+ id?: string;
17
+ }
18
+ export default class LinkSearchList extends PureComponent<Props, {}> {
19
+ render(): JSX.Element;
20
+ }
@@ -0,0 +1,17 @@
1
+ /// <reference types="react" />
2
+ import { WrappedComponentProps } from 'react-intl-next';
3
+ import { LinkSearchListItemData } from '../types';
4
+ export interface Props {
5
+ item: LinkSearchListItemData;
6
+ selected: boolean;
7
+ active: boolean;
8
+ onSelect: (objectId: string) => void;
9
+ onMouseEnter: (objectId: string) => void;
10
+ onMouseLeave: (objectId: string) => void;
11
+ id?: string;
12
+ role?: string;
13
+ }
14
+ declare const _default: import("react").FC<import("react-intl-next").WithIntlProps<WrappedComponentProps<"intl"> & Props>> & {
15
+ WrappedComponent: import("react").ComponentType<WrappedComponentProps<"intl"> & Props>;
16
+ };
17
+ export default _default;
@@ -0,0 +1,17 @@
1
+ /// <reference types="react" />
2
+ import { TextFieldProps } from '@atlaskit/textfield';
3
+ export interface Props extends Omit<TextFieldProps, 'value' | 'onChange' | 'autoFocus' | 'onSubmit'> {
4
+ name: string;
5
+ label?: string;
6
+ autoFocus?: boolean;
7
+ value: string;
8
+ onChange: (value: string) => void;
9
+ onSubmit?: (value: string) => void;
10
+ onUndo?: Function;
11
+ onRedo?: Function;
12
+ onClear?: () => void;
13
+ clearLabel?: string;
14
+ error?: string | null;
15
+ }
16
+ declare const PanelTextInput: (props: Props) => JSX.Element;
17
+ export default PanelTextInput;
@@ -0,0 +1,22 @@
1
+ import React, { AriaAttributes, Ref } from 'react';
2
+ declare type AnnouncerProps = {
3
+ ref?: Ref<HTMLDivElement>;
4
+ /** Set 'false' for announcing only changed text
5
+ * (not announce duplicate part of string after second render),
6
+ * and 'true' for announcing all the string after each render */
7
+ ariaAtomic?: AriaAttributes['aria-atomic'];
8
+ /** Set politeness settings */
9
+ ariaLive?: AriaAttributes['aria-live'];
10
+ /** Used to describe what types of changes have occurred to an aria-live region */
11
+ ariaRelevant?: AriaAttributes['aria-relevant'];
12
+ /** Role used to set attribute role. See more details https://dequeuniversity.com/library/aria/liveregion-playground#configOptions */
13
+ role?: 'status' | 'log' | 'alert' | 'timer' | 'marquee';
14
+ /** Text message that will be announced */
15
+ text: string;
16
+ /** Debounce delay.
17
+ * Set delay (ms) to prevent announce the same string multiple times.
18
+ * It can be useful for cases when the parent component re-renders with the same announcer's text. */
19
+ delay?: number;
20
+ };
21
+ declare const _default: React.NamedExoticComponent<AnnouncerProps>;
22
+ export default _default;
@@ -0,0 +1,51 @@
1
+ /** @jsx jsx */
2
+ import React from 'react';
3
+ import { WrappedComponentProps } from 'react-intl-next';
4
+ import { LinkSearchListItemData, LinkInputType, LinkPickerPlugin } from '../types';
5
+ export declare const RECENT_SEARCH_LIST_SIZE = 5;
6
+ interface Meta {
7
+ /** Indicates how the link was picked. */
8
+ inputMethod: LinkInputType;
9
+ }
10
+ interface OnSubmitParameter {
11
+ /** The `url` of the linked resource. */
12
+ url: string;
13
+ /** The desired text to be displayed alternatively to the title of the linked resource. */
14
+ displayText: string | null;
15
+ /** The resolved `title` of the resource at the time of link picking (if applicable, null if not known). */
16
+ title: string | null;
17
+ /** Meta data about the link picking submission. */
18
+ meta: Meta;
19
+ /**
20
+ * The input value of the `url` field at time of submission if inserted "manually".
21
+ * This can useful if the `url` was manually inserted with a value that is different from the normalised value returned as `url`.
22
+ * @example
23
+ * { url: 'https://google.com', rawUrl: 'google.com' }
24
+ */
25
+ rawUrl?: string;
26
+ }
27
+ export interface LinkPickerProps {
28
+ /** Callback to fire on form submission. */
29
+ onSubmit: (arg: OnSubmitParameter) => void;
30
+ /** Callback to fire when the cancel button is clicked. */
31
+ onCancel: () => void;
32
+ /** The url of the linked resource for editing. */
33
+ url?: string;
34
+ /** The desired text to be displayed alternatively to the title of the linked resource for editing. */
35
+ displayText?: string | null;
36
+ /** Plugins that provide link suggestions / search capabilities. */
37
+ plugins?: LinkPickerPlugin[];
38
+ }
39
+ export interface State {
40
+ items: LinkSearchListItemData[];
41
+ selectedIndex: number;
42
+ activeIndex: number;
43
+ url: string;
44
+ isLoading: boolean;
45
+ displayText: string;
46
+ invalidUrl: string | null;
47
+ }
48
+ export declare const LinkPickerWithIntl: React.FC<import("react-intl-next").WithIntlProps<WrappedComponentProps<"intl"> & LinkPickerProps>> & {
49
+ WrappedComponent: React.ComponentType<WrappedComponentProps<"intl"> & LinkPickerProps>;
50
+ };
51
+ export {};
@@ -0,0 +1,5 @@
1
+ export declare const isSafeUrl: (url: string) => boolean;
2
+ /**
3
+ * Adds protocol to url if needed.
4
+ */
5
+ export declare function normalizeUrl(url?: string | null): string | null;
@@ -0,0 +1,4 @@
1
+ import { KeyboardEvent } from 'react';
2
+ export declare const relativeFontSizeToBase16: (px: number | string) => string;
3
+ export declare const isUndoEvent: (e: KeyboardEvent<HTMLInputElement>) => boolean;
4
+ export declare const isRedoEvent: (e: KeyboardEvent<HTMLInputElement>) => boolean;
@@ -0,0 +1,9 @@
1
+ {
2
+ "name": "recent-work-service",
3
+ "publishMetadata": {
4
+ "metricTags": {}
5
+ },
6
+ "dimensions": {},
7
+ "tagScheme": "v001-n_$name$",
8
+ "frontend": true
9
+ }
@@ -0,0 +1,133 @@
1
+ {
2
+ "hydrators": {
3
+ "TownsquareGoal": {
4
+ "hydratorPaths": {
5
+ "id": [
6
+ "id"
7
+ ],
8
+ "key": [
9
+ "key"
10
+ ],
11
+ "name": [
12
+ "name"
13
+ ],
14
+ "url": [
15
+ "url"
16
+ ],
17
+ "icon": [
18
+ "iconData"
19
+ ]
20
+ }
21
+ },
22
+ "TownsquareProject": {
23
+ "hydratorPaths": {
24
+ "id": [
25
+ "id"
26
+ ],
27
+ "key": [
28
+ "key"
29
+ ],
30
+ "name": [
31
+ "name"
32
+ ],
33
+ "url": [
34
+ "url"
35
+ ],
36
+ "icon": [
37
+ "iconData"
38
+ ]
39
+ }
40
+ },
41
+ "TownsquareComment": {
42
+ "hydratorPaths": {
43
+ "id": [
44
+ "id"
45
+ ],
46
+ "name": [
47
+ "object.name"
48
+ ],
49
+ "url": [
50
+ "object.url"
51
+ ],
52
+ "icon": [
53
+ "object.iconData"
54
+ ]
55
+ }
56
+ },
57
+ "ConfluencePage": {
58
+ "hydratorPaths": {
59
+ "id": [
60
+ "id"
61
+ ],
62
+ "name": [
63
+ "title"
64
+ ],
65
+ "localResourceId": [
66
+ "pageId"
67
+ ],
68
+ "url": [
69
+ "links.base",
70
+ "links.webUi"
71
+ ],
72
+ "containers": [
73
+ "space.name"
74
+ ],
75
+ "icon": [
76
+ "metadata.titleEmojiDraft",
77
+ "metadata.titleEmojiPublished"
78
+ ]
79
+ },
80
+ "staticFallbacks": {
81
+ "icon": "https://home-static.us-east-1.staging.public.atl-paas.net/confluence-page-icon.svg"
82
+ }
83
+ },
84
+ "ConfluenceBlogPost": {
85
+ "hydratorPaths": {
86
+ "id": [
87
+ "id"
88
+ ],
89
+ "name": [
90
+ "title"
91
+ ],
92
+ "localResourceId": [
93
+ "blogPostId"
94
+ ],
95
+ "url": [
96
+ "links.base",
97
+ "links.webUi"
98
+ ],
99
+ "containers": [
100
+ "space.name"
101
+ ],
102
+ "icon": [
103
+ "metadata.titleEmojiDraft",
104
+ "metadata.titleEmojiPublished"
105
+ ]
106
+ },
107
+ "staticFallbacks": {
108
+ "icon": "https://home-static.us-east-1.prod.public.atl-paas.net/confluence-blogpost-icon.svg"
109
+ }
110
+ },
111
+ "ConfluenceComment": {
112
+ "hydratorPaths": {
113
+ "id": [
114
+ "id"
115
+ ],
116
+ "name": [
117
+ "container.title"
118
+ ],
119
+ "url": [
120
+ "links.base",
121
+ "links.webUi"
122
+ ],
123
+ "containers": [
124
+ "container.space.name"
125
+ ]
126
+ },
127
+ "staticFallbacks": {
128
+ "icon": "https://home-static.us-east-1.staging.public.atl-paas.net/confluence-page-icon.svg"
129
+ }
130
+ }
131
+ },
132
+ "queryFragments": "\n\n fragment townsquareGoal on TownsquareGoal {\n id\n key\n name\n url\n iconData\n }\n\n\n fragment townsquareProject on TownsquareProject {\n id\n key\n name\n url\n iconData\n }\n\n\n fragment townsquareComment on TownsquareComment {\n id\n url\n object {\n name\n iconData\n url\n }\n }\n\n\n fragment confluencePage on ConfluencePage {\n id\n title\n pageId\n links {\n base\n webUi\n }\n space {\n name\n }\n }\n\n\n fragment confluenceBlogPost on ConfluenceBlogPost {\n id\n title\n blogPostId\n links {\n base\n webUi\n }\n space {\n name\n }\n }\n\n\n fragment confluenceComment on ConfluenceComment {\n id\n links {\n base\n webUi\n }\n container {\n __typename\n ...confluenceBlogPost\n ...confluencePage\n }\n }\n\nfragment activityItemEdge on ActivityItemEdge {\n cursor\n node {\n id\n object {\n id\n type\n product\n rootContainerId\n contributors {\n profile {\n name\n picture\n accountId\n }\n }\n data {\n __typename\n\t...townsquareGoal\n\t...townsquareProject\n\t...townsquareComment\n\t...confluencePage\n\t...confluenceBlogPost\n\t...confluenceComment\n }\n }\n event {\n id\n timestamp\n eventType\n }\n }\n}\nfragment activityItemConnection on ActivityConnection {\n edges {\n ...activityItemEdge\n }\n}\n\n"
133
+ }