superdesk-ui-framework 3.0.82 → 3.1.1

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 (34) hide show
  1. package/app/img/DotsSmall-dark.svg +14 -0
  2. package/app/img/OneDot.svg +3 -0
  3. package/app/styles/_design-tokens.scss +2 -1
  4. package/app/styles/_drag-handle.scss +36 -12
  5. package/app/styles/app.scss +1 -0
  6. package/app/styles/design-tokens/_component-tokens.scss +11 -0
  7. package/app-typescript/components/DragHandle.tsx +27 -5
  8. package/app-typescript/components/DragHandleDots.tsx +19 -0
  9. package/app-typescript/components/Menu.tsx +0 -1
  10. package/app-typescript/components/TreeMenu.tsx +60 -69
  11. package/app-typescript/helpers.tsx +4 -0
  12. package/app-typescript/index.ts +2 -0
  13. package/dist/OneDot.svg +3 -0
  14. package/dist/examples.bundle.css +22 -24
  15. package/dist/examples.bundle.js +1692 -1603
  16. package/dist/playgrounds/react-playgrounds/TestGround.tsx +1 -40
  17. package/dist/react/DragHandleDocs.tsx +68 -2
  18. package/dist/superdesk-ui.bundle.css +47 -20
  19. package/dist/superdesk-ui.bundle.js +1625 -1205
  20. package/examples/css/docs-page.css +22 -4
  21. package/examples/pages/playgrounds/react-playgrounds/TestGround.tsx +1 -40
  22. package/examples/pages/react/DragHandleDocs.tsx +68 -2
  23. package/package.json +1 -1
  24. package/react/components/DragHandle.d.ts +9 -2
  25. package/react/components/DragHandle.js +14 -4
  26. package/react/components/DragHandleDots.d.ts +9 -0
  27. package/react/components/DragHandleDots.js +61 -0
  28. package/react/components/Menu.js +1 -1
  29. package/react/components/TreeMenu.d.ts +62 -0
  30. package/react/components/TreeMenu.js +340 -0
  31. package/react/helpers.d.ts +1 -0
  32. package/react/helpers.js +5 -1
  33. package/react/index.d.ts +2 -0
  34. package/react/index.js +5 -1
@@ -0,0 +1,14 @@
1
+ <svg width="10" height="14" viewBox="0 0 10 14" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <path d="M1 0C0.447715 0 0 0.447715 0 1C0 1.55228 0.447715 2 1 2C1.55228 2 2 1.55228 2 1C2 0.447715 1.55228 0 1 0Z" fill="#2C323A"/>
3
+ <path d="M0 5C0 4.44772 0.447715 4 1 4C1.55228 4 2 4.44772 2 5C2 5.55228 1.55228 6 1 6C0.447715 6 0 5.55228 0 5Z" fill="#2C323A"/>
4
+ <path d="M1 8C0.447715 8 0 8.44771 0 9C0 9.55229 0.447715 10 1 10C1.55228 10 2 9.55229 2 9C2 8.44771 1.55228 8 1 8Z" fill="#2C323A"/>
5
+ <path d="M1 12C0.447715 12 0 12.4477 0 13C0 13.5523 0.447715 14 1 14C1.55228 14 2 13.5523 2 13C2 12.4477 1.55228 12 1 12Z" fill="#2C323A"/>
6
+ <path d="M5 0C4.44772 0 4 0.447715 4 1C4 1.55228 4.44772 2 5 2C5.55228 2 6 1.55228 6 1C6 0.447715 5.55228 0 5 0Z" fill="#2C323A"/>
7
+ <path d="M4 5C4 4.44772 4.44772 4 5 4C5.55228 4 6 4.44772 6 5C6 5.55228 5.55228 6 5 6C4.44772 6 4 5.55228 4 5Z" fill="#2C323A"/>
8
+ <path d="M5 8C4.44772 8 4 8.44771 4 9C4 9.55229 4.44772 10 5 10C5.55228 10 6 9.55229 6 9C6 8.44771 5.55228 8 5 8Z" fill="#2C323A"/>
9
+ <path d="M5 12C4.44772 12 4 12.4477 4 13C4 13.5523 4.44772 14 5 14C5.55228 14 6 13.5523 6 13C6 12.4477 5.55228 12 5 12Z" fill="#2C323A"/>
10
+ <path d="M8 1C8 0.447715 8.44771 0 9 0C9.55228 0 10 0.447715 10 1C10 1.55228 9.55228 2 9 2C8.44771 2 8 1.55228 8 1Z" fill="#2C323A"/>
11
+ <path d="M9 4C8.44771 4 8 4.44772 8 5C8 5.55228 8.44771 6 9 6C9.55228 6 10 5.55228 10 5C10 4.44772 9.55228 4 9 4Z" fill="#2C323A"/>
12
+ <path d="M8 9C8 8.44771 8.44771 8 9 8C9.55228 8 10 8.44771 10 9C10 9.55229 9.55228 10 9 10C8.44771 10 8 9.55229 8 9Z" fill="#2C323A"/>
13
+ <path d="M8 13C8 12.4477 8.44771 12 9 12C9.55228 12 10 12.4477 10 13C10 13.5523 9.55228 14 9 14C8.44771 14 8 13.5523 8 13Z" fill="#2C323A"/>
14
+ </svg>
@@ -0,0 +1,3 @@
1
+ <svg width="4" height="4" viewBox="0 0 4 4" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <path d="M1 0C0.447715 0 0 0.447715 0 1C0 1.55228 0.447715 2 1 2C1.55228 2 2 1.55228 2 1C2 0.447715 1.55228 0 1 0Z" fill="#2C323A"/>
3
+ </svg>
@@ -1,2 +1,3 @@
1
1
  @import 'design-tokens/design-tokens-general';
