superdesk-ui-framework 5.2.0 → 5.2.2

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 (35) hide show
  1. package/app/styles/app.scss +1 -0
  2. package/app/styles/components/_overflow-stack.scss +120 -0
  3. package/app-typescript/components/CopyableTextBox.tsx +99 -0
  4. package/app-typescript/components/IconButton.tsx +21 -27
  5. package/app-typescript/components/OverflowStack/OverflowStack.tsx +418 -0
  6. package/app-typescript/components/OverflowStack/OverflowStackPopover.tsx +45 -0
  7. package/app-typescript/components/OverflowStack/utils.tsx +16 -0
  8. package/app-typescript/components/SearchBar.tsx +149 -99
  9. package/app-typescript/index.ts +2 -0
  10. package/app-typescript/translations.ts +3 -0
  11. package/dist/components/CopyableTextBox.tsx +98 -0
  12. package/dist/components/Index.tsx +16 -1
  13. package/dist/components/OverflowStack.tsx +915 -0
  14. package/dist/components/SearchBar.tsx +394 -0
  15. package/dist/examples.bundle.js +5066 -3900
  16. package/dist/superdesk-ui.bundle.css +85 -0
  17. package/dist/superdesk-ui.bundle.js +4079 -3539
  18. package/dist/vendor.bundle.js +19 -19
  19. package/package.json +2 -2
  20. package/react/components/CopyableTextBox.d.ts +12 -0
  21. package/react/components/CopyableTextBox.js +88 -0
  22. package/react/components/IconButton.d.ts +1 -7
  23. package/react/components/IconButton.js +11 -36
  24. package/react/components/OverflowStack/OverflowStack.d.ts +87 -0
  25. package/react/components/OverflowStack/OverflowStack.js +305 -0
  26. package/react/components/OverflowStack/OverflowStackPopover.d.ts +14 -0
  27. package/react/components/OverflowStack/OverflowStackPopover.js +78 -0
  28. package/react/components/OverflowStack/utils.d.ts +4 -0
  29. package/react/components/OverflowStack/utils.js +49 -0
  30. package/react/components/SearchBar.d.ts +19 -19
  31. package/react/components/SearchBar.js +90 -83
  32. package/react/index.d.ts +2 -0
  33. package/react/index.js +7 -3
  34. package/react/translations.d.ts +3 -0
  35. package/react/translations.js +3 -0
@@ -7,7 +7,7 @@
7
7
  var a = typeof exports === 'object' ? factory(require("react"), require("react-dom"), require("angular")) : factory(root["react"], root["react-dom"], root["angular"]);
8
8
  for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];
9
9
  }
10
- })(typeof self !== 'undefined' ? self : this, function(__WEBPACK_EXTERNAL_MODULE_0__, __WEBPACK_EXTERNAL_MODULE_14__, __WEBPACK_EXTERNAL_MODULE_923__) {
10
+ })(typeof self !== 'undefined' ? self : this, function(__WEBPACK_EXTERNAL_MODULE_0__, __WEBPACK_EXTERNAL_MODULE_14__, __WEBPACK_EXTERNAL_MODULE_927__) {
11
11
  return /******/ (function(modules) { // webpackBootstrap
12
12
  /******/ // The module cache
13
13
  /******/ var installedModules = {};
@@ -70,7 +70,7 @@ return /******/ (function(modules) { // webpackBootstrap
70
70
  /******/ __webpack_require__.p = "";
71
71
  /******/
72
72
  /******/ // Load entry module and return exports
73
- /******/ return __webpack_require__(__webpack_require__.s = 920);
73
+ /******/ return __webpack_require__(__webpack_require__.s = 924);
74
74
  /******/ })
75
75
  /************************************************************************/
76
76
  /******/ ({
@@ -17303,11 +17303,11 @@ module.exports = __WEBPACK_EXTERNAL_MODULE_14__;
17303
17303
  }
17304
17304
  }.call(this));
17305
17305
 
17306
- /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(56), __webpack_require__(73)(module)))
17306
+ /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(57), __webpack_require__(73)(module)))
17307
17307
 
