superdesk-ui-framework 2.4.10 → 2.4.15
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.
- package/app/scripts/modals.js +22 -9
- package/app/styles/app.scss +1 -0
- package/app/styles/form-elements/_select-grid.scss +77 -0
- package/app/styles/pr-superdesk-theme.scss +1 -0
- package/app/styles/primereact/_pr-skeleton.scss +35 -0
- package/app-typescript/components/IconPicker.tsx +277 -0
- package/app-typescript/components/ListItemLoader.tsx +30 -0
- package/app-typescript/components/SelectGrid.tsx +233 -0
- package/app-typescript/components/Skeleton.tsx +48 -0
- package/app-typescript/components/Tag.tsx +4 -3
- package/app-typescript/index.ts +5 -0
- package/dist/components/modals.html +1 -0
- package/dist/examples.bundle.js +3051 -1766
- package/dist/react/IconFont.tsx +7 -6
- package/dist/react/IconPicker.tsx +65 -0
- package/dist/react/Index.tsx +16 -1
- package/dist/react/ListItems.tsx +34 -0
- package/dist/react/SelectGrid.tsx +121 -0
- package/dist/react/Tags.tsx +14 -3
- package/dist/superdesk-ui.bundle.css +3356 -0
- package/dist/superdesk-ui.bundle.js +2563 -1480
- package/dist/vendor.bundle.js +49646 -49624
- package/examples/pages/components/modals.html +1 -0
- package/examples/pages/react/IconFont.tsx +7 -6
- package/examples/pages/react/IconPicker.tsx +65 -0
- package/examples/pages/react/Index.tsx +16 -1
- package/examples/pages/react/ListItems.tsx +34 -0
- package/examples/pages/react/SelectGrid.tsx +121 -0
- package/examples/pages/react/Tags.tsx +14 -3
- package/package.json +1 -1
- package/react/components/IconPicker.d.ts +24 -0
- package/react/components/IconPicker.js +283 -0
- package/react/components/ListItemLoader.d.ts +4 -0
- package/react/components/ListItemLoader.js +62 -0
- package/react/components/SelectGrid.d.ts +45 -0
- package/react/components/SelectGrid.js +179 -0
- package/react/components/Skeleton.d.ts +30 -0
- package/react/components/Skeleton.js +55 -0
- package/react/components/Tag.d.ts +2 -1
- package/react/components/Tag.js +3 -3
- package/react/index.d.ts +4 -0
- package/react/index.js +8 -0
@@ -20,6 +20,7 @@
|
|
20
20
|
<div class="modal__body">
|
21
21
|
<p>This is sample message inside modal!</p>
|
22
22
|
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. </p>
|
23
|
+
<button class="btn" ng-click="openModal('modalActive6')">Open modal inside modal</button>
|
23
24
|
</div>
|
24
25
|
<div class="modal__footer">
|
25
26
|
<button class="btn" ng-click="closeModal('modalActive')">Cancel</button>
|
@@ -3,19 +3,20 @@ import * as Markup from "../../js/react";
|
|
3
3
|
|
4
4
|
import { Icon, Prop, PropsList } from '../../../app-typescript';
|
5
5
|
|
6
|
+
//@ts-ignore
|
6
7
|
import * as iconFont from '../../../app/styles/_icon-font.scss';
|
7
8
|
|
8
|
-
export default class IconFontDoc extends React.PureComponent{
|
9
|
-
render(){
|
9
|
+
export default class IconFontDoc extends React.PureComponent {
|
10
|
+
render() {
|
10
11
|
const array = iconFont.icon.split(', ');
|
11
12
|
const icons = array.map((icon, index) =>
|
12
13
|
<li key={index}>
|
13
|
-
<Icon name={icon}/>
|
14
|
+
<Icon name={icon} />
|
14
15
|
<span>{icon}</span>
|
15
16
|
</li>
|
16
|
-
|
17
|
-
return(
|
18
|
-
<section className="docs-page__container">
|
17
|
+
);
|
18
|
+
return (
|
19
|
+
<section className="docs-page__container">
|
19
20
|
<h2 className="docs-page__h2 docs-page__text-align--center">Icon font</h2>
|
20
21
|
<Markup.ReactMarkupCodePreview>{`
|
21
22
|
<Icon name="photo" />
|
@@ -0,0 +1,65 @@
|
|
1
|
+
import * as React from "react";
|
2
|
+
import * as Markup from "../../js/react";
|
3
|
+
import { IconPicker, PropsList, Prop } from "../../../app-typescript";
|
4
|
+
|
5
|
+
const IconPickerDocs = () => {
|
6
|
+
|
7
|
+
const [value, setValue] = React.useState('amp');
|
8
|
+
|
9
|
+
return (
|
10
|
+
<section className="docs-page__container">
|
11
|
+
<h2 className="docs-page__h2">Icon Picker</h2>
|
12
|
+
<Markup.ReactMarkupCodePreview>{`
|
13
|
+
<IconPicker
|
14
|
+
label="Icon"
|
15
|
+
filterPlaceholder="Search..."
|
16
|
+
translateFunction={(text: string): string => text}
|
17
|
+
value={value}
|
18
|
+
onChange={(value) => {
|
19
|
+
setValue(value);
|
20
|
+
}}
|
21
|
+
/>
|
22
|
+
`}
|
23
|
+
</Markup.ReactMarkupCodePreview>
|
24
|
+
<Markup.ReactMarkup>
|
25
|
+
<Markup.ReactMarkupPreview>
|
26
|
+
<IconPicker
|
27
|
+
label="Icon"
|
28
|
+
filterPlaceholder="Search..."
|
29
|
+
translateFunction={(text: string): string => text}
|
30
|
+
value={value}
|
31
|
+
onChange={(value) => {
|
32
|
+
setValue(value);
|
33
|
+
}}
|
34
|
+
/>
|
35
|
+
</Markup.ReactMarkupPreview>
|
36
|
+
<Markup.ReactMarkupCode>{`
|
37
|
+
|
38
|
+
const [value, setValue] = React.useState("amp");
|
39
|
+
...
|
40
|
+
<IconPicker
|
41
|
+
label="Icon"
|
42
|
+
filterPlaceholder="Search..."
|
43
|
+
translateFunction={(text: string): string => text}
|
44
|
+
value={value}
|
45
|
+
onChange={(value) => {
|
46
|
+
setValue(value);
|
47
|
+
}}
|
48
|
+
/>
|
49
|
+
`}</Markup.ReactMarkupCode>
|
50
|
+
</Markup.ReactMarkup>
|
51
|
+
|
52
|
+
<h3 className="docs-page__h3">Props</h3>
|
53
|
+
<PropsList>
|
54
|
+
<Prop name='label' isRequired={false} type='string' default='Icon' description='Select label' />
|
55
|
+
<Prop name='filterPlaceholder' isRequired={false} type='string' default='Search...' description='Filter placeholder' />
|
56
|
+
<Prop name='translateFunction' isRequired={false} type='function' default='(text) => text' description='eg: gettext' />
|
57
|
+
<Prop name='value' isRequired={true} type='string' default='null' description='Current value' />
|
58
|
+
<Prop name='onChange' isRequired={true} type='Function' default='null' description='Callback onChange event ' />
|
59
|
+
</PropsList>
|
60
|
+
|
61
|
+
</section>
|
62
|
+
)
|
63
|
+
}
|
64
|
+
|
65
|
+
export default IconPickerDocs;
|
@@ -41,6 +41,9 @@ import GridItemDoc from './GridItem';
|
|
41
41
|
import ModalDoc from './Modal';
|
42
42
|
import CarouselDoc from './Carousel';
|
43
43
|
import ToggleboxDocs from './Togglebox';
|
44
|
+
import ListItemsDoc from './ListItems';
|
45
|
+
import SelectGridDocs from './SelectGrid';
|
46
|
+
import IconPickerDocs from "./IconPicker";
|
44
47
|
|
45
48
|
import * as Playgrounds from '../playgrounds/react-playgrounds/Index';
|
46
49
|
import { SelectWithTemplateDocs } from './SelectWithTemplate';
|
@@ -137,7 +140,10 @@ const pages = {
|
|
137
140
|
},
|
138
141
|
"togglebox": {
|
139
142
|
name: "Togglebox"
|
140
|
-
}
|
143
|
+
},
|
144
|
+
'list-items': {
|
145
|
+
name: 'List items'
|
146
|
+
},
|
141
147
|
}
|
142
148
|
},
|
143
149
|
formComponents: {
|
@@ -155,6 +161,9 @@ const pages = {
|
|
155
161
|
'select': {
|
156
162
|
name: 'Select',
|
157
163
|
},
|
164
|
+
'select-grid': {
|
165
|
+
name: 'Select Grid',
|
166
|
+
},
|
158
167
|
'select-with-template': {
|
159
168
|
name: 'Select with template',
|
160
169
|
},
|
@@ -164,6 +173,9 @@ const pages = {
|
|
164
173
|
'time-picker': {
|
165
174
|
name: 'Time Picker',
|
166
175
|
},
|
176
|
+
'icon-picker': {
|
177
|
+
name: 'Icon Picker',
|
178
|
+
},
|
167
179
|
'switch': {
|
168
180
|
name: 'Switch'
|
169
181
|
},
|
@@ -231,6 +243,9 @@ class ReactDoc extends React.Component {
|
|
231
243
|
<Route path="/react/carousel" component={CarouselDoc} />
|
232
244
|
<Route path="/react/menu" component={MenuDocs} />
|
233
245
|
<Route path="/react/togglebox" component={ToggleboxDocs} />
|
246
|
+
<Route path="/react/list-items" component={ListItemsDoc} />
|
247
|
+
<Route path="/react/select-grid" component={SelectGridDocs} />
|
248
|
+
<Route path="/react/icon-picker" component={IconPickerDocs} />
|
234
249
|
<Route path="/" component={ReactDefault} />
|
235
250
|
</Switch>
|
236
251
|
</main>
|
@@ -0,0 +1,34 @@
|
|
1
|
+
import * as React from "react";
|
2
|
+
import * as Markup from "../../js/react";
|
3
|
+
import { ListItemLoader, PropsList } from "../../../app-typescript";
|
4
|
+
|
5
|
+
export default class ListItemsDoc extends React.Component {
|
6
|
+
render() {
|
7
|
+
return (
|
8
|
+
<section className="docs-page__container">
|
9
|
+
<h2 className="docs-page__h2">List Items</h2>
|
10
|
+
<Markup.ReactMarkupCodePreview>{`
|
11
|
+
<ListItemLoader />
|
12
|
+
`}
|
13
|
+
</Markup.ReactMarkupCodePreview>
|
14
|
+
<h3 className="docs-page__h3 docs-page__h3--small-top-m">Loader type of list items</h3>
|
15
|
+
<p className="docs-page__paragraph">Basic layout structure for list elements. The content inside the elements serves just as an example.</p>
|
16
|
+
<Markup.ReactMarkup>
|
17
|
+
<Markup.ReactMarkupPreview>
|
18
|
+
<div className="docs-page__content-row">
|
19
|
+
<ListItemLoader />
|
20
|
+
</div>
|
21
|
+
</Markup.ReactMarkupPreview>
|
22
|
+
<Markup.ReactMarkupCode>{`
|
23
|
+
<ListItemLoader />
|
24
|
+
`}</Markup.ReactMarkupCode>
|
25
|
+
</Markup.ReactMarkup>
|
26
|
+
|
27
|
+
<h3 className="docs-page__h3">Props</h3>
|
28
|
+
<PropsList>
|
29
|
+
|
30
|
+
</PropsList>
|
31
|
+
</section>
|
32
|
+
)
|
33
|
+
}
|
34
|
+
}
|
@@ -0,0 +1,121 @@
|
|
1
|
+
import * as React from "react";
|
2
|
+
import * as Markup from "../../js/react";
|
3
|
+
import { SelectGrid, Alert, PropsList, Prop } from "../../../app-typescript";
|
4
|
+
|
5
|
+
const SelectGridDocs = () => {
|
6
|
+
const letters = [
|
7
|
+
{ value: 'A', label: 'A' },
|
8
|
+
{ value: 'B', label: 'B' },
|
9
|
+
{ value: 'C', label: 'C' },
|
10
|
+
{ value: 'D', label: 'D' },
|
11
|
+
{ value: 'E', label: 'E' },
|
12
|
+
{ value: 'F', label: 'F' },
|
13
|
+
{ value: 'G', label: 'G' },
|
14
|
+
{ value: 'H', label: 'H' },
|
15
|
+
{ value: 'K', label: 'K' },
|
16
|
+
{ value: 'L', label: 'L' },
|
17
|
+
{ value: 'M', label: 'M' },
|
18
|
+
{ value: 'N', label: 'N' },
|
19
|
+
{ value: 'O', label: 'O' },
|
20
|
+
{ value: 'P', label: 'P' },
|
21
|
+
{ value: 'R', label: 'R' },
|
22
|
+
{ value: 'S', label: 'S' },
|
23
|
+
{ value: 'T', label: 'T' },
|
24
|
+
{ value: 'U', label: 'U' }
|
25
|
+
];
|
26
|
+
|
27
|
+
const [selectedItem, setSelectedItem] = React.useState(letters[0]);
|
28
|
+
|
29
|
+
return (
|
30
|
+
<section className="docs-page__container">
|
31
|
+
<h2 className="docs-page__h2">Select Grid</h2>
|
32
|
+
<p className="docs-page__paragraph">Universal select component with grid display of items. You can define your own trigger and item template.</p>
|
33
|
+
<p className="docs-page__paragraph">IconPicker is built on top of it.</p>
|
34
|
+
<Markup.ReactMarkupCodePreview>{`
|
35
|
+
<SelectGrid
|
36
|
+
label="Label"
|
37
|
+
filterPlaceholder="Search..."
|
38
|
+
getItems={(searchString) => {
|
39
|
+
return new Promise((resolve) => {
|
40
|
+
resolve([{ value: 'value', label: 'Label' }]);
|
41
|
+
});
|
42
|
+
}}
|
43
|
+
onChange={(value) => { }}
|
44
|
+
itemTemplate={({ item }) => <div />}
|
45
|
+
triggerTemplate={() => <button />}
|
46
|
+
/>
|
47
|
+
`}
|
48
|
+
</Markup.ReactMarkupCodePreview>
|
49
|
+
<Markup.ReactMarkup>
|
50
|
+
<Markup.ReactMarkupPreview>
|
51
|
+
<SelectGrid
|
52
|
+
label="Letter"
|
53
|
+
filterPlaceholder="Search..."
|
54
|
+
getItems={(searchString) => {
|
55
|
+
return new Promise((resolve) => {
|
56
|
+
if (searchString == null) {
|
57
|
+
resolve(letters);
|
58
|
+
} else {
|
59
|
+
resolve(letters.filter(({ label }) => label.toLocaleLowerCase().includes(searchString.toLocaleLowerCase())));
|
60
|
+
}
|
61
|
+
});
|
62
|
+
}}
|
63
|
+
onChange={(value) => {
|
64
|
+
setSelectedItem(value);
|
65
|
+
}}
|
66
|
+
itemTemplate={({ item }) => <div style={{ fontSize: '20px' }}>{item.label}</div>}
|
67
|
+
triggerTemplate={({ onClick }) => <button className="btn" onClick={onClick}>{selectedItem.label}</button>}
|
68
|
+
|
69
|
+
/>
|
70
|
+
</Markup.ReactMarkupPreview>
|
71
|
+
<Markup.ReactMarkupCode>{`
|
72
|
+
const letters = [
|
73
|
+
{ value: 'A', label: 'A' },
|
74
|
+
{ value: 'B', label: 'B' },
|
75
|
+
{ value: 'C', label: 'C' },
|
76
|
+
...
|
77
|
+
];
|
78
|
+
|
79
|
+
const [selectedItem, setSelectedItem] = React.useState(letters[0]);
|
80
|
+
...
|
81
|
+
<SelectGrid
|
82
|
+
label="Letter"
|
83
|
+
filterPlaceholder="Search..."
|
84
|
+
getItems={(searchString) => {
|
85
|
+
return new Promise((resolve) => {
|
86
|
+
if (searchString == null) {
|
87
|
+
resolve(letters);
|
88
|
+
} else {
|
89
|
+
resolve(letters.filter(({ label }) => label.toLocaleLowerCase().includes(searchString.toLocaleLowerCase())));
|
90
|
+
}
|
91
|
+
});
|
92
|
+
}}
|
93
|
+
onChange={(value) => {
|
94
|
+
setSelectedItem(value);
|
95
|
+
}}
|
96
|
+
itemTemplate={({ item }) => <div style={{ fontSize: '20px' }}>{item.label}</div>}
|
97
|
+
triggerTemplate={({ onClick }) => <button className="btn" onClick={onClick}>{selectedItem.label}</button>}
|
98
|
+
|
99
|
+
/>
|
100
|
+
`}</Markup.ReactMarkupCode>
|
101
|
+
</Markup.ReactMarkup>
|
102
|
+
|
103
|
+
<h3 className="docs-page__h3">Props</h3>
|
104
|
+
<PropsList>
|
105
|
+
<Prop name='label' isRequired={true} type='string' default='null' description='Select label' />
|
106
|
+
<Prop name='filterPlaceholder' isRequired={false} type='string' default='Search...' description='Filter placeholder' />
|
107
|
+
<Prop name='getItems' isRequired={true} type='function' default='false' description='Callback function that should return promise which resolves with array of items' />
|
108
|
+
<Prop name='onChange' isRequired={true} type='function' default='false' description='Callback on change event' />
|
109
|
+
<Prop name='itemTemplate' isRequired={true} type='Component' default='null' description='item renderer' />
|
110
|
+
<Prop name='triggerTemplate' isRequired={true} type='Component' default='null' description='trigger button renderer' />
|
111
|
+
</PropsList>
|
112
|
+
<Alert style='hollow' size='normal' type='alert' restoreIcon='info'>
|
113
|
+
1. triggerTemplate should include <button /> with onClick event. Otherwise keyboard controls won't work. <br />
|
114
|
+
2. Item should be an object with at least label and value.
|
115
|
+
</Alert>
|
116
|
+
</section>
|
117
|
+
)
|
118
|
+
}
|
119
|
+
|
120
|
+
|
121
|
+
export default SelectGridDocs;
|
@@ -10,7 +10,13 @@ export default class TagDoc extends React.Component<{}, ITag> {
|
|
10
10
|
constructor(props){
|
11
11
|
super(props);
|
12
12
|
this.state = {
|
13
|
-
tags: [
|
13
|
+
tags: [
|
14
|
+
{text: 'This is a tag'},
|
15
|
+
{text: 'This is another tag', shade:'darker'},
|
16
|
+
{text: 'Lorem ipsum', shade:'highlight1'},
|
17
|
+
{text: 'Dolor amet', shade:'highlight2', shape:'square'},
|
18
|
+
{text: 'Read only tag', readOnly: true}
|
19
|
+
],
|
14
20
|
}
|
15
21
|
this.handleClick=this.handleClick.bind(this);
|
16
22
|
}
|
@@ -37,7 +43,12 @@ export default class TagDoc extends React.Component<{}, ITag> {
|
|
37
43
|
{this.state.tags.map((tag,index)=>{
|
38
44
|
return (
|
39
45
|
<React.Fragment key={index}>
|
40
|
-
<Tag keyValue={index}
|
46
|
+
<Tag keyValue={index}
|
47
|
+
text={tag.text}
|
48
|
+
shade={tag.shade}
|
49
|
+
shape={tag.shape}
|
50
|
+
readOnly={tag.readOnly}
|
51
|
+
onClick={()=>this.handleClick(index)}/>
|
41
52
|
</React.Fragment>
|
42
53
|
)
|
43
54
|
})}
|
@@ -63,4 +74,4 @@ export default class TagDoc extends React.Component<{}, ITag> {
|
|
63
74
|
</section>
|
64
75
|
)
|
65
76
|
}
|
66
|
-
}
|
77
|
+
}
|
package/package.json
CHANGED
@@ -0,0 +1,24 @@
|
|
1
|
+
import * as React from 'react';
|
2
|
+
import { IItem } from "./SelectGrid";
|
3
|
+
interface IProps {
|
4
|
+
label?: string;
|
5
|
+
filterPlaceholder?: string;
|
6
|
+
translateFunction?: (text: string) => string;
|
7
|
+
value: string;
|
8
|
+
onChange(icon: string): void;
|
9
|
+
}
|
10
|
+
interface IState {
|
11
|
+
icons: Array<IItem>;
|
12
|
+
}
|
13
|
+
export declare class IconPicker extends React.PureComponent<IProps, IState> {
|
14
|
+
constructor(props: IProps);
|
15
|
+
componentDidMount(): void;
|
16
|
+
getItems: (searchString: string | null) => Promise<Array<IItem>>;
|
17
|
+
onChange: (item: IItem) => void;
|
18
|
+
triggerTemplate: (props: any) => JSX.Element;
|
19
|
+
itemTemplate: ({ item }: {
|
20
|
+
item: IItem | null;
|
21
|
+
}) => JSX.Element | null;
|
22
|
+
render(): JSX.Element;
|
23
|
+
}
|
24
|
+
export {};
|
@@ -0,0 +1,283 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
3
|
+
var extendStatics = function (d, b) {
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
6
|
+
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
7
|
+
return extendStatics(d, b);
|
8
|
+
};
|
9
|
+
return function (d, b) {
|
10
|
+
extendStatics(d, b);
|
11
|
+
function __() { this.constructor = d; }
|
12
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
13
|
+
};
|
14
|
+
})();
|
15
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
16
|
+
if (k2 === undefined) k2 = k;
|
17
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
18
|
+
}) : (function(o, m, k, k2) {
|
19
|
+
if (k2 === undefined) k2 = k;
|
20
|
+
o[k2] = m[k];
|
21
|
+
}));
|
22
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
23
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
24
|
+
}) : function(o, v) {
|
25
|
+
o["default"] = v;
|
26
|
+
});
|
27
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
28
|
+
if (mod && mod.__esModule) return mod;
|
29
|
+
var result = {};
|
30
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
31
|
+
__setModuleDefault(result, mod);
|
32
|
+
return result;
|
33
|
+
};
|
34
|
+
var __spreadArrays = (this && this.__spreadArrays) || function () {
|
35
|
+
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
|
36
|
+
for (var r = Array(s), k = 0, i = 0; i < il; i++)
|
37
|
+
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
|
38
|
+
r[k] = a[j];
|
39
|
+
return r;
|
40
|
+
};
|
41
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
42
|
+
exports.IconPicker = void 0;
|
43
|
+
var React = __importStar(require("react"));
|
44
|
+
// @ts-ignore
|
45
|
+
var iconFont = __importStar(require("../../app/styles/_icon-font.scss"));
|
46
|
+
var Button_1 = require("./Button");
|
47
|
+
var Icon_1 = require("./Icon");
|
48
|
+
var SelectGrid_1 = require("./SelectGrid");
|
49
|
+
var IconPicker = /** @class */ (function (_super) {
|
50
|
+
__extends(IconPicker, _super);
|
51
|
+
function IconPicker(props) {
|
52
|
+
var _this = _super.call(this, props) || this;
|
53
|
+
_this.getItems = function (searchString) {
|
54
|
+
return new Promise(function (resolve) {
|
55
|
+
var icons = __spreadArrays(_this.state.icons);
|
56
|
+
if (searchString) {
|
57
|
+
icons = icons.filter(function (icon) { return (icon.value.toLowerCase().includes(searchString) ||
|
58
|
+
icon.label.toLowerCase().includes(searchString)); });
|
59
|
+
}
|
60
|
+
resolve(icons);
|
61
|
+
});
|
62
|
+
};
|
63
|
+
_this.onChange = function (item) {
|
64
|
+
_this.props.onChange(item.value);
|
65
|
+
};
|
66
|
+
_this.triggerTemplate = function (props) { return React.createElement(Button_1.Button, { icon: _this.props.value, text: _this.props.value, onClick: function (e) { props.onClick(e); }, iconOnly: true }); };
|
67
|
+
_this.itemTemplate = function (_a) {
|
68
|
+
var item = _a.item;
|
69
|
+
return item ?
|
70
|
+
(React.createElement(React.Fragment, null,
|
71
|
+
React.createElement(Icon_1.Icon, { name: item.value }),
|
72
|
+
React.createElement("span", { className: "sd-text__normal sd-padding-t--1" }, item.label))) : null;
|
73
|
+
};
|
74
|
+
_this.state = { icons: [] };
|
75
|
+
return _this;
|
76
|
+
}
|
77
|
+
IconPicker.prototype.componentDidMount = function () {
|
78
|
+
var translateFunction = this.props.translateFunction ?
|
79
|
+
this.props.translateFunction : function (text) { return text; };
|
80
|
+
this.setState({
|
81
|
+
icons: getIcons(translateFunction),
|
82
|
+
});
|
83
|
+
};
|
84
|
+
IconPicker.prototype.render = function () {
|
85
|
+
return (React.createElement(SelectGrid_1.SelectGrid, { label: this.props.label || "Icon", filterPlaceholder: this.props.filterPlaceholder || "Search...", getItems: this.getItems, onChange: this.onChange, itemTemplate: this.itemTemplate, triggerTemplate: this.triggerTemplate }));
|
86
|
+
};
|
87
|
+
return IconPicker;
|
88
|
+
}(React.PureComponent));
|
89
|
+
exports.IconPicker = IconPicker;
|
90
|
+
var getIcons = function (translateFunction) {
|
91
|
+
var translatedIconNameMap = {
|
92
|
+
'add-gallery': 'Add Gallery',
|
93
|
+
'add-image': 'Add Image',
|
94
|
+
'adjust': 'Adjust',
|
95
|
+
'align-center': 'Align Center',
|
96
|
+
'align-justify': 'Align Justify',
|
97
|
+
'align-left': 'Align Left',
|
98
|
+
'align-right': 'Align Right',
|
99
|
+
'amp': 'AMP',
|
100
|
+
'analytics': 'Analytics',
|
101
|
+
'archive': 'Archive',
|
102
|
+
'arrow-left': 'Arrow Left',
|
103
|
+
'arrow-right': 'Arrow Right',
|
104
|
+
'arrow-small': 'Arrow Small',
|
105
|
+
'ascending': 'Ascending',
|
106
|
+
'assign': 'Assign',
|
107
|
+
'attachment': 'Attachment',
|
108
|
+
'attachment-large': 'Attachment Large',
|
109
|
+
'audio': 'Audio',
|
110
|
+
'backward-thin': 'Backward Thin',
|
111
|
+
'ban-circle': 'Ban Circle',
|
112
|
+
'bell': 'Bell',
|
113
|
+
'bold': 'Bold',
|
114
|
+
'broadcast': 'Broadcast',
|
115
|
+
'broadcast-create': 'Broadcast Create',
|
116
|
+
'business': 'Business',
|
117
|
+
'calendar': 'Calendar',
|
118
|
+
'calendar-list': 'Calendar List',
|
119
|
+
'chevron-down-thin': 'Chevron Down Thin',
|
120
|
+
'chevron-left-thin': 'Chevron Left Thin',
|
121
|
+
'chevron-right-thin': 'Chevron Right Thin',
|
122
|
+
'chevron-up-thin': 'Chevron Up Thin',
|
123
|
+
'clear-all': 'Clear All',
|
124
|
+
'clear-format': 'Clear Format',
|
125
|
+
'close-small': 'Close Small',
|
126
|
+
'close-thick': 'Close Thick',
|
127
|
+
'code': 'Code',
|
128
|
+
'collapse': 'Collapse',
|
129
|
+
'comment': 'Comment',
|
130
|
+
'composite': 'Composite',
|
131
|
+
'copy': 'Copy',
|
132
|
+
'crop': 'Crop',
|
133
|
+
'cut': 'Cut',
|
134
|
+
'descending': 'Descending',
|
135
|
+
'dots': 'Dots',
|
136
|
+
'dots-vertical': 'Dots Vertical',
|
137
|
+
'download': 'Download',
|
138
|
+
'download-alt': 'Download Alternate',
|
139
|
+
'edit-line': 'Edit Line',
|
140
|
+
'envelope': 'Envelope',
|
141
|
+
'event': 'Event',
|
142
|
+
'exclamation-sign': 'Exclamation Sign',
|
143
|
+
'expand': 'Expand',
|
144
|
+
'expand-thin': 'Expand Thin',
|
145
|
+
'external': 'External',
|
146
|
+
'eye-open': 'Eye Open',
|
147
|
+
'facebook': 'Facebook',
|
148
|
+
'facebook-circle': 'Facebook Circle',
|
149
|
+
'fast_forward': 'Fast Forward',
|
150
|
+
'fast_rewind': 'Fast Rewind',
|
151
|
+
'fetch-as': 'Fetch As',
|
152
|
+
'file': 'File',
|
153
|
+
'filter-large': 'Filter Large',
|
154
|
+
'flip-horizontal': 'Flip Horizontal',
|
155
|
+
'flip-vertical': 'Flip Vertical',
|
156
|
+
'folder-close': 'Folder Close',
|
157
|
+
'folder-open': 'Folder Open',
|
158
|
+
'font': 'Font',
|
159
|
+
'forward-thin': 'Forward Thin',
|
160
|
+
'fullscreen': 'Fullscreen',
|
161
|
+
'globe': 'Globe',
|
162
|
+
'graphic': 'Graphic',
|
163
|
+
'grid-view': 'Grid View',
|
164
|
+
'grid-view-large': 'Grid View Large',
|
165
|
+
'heading-1': 'Heading 1',
|
166
|
+
'heading-2': 'Heading 2',
|
167
|
+
'heading-3': 'Heading 3',
|
168
|
+
'heading-4': 'Heading 4',
|
169
|
+
'heading-5': 'Heading 5',
|
170
|
+
'heading-6': 'Heading 6',
|
171
|
+
'heart': 'Heart',
|
172
|
+
'help-large': 'Help Large',
|
173
|
+
'highlight-package': 'Highlight Package',
|
174
|
+
'home': 'Home',
|
175
|
+
'indent-left': 'Indent Left',
|
176
|
+
'indent-right': 'Indent Right',
|
177
|
+
'info-large': 'Info Large',
|
178
|
+
'info-sign': 'Info Sign',
|
179
|
+
'ingest': 'Ingest',
|
180
|
+
'instagram': 'Instagram',
|
181
|
+
'italic': 'Italic',
|
182
|
+
'kanban-view': 'Kanban View',
|
183
|
+
'kill': 'Kill',
|
184
|
+
'link': 'Link',
|
185
|
+
'linked-in': 'LinkedIn',
|
186
|
+
'linked-in-circle': 'LinkedIn Circle',
|
187
|
+
'list-alt': 'List Alternate',
|
188
|
+
'list-menu': 'List Menu',
|
189
|
+
'list-plus': 'List Plus',
|
190
|
+
'list-view': 'List View',
|
191
|
+
'lock': 'Lock',
|
192
|
+
'map-marker': 'Map Marker',
|
193
|
+
'minus-sign': 'Minus Sign',
|
194
|
+
'minus-small': 'Minus Small',
|
195
|
+
'mobile': 'Mobile',
|
196
|
+
'move': 'Move',
|
197
|
+
'multi-star': 'Multi Start',
|
198
|
+
'multiedit': 'Multi Edit',
|
199
|
+
'new-doc': 'New Document',
|
200
|
+
'ok': 'Okay',
|
201
|
+
'ordered-list': 'Ordered List',
|
202
|
+
'package-create': 'Package Create',
|
203
|
+
'package-plus': 'Package Plus',
|
204
|
+
'paragraph': 'Paragraph',
|
205
|
+
'paste': 'Paste',
|
206
|
+
'pause': 'Pause',
|
207
|
+
'paywall': 'Paywall',
|
208
|
+
'pencil': 'Pencil',
|
209
|
+
'phone': 'Phone',
|
210
|
+
'photo': 'Photo',
|
211
|
+
'pick': 'Pick',
|
212
|
+
'picture': 'Picture',
|
213
|
+
'pin': 'Pin',
|
214
|
+
'play': 'Play',
|
215
|
+
'plus-large': 'Plus Large',
|
216
|
+
'plus-sign': 'Plus Sign',
|
217
|
+
'plus-small': 'Plus Small',
|
218
|
+
'post': 'Post',
|
219
|
+
'preformatted': 'Preformatted',
|
220
|
+
'preview-mode': 'Preview Mode',
|
221
|
+
'print': 'Print',
|
222
|
+
'question-sign': 'Question Sign',
|
223
|
+
'quote': 'Quote',
|
224
|
+
'random': 'Random',
|
225
|
+
'recurring': 'Recurring',
|
226
|
+
'redo': 'Redo',
|
227
|
+
'refresh': 'Refresh',
|
228
|
+
'remove-sign': 'Remove Sign',
|
229
|
+
'repeat': 'Repeat',
|
230
|
+
'retweet': 'Retweet',
|
231
|
+
'revert': 'Revert',
|
232
|
+
'rotate-left': 'Rotate Left',
|
233
|
+
'rotate-right': 'Rotate Right',
|
234
|
+
'search': 'Search',
|
235
|
+
'settings': 'Settings',
|
236
|
+
'share-alt': 'Share Alternate',
|
237
|
+
'signal': 'Signal',
|
238
|
+
'skip_next': 'Skip Next',
|
239
|
+
'skip_previous': 'Skip Previous',
|
240
|
+
'slideshow': 'Slideshow',
|
241
|
+
'star': 'Star',
|
242
|
+
'star-empty': 'Star Empty',
|
243
|
+
'stop': 'Stop',
|
244
|
+
'stream': 'Stream',
|
245
|
+
'strikethrough': 'Strikethrough',
|
246
|
+
'subscript': 'Subscript',
|
247
|
+
'suggestion': 'Suggestion',
|
248
|
+
'superscript': 'Superscript',
|
249
|
+
'switches': 'Switches',
|
250
|
+
'table': 'Table',
|
251
|
+
'takes-package': 'Takes Package',
|
252
|
+
'tasks': 'Tasks',
|
253
|
+
'text': 'Text',
|
254
|
+
'text-format': 'Text Format',
|
255
|
+
'th': 'Table Header',
|
256
|
+
'th-large': 'Table Header Large',
|
257
|
+
'th-list': 'Table Header List',
|
258
|
+
'time': 'Time',
|
259
|
+
'to-lowercase': 'To Lowercase',
|
260
|
+
'to-uppercase': 'To Uppercase',
|
261
|
+
'trash': 'Trash',
|
262
|
+
'twitter': 'Twitter',
|
263
|
+
'twitter-circle': 'Twitter Circle',
|
264
|
+
'underline': 'Underline',
|
265
|
+
'undo': 'Undo',
|
266
|
+
'unlocked': 'Unlocked',
|
267
|
+
'unordered-list': 'Unordered List',
|
268
|
+
'unspike': 'Unspike',
|
269
|
+
'upload': 'Upload',
|
270
|
+
'user': 'User',
|
271
|
+
'video': 'Video',
|
272
|
+
'warning-sign': 'Warning Sign',
|
273
|
+
'zoom-in': 'Zoom In',
|
274
|
+
'zoom-out': 'Zoom Out',
|
275
|
+
};
|
276
|
+
return iconFont.icon
|
277
|
+
.split(', ')
|
278
|
+
.sort()
|
279
|
+
.map(function (icon) { return ({
|
280
|
+
value: icon,
|
281
|
+
label: translatedIconNameMap[icon] ? translateFunction(translatedIconNameMap[icon]) : icon,
|
282
|
+
}); });
|
283
|
+
};
|