@performant-software/semantic-components 1.1.5-beta.1 → 1.1.5

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.
@@ -197,6 +197,11 @@ type Props = {
197
197
  */
198
198
  renderSearch?: () => Element<any>,
199
199
 
200
+ /**
201
+ * Returns true if the renderSearch prop should be used to render a search input element.
202
+ */
203
+ searchable?: boolean,
204
+
200
205
  /**
201
206
  * If set to <code>true</code>, checkboxes will render as the first table column, allowing each row to be selectable.
202
207
  * The consuming component is responsible for tracking the selected items.
@@ -841,10 +846,15 @@ const useList = (WrappedComponent: ComponentType<any>) => (
841
846
  filters,
842
847
  perPageOptions,
843
848
  renderListHeader,
844
- renderSearch
849
+ renderSearch,
850
+ searchable
845
851
  } = this.props;
846
852
 
847
- if (filters || perPageOptions || renderListHeader || renderSearch) {
853
+ const hasFilters = filters && filters.component;
854
+ const hasSearch = searchable && renderSearch;
855
+ const headerContent = renderListHeader && renderListHeader();
856
+
857
+ if (hasFilters || perPageOptions || headerContent || hasSearch) {
848
858
  renderHeader = true;
849
859
  }
850
860
 
@@ -879,9 +889,9 @@ const useList = (WrappedComponent: ComponentType<any>) => (
879
889
  secondary
880
890
  className='flex-end-menu'
881
891
  >
882
- { renderListHeader && (
892
+ { headerContent && (
883
893
  <Menu.Menu className='list-header-menu'>
884
- { renderListHeader() }
894
+ { headerContent }
885
895
  </Menu.Menu>
886
896
  )}
887
897
  <Menu.Menu>
@@ -0,0 +1,68 @@
1
+ // @flow
2
+
3
+ import React, { useMemo } from 'react';
4
+ import { Icon, Button } from 'semantic-ui-react';
5
+ import i18n from '../i18n/i18n';
6
+
7
+ type Props = {
8
+ basic?: boolean,
9
+ className?: string,
10
+ color?: string,
11
+ compact?: boolean,
12
+ primary?: boolean,
13
+ size?: string,
14
+ secondary?: boolean,
15
+ url: string,
16
+ };
17
+
18
+ const ViewPDFButton = (props: Props) => {
19
+ /**
20
+ * Sets the appropriate class names based on the formatting props.
21
+ *
22
+ * @type {string}
23
+ */
24
+ const className = useMemo(() => {
25
+ const classNames = ['ui', 'button'];
26
+
27
+ if (props.basic) {
28
+ classNames.push('basic');
29
+ }
30
+
31
+ if (props.className) {
32
+ classNames.push(...props.className.split(' '));
33
+ }
34
+
35
+ if (props.color) {
36
+ classNames.push(props.color);
37
+ }
38
+
39
+ if (props.compact) {
40
+ classNames.push('compact');
41
+ }
42
+
43
+ if (props.primary) {
44
+ classNames.push('primary');
45
+ }
46
+
47
+ if (props.secondary) {
48
+ classNames.push('secondary');
49
+ }
50
+
51
+ if (props.size) {
52
+ classNames.push(props.size);
53
+ }
54
+
55
+ return classNames.join(' ');
56
+ }, [props.basic, props.color]);
57
+
58
+ return (
59
+ <Button className={className} onClick={() => window.open(props.url, '_blank')}>
60
+ <Icon
61
+ name='file pdf'
62
+ />
63
+ {i18n.t('Common.buttons.pdf')}
64
+ </Button>
65
+ );
66
+ };
67
+
68
+ export default ViewPDFButton;
@@ -99,6 +99,7 @@ export { default as Toaster } from './components/Toaster';
99
99
  export { default as VideoFrameSelector } from './components/VideoFrameSelector';
100
100
  export { default as VideoPlayer } from './components/VideoPlayer';
101
101
  export { default as VideoPlayerButton } from './components/VideoPlayerButton';
102
+ export { default as ViewPDFButton } from './components/ViewPDFButton';
102
103
  export { default as ViewXML } from './components/ViewXML';
103
104
 
104
105
  // Context
package/webpack.config.js CHANGED
@@ -10,6 +10,10 @@ module.exports = configure(__dirname, {
10
10
  './react-calendar/dist/Calendar.css$': path.resolve(
11
11
  __dirname,
12
12
  '../../node_modules/react-calendar/dist/Calendar.css'
13
+ ),
14
+ './rc-slider/assets/index.css$': path.resolve(
15
+ __dirname,
16
+ '../../node_modules/rc-slider/assets/index.css'
13
17
  )
14
18
  }
15
19
  },