17308
17308
  /***/ }),
17309
17309
 
17310
- /***/ 56:
17310
+ /***/ 57:
17311
17311
  /***/ (function(module, exports) {
17312
17312
 
17313
17313
  var g;
@@ -17364,7 +17364,7 @@ module.exports = function(module) {
17364
17364
 
17365
17365
  /***/ }),
17366
17366
 
17367
- /***/ 89:
17367
+ /***/ 90:
17368
17368
  /***/ (function(module, exports, __webpack_require__) {
17369
17369
 
17370
17370
  var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/*!
@@ -28253,24 +28253,24 @@ return jQuery;
28253
28253
 
28254
28254
  /***/ }),
28255
28255
 
28256
- /***/ 920:
28256
+ /***/ 924:
28257
28257
  /***/ (function(module, exports, __webpack_require__) {
28258
28258
 
28259
28259
  "use strict";
28260
28260
 
28261
28261
  Object.defineProperty(exports, "__esModule", { value: true });
28262
28262
  __webpack_require__(24);
28263
- __webpack_require__(89);
28264
- __webpack_require__(921);
28265
- __webpack_require__(923);
28266
- __webpack_require__(924);
28263
+ __webpack_require__(90);
28264
+ __webpack_require__(925);
28265
+ __webpack_require__(927);
28266
+ __webpack_require__(928);
28267
28267
  __webpack_require__(0);
28268
28268
  __webpack_require__(14);
28269
28269
 
28270
28270
 
28271
28271
  /***/ }),
28272
28272
 
28273
- /***/ 921:
28273
+ /***/ 925:
28274
28274
  /***/ (function(module, exports, __webpack_require__) {
28275
28275
 
28276
28276
  var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/*!
@@ -28294,7 +28294,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
28294
28294
  if ( true ) {
28295
28295
 
28296
28296
  // AMD. Register as an anonymous module.
28297
- !(__WEBPACK_AMD_DEFINE_ARRAY__ = [ __webpack_require__(89), __webpack_require__(922) ], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory),
28297
+ !(__WEBPACK_AMD_DEFINE_ARRAY__ = [ __webpack_require__(90), __webpack_require__(926) ], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory),
28298
28298
  __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?
28299
28299
  (__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__),
28300
28300
  __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
@@ -29032,7 +29032,7 @@ return $.widget;
29032
29032
 
29033
29033
  /***/ }),
29034
29034
 
29035
- /***/ 922:
29035
+ /***/ 926:
29036
29036
  /***/ (function(module, exports, __webpack_require__) {
29037
29037
 
29038
29038
  var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;( function( factory ) {
@@ -29041,7 +29041,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
29041
29041
  if ( true ) {
29042
29042
 
29043
29043
  // AMD. Register as an anonymous module.
29044
- !(__WEBPACK_AMD_DEFINE_ARRAY__ = [ __webpack_require__(89) ], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory),
29044
+ !(__WEBPACK_AMD_DEFINE_ARRAY__ = [ __webpack_require__(90) ], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory),
29045
29045
  __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?
29046
29046
  (__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__),
29047
29047
  __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
@@ -29062,23 +29062,23 @@ return $.ui.version = "1.13.0";
29062
29062
 
29063
29063
  /***/ }),
29064
29064
 
29065
- /***/ 923:
29065
+ /***/ 927:
29066
29066
  /***/ (function(module, exports) {
29067
29067
 
29068
- module.exports = __WEBPACK_EXTERNAL_MODULE_923__;
29068
+ module.exports = __WEBPACK_EXTERNAL_MODULE_927__;
29069
29069
 
29070
29070
  /***/ }),
29071
29071
 
29072
- /***/ 924:
29072
+ /***/ 928:
29073
29073
  /***/ (function(module, exports, __webpack_require__) {
29074
29074
 
29075
- __webpack_require__(925);
29075
+ __webpack_require__(929);
29076
29076
  module.exports = 'ngAnimate';
29077
29077
 
29078
29078
 
29079
29079
  /***/ }),
29080
29080
 
29081
- /***/ 925:
29081
+ /***/ 929:
29082
29082
  /***/ (function(module, exports) {
29083
29083
 
29084
29084
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "superdesk-ui-framework",
3
- "version": "5.2.0",
3
+ "version": "5.2.2",
4
4
  "license": "AGPL-3.0",
5
5
  "repository": {
6
6
  "type": "git",
@@ -20,7 +20,7 @@
20
20
  ],
21
21
  "scripts": {
22
22
  "start": "webpack-dev-server --config tasks/webpack.dev.js",
23
- "server": "webpack --watch --config tasks/webpack.prod.js && tsc-watch",
23
+ "watch": "webpack --watch --config tasks/webpack.prod.js & tsc --watch",
24
24
  "build": "tsc -p tsconfig.json --noEmit && webpack --config tasks/webpack.prod.js && tsc",
25
25
  "build-ui": "webpack && tsc && npm run lint",
26
26
  "playground-lint": "tsc -p examples/pages/playgrounds/react-playgrounds --noEmit",
@@ -0,0 +1,12 @@
1
+ import React from 'react';
2
+ import { IInputCommon } from './Form/InputWrapper';
3
+ interface ICopyableTextBoxProps extends IInputCommon {
4
+ value: string;
5
+ /**
6
+ * Defaults to medium
7
+ */
8
+ size?: 'medium' | 'large';
9
+ 'data-test-id'?: string;
10
+ }
11
+ export declare const CopyableTextBox: React.FC<ICopyableTextBoxProps>;
12
+ export {};
@@ -0,0 +1,88 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __importDefault = (this && this.__importDefault) || function (mod) {
36
+ return (mod && mod.__esModule) ? mod : { "default": mod };
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.CopyableTextBox = void 0;
40
+ var react_1 = __importStar(require("react"));
41
+ var Button_1 = require("./Button");
42
+ var translations_1 = require("../translations");
43
+ var Form_1 = require("./Form");
44
+ var react_id_generator_1 = __importDefault(require("react-id-generator"));
45
+ var Toast_1 = require("./Toast");
46
+ var CopyableTextBox = function (props) {
47
+ var _a, _b;
48
+ var htmlId = (0, react_id_generator_1.default)();
49
+ var timeoutIdRef = react_1.default.useRef();
50
+ var _c = react_1.default.useState(false), copied = _c[0], setCopied = _c[1];
51
+ (0, react_1.useEffect)(function () {
52
+ return function () {
53
+ if (timeoutIdRef.current) {
54
+ window.clearTimeout(timeoutIdRef.current);
55
+ }
56
+ };
57
+ }, []);
58
+ var handleCopy = function () {
59
+ navigator.clipboard
60
+ .writeText(props.value)
61
+ .then(function () {
62
+ Toast_1.toasted.notify((0, translations_1.gettext)('Copied to clipboard'), {
63
+ type: 'success',
64
+ duration: 500,
65
+ });
66
+ setCopied(true);
67
+ if (timeoutIdRef.current) {
68
+ window.clearTimeout(timeoutIdRef.current);
69
+ }
70
+ timeoutIdRef.current = window.setTimeout(function () {
71
+ setCopied(false);
72
+ }, 2000);
73
+ })
74
+ .catch(function () {
75
+ Toast_1.toasted.notify((0, translations_1.gettext)("Couldn't copy"), {
76
+ type: 'warning',
77
+ });
78
+ });
79
+ };
80
+ return (react_1.default.createElement(Form_1.InputWrapper, { label: props.label, disabled: props.disabled, value: props.value, error: props.error, invalid: props.error != null, info: props.info, size: (_a = props.size) !== null && _a !== void 0 ? _a : 'medium', fullWidth: true, htmlId: htmlId, tabindex: props.tabindex },
81
+ react_1.default.createElement("div", { className: "d-flex items-center gap-1" },
82
+ react_1.default.createElement("input", { id: htmlId, "aria-describedby": htmlId + 'label', type: "text", className: "sd-input__input", style: {
83
+ border: '1px solid var(--color-input-border)',
84
+ borderRadius: 'var(--b-radius--medium)',
85
+ }, value: props.value, disabled: true, "data-test-id": props['data-test-id'] }),
86
+ react_1.default.createElement(Button_1.Button, { text: (0, translations_1.gettext)('Copy'), icon: copied ? 'ok' : 'copy', iconOnly: true, onClick: handleCopy, type: "default", style: "hollow", size: props.size === 'medium' ? 'normal' : ((_b = props.size) !== null && _b !== void 0 ? _b : 'normal'), "data-test-id": "copy-button" }))));
87
+ };
88
+ exports.CopyableTextBox = CopyableTextBox;
@@ -4,16 +4,10 @@ interface IProps {
4
4
  icon: string;
5
5
  ariaValue: string;
6
6
  toolTipFlow?: 'top' | 'left' | 'right' | 'down';
7
- toolTipAppend?: boolean;
8
7
  size?: 'default' | 'small' | 'x-large';
9
8
  style?: 'default' | 'outline' | 'outlineWhite';
10
9
  disabled?: boolean;
11
10
  onClick(event: React.MouseEvent): void;
12
11
  }
13
- export declare class IconButton extends React.PureComponent<IProps> {
14
- static defaultProps: {
15
- toolTipAppend: boolean;
16
- };
17
- render(): JSX.Element;
18
- }
12
+ export declare const IconButton: React.FC<IProps>;
19
13
  export {};
@@ -1,19 +1,4 @@
1
1
  "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- if (typeof b !== "function" && b !== null)
11
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
- extendStatics(d, b);
13
- function __() { this.constructor = d; }
14
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
- };
16
- })();
17
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
18
3
  if (k2 === undefined) k2 = k;
19
4
  var desc = Object.getOwnPropertyDescriptor(m, k);
@@ -56,25 +41,15 @@ var React = __importStar(require("react"));
56
41
  var Icon_1 = require("./Icon");
57
42
  var Tooltip_1 = require("./Tooltip");
58
43
  var classnames_1 = __importDefault(require("classnames"));
59
- var IconButton = /** @class */ (function (_super) {
60
- __extends(IconButton, _super);
61
- function IconButton() {
62
- return _super !== null && _super.apply(this, arguments) || this;
63
- }
64
- IconButton.prototype.render = function () {
65
- var _a;
66
- var classes = (0, classnames_1.default)('icn-btn', (_a = {},
67
- _a["icn-btn--".concat(this.props.size)] = this.props.size || this.props.size !== undefined,
68
- _a["icn-btn--".concat(this.props.style)] = this.props.style || this.props.style !== undefined,
69
- _a['icn-btn--disabled'] = this.props.disabled,
70
- _a));
71
- return (React.createElement(Tooltip_1.Tooltip, { text: this.props.disabled ? null : this.props.ariaValue, flow: this.props.toolTipFlow },
72
- React.createElement("button", { id: this.props.id, tabIndex: 0, onClick: this.props.onClick, className: classes, disabled: this.props.disabled, "aria-label": this.props.ariaValue },
73
- React.createElement(Icon_1.Icon, { name: this.props.icon, ariaHidden: true }))));
74
- };
75
- IconButton.defaultProps = {
76
- toolTipAppend: true,
77
- };
78
- return IconButton;
79
- }(React.PureComponent));
44
+ var IconButton = function (props) {
45
+ var _a;
46
+ var classes = (0, classnames_1.default)('icn-btn', (_a = {},
47
+ _a["icn-btn--".concat(props.size)] = props.size || props.size !== undefined,
48
+ _a["icn-btn--".concat(props.style)] = props.style || props.style !== undefined,
49
+ _a['icn-btn--disabled'] = props.disabled,
50
+ _a));
51
+ return (React.createElement(Tooltip_1.Tooltip, { text: props.disabled ? null : props.ariaValue, flow: props.toolTipFlow },
52
+ React.createElement("button", { id: props.id, tabIndex: 0, onClick: props.onClick, className: classes, disabled: props.disabled, "aria-label": props.ariaValue },
53
+ React.createElement(Icon_1.Icon, { name: props.icon, ariaHidden: true }))));
54
+ };
80
55
  exports.IconButton = IconButton;
@@ -0,0 +1,87 @@
1
+ import * as React from 'react';
2
+ interface IPropsOverflowStackBase {
3
+ /**
4
+ * Default: {type: `fixed`, max: 4}
5
+ */
6
+ overflow?: {
7
+ type: 'fixed';
8
+ max?: number | 'show-all';
9
+ } | {
10
+ type: 'auto';
11
+ };
12
+ /**
13
+ * Defaults to `compact`
14
+ */
15
+ gap?: 'compact' | 'loose' | 'none';
16
+ /**
17
+ * When `true`, items will have negative margin and expand on hover
18
+ */
19
+ overlap?: boolean;
20
+ showOnlyHiddenInPopover?: boolean;
21
+ /**
22
+ * Defaults to `count`
23
+ * `count`: Shows "+N" with the number of hidden items
24
+ * `dots`: Shows a three dots icon without the count
25
+ */
26
+ indicatorStyle?: 'count' | 'dots';
27
+ renderIndicator?: (count: number) => React.ReactNode;
28
+ onIndicatorClick?: () => void;
29
+ /**
30
+ * Defaults to `full`
31
+ * Border radius for the indicator button
32
+ */
33
+ indicatorRadius?: 'x-small' | 'small' | 'medium' | 'full';
34
+ containerClassName?: string;
35
+ }
36
+ interface IPropsOverflowStackSimple extends IPropsOverflowStackBase {
37
+ type: 'simple';
38
+ items: Array<React.ReactNode>;
39
+ /**
40
+ * Custom render function for items in the popover.
41
+ * Useful if you just want to wrap children, but still keep everything else default.
42
+ * If not provided, items will be rendered as-is
43
+ */
44
+ renderPopoverItem?: (item: React.ReactNode, index: number) => React.ReactNode;
45
+ }
46
+ interface IPropsOverflowStackData<T> extends IPropsOverflowStackBase {
47
+ type: 'data';
48
+ items: Array<T>;
49
+ renderVisibleItem: (data: T, index: number) => React.ReactNode;
50
+ /**
51
+ * If not provided, `renderVisibleItem` will be used
52
+ */
53
+ renderHiddenItem?: (data: T, index: number) => React.ReactNode;
54
+ }
55
+ export type IPropsOverflowStack<T> = IPropsOverflowStackSimple | IPropsOverflowStackData<T>;
56
+ interface IStateOverflowStack {
57
+ /**
58
+ * Number of visible items when using auto overflow
59
+ */
60
+ visibleCount: number;
61
+ }
62
+ export declare class OverflowStack<T> extends React.PureComponent<IPropsOverflowStack<T>, IStateOverflowStack> {
63
+ private containerRef;
64
+ private itemRefs;
65
+ private indicatorRef;
66
+ private resizeObserver;
67
+ private popoverContentRef;
68
+ /**
69
+ * Use a ref to avoid closure when passing props.
70
+ */
71
+ private currentPropsRef;
72
+ /**
73
+ * Debounced calculation to avoid excessive updates during resize
74
+ */
75
+ private debouncedCalculate;
76
+ constructor(props: IPropsOverflowStack<T>);
77
+ private getItemCount;
78
+ componentDidMount(): void;
79
+ componentDidUpdate(prevProps: IPropsOverflowStack<T>): void;
80
+ componentWillUnmount(): void;
81
+ private setupResizeObserver;
82
+ private cleanupResizeObserver;
83
+ private getGapSize;
84
+ private calculateVisibleItems;
85
+ render(): JSX.Element;
86
+ }
87
+ export {};