2
- @import 'design-tokens/new-colors';
2
+ @import 'design-tokens/new-colors';
3
+ @import 'design-tokens/component-tokens';
@@ -1,24 +1,48 @@
1
- .drag-handle {
2
- height: 30px;
3
- width: 8px;
4
- opacity: 0.85;
5
- }
6
1
 
7
2
  .drag-handle-wrapper {
8
- padding: 6px;
9
3
  display: inline-flex;
10
4
  justify-content: center;
11
5
  align-items: center;
12
- background-color: var(--sd-colour-line--medium);
13
- border-start-start-radius: 3px;
14
- border-end-start-radius: 3px;
6
+ transition: all 0.2s ease;
7
+ outline: none;
8
+ color: var(--color-text);
9
+ background-color: transparent;
10
+ .drag-handle-dots {
11
+ transition: all 0.1s ease;
12
+ opacity: 0.4;
13
+ }
15
14
  &:hover {
16
- background-color: var(--sd-colour-line--strong);
17
15
  cursor: grab;
16
+ .drag-handle-dots {
17
+ opacity: 0.8;
18
+ }
18
19
  }
19
20
  &:active {
20
- background-color: var(--sd-colour-interactive);
21
21
  cursor: grabbing;
22
- opacity: 1;
22
+ .drag-handle-dots {
23
+ opacity: 1;
24
+ }
25
+ }
26
+ &.drag-handle-wrapper--boxed {
27
+ padding: var(--drag-handle-boxed-padding);
28
+ background-color: var(--drag-handle-boxed-color-bg-normal);
29
+ border-radius: var(--drag-handle-boxed-radius);
30
+ &:hover {
31
+ background-color: var(--drag-handle-boxed-color-bg-hover);
32
+ }
33
+ &:active {
34
+ background-color: var(--drag-handle-boxed-color-bg-active);
35
+ color: white;
36
+ }
23
37
  }
24
38
  }
39
+
40
+ .drag-handle-dots {
41
+ mask-image: url(../img/OneDot.svg);
42
+ mask-repeat: repeat;
43
+ width: var(--handle-width);
44
+ height: var(--handle-height);
45
+ background-color: currentColor;
46
+ margin-block: auto;
47
+ }
48
+
@@ -35,6 +35,7 @@
35
35
  @import 'spinner';
36
36
  @import 'table-list';
37
37
  @import 'hamburger';
38
+ @import 'drag-handle';
38
39
 
39
40
  // Interface elements
