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.
- package/app/styles/app.scss +1 -0
- package/app/styles/components/_overflow-stack.scss +120 -0
- package/app-typescript/components/CopyableTextBox.tsx +99 -0
- package/app-typescript/components/IconButton.tsx +21 -27
- package/app-typescript/components/OverflowStack/OverflowStack.tsx +418 -0
- package/app-typescript/components/OverflowStack/OverflowStackPopover.tsx +45 -0
- package/app-typescript/components/OverflowStack/utils.tsx +16 -0
- package/app-typescript/components/SearchBar.tsx +149 -99
- package/app-typescript/index.ts +2 -0
- package/app-typescript/translations.ts +3 -0
- package/dist/components/CopyableTextBox.tsx +98 -0
- package/dist/components/Index.tsx +16 -1
- package/dist/components/OverflowStack.tsx +915 -0
- package/dist/components/SearchBar.tsx +394 -0
- package/dist/examples.bundle.js +5066 -3900
- package/dist/superdesk-ui.bundle.css +85 -0
- package/dist/superdesk-ui.bundle.js +4079 -3539
- package/dist/vendor.bundle.js +19 -19
- package/package.json +2 -2
- package/react/components/CopyableTextBox.d.ts +12 -0
- package/react/components/CopyableTextBox.js +88 -0
- package/react/components/IconButton.d.ts +1 -7
- package/react/components/IconButton.js +11 -36
- package/react/components/OverflowStack/OverflowStack.d.ts +87 -0
- package/react/components/OverflowStack/OverflowStack.js +305 -0
- package/react/components/OverflowStack/OverflowStackPopover.d.ts +14 -0
- package/react/components/OverflowStack/OverflowStackPopover.js +78 -0
- package/react/components/OverflowStack/utils.d.ts +4 -0
- package/react/components/OverflowStack/utils.js +49 -0
- package/react/components/SearchBar.d.ts +19 -19
- package/react/components/SearchBar.js +90 -83
- package/react/index.d.ts +2 -0
- package/react/index.js +7 -3
- package/react/translations.d.ts +3 -0
- package/react/translations.js +3 -0
|
@@ -0,0 +1,305 @@
|
|
|
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
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
18
|
+
if (k2 === undefined) k2 = k;
|
|
19
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
20
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
21
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
22
|
+
}
|
|
23
|
+
Object.defineProperty(o, k2, desc);
|
|
24
|
+
}) : (function(o, m, k, k2) {
|
|
25
|
+
if (k2 === undefined) k2 = k;
|
|
26
|
+
o[k2] = m[k];
|
|
27
|
+
}));
|
|
28
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
29
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
30
|
+
}) : function(o, v) {
|
|
31
|
+
o["default"] = v;
|
|
32
|
+
});
|
|
33
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
34
|
+
var ownKeys = function(o) {
|
|
35
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
36
|
+
var ar = [];
|
|
37
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
38
|
+
return ar;
|
|
39
|
+
};
|
|
40
|
+
return ownKeys(o);
|
|
41
|
+
};
|
|
42
|
+
return function (mod) {
|
|
43
|
+
if (mod && mod.__esModule) return mod;
|
|
44
|
+
var result = {};
|
|
45
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
46
|
+
__setModuleDefault(result, mod);
|
|
47
|
+
return result;
|
|
48
|
+
};
|
|
49
|
+
})();
|
|
50
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
51
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
52
|
+
};
|
|
53
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
54
|
+
exports.OverflowStack = void 0;
|
|
55
|
+
var React = __importStar(require("react"));
|
|
56
|
+
var classnames_1 = __importDefault(require("classnames"));
|
|
57
|
+
var debounce_1 = __importDefault(require("lodash/debounce"));
|
|
58
|
+
var WithPopover_1 = require("../WithPopover");
|
|
59
|
+
var HeadlessButton_1 = require("../HeadlessButton");
|
|
60
|
+
var IconButton_1 = require("../IconButton");
|
|
61
|
+
var OverflowStackPopover_1 = require("./OverflowStackPopover");
|
|
62
|
+
var utils_1 = require("./utils");
|
|
63
|
+
var OverflowStack = /** @class */ (function (_super) {
|
|
64
|
+
__extends(OverflowStack, _super);
|
|
65
|
+
function OverflowStack(props) {
|
|
66
|
+
var _this = _super.call(this, props) || this;
|
|
67
|
+
_this.containerRef = React.createRef();
|
|
68
|
+
_this.itemRefs = [];
|
|
69
|
+
_this.indicatorRef = React.createRef();
|
|
70
|
+
_this.resizeObserver = null;
|
|
71
|
+
_this.popoverContentRef = React.createRef();
|
|
72
|
+
/**
|
|
73
|
+
* Use a ref to avoid closure when passing props.
|
|
74
|
+
*/
|
|
75
|
+
_this.currentPropsRef = { current: null };
|
|
76
|
+
/**
|
|
77
|
+
* Debounced calculation to avoid excessive updates during resize
|
|
78
|
+
*/
|
|
79
|
+
_this.debouncedCalculate = (0, debounce_1.default)(function () {
|
|
80
|
+
_this.calculateVisibleItems();
|
|
81
|
+
}, 50);
|
|
82
|
+
var itemCount = _this.getItemCount(props);
|
|
83
|
+
_this.state = {
|
|
84
|
+
visibleCount: itemCount,
|
|
85
|
+
};
|
|
86
|
+
_this.itemRefs = Array.from({ length: itemCount }, function () { return React.createRef(); });
|
|
87
|
+
_this.currentPropsRef.current = props;
|
|
88
|
+
return _this;
|
|
89
|
+
}
|
|
90
|
+
OverflowStack.prototype.getItemCount = function (props) {
|
|
91
|
+
var _a, _b;
|
|
92
|
+
if (props.type === 'data') {
|
|
93
|
+
return props.items.length;
|
|
94
|
+
}
|
|
95
|
+
return (_b = (_a = props.items) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0;
|
|
96
|
+
};
|
|
97
|
+
OverflowStack.prototype.componentDidMount = function () {
|
|
98
|
+
var _this = this;
|
|
99
|
+
var _a;
|
|
100
|
+
if (((_a = this.props.overflow) === null || _a === void 0 ? void 0 : _a.type) === 'auto') {
|
|
101
|
+
this.setupResizeObserver();
|
|
102
|
+
requestAnimationFrame(function () {
|
|
103
|
+
_this.calculateVisibleItems();
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
OverflowStack.prototype.componentDidUpdate = function (prevProps) {
|
|
108
|
+
var _this = this;
|
|
109
|
+
var _a, _b, _c;
|
|
110
|
+
// Update the props ref for the popover
|
|
111
|
+
this.currentPropsRef.current = this.props;
|
|
112
|
+
(_b = (_a = this.popoverContentRef.current) === null || _a === void 0 ? void 0 : _a.forceUpdate) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
113
|
+
var isAutoMode = ((_c = this.props.overflow) === null || _c === void 0 ? void 0 : _c.type) === 'auto';
|
|
114
|
+
if (prevProps.overflow !== this.props.overflow) {
|
|
115
|
+
if (isAutoMode) {
|
|
116
|
+
this.setupResizeObserver();
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
this.cleanupResizeObserver();
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
if (isAutoMode) {
|
|
123
|
+
var prevItemCount = this.getItemCount(prevProps);
|
|
124
|
+
var currentItemCount = this.getItemCount(this.props);
|
|
125
|
+
if (prevItemCount !== currentItemCount) {
|
|
126
|
+
// Recreate refs if item count changed
|
|
127
|
+
this.itemRefs = Array.from({ length: currentItemCount }, function () { return React.createRef(); });
|
|
128
|
+
this.setState({ visibleCount: currentItemCount }, function () {
|
|
129
|
+
requestAnimationFrame(function () { return _this.calculateVisibleItems(); });
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
else {
|
|
133
|
+
requestAnimationFrame(function () { return _this.calculateVisibleItems(); });
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
OverflowStack.prototype.componentWillUnmount = function () {
|
|
138
|
+
this.cleanupResizeObserver();
|
|
139
|
+
this.debouncedCalculate.cancel();
|
|
140
|
+
};
|
|
141
|
+
OverflowStack.prototype.setupResizeObserver = function () {
|
|
142
|
+
var _this = this;
|
|
143
|
+
if (this.resizeObserver) {
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
this.resizeObserver = new ResizeObserver(function () {
|
|
147
|
+
_this.debouncedCalculate();
|
|
148
|
+
});
|
|
149
|
+
if (this.containerRef.current) {
|
|
150
|
+
this.resizeObserver.observe(this.containerRef.current);
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
OverflowStack.prototype.cleanupResizeObserver = function () {
|
|
154
|
+
if (this.resizeObserver) {
|
|
155
|
+
this.resizeObserver.disconnect();
|
|
156
|
+
this.resizeObserver = null;
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
OverflowStack.prototype.getGapSize = function () {
|
|
160
|
+
var _a = this.props, _b = _a.gap, gap = _b === void 0 ? 'compact' : _b, _c = _a.overlap, overlap = _c === void 0 ? false : _c;
|
|
161
|
+
if (overlap) {
|
|
162
|
+
return -8; // Overlapping items have negative margin
|
|
163
|
+
}
|
|
164
|
+
switch (gap) {
|
|
165
|
+
case 'compact':
|
|
166
|
+
return 4;
|
|
167
|
+
case 'loose':
|
|
168
|
+
return 8;
|
|
169
|
+
case 'none':
|
|
170
|
+
return 0;
|
|
171
|
+
default:
|
|
172
|
+
return 4;
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
OverflowStack.prototype.calculateVisibleItems = function () {
|
|
176
|
+
var _a, _b;
|
|
177
|
+
if (!this.containerRef.current || ((_a = this.props.overflow) === null || _a === void 0 ? void 0 : _a.type) !== 'auto') {
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
var containerWidth = this.containerRef.current.offsetWidth;
|
|
181
|
+
// If container has no width yet, skip calculation
|
|
182
|
+
if (containerWidth === 0) {
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
var gapSize = this.getGapSize();
|
|
186
|
+
var indicatorWidth = ((_b = this.indicatorRef.current) === null || _b === void 0 ? void 0 : _b.offsetWidth) || 40;
|
|
187
|
+
var totalItemCount = this.getItemCount(this.props);
|
|
188
|
+
var totalWidth = 0;
|
|
189
|
+
var visibleCount = 0;
|
|
190
|
+
// Calculate how many items fit
|
|
191
|
+
for (var i = 0; i < this.itemRefs.length; i++) {
|
|
192
|
+
var itemRef = this.itemRefs[i];
|
|
193
|
+
if (!itemRef.current) {
|
|
194
|
+
visibleCount = totalItemCount;
|
|
195
|
+
break;
|
|
196
|
+
}
|
|
197
|
+
var itemWidth = itemRef.current.offsetWidth;
|
|
198
|
+
if (itemWidth === 0) {
|
|
199
|
+
visibleCount = totalItemCount;
|
|
200
|
+
break;
|
|
201
|
+
}
|
|
202
|
+
var widthWithGap = itemWidth + (i > 0 ? gapSize : 0);
|
|
203
|
+
var needsIndicator = i < totalItemCount - 1;
|
|
204
|
+
var availableWidth = containerWidth - (needsIndicator ? indicatorWidth + gapSize : 0);
|
|
205
|
+
if (totalWidth + widthWithGap <= availableWidth) {
|
|
206
|
+
totalWidth += widthWithGap;
|
|
207
|
+
visibleCount = i + 1;
|
|
208
|
+
}
|
|
209
|
+
else {
|
|
210
|
+
break;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
if (visibleCount === 0 && totalItemCount > 0) {
|
|
214
|
+
visibleCount = 1;
|
|
215
|
+
}
|
|
216
|
+
if (this.state.visibleCount !== visibleCount) {
|
|
217
|
+
this.setState({ visibleCount: visibleCount });
|
|
218
|
+
}
|
|
219
|
+
};
|
|
220
|
+
OverflowStack.prototype.render = function () {
|
|
221
|
+
var _a;
|
|
222
|
+
var _this = this;
|
|
223
|
+
var _b;
|
|
224
|
+
var _c = this.props, _d = _c.gap, gap = _d === void 0 ? 'compact' : _d, _e = _c.overlap, overlap = _e === void 0 ? false : _e, _f = _c.overflow, overflow = _f === void 0 ? {
|
|
225
|
+
type: 'fixed',
|
|
226
|
+
max: 4,
|
|
227
|
+
} : _f, _g = _c.showOnlyHiddenInPopover, showOnlyHiddenInPopover = _g === void 0 ? false : _g, _h = _c.indicatorStyle, indicatorStyle = _h === void 0 ? 'count' : _h, renderIndicator = _c.renderIndicator, onIndicatorClick = _c.onIndicatorClick, _j = _c.indicatorRadius, indicatorRadius = _j === void 0 ? 'full' : _j, className = _c.containerClassName;
|
|
228
|
+
var itemCount = this.getItemCount(this.props);
|
|
229
|
+
var max;
|
|
230
|
+
if (overflow.type === 'auto') {
|
|
231
|
+
max = this.state.visibleCount;
|
|
232
|
+
}
|
|
233
|
+
else if (overflow.max === 'show-all') {
|
|
234
|
+
max = itemCount;
|
|
235
|
+
}
|
|
236
|
+
else {
|
|
237
|
+
max = (_b = overflow.max) !== null && _b !== void 0 ? _b : 4;
|
|
238
|
+
}
|
|
239
|
+
var itemsOverLimit = itemCount - max;
|
|
240
|
+
var renderVisibleItems = function () {
|
|
241
|
+
var renderItemWrapper = function (content, index) {
|
|
242
|
+
var isVisible = index < max;
|
|
243
|
+
return (React.createElement("div", { key: index, ref: overflow.type === 'auto' ? _this.itemRefs[index] : undefined, className: "overflow-stack__item", style: overflow.type === 'auto' && !isVisible ? utils_1.HIDDEN_ITEM_STYLE : undefined }, content));
|
|
244
|
+
};
|
|
245
|
+
var props = _this.props;
|
|
246
|
+
if (props.type === 'data') {
|
|
247
|
+
var itemsToRender = overflow.type === 'auto' ? props.items : props.items.slice(0, max);
|
|
248
|
+
return itemsToRender.map(function (data, index) {
|
|
249
|
+
return renderItemWrapper(props.renderVisibleItem(data, index), index);
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
else {
|
|
253
|
+
var itemsToRender = overflow.type === 'auto' ? props.items : props.items.slice(0, max);
|
|
254
|
+
return itemsToRender.map(function (item, index) { return renderItemWrapper(item, index); });
|
|
255
|
+
}
|
|
256
|
+
};
|
|
257
|
+
var ariaLabel = showOnlyHiddenInPopover
|
|
258
|
+
? "Show ".concat(itemsOverLimit, " hidden items")
|
|
259
|
+
: "Show ".concat(itemsOverLimit, " more items");
|
|
260
|
+
var renderIndicatorButton = function (onToggle) {
|
|
261
|
+
var _a;
|
|
262
|
+
var handleClick = function (e) {
|
|
263
|
+
e.stopPropagation();
|
|
264
|
+
if (onIndicatorClick == null) {
|
|
265
|
+
onToggle(e.currentTarget);
|
|
266
|
+
}
|
|
267
|
+
else {
|
|
268
|
+
onIndicatorClick();
|
|
269
|
+
}
|
|
270
|
+
};
|
|
271
|
+
var indicator;
|
|
272
|
+
if (indicatorStyle === 'dots') {
|
|
273
|
+
indicator = React.createElement(IconButton_1.IconButton, { size: "small", icon: "dots", ariaValue: ariaLabel, onClick: handleClick });
|
|
274
|
+
}
|
|
275
|
+
else {
|
|
276
|
+
var content = (_a = renderIndicator === null || renderIndicator === void 0 ? void 0 : renderIndicator(itemsOverLimit)) !== null && _a !== void 0 ? _a : (0, utils_1.defaultIndicator)(itemsOverLimit);
|
|
277
|
+
indicator = (React.createElement(HeadlessButton_1.HeadlessButton, { radius: indicatorRadius, onClick: handleClick, ariaLabel: ariaLabel, tooltip: ariaLabel }, content));
|
|
278
|
+
}
|
|
279
|
+
// Wrap in a div with ref for auto mode (needed for width measurement)
|
|
280
|
+
if (overflow.type === 'auto') {
|
|
281
|
+
return (React.createElement("div", { ref: _this.indicatorRef, style: { display: 'inline-flex' } }, indicator));
|
|
282
|
+
}
|
|
283
|
+
return indicator;
|
|
284
|
+
};
|
|
285
|
+
var classes = (0, classnames_1.default)('overflow-stack', (_a = {
|
|
286
|
+
'overflow-stack--overlap': overlap
|
|
287
|
+
},
|
|
288
|
+
_a["overflow-stack--gap-".concat(gap)] = !overlap,
|
|
289
|
+
_a), className);
|
|
290
|
+
return (React.createElement(WithPopover_1.WithPopover, { component: function (_a) {
|
|
291
|
+
var closePopup = _a.closePopup;
|
|
292
|
+
return (React.createElement(OverflowStackPopover_1.OverflowStackPopover, { ref: _this.popoverContentRef, propsRef: _this.currentPropsRef, max: max, showOnlyHiddenInPopover: showOnlyHiddenInPopover, closePopup: closePopup }));
|
|
293
|
+
} }, function (onToggle) {
|
|
294
|
+
var stackContent = (React.createElement("div", { ref: _this.containerRef, className: classes, role: "group", style: overflow.type === 'auto' ? { width: '100%' } : undefined },
|
|
295
|
+
renderVisibleItems(),
|
|
296
|
+
itemsOverLimit > 0 && renderIndicatorButton(onToggle)));
|
|
297
|
+
if (overflow.type === 'auto') {
|
|
298
|
+
return React.createElement("div", { style: { display: 'flex', width: '100%', minWidth: 0 } }, stackContent);
|
|
299
|
+
}
|
|
300
|
+
return stackContent;
|
|
301
|
+
}));
|
|
302
|
+
};
|
|
303
|
+
return OverflowStack;
|
|
304
|
+
}(React.PureComponent));
|
|
305
|
+
exports.OverflowStack = OverflowStack;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { IPropsOverflowStack } from './OverflowStack';
|
|
3
|
+
interface IPopoverContentProps<T> {
|
|
4
|
+
max: number;
|
|
5
|
+
closePopup(): void;
|
|
6
|
+
showOnlyHiddenInPopover: boolean;
|
|
7
|
+
propsRef: {
|
|
8
|
+
current: IPropsOverflowStack<T> | null;
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
export declare class OverflowStackPopover<T> extends React.Component<IPopoverContentProps<T>> {
|
|
12
|
+
render(): JSX.Element | null;
|
|
13
|
+
}
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,78 @@
|
|
|
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
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
18
|
+
if (k2 === undefined) k2 = k;
|
|
19
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
20
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
21
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
22
|
+
}
|
|
23
|
+
Object.defineProperty(o, k2, desc);
|
|
24
|
+
}) : (function(o, m, k, k2) {
|
|
25
|
+
if (k2 === undefined) k2 = k;
|
|
26
|
+
o[k2] = m[k];
|
|
27
|
+
}));
|
|
28
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
29
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
30
|
+
}) : function(o, v) {
|
|
31
|
+
o["default"] = v;
|
|
32
|
+
});
|
|
33
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
34
|
+
var ownKeys = function(o) {
|
|
35
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
36
|
+
var ar = [];
|
|
37
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
38
|
+
return ar;
|
|
39
|
+
};
|
|
40
|
+
return ownKeys(o);
|
|
41
|
+
};
|
|
42
|
+
return function (mod) {
|
|
43
|
+
if (mod && mod.__esModule) return mod;
|
|
44
|
+
var result = {};
|
|
45
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
46
|
+
__setModuleDefault(result, mod);
|
|
47
|
+
return result;
|
|
48
|
+
};
|
|
49
|
+
})();
|
|
50
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
51
|
+
exports.OverflowStackPopover = void 0;
|
|
52
|
+
var React = __importStar(require("react"));
|
|
53
|
+
var utils_1 = require("./utils");
|
|
54
|
+
var OverflowStackPopover = /** @class */ (function (_super) {
|
|
55
|
+
__extends(OverflowStackPopover, _super);
|
|
56
|
+
function OverflowStackPopover() {
|
|
57
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
58
|
+
}
|
|
59
|
+
OverflowStackPopover.prototype.render = function () {
|
|
60
|
+
var _a, _b;
|
|
61
|
+
var _c = this.props, propsRef = _c.propsRef, max = _c.max, showOnlyHiddenInPopover = _c.showOnlyHiddenInPopover;
|
|
62
|
+
var props = propsRef.current;
|
|
63
|
+
if (props == null) {
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
var itemsToShow = showOnlyHiddenInPopover ? props.items.slice(max) : props.items;
|
|
67
|
+
if (props.type === 'data') {
|
|
68
|
+
var renderFn_1 = (_a = props.renderHiddenItem) !== null && _a !== void 0 ? _a : props.renderVisibleItem;
|
|
69
|
+
return (React.createElement("div", { className: "overflow-stack__popover" }, itemsToShow.map(function (data, index) { return (React.createElement("div", { key: index, className: "overflow-stack__popover-item" }, renderFn_1(data, showOnlyHiddenInPopover ? index + max : index))); })));
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
var renderFn_2 = (_b = props.renderPopoverItem) !== null && _b !== void 0 ? _b : utils_1.renderHiddenItemDefault;
|
|
73
|
+
return (React.createElement("div", { className: "overflow-stack__popover" }, itemsToShow.map(function (item, index) { return renderFn_2(item, showOnlyHiddenInPopover ? index + max : index); })));
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
return OverflowStackPopover;
|
|
77
|
+
}(React.Component));
|
|
78
|
+
exports.OverflowStackPopover = OverflowStackPopover;
|
|
@@ -0,0 +1,49 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.renderHiddenItemDefault = exports.defaultIndicator = exports.HIDDEN_ITEM_STYLE = void 0;
|
|
37
|
+
var React = __importStar(require("react"));
|
|
38
|
+
exports.HIDDEN_ITEM_STYLE = {
|
|
39
|
+
position: 'absolute',
|
|
40
|
+
visibility: 'hidden',
|
|
41
|
+
pointerEvents: 'none',
|
|
42
|
+
whiteSpace: 'nowrap',
|
|
43
|
+
};
|
|
44
|
+
var defaultIndicator = function (count) { return React.createElement("span", { className: "overflow-stack__indicator-content" },
|
|
45
|
+
"+",
|
|
46
|
+
count); };
|
|
47
|
+
exports.defaultIndicator = defaultIndicator;
|
|
48
|
+
var renderHiddenItemDefault = function (item, index) { return (React.createElement("div", { key: index, className: "overflow-stack__popover-item" }, item)); };
|
|
49
|
+
exports.renderHiddenItemDefault = renderHiddenItemDefault;
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React from 'react';
|
|
2
2
|
interface IProps {
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
children?: React.ReactNode;
|
|
4
|
+
/**
|
|
5
|
+
* Defaults to `expanded`
|
|
6
|
+
*/
|
|
7
|
+
type?: 'expanded' | 'collapsed';
|
|
5
8
|
placeholder: string;
|
|
6
|
-
focused?: boolean;
|
|
7
9
|
boxed?: boolean;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
export declare class SearchBar extends React.PureComponent<IProps, IState> {
|
|
18
|
-
private inputRef;
|
|
19
|
-
constructor(props: IProps);
|
|
20
|
-
componentDidUpdate(prevProps: any): void;
|
|
21
|
-
componentDidMount: () => void;
|
|
22
|
-
render(): JSX.Element;
|
|
10
|
+
hideSearchButton?: boolean;
|
|
11
|
+
searchOptions?: {
|
|
12
|
+
searchOnType: true;
|
|
13
|
+
/**
|
|
14
|
+
* Defaults to 300ms
|
|
15
|
+
*/
|
|
16
|
+
searchDelay: number;
|
|
17
|
+
};
|
|
18
|
+
onSubmit(value: string): void;
|
|
23
19
|
}
|
|
20
|
+
export declare const SearchBar: React.ForwardRefExoticComponent<IProps & React.RefAttributes<{
|
|
21
|
+
focus: () => void;
|
|
22
|
+
search: () => void;
|
|
23
|
+
}>>;
|
|
24
24
|
export {};
|