superdesk-ui-framework 4.0.36 → 4.0.38

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 (37) hide show
  1. package/app-typescript/components/DatePicker.tsx +1 -0
  2. package/app-typescript/components/DateTimePicker.tsx +1 -0
  3. package/app-typescript/components/DurationInput.tsx +1 -0
  4. package/app-typescript/components/Form/InputWrapper.tsx +16 -3
  5. package/app-typescript/components/FormLabel.tsx +12 -1
  6. package/app-typescript/components/Input.tsx +3 -1
  7. package/app-typescript/components/MultiSelect.tsx +1 -0
  8. package/app-typescript/components/Select.tsx +1 -0
  9. package/app-typescript/components/SelectWithTemplate.tsx +52 -49
  10. package/app-typescript/components/TagInput.tsx +1 -0
  11. package/app-typescript/components/TimePicker.tsx +1 -0
  12. package/app-typescript/components/TimePickerV2.tsx +1 -0
  13. package/app-typescript/components/TreeSelect/TreeSelect.tsx +1 -0
  14. package/app-typescript/components/card.tsx +36 -0
  15. package/dist/components/Card.tsx +24 -0
  16. package/dist/components/Index.tsx +5 -0
  17. package/dist/examples.bundle.js +253 -101
  18. package/dist/superdesk-ui.bundle.js +102 -89
  19. package/examples/pages/components/Card.tsx +24 -0
  20. package/examples/pages/components/Index.tsx +5 -0
  21. package/package.json +1 -1
  22. package/react/components/DatePicker.js +1 -1
  23. package/react/components/DateTimePicker.js +1 -1
  24. package/react/components/DurationInput.js +1 -1
  25. package/react/components/Form/InputWrapper.d.ts +10 -3
  26. package/react/components/Form/InputWrapper.js +8 -4
  27. package/react/components/FormLabel.d.ts +1 -0
  28. package/react/components/FormLabel.js +8 -1
  29. package/react/components/Input.d.ts +2 -1
  30. package/react/components/Input.js +1 -1
  31. package/react/components/MultiSelect.js +1 -1
  32. package/react/components/Select.js +1 -1
  33. package/react/components/SelectWithTemplate.js +1 -1
  34. package/react/components/TagInput.js +1 -1
  35. package/react/components/TimePicker.js +1 -1
  36. package/react/components/TimePickerV2.js +1 -1
  37. package/react/components/TreeSelect/TreeSelect.js +1 -1