40
41
  @import 'interface-elements/side-panel';
@@ -0,0 +1,11 @@
1
+ :root,
2
+ [data-theme="dark-ui"],
3
+ [data-theme="accessible-light-ui"],
4
+ [data-theme="contrast-light-ui"] {
5
+ // Drag Handle
6
+ --drag-handle-boxed-color-bg-normal: var(--sd-colour-line--medium);
7
+ --drag-handle-boxed-color-bg-hover: var(--sd-colour-line--strong);
8
+ --drag-handle-boxed-color-bg-active: var(--sd-colour-interactive);
9
+ --drag-handle-boxed-radius: var(--b-radius--medium) 0 0 var(--b-radius--medium);
10
+ --drag-handle-boxed-padding: var(--space--1);
11
+ }
@@ -1,12 +1,34 @@
1
1
  import * as React from 'react';
2
- import '../../app/styles/_drag-handle.scss';
3
- import dragHandleImg from '../../app/img/dots.svg';
2
+ import classNames from 'classnames';
3
+ import { DragHandleDots } from './DragHandleDots';
4
4
 
5
- export class DragHandle extends React.PureComponent {
5
+ interface IProps {
6
+ blank?: boolean;
7
+ dotRows?: '4' | '5' | '6' | '7' | '8' | '10';
8
+ dotsInRow?: '2' | '3' | '4' | '5';
9
+ dotColor?: 'light' | 'dark'; // The default is the theme text color, this is an explicit override.
10
+ className?: string;
11
+ }
12
+
13
+ const dotSize = 4; // Size of the single dot image (OneDot.svg) that gets repeated and forms the dotted pattern.
14
+
15
+ export class DragHandle extends React.PureComponent<IProps> {
6
16
  render() {
17
+ const classes = classNames('drag-handle-wrapper', {
18
+ [`drag-handle-wrapper--boxed`]: !this.props.blank,
19
+ 'drag-handle-wrapper--blank': this.props.blank,
20
+ }, this.props.className);
21
+
22
+ const calcSize = (numberOfDots: string) => {
23
+ return Number(numberOfDots) * dotSize - (dotSize / 2);
24
+ };
25
+
7
26
  return (
8
- <div className="drag-handle-wrapper">
9
- <img src={dragHandleImg} className="drag-handle" draggable={false} />
27
+ <div className={classes}>
28
+ <DragHandleDots
29
+ style={{width: calcSize(this.props.dotsInRow ?? '2'), height: calcSize(this.props.dotRows ?? '4')}}
30
+ color={this.props.dotColor}
31
+ />
10
32
  </div>
11
33
  );
12
34
  }
@@ -0,0 +1,19 @@
1
+ import * as React from 'react';
2
+ import classNames from 'classnames';
3
+
4
+ interface IProps {
5
+ color?: 'light' | 'dark';
6
+ style?: any;
7
+ }
8
+
9
+ export class DragHandleDots extends React.PureComponent<IProps> {
10
+ render() {
11
+ const classes = classNames('drag-handle-dots', {
12
+ [`drag-handle-dots--${this.props.color}`]: this.props.color,
13
+ });
14
+
15
+ return (
16
+ <div style={this.props.style} className={classes}></div>
17
+ );
18
+ }
19
+ }
@@ -150,7 +150,6 @@ export class Menu extends React.Component<IProps, {}> {
150
150
  }}
151
151
  >
152
152
  <TieredMenu
153
- className='sd-overflow--y-auto max-h-full'
154
153
  popup
155
154
  model={this.toPrimeReactInterface(this.props.items)}
156
155
  ref={(el) => this.menu = el}
@@ -3,8 +3,8 @@ import { Icon } from "./Icon";
3
3
  import { createPopper, Instance } from '@popperjs/core';
4
4
  import {getPrefixedItemId, TreeSelectItem} from './TreeSelect/TreeSelectItem';
5
5
  import {keyboardNavigation} from './TreeSelect/KeyboardNavigation';
6
- import {createPortal} from 'react-dom';
7
6
  import {WithPortal} from './WithPortal';
7
+ import {nameof} from '../helpers';
8
8
 
9
9
  interface IState<T> {
10
10
  options: Array<ITreeMenuNode<T>>;
@@ -48,11 +48,27 @@ interface IChildren<T> {
48
48
  export type ITreeMenuNode<T> = IParent<T> | IChildren<T>;
49
49
 
50
50
  function nodeHasChildren<T>(item: IParent<T> | IChildren<T>): item is IParent<T> {
51
- return item['children'] != null;
51
+ return (item as unknown as any)[nameof<IParent<T>>('children')] != null;
52
52
  }
53
53
 
54
54
  function nodeCanBeSelected<T>(item: IParent<T> | IChildren<T>): item is IChildren<T> {
55
- return item['onSelect'] != null;
55
+ return (item as unknown as any)[nameof<IChildren<T>>('onSelect')] != null;
56
+ }
57
+
58
+ function onSelect<T>(item: ITreeMenuNode<T>) {
59
+ if (nodeCanBeSelected(item)) {
60
+ return item.onSelect;
61
+ }
62
+
63
+ return undefined;
64
+ }
65
+
66
+ function disabledItem<T>(item: ITreeMenuNode<T>) {
67
+ if (nodeCanBeSelected(item)) {
68
+ return item.disabled;
69
+ }
70
+
71
+ return undefined;
56
72
  }
57
73
 
58
74
  export class TreeMenu<T> extends React.Component<IProps<T>, IState<T>> {
@@ -163,7 +179,7 @@ export class TreeMenu<T> extends React.Component<IProps<T>, IState<T>> {
163
179
  document.addEventListener("keydown", this.onPressEsc);
164
180
  }
165
181
 
166
- componentDidUpdate(prevProps: Readonly<IProps<T>>, prevState: Readonly<IState<T>>): void {
182
+ componentDidUpdate(_prevProps: Readonly<IProps<T>>, prevState: Readonly<IState<T>>): void {
167
183
  if (prevState.openDropdown !== this.state.openDropdown) {
168
184
  this.toggleMenu();
169
185
  }
@@ -208,7 +224,7 @@ export class TreeMenu<T> extends React.Component<IProps<T>, IState<T>> {
208
224
  }
209
225
  }
210
226
 
211
- toggle(event) {
227
+ toggle(event: React.SyntheticEvent) {
212
228
  event.stopPropagation();
213
229
 
214
230
  this.setState({
@@ -238,7 +254,7 @@ export class TreeMenu<T> extends React.Component<IProps<T>, IState<T>> {
238
254
  });
239
255
  }
240
256
 
241
- handleTree(event: React.MouseEvent<HTMLLIElement, MouseEvent>, option: ITreeMenuNode<T>) {
257
+ handleTree(_event: React.MouseEvent<HTMLLIElement, MouseEvent>, option: ITreeMenuNode<T>) {
242
258
  if (nodeHasChildren(option)) {
243
259
  this.handleButton(option);
244
260
  this.handleMultiLevel(option);
@@ -305,40 +321,29 @@ export class TreeMenu<T> extends React.Component<IProps<T>, IState<T>> {
305
321
  if (filteredArr.length === 0) {
306
322
  return <li className="suggestion-item--nothing-found">Nothing found</li>;
307
323
  } else {
308
- return filteredArr.map((option, i) => {
309
- const onSelect = (item) => {
310
- if (nodeCanBeSelected(item)) {
311
- return item.onSelect;
312
- }
313
- };
314
-
315
- const disabledItem = (item) => {
316
- if (nodeCanBeSelected(item)) {
317
- return item.disabled;
318
- }
319
- };
320
-
321
- return (
322
- <TreeSelectItem
323
- key={i}
324
- option={option}
325
- handleTree={this.handleTree}
326
- disabledItem={disabledItem(option)}
327
- getBorderColor={this.props.getBorderColor}
328
- getBackgroundColor={this.props.getBackgroundColor}
329
- getId={this.props.getId}
330
- optionTemplate={this.props.optionTemplate}
331
- getLabel={this.props.getLabel}
332
- onClick={() => {
324
+ return filteredArr.map((option, i) => (
325
+ <TreeSelectItem
326
+ key={i}
327
+ option={option}
328
+ handleTree={this.handleTree}
329
+ disabledItem={disabledItem(option)}
330
+ getBorderColor={this.props.getBorderColor}
331
+ getBackgroundColor={this.props.getBackgroundColor}
332
+ getId={this.props.getId}
333
+ optionTemplate={this.props.optionTemplate}
334
+ getLabel={this.props.getLabel}
335
+ onClick={() => {
336
+ if (onSelect != null) {
333
337
  onSelect(option);
334
338
 
335
339
  this.setState({
336
340
  searchFieldValue: '',
337
341
  });
338
- }}
339
- />
340
- );
341
- });
342
+ }
343
+
344
+ }}
345
+ />
346
+ ));
342
347
  }
343
348
  }
344
349
 
@@ -410,40 +415,26 @@ export class TreeMenu<T> extends React.Component<IProps<T>, IState<T>> {
410
415
  ref={this.ref}
411
416
  className="suggestion-list suggestion-list--multi-select"
412
417
  >
413
- {this.state.options.map((option, i: React.Key | undefined) => {
414
- const onSelect = (item) => {
415
- if (nodeCanBeSelected(item)) {
416
- return item.onSelect;
417
- }
418
- };
419
-
420
- const disabledItem = (item) => {
421
- if (nodeCanBeSelected(item)) {
422
- return item.disabled;
423
- }
424
- };
425
-
426
- return (
427
- <TreeSelectItem
428
- key={i}
429
- option={option}
430
- handleTree={this.handleTree}
431
- onClick={onSelect(option)}
432
- disabledItem={disabledItem(option)}
433
- getBorderColor={this.props.getBorderColor}
434
- getBackgroundColor={this.props.getBackgroundColor}
435
- getId={this.props.getId}
436
- optionTemplate={this.props.optionTemplate}
437
- getLabel={this.props.getLabel}
438
- onKeyDown={() => this.setState({
439
- buttonTarget: [
440
- ...this.state.buttonTarget,
441
- this.props.getId(option.value),
442
- ],
443
- })}
444
- />
445
- );
446
- })}
418
+ {this.state.options.map((option, i: React.Key | undefined) => (
419
+ <TreeSelectItem
420
+ key={i}
421
+ option={option}
422
+ handleTree={this.handleTree}
423
+ onClick={onSelect(option)}
424
+ disabledItem={disabledItem(option)}
425
+ getBorderColor={this.props.getBorderColor}
426
+ getBackgroundColor={this.props.getBackgroundColor}
427
+ getId={this.props.getId}
428
+ optionTemplate={this.props.optionTemplate}
429
+ getLabel={this.props.getLabel}
430
+ onKeyDown={() => this.setState({
431
+ buttonTarget: [
432
+ ...this.state.buttonTarget,
433
+ this.props.getId(option.value),
434
+ ],
435
+ })}
436
+ />
437
+ ))}
447
438
  </ul>
448
439
  : null
449
440
  : <ul
@@ -1,3 +1,7 @@
1
1
  export function assertNever(x: never): never {
2
2
  throw new Error('Unexpected object: ' + x);
3
3
  }
4
+
5
+ export function nameof<T>(name: keyof T): string {
6
+ return name.toString();
7
+ }
@@ -93,6 +93,7 @@ export { Time } from './components/Text/Time';
93
93
  export { Heading } from './components/Text/Heading';
94
94
  export { BottomNav } from './components/Navigation/BottomNav';
95
95
  export { TreeSelect } from './components/TreeSelect/TreeSelect';
96
+ export { TreeMenu } from './components/TreeMenu';
96
97
  export { TableList, TableListItem } from './components/Lists/TableList';
97
98
  export { ContentListItem } from './components/Lists/ContentList';
98
99
  export { MultiSelect } from './components/MultiSelect';
@@ -100,6 +101,7 @@ export { ResizablePanels } from './components/ResizablePanels';
100
101
  export { WithPopover } from './components/WithPopover';
101
102
  export { Spacer, SpacerBlock } from './components/Spacer';
102
103
  export { ResizeObserverComponent } from './components/ResizeObserverComponent';
104
+ export { DragHandleDots } from './components/DragHandleDots';
103
105
  export { DragHandle } from './components/DragHandle';
104
106
 
105
107
  // declare non-typescript exports to prevent errors
@@ -0,0 +1,3 @@
1
+ <svg width="4" height="4" viewBox="0 0 4 4" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <path d="M1 0C0.447715 0 0 0.447715 0 1C0 1.55228 0.447715 2 1 2C1.55228 2 2 1.55228 2 1C2 0.447715 1.55228 0 1 0Z" fill="#2C323A"/>
3
+ </svg>
@@ -338,6 +338,8 @@ table {
338
338
  --docs-page-border__window-bar--top: hsla(0, 0%, 100%, 0.9);
339
339
  --docs-page-border__window-bar--bottom: hsla(0, 0%, 88%, 1);
340
340
  --docs-page-border__table: hsla(0, 0%, 0%, 0.16);
341
+
342
+ --docs-page-bg__table-tr-even: hsla(214, 13%, 50%, 0.08);
341
343
  }
342
344
 
343
345
  :root [data-theme="dark-ui"] {
@@ -1022,7 +1024,7 @@ pre.prettyprint {
1022
1024
  }
1023
1025
 
1024
1026
  .docs-page__container {
1025
- max-width: 832px;
1027
+ max-width: 1200px;
1026
1028
  margin: 30px auto 0;
1027
1029
  }
1028
1030
  .docs-page__container--large {
@@ -1039,11 +1041,16 @@ pre.prettyprint {
1039
1041
  justify-content: center;
1040
1042
  }
1041
1043
 
1044
+
1045
+ .docs-page__container .docs-page__code-window {
1046
+ max-width: none !important;
1047
+ }
1048
+
1042
1049
  .docs-page__container .docs-page__h2,
1043
1050
  .docs-page__container .docs-page__h3,
1044
- .docs-page__container .docs-page__code-window,
1045
- .docs-page__container .docs-page__paragraph {
1046
- max-width: none !important;
1051
+ .docs-page__container .docs-page__paragraph,
1052
+ .docs-page__container .docs-page__paragraph--small {
1053
+ max-width: 85ch;
1047
1054
  }
1048
1055
 
1049
1056
  .docs-page__content-block {
@@ -1276,6 +1283,17 @@ doc-gif-img:hover img {
1276
1283
  border-color: var(--docs-page-border__table) !important;
1277
1284
  }
1278
1285
 
1286
+ .docs-page__container table tr td:nth-child(3) {
1287
+ white-space: nowrap;
1288
+ }
1289
+
1290
+ .docs-page__container table tr:nth-child(even),
1291
+ .docs-page__container table thead tr {
1292
+ background-color: var(--docs-page-bg__table-tr-even);
1293
+ }
1294
+
1295
+
1296
+
1279
1297
 
1280
1298
  /* -------------- END COLOR SWATCHES -------------- */
1281
1299
  /* -------------- PrismJS overrides -------------- */
@@ -12066,26 +12084,6 @@ doc-react-playground {
12066
12084
  .side-panel__top-tools--dark-blue-grey .icn-mix__icn {
12067
12085
  color: inherit;
12068
12086
  opacity: 1; }
12069
- .drag-handle {
12070
- height: 30px;
12071
- width: 8px;
12072
- opacity: 0.85; }
12073
-
12074
- .drag-handle-wrapper {
12075
- padding: 6px;
12076
- display: inline-flex;
12077
- justify-content: center;
12078
- align-items: center;
12079
- background-color: var(--sd-colour-line--medium);
12080
- border-start-start-radius: 3px;
12081
- border-end-start-radius: 3px; }
12082
- .drag-handle-wrapper:hover {
12083
- background-color: var(--sd-colour-line--strong);
12084
- cursor: grab; }
12085
- .drag-handle-wrapper:active {
12086
- background-color: var(--sd-colour-interactive);
12087
- cursor: grabbing;
12088
- opacity: 1; }
12089
12087
  @charset "UTF-8";
12090
12088
  .red--100 {
12091
12089
  background-color: #fde4e2; }