superdesk-ui-framework 2.4.11 → 2.4.16

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.
@@ -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;
@@ -42,6 +42,8 @@ import ModalDoc from './Modal';
42
42
  import CarouselDoc from './Carousel';
43
43
  import ToggleboxDocs from './Togglebox';
44
44
  import ListItemsDoc from './ListItems';
45
+ import SelectGridDocs from './SelectGrid';
46
+ import IconPickerDocs from "./IconPicker";
45
47
 
46
48
  import * as Playgrounds from '../playgrounds/react-playgrounds/Index';
47
49
  import { SelectWithTemplateDocs } from './SelectWithTemplate';
@@ -159,6 +161,9 @@ const pages = {
159
161
  'select': {
160
162
  name: 'Select',
161
163
  },
164
+ 'select-grid': {
165
+ name: 'Select Grid',
166
+ },
162
167
  'select-with-template': {
163
168
  name: 'Select with template',
164
169
  },
@@ -168,6 +173,9 @@ const pages = {
168
173
  'time-picker': {
169
174
  name: 'Time Picker',
170
175
  },
176
+ 'icon-picker': {
177
+ name: 'Icon Picker',
178
+ },
171
179
  'switch': {
172
180
  name: 'Switch'
173
181
  },
@@ -236,6 +244,8 @@ class ReactDoc extends React.Component {
236
244
  <Route path="/react/menu" component={MenuDocs} />
237
245
  <Route path="/react/togglebox" component={ToggleboxDocs} />
238
246
  <Route path="/react/list-items" component={ListItemsDoc} />
247
+ <Route path="/react/select-grid" component={SelectGridDocs} />
248
+ <Route path="/react/icon-picker" component={IconPickerDocs} />
239
249
  <Route path="/" component={ReactDefault} />
240
250
  </Switch>
241
251
  </main>
@@ -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 &#x3C;button /&#x3E; 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: [{text: 'This is a tag'},{text: 'This is another tag', shade:'darker'},{text: 'Lorem ipsum', shade:'highlight1'}, {text: 'Dolor amet', shade:'highlight2', shape:'square'}],
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} text={tag.text} shade={tag.shade} shape={tag.shape} onClick={()=>this.handleClick(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
+ }