@@ -164,6 +164,7 @@ export class DatePicker extends React.PureComponent<IDatePicker, IState> {
164
164
  labelHidden={this.props.labelHidden}
165
165
  htmlId={this.htmlId}
166
166
  tabindex={this.props.tabindex}
167
+ inputWrapper={this.props.inputWrapper}
167
168
  >
168
169
  <Calendar
169
170
  className='sd-input__input'
@@ -75,6 +75,7 @@ export class DateTimePicker extends React.PureComponent<IProps> {
75
75
  htmlId={this.htmlId}
76
76
  tabindex={this.props.tabindex}
77
77
  fullWidth={this.props.fullWidth}
78
+ inputWrapper={this.props.inputWrapper}
78
79
  data-test-id={this.props["data-test-id"]}
79
80
  ref={this.props.ref}
80
81
  >
@@ -312,6 +312,7 @@ export class DurationInput extends React.PureComponent<IProps, IState> {
312
312
  labelHidden={this.props.labelHidden}
313
313
  htmlId={this.htmlId}
314
314
  tabindex={this.props.tabindex}
315
+ inputWrapper={this.props.inputWrapper}
315
316
  >
316
317
  <div className={'sd-input__duration-input'}>
317
318
  <input
@@ -25,9 +25,14 @@ export interface IInputCommon {
25
25
 
26
26
  export interface IInputWrapper extends IInputCommon {
27
27
  invalid?: boolean;
28
+
29
+ inputWrapper?: {
30
+ kind: 'custom'; // added to allow union types later
31
+ component: React.ComponentType<{label: string; input: React.ReactNode}>;
32
+ };
28
33
  }
29
34
 
30
- interface IPropsBase extends IInputWrapper {
35
+ interface IProps extends IInputWrapper {
31
36
  children: React.ReactNode;
32
37
  maxLength?: number;
33
38
  value?: string | number;
@@ -40,8 +45,8 @@ interface IState {
40
45
  value: string | number;
41
46
  }
42
47
 
43
- export class InputWrapper extends React.Component<IPropsBase, IState> {
44
- constructor(props: IPropsBase) {
48
+ export class InputWrapper extends React.Component<IProps, IState> {
49
+ constructor(props: IProps) {
45
50
  super(props);
46
51
 
47
52
  this.state = {
@@ -50,6 +55,14 @@ export class InputWrapper extends React.Component<IPropsBase, IState> {
50
55
  }
51
56
 
52
57
  render() {
58
+ if (this.props.inputWrapper?.kind === 'custom') {
59
+ const Component = this.props.inputWrapper.component;
60
+
61
+ return (
62
+ <Component input={this.props.children} label={this.props.label ?? ''} />
63
+ );
64
+ }
65
+
53
66
  const fullWidth = this.props.fullWidth ?? true;
54
67
 
55
68
  const classes = classNames('sd-input', {
@@ -5,6 +5,7 @@ interface IProps {
5
5
  text: string;
6
6
  style?: 'normal' | 'light'; // defaults to normal
7
7
  noMinHeight?: boolean;
8
+ noMinWidth?: boolean;
8
9
  }
9
10
 
10
11
  export class FormLabel extends React.PureComponent<IProps> {
@@ -14,10 +15,20 @@ export class FormLabel extends React.PureComponent<IProps> {
14
15
 
15
16
  });
16
17
 
18
+ const style: React.CSSProperties = {};
19
+
20
+ if (this.props.noMinWidth) {
21
+ style.minWidth = 'auto';
22
+ }
23
+
24
+ if (this.props.noMinHeight) {
25
+ style.minHeight = 'auto';
26
+ }
27
+
17
28
  return (
18
29
  <label
19
30
  className={classes}
20
- style={this.props.noMinHeight === true ? {minHeight: 'auto'} : undefined}
31
+ style={style}
21
32
  >
22
33
  {this.props.text}
23
34
  </label>
@@ -1,12 +1,13 @@
1
1
  import * as React from 'react';
2
2
  import nextId from "react-id-generator";
3
- import {IInputCommon, InputWrapper} from './Form/InputWrapper';
3
+ import {IInputCommon, IInputWrapper, InputWrapper} from './Form/InputWrapper';
4
4
 
5
5
  interface IPropsBase extends IInputCommon {
6
6
  maxLength?: number;
7
7
  placeholder?: string;
8
8
  size?: 'medium' | 'large' | 'x-large'; // default: 'medium'
9
9
  'data-test-id'?: string;
10
+ inputWrapper?: IInputWrapper['inputWrapper'];
10
11
  }
11
12
 
12
13
  interface IPropsText extends IPropsBase {
@@ -73,6 +74,7 @@ export class Input extends React.Component<IProps> {
73
74
  boxedStyle={this.props.boxedStyle}
74
75
  boxedLable={this.props.boxedLable}
75
76
  tabindex={this.props.tabindex}
77
+ inputWrapper={this.props.inputWrapper}
76
78
  >
77
79
  <input
78
80
  className='sd-input__input'
@@ -74,6 +74,7 @@ export class MultiSelect<T> extends React.Component<IProps<T>, IState<T>> {
74
74
  labelHidden={this.props.labelHidden}
75
75
  htmlId={this.htmlId}
76
76
  tabindex={this.props.tabindex}
77
+ inputWrapper={this.props.inputWrapper}
77
78
  >
78
79
  <PrimeMultiSelect
79
80
  panelClassName={classes}
@@ -44,6 +44,7 @@ class Select extends React.Component<ISelect> {
44
44
  fullWidth={this.props.fullWidth}
45
45
  htmlId={this.htmlId}
46
46
  tabindex={this.props.tabindex}
47
+ inputWrapper={this.props.inputWrapper}
47
48
  >
48
49
  <span className='sd-input__select-caret-wrapper'>
49
50
  <select
@@ -94,57 +94,60 @@ export class SelectWithTemplate<T> extends React.Component<IProps<T>, IState<T>>
94
94
 
95
95
  return (
96
96
  <InputWrapper
97
- label={this.props.label}
98
- error={this.props.error}
99
- required={this.props.required}
100
- disabled={this.props.disabled}
101
- invalid={this.state.invalid}
102
- info={this.props.info}
103
- inlineLabel={this.props.inlineLabel}
104
- labelHidden={this.props.labelHidden}
105
- fullWidth={this.props.fullWidth}
106
- htmlId={this.htmlId}
107
- tabindex={this.props.tabindex}>
97
+ label={this.props.label}
98
+ error={this.props.error}
99
+ required={this.props.required}
100
+ disabled={this.props.disabled}
101
+ invalid={this.state.invalid}
102
+ info={this.props.info}
103
+ inlineLabel={this.props.inlineLabel}
104
+ labelHidden={this.props.labelHidden}
105
+ fullWidth={this.props.fullWidth}
106
+ htmlId={this.htmlId}
107
+ tabindex={this.props.tabindex}
108
+ inputWrapper={this.props.inputWrapper}
109
+ >
108
110
  <Dropdown
109
- inputId={this.htmlId}
110
- ariaLabelledBy={this.htmlId + 'label'}
111
- value={valueInternal}
112
- options={optionsInternal}
113
- onChange={(e) => {
114
- onChange(e.value == null ? null : e.value.original);
115
- }}
116
- placeholder={fakePlaceholderWithNonBreakingSpace}
117
- filterPlaceholder={filterPlaceholder}
118
- filter
119
- filterBy={labelKey}
120
- showClear={!required}
121
- emptyFilterMessage={emptyFilterMessage}
122
- itemTemplate={(option) => <ItemTemplate option={option?.original ?? null} />}
123
- valueTemplate={(option) => ValueTemplate != null
124
- ? (
125
- <ValueTemplate option={option?.original ?? null} />
111
+ inputId={this.htmlId}
112
+ ariaLabelledBy={this.htmlId + 'label'}
113
+ value={valueInternal}
114
+ options={optionsInternal}
115
+ onChange={(e) => {
116
+ onChange(e.value == null ? null : e.value.original);
117
+ }}
118
+ placeholder={fakePlaceholderWithNonBreakingSpace}
119
+ filterPlaceholder={filterPlaceholder}
120
+ filter
121
+ filterBy={labelKey}
122
+ showClear={!required}
123
+ emptyFilterMessage={emptyFilterMessage}
124
+ itemTemplate={(option) => <ItemTemplate option={option?.original ?? null} />}
125
+ valueTemplate={(option) => ValueTemplate != null
126
+ ? (
127
+ <ValueTemplate option={option?.original ?? null} />
126
128
 
127
- )
128
- : (
129
- <ItemTemplate option={option?.original ?? null} />
130
- )
131
- }
132
- disabled={disabled}
133
- required={required}
134
- autoFocus={autoFocus}
135
- appendTo={document.body}
136
- loading={loading}
137
- onFilterInputChange={(searchString) => {
138
- this.setState({loading: true});
139
- getItems(searchString).then((_options) => {
140
- this.setState({options: _options, loading: false});
141
- });
142
- }}
143
- zIndex={zIndex}
144
- style={width === '100%' ? {display: 'flex', width: '100%'} : {}}
145
- ref={(componentRef) => {
146
- this.componentRef = componentRef;
147
- }}/>
129
+ )
130
+ : (
131
+ <ItemTemplate option={option?.original ?? null} />
132
+ )
133
+ }
134
+ disabled={disabled}
135
+ required={required}
136
+ autoFocus={autoFocus}
137
+ appendTo={document.body}
138
+ loading={loading}
139
+ onFilterInputChange={(searchString) => {
140
+ this.setState({loading: true});
141
+ getItems(searchString).then((_options) => {
142
+ this.setState({options: _options, loading: false});
143
+ });
144
+ }}
145
+ zIndex={zIndex}
146
+ style={width === '100%' ? {display: 'flex', width: '100%'} : {}}
147
+ ref={(componentRef) => {
148
+ this.componentRef = componentRef;
149
+ }}
150
+ />
148
151
  </InputWrapper>
149
152
  );
150
153
  }
@@ -39,6 +39,7 @@ export class TagInput extends React.Component<IProps> {
39
39
  labelHidden={this.props.labelHidden}
40
40
  htmlId={this.htmlId}
41
41
  tabindex={this.props.tabindex}
42
+ inputWrapper={this.props.inputWrapper}
42
43
  >
43
44
  <Chips
44
45
  className={`
@@ -34,6 +34,7 @@ export class TimePicker extends React.PureComponent<IProps> {
34
34
  labelHidden={this.props.labelHidden}
35
35
  htmlId={this.htmlId}
36
36
  tabindex={this.props.tabindex}
37
+ inputWrapper={this.props.inputWrapper}
37
38
  >
38
39
  <input
39
40
  value={this.props.value}
@@ -147,6 +147,7 @@ export class TimePickerV2 extends React.PureComponent<IProps> {
147
147
  inlineLabel={this.props.inlineLabel}
148
148
  labelHidden={this.props.labelHidden}
149
149
  tabindex={this.props.tabindex}
150
+ inputWrapper={this.props.inputWrapper}
150
151
  >
151
152
  <div className='sd__input__time-picker-v2' data-test-id={this.props['data-test-id']}>
152
153
  <div className='input-wrapper__time-picker-v2'>
@@ -725,6 +725,7 @@ export class TreeSelect<T> extends React.Component<IProps<T>, IState<T>> {
725
725
  tabindex={this.props.tabindex}
726
726
  fullWidth={this.props.fullWidth}
727
727
  data-test-id={this.props['data-test-id']}
728
+ inputWrapper={this.props.inputWrapper}
728
729
  >
729
730
  <div
730
731
  className={`
@@ -0,0 +1,36 @@
1
+ import * as React from 'react';
2
+
3
+ interface IProps extends Pick<React.CSSProperties, 'paddingBlock'> {
4
+ children: React.ReactNode;
5
+ paddingBase: '0' | '1' | '2' | '3' | '4';
6
+ paddingBlock?: React.CSSProperties['paddingBlock'];
7
+ paddingBlockStart?: React.CSSProperties['paddingBlockStart'];
8
+ paddingBlockEnd?: React.CSSProperties['paddingBlockEnd'];
9
+ paddingInline?: React.CSSProperties['paddingInline'];
10
+ paddingInlineStart?: React.CSSProperties['paddingInlineStart'];
11
+ paddingInlineEnd?: React.CSSProperties['paddingInlineEnd'];
12
+ }
13
+
14
+ export class Card extends React.PureComponent<IProps> {
15
+ render() {
16
+ return (
17
+ <div
18
+ style={{
19
+ width: '100%',
20
+ background: 'var(--sd-item__main-Bg)',
21
+ borderRadius: 'var(--b-radius--medium)',
22
+ padding: `calc( ${this.props.paddingBase} * var(--base-increment))`,
23
+ boxShadow: 'var(--sd-shadow--z2)',
24
+ paddingBlock: this.props.paddingBlock,
25
+ paddingBlockStart: this.props.paddingBlockStart,
26
+ paddingBlockEnd: this.props.paddingBlockEnd,
27
+ paddingInline: this.props.paddingInline,
28
+ paddingInlineStart: this.props.paddingInlineStart,
29
+ paddingInlineEnd: this.props.paddingInlineEnd,
30
+ }}
31
+ >
32
+ {this.props.children}
33
+ </div>
34
+ );
35
+ }
36
+ }
@@ -0,0 +1,24 @@
1
+ import * as React from "react";
2
+ import * as Markup from "../../js/react";
3
+ import {Card} from '../../../app-typescript/components/card';
4
+
5
+ export default class CardDoc extends React.Component {
6
+ render() {
7
+ return (
8
+ <section className="docs-page__container">
9
+ <h2 className="docs-page__h2">Card</h2>
10
+
11
+ <Markup.ReactMarkupCodePreview>{`
12
+ <Card paddingBase="1">
13
+ card content
14
+ </Card>
15
+ `}
16
+ </Markup.ReactMarkupCodePreview>
17
+
18
+ <Card paddingBase="1">
19
+ card content
20
+ </Card>
21
+ </section>
22
+ )
23
+ }
24
+ }
@@ -86,6 +86,7 @@ import { OpacityUtilitiesDoc } from './utilities/OpacityUtilities';
86
86
  import { ObjectFitUtilitiesDoc } from './utilities/ObjectFitUtilities';
87
87
  import { ObjectPositionUtilitiesDoc } from './utilities/ObjectPositionUtilities';
88
88
  import LoaderDoc from './Loader';
89
+ import CardDoc from './Card';
89
90
 
90
91
 
91
92
  interface IPages {
@@ -104,6 +105,10 @@ const pages: IPages = {
104
105
  basicComponents: {
105
106
  name: 'Basic Components',
106
107
  items: {
108
+ 'card': {
109
+ name: 'Card',
110
+ component: CardDoc,
111
+ },
107
112
  'buttons': {
108
113
  name: 'Buttons',
109
114
  component: ButtonsDoc,