superdesk-ui-framework 4.0.26 → 4.0.28
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-typescript/components/Button.tsx +2 -0
- package/app-typescript/components/FormLabel.tsx +7 -1
- package/app-typescript/components/Label.tsx +2 -13
- package/app-typescript/components/RadioButtonGroup.tsx +6 -5
- package/app-typescript/components/Select.tsx +2 -0
- package/app-typescript/components/SelectPreview.tsx +1 -1
- package/app-typescript/components/ShowPopup.tsx +28 -19
- package/app-typescript/components/TreeMenu.tsx +16 -0
- package/app-typescript/components/TreeSelect/TreeSelect.tsx +4 -21
- package/app-typescript/components/TreeSelect/TreeSelectItem.tsx +1 -1
- package/app-typescript/components/TreeSelect/TreeSelectPill.tsx +1 -1
- package/app-typescript/helpers.tsx +13 -0
- package/app-typescript/index.ts +1 -0
- package/dist/examples.bundle.js +1426 -1406
- package/dist/playgrounds/react-playgrounds/TestGround.tsx +1 -1
- package/dist/superdesk-ui.bundle.js +1364 -1345
- package/dist/vendor.bundle.js +7 -7
- package/examples/pages/playgrounds/react-playgrounds/TestGround.tsx +1 -1
- package/package.json +1 -1
- package/react/components/Button.d.ts +1 -0
- package/react/components/Button.js +1 -1
- package/react/components/FormLabel.d.ts +1 -0
- package/react/components/FormLabel.js +1 -1
- package/react/components/Label.d.ts +0 -1
- package/react/components/Label.js +3 -15
- package/react/components/RadioButtonGroup.d.ts +3 -2
- package/react/components/RadioButtonGroup.js +3 -3
- package/react/components/Select.d.ts +1 -0
- package/react/components/Select.js +1 -1
- package/react/components/SelectPreview.js +3 -3
- package/react/components/ShowPopup.d.ts +1 -1
- package/react/components/ShowPopup.js +7 -7
- package/react/components/TreeMenu.js +25 -0
- package/react/components/TreeSelect/TreeSelect.js +5 -14
- package/react/components/TreeSelect/TreeSelectItem.js +2 -2
- package/react/components/TreeSelect/TreeSelectPill.js +3 -3
- package/react/helpers.d.ts +1 -0
- package/react/helpers.js +14 -1
- package/react/index.d.ts +1 -0
- package/react/index.js +3 -1
@@ -22,6 +22,7 @@ interface IPropsButton {
|
|
22
22
|
icon?: string;
|
23
23
|
disabled?: boolean;
|
24
24
|
iconOnly?: boolean;
|
25
|
+
noMargin?: boolean;
|
25
26
|
'data-test-id'?: string;
|
26
27
|
}
|
27
28
|
|
@@ -51,6 +52,7 @@ export class Button extends React.PureComponent<IPropsButton> {
|
|
51
52
|
aria-label={this.props.iconOnly ? this.props.text : ''}
|
52
53
|
data-test-id={this.props['data-test-id']}
|
53
54
|
title={this.props.tooltip}
|
55
|
+
style={this.props.noMargin ? {margin: 0} : undefined}
|
54
56
|
>
|
55
57
|
{this.props.isLoading ? <Spinner size="mini" /> : null}
|
56
58
|
{this.props.icon && !this.props.isLoading ? <Icon ariaHidden name={this.props.icon} /> : null}
|
@@ -4,6 +4,7 @@ import classNames from 'classnames';
|
|
4
4
|
interface IProps {
|
5
5
|
text: string;
|
6
6
|
style?: 'normal' | 'light'; // defaults to normal
|
7
|
+
noMinHeight?: boolean;
|
7
8
|
}
|
8
9
|
|
9
10
|
export class FormLabel extends React.PureComponent<IProps> {
|
@@ -14,7 +15,12 @@ export class FormLabel extends React.PureComponent<IProps> {
|
|
14
15
|
});
|
15
16
|
|
16
17
|
return (
|
17
|
-
<label
|
18
|
+
<label
|
19
|
+
className={classes}
|
20
|
+
style={this.props.noMinHeight === true ? {minHeight: 'auto'} : undefined}
|
21
|
+
>
|
22
|
+
{this.props.text}
|
23
|
+
</label>
|
18
24
|
);
|
19
25
|
}
|
20
26
|
}
|
@@ -1,5 +1,7 @@
|
|
1
1
|
import * as React from 'react';
|
2
2
|
import classNames from 'classnames';
|
3
|
+
import {getTextColor} from '../helpers';
|
4
|
+
|
3
5
|
interface IProps {
|
4
6
|
text: string;
|
5
7
|
link?: string;
|
@@ -77,16 +79,3 @@ export class Label extends React.PureComponent<IProps> {
|
|
77
79
|
}
|
78
80
|
}
|
79
81
|
}
|
80
|
-
|
81
|
-
export function getTextColor(backgroundColor: string): 'black' | 'white' | undefined {
|
82
|
-
if (backgroundColor) {
|
83
|
-
const r = parseInt(backgroundColor.substr(1, 2), 16);
|
84
|
-
const g = parseInt(backgroundColor.substr(3, 2), 16);
|
85
|
-
const b = parseInt(backgroundColor.substr(5, 2), 16);
|
86
|
-
const yiq = ((r * 299) + (g * 587) + (b * 114)) / 1000;
|
87
|
-
|
88
|
-
return (yiq >= 128) ? 'black' : 'white';
|
89
|
-
} else {
|
90
|
-
return;
|
91
|
-
}
|
92
|
-
}
|
@@ -4,7 +4,9 @@ import nextId from "react-id-generator";
|
|
4
4
|
import {FormLabel} from './Form/FormLabel';
|
5
5
|
|
6
6
|
interface IProps {
|
7
|
-
value
|
7
|
+
value: string;
|
8
|
+
onChange(nextValue: string): void;
|
9
|
+
disabled?: boolean;
|
8
10
|
group?: {
|
9
11
|
orientation?: 'horizontal' | 'vertical'; // defaults to 'horizontal'
|
10
12
|
grid?: boolean;
|
@@ -22,7 +24,6 @@ interface IProps {
|
|
22
24
|
}>;
|
23
25
|
required?: boolean;
|
24
26
|
tabindex?: number;
|
25
|
-
onChange(nextValue: string): void;
|
26
27
|
'data-test-id'?: string;
|
27
28
|
}
|
28
29
|
|
@@ -35,7 +36,7 @@ export class RadioButtonGroup extends React.Component<IProps> {
|
|
35
36
|
}
|
36
37
|
|
37
38
|
handleChange(item: any) {
|
38
|
-
if (
|
39
|
+
if (this.props.disabled !== true && item.disabled !== true) {
|
39
40
|
this.props.onChange(item.value);
|
40
41
|
}
|
41
42
|
}
|
@@ -73,7 +74,7 @@ export class RadioButtonGroup extends React.Component<IProps> {
|
|
73
74
|
tabIndex={this.props.tabindex}
|
74
75
|
name={this.htmlId}
|
75
76
|
onChange={() => this.handleChange(item)}
|
76
|
-
disabled={item.disabled}
|
77
|
+
disabled={this.props.disabled || item.disabled}
|
77
78
|
required={this.props.required}
|
78
79
|
checked={item.value === this.props.value} />
|
79
80
|
<label
|
@@ -110,7 +111,7 @@ export class RadioButtonGroup extends React.Component<IProps> {
|
|
110
111
|
tabIndex={0}
|
111
112
|
name={this.htmlId}
|
112
113
|
onChange={() => this.handleChange(item)}
|
113
|
-
disabled={item.disabled}
|
114
|
+
disabled={this.props.disabled || item.disabled}
|
114
115
|
required={this.props.required}
|
115
116
|
checked={item.value === this.props.value} />
|
116
117
|
<label className="sd-check-button__text-label" htmlFor={this.htmlId + index}
|
@@ -6,6 +6,7 @@ import {IInputWrapper} from './Form/InputWrapper';
|
|
6
6
|
interface ISelect extends IInputWrapper {
|
7
7
|
value?: string;
|
8
8
|
onChange(newValue: string): void;
|
9
|
+
'data-test-id'?: string;
|
9
10
|
}
|
10
11
|
|
11
12
|
class Select extends React.Component<ISelect> {
|
@@ -53,6 +54,7 @@ class Select extends React.Component<ISelect> {
|
|
53
54
|
tabIndex={this.props.tabindex}
|
54
55
|
onChange={this.handleChange}
|
55
56
|
disabled={this.props.disabled || this.props.readonly}
|
57
|
+
data-test-id={this.props['data-test-id']}
|
56
58
|
>
|
57
59
|
{this.props.children}
|
58
60
|
</select>
|
@@ -7,7 +7,7 @@ import maxSize from 'popper-max-size-modifier';
|
|
7
7
|
import {getNextZIndex} from '../zIndex';
|
8
8
|
|
9
9
|
interface IPropsPopupPositioner {
|
10
|
-
|
10
|
+
getReferenceElement(): HTMLElement;
|
11
11
|
placement: Placement;
|
12
12
|
onClose(): void;
|
13
13
|
closeOnHoverEnd?: boolean;
|
@@ -34,7 +34,7 @@ export class PopupPositioner extends React.PureComponent<IPropsPopupPositioner>
|
|
34
34
|
}
|
35
35
|
|
36
36
|
if (
|
37
|
-
this.props.
|
37
|
+
this.props.getReferenceElement().contains(event.target as Node) !== true
|
38
38
|
&& this.wrapperEl.contains(event.target as Node) !== true
|
39
39
|
) {
|
40
40
|
this.props.onClose();
|
@@ -66,7 +66,7 @@ export class PopupPositioner extends React.PureComponent<IPropsPopupPositioner>
|
|
66
66
|
window.addEventListener('scroll', this.closeOnScroll, true);
|
67
67
|
|
68
68
|
if (this.props.closeOnHoverEnd && this.wrapperEl != null) {
|
69
|
-
this.props.
|
69
|
+
this.props.getReferenceElement().addEventListener('mouseleave', this.closeOnMouseLeave);
|
70
70
|
this.wrapperEl.addEventListener('mouseleave', this.closeOnMouseLeave);
|
71
71
|
}
|
72
72
|
|
@@ -91,7 +91,7 @@ export class PopupPositioner extends React.PureComponent<IPropsPopupPositioner>
|
|
91
91
|
setTimeout(() => {
|
92
92
|
if (this.wrapperEl != null) {
|
93
93
|
this.popper = createPopper(
|
94
|
-
this.props.
|
94
|
+
this.props.getReferenceElement(),
|
95
95
|
this.wrapperEl,
|
96
96
|
{
|
97
97
|
placement: this.props.placement,
|
@@ -111,7 +111,7 @@ export class PopupPositioner extends React.PureComponent<IPropsPopupPositioner>
|
|
111
111
|
window.removeEventListener('scroll', this.closeOnScroll, true);
|
112
112
|
|
113
113
|
if (this.props.closeOnHoverEnd && this.wrapperEl != null) {
|
114
|
-
this.props.
|
114
|
+
this.props.getReferenceElement().removeEventListener('mouseleave', this.closeOnMouseLeave);
|
115
115
|
this.wrapperEl.removeEventListener('mouseleave', this.closeOnMouseLeave);
|
116
116
|
}
|
117
117
|
|
@@ -120,19 +120,28 @@ export class PopupPositioner extends React.PureComponent<IPropsPopupPositioner>
|
|
120
120
|
|
121
121
|
render() {
|
122
122
|
return (
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
123
|
+
<>
|
124
|
+
{
|
125
|
+
ReactDOM.createPortal(
|
126
|
+
(
|
127
|
+
<div
|
128
|
+
ref={(el) => {
|
129
|
+
this.wrapperEl = el;
|
130
|
+
}}
|
131
|
+
style={{
|
132
|
+
position: 'absolute',
|
133
|
+
left: '-100vw',
|
134
|
+
display: 'flex',
|
135
|
+
zIndex: this.zIndex,
|
136
|
+
}}
|
137
|
+
>
|
138
|
+
{this.props.children}
|
139
|
+
</div>
|
140
|
+
),
|
141
|
+
document.body,
|
142
|
+
)
|
143
|
+
}
|
144
|
+
</>
|
136
145
|
);
|
137
146
|
}
|
138
147
|
}
|
@@ -160,7 +169,7 @@ export function showPopup(
|
|
160
169
|
ReactDOM.render(
|
161
170
|
(
|
162
171
|
<PopupPositioner
|
163
|
-
|
172
|
+
getReferenceElement={() => referenceElement}
|
164
173
|
placement={placement}
|
165
174
|
onClose={closeFn}
|
166
175
|
closeOnHoverEnd={closeOnHoverEnd || false}
|
@@ -199,6 +199,22 @@ export class TreeMenu<T> extends React.Component<IProps<T>, IState<T>> {
|
|
199
199
|
if (this.openDropdownRef.current && this.dropdownRef.current) {
|
200
200
|
this.popperInstance = createPopper(this.openDropdownRef.current, this.dropdownRef.current, {
|
201
201
|
placement: 'bottom-start',
|
202
|
+
modifiers: [
|
203
|
+
{
|
204
|
+
name: 'flip',
|
205
|
+
enabled: true,
|
206
|
+
},
|
207
|
+
],
|
208
|
+
onFirstUpdate: (state) => {
|
209
|
+
this.popperInstance?.setOptions({
|
210
|
+
placement: state.placement,
|
211
|
+
modifiers: this.popperInstance.state.options.modifiers.map((modifier) => (
|
212
|
+
modifier.name === 'flip'
|
213
|
+
? {...modifier, enabled: false}
|
214
|
+
: modifier
|
215
|
+
)),
|
216
|
+
});
|
217
|
+
},
|
202
218
|
});
|
203
219
|
}
|
204
220
|
|
@@ -6,7 +6,7 @@ import _debounce from 'lodash/debounce';
|
|
6
6
|
import { InputWrapper } from "../Form";
|
7
7
|
import { createPopper, Instance } from '@popperjs/core';
|
8
8
|
import {isEqual} from 'lodash';
|
9
|
-
import {getTextColor} from '
|
9
|
+
import {getTextColor} from '../../helpers';
|
10
10
|
import {IInputWrapper} from '../Form/InputWrapper';
|
11
11
|
import {SelectPreview} from '../SelectPreview';
|
12
12
|
import {TreeSelectPill} from './TreeSelectPill';
|
@@ -15,14 +15,7 @@ import {keyboardNavigation} from './KeyboardNavigation';
|
|
15
15
|
import {WithPortal} from '../WithPortal';
|
16
16
|
import { DragDropContext, Droppable, Draggable, DropResult } from "react-beautiful-dnd";
|
17
17
|
import {getNextZIndex} from '../../zIndex';
|
18
|
-
|
19
|
-
const reorder = (list: Array<any>, startIndex: number, endIndex: number) => {
|
20
|
-
const result = Array.from(list);
|
21
|
-
const [removed] = result.splice(startIndex, 1);
|
22
|
-
result.splice(endIndex, 0, removed);
|
23
|
-
|
24
|
-
return result;
|
25
|
-
};
|
18
|
+
import {arrayMove} from '@superdesk/common';
|
26
19
|
|
27
20
|
interface IState<T> {
|
28
21
|
value: Array<T>;
|
@@ -282,14 +275,9 @@ export class TreeSelect<T> extends React.Component<IProps<T>, IState<T>> {
|
|
282
275
|
}
|
283
276
|
|
284
277
|
removeClick(i: number) {
|
285
|
-
let newTags = this.state.value;
|
286
|
-
newTags?.splice(i, 1);
|
287
|
-
|
288
278
|
this.setState({
|
289
|
-
value:
|
279
|
+
value: this.state.value.filter((_item, index) => index !== i),
|
290
280
|
});
|
291
|
-
|
292
|
-
this.props.onChange(this.state.value);
|
293
281
|
}
|
294
282
|
|
295
283
|
handleMultiLevel(item: ITreeNode<T>) {
|
@@ -639,13 +627,8 @@ export class TreeSelect<T> extends React.Component<IProps<T>, IState<T>> {
|
|
639
627
|
return;
|
640
628
|
}
|
641
629
|
|
642
|
-
const value = reorder(
|
643
|
-
this.state.value,
|
644
|
-
result.source.index,
|
645
|
-
result.destination.index,
|
646
|
-
);
|
647
630
|
this.setState({
|
648
|
-
value: value,
|
631
|
+
value: arrayMove(this.state.value, result.source.index, result.destination.index),
|
649
632
|
});
|
650
633
|
}
|
651
634
|
|
@@ -2,7 +2,7 @@ import classNames from 'classnames';
|
|
2
2
|
import * as React from "react";
|
3
3
|
import {DragHandle} from '../DragHandle';
|
4
4
|
import {Icon} from "../Icon";
|
5
|
-
import {getTextColor} from '
|
5
|
+
import {getTextColor} from '../../helpers';
|
6
6
|
|
7
7
|
interface IProps<T> {
|
8
8
|
item: T;
|
@@ -5,3 +5,16 @@ export function assertNever(x: never): never {
|
|
5
5
|
export function nameof<T>(name: keyof T): string {
|
6
6
|
return name.toString();
|
7
7
|
}
|
8
|
+
|
9
|
+
export function getTextColor(backgroundColor: string): 'black' | 'white' | undefined {
|
10
|
+
if (backgroundColor) {
|
11
|
+
const r = parseInt(backgroundColor.substr(1, 2), 16);
|
12
|
+
const g = parseInt(backgroundColor.substr(3, 2), 16);
|
13
|
+
const b = parseInt(backgroundColor.substr(5, 2), 16);
|
14
|
+
const yiq = ((r * 299) + (g * 587) + (b * 114)) / 1000;
|
15
|
+
|
16
|
+
return (yiq >= 128) ? 'black' : 'white';
|
17
|
+
} else {
|
18
|
+
return;
|
19
|
+
}
|
20
|
+
}
|
package/app-typescript/index.ts
CHANGED
@@ -107,6 +107,7 @@ export { ResizeObserverComponent } from './components/ResizeObserverComponent';
|
|
107
107
|
export { DragHandleDots } from './components/DragHandleDots';
|
108
108
|
export { DragHandle } from './components/DragHandle';
|
109
109
|
export { CalendarWeekDayItem } from './components/Lists/CalendarWeekDayItem';
|
110
|
+
export { getTextColor } from './helpers';
|
110
111
|
|
111
112
|
// declare non-typescript exports to prevent errors
|
112
113
|
export declare const ToggleBoxNext: any;
|