@db-ux/react-core-components 4.4.0-loading-567cd0c → 4.4.1-floating-components-066d296
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/CHANGELOG.md +8 -0
- package/dist/components/custom-select/custom-select.js +8 -7
- package/dist/components/notification/notification.d.ts +1 -4
- package/dist/components/popover/popover.d.ts +1 -4
- package/dist/components/popover/popover.js +1 -1
- package/dist/components/tooltip/tooltip.d.ts +1 -4
- package/dist/components/tooltip/tooltip.js +2 -1
- package/dist/index.d.ts +0 -2
- package/dist/index.js +0 -2
- package/dist/shared/model.d.ts +4 -6
- package/dist/utils/floating-components.js +65 -15
- package/package.json +3 -3
- package/dist/components/loading-indicator/examples/_indicators.data.d.ts +0 -49
- package/dist/components/loading-indicator/examples/_indicators.data.js +0 -91
- package/dist/components/loading-indicator/index.d.ts +0 -1
- package/dist/components/loading-indicator/index.js +0 -1
- package/dist/components/loading-indicator/loading-indicator.d.ts +0 -3
- package/dist/components/loading-indicator/loading-indicator.js +0 -153
- package/dist/components/loading-indicator/model.d.ts +0 -39
- package/dist/components/loading-indicator/model.js +0 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @db-ux/react-core-components
|
|
2
2
|
|
|
3
|
+
## 4.4.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- fix: issue with tailwind not reflecting adaptive color changes with `[data-color="xxx"]` - [see commit 936638d](https://github.com/db-ux-design-system/core-web/commit/936638d672bbb6c0f8a0ecf77bf41fafa0e31656)
|
|
8
|
+
|
|
9
|
+
- DBCustomSelect: Prevent floating label from flickering during initial render - [see commit e5ceff8](https://github.com/db-ux-design-system/core-web/commit/e5ceff861534186cf86d1f5f0a876e04aeac9e41)
|
|
10
|
+
|
|
3
11
|
## 4.4.0
|
|
4
12
|
|
|
5
13
|
### Minor Changes
|
|
@@ -14,11 +14,10 @@ import DBCustomSelectListItem from "../custom-select-list-item/custom-select-lis
|
|
|
14
14
|
import DBCustomSelectList from "../custom-select-list/custom-select-list";
|
|
15
15
|
import DBInfotext from "../infotext/infotext";
|
|
16
16
|
import DBInput from "../input/input";
|
|
17
|
-
import DBLoadingIndicator from "../loading-indicator/loading-indicator";
|
|
18
17
|
import DBTag from "../tag/tag";
|
|
19
18
|
import DBTooltip from "../tooltip/tooltip";
|
|
20
19
|
function DBCustomSelectFn(props, component) {
|
|
21
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l
|
|
20
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
22
21
|
props = Object.assign({ clearSelectionText: "Clear selection", showClearSelection: true }, props);
|
|
23
22
|
const _ref = component || useRef(component);
|
|
24
23
|
const detailsRef = useRef(null);
|
|
@@ -690,20 +689,22 @@ function DBCustomSelectFn(props, component) {
|
|
|
690
689
|
React.createElement(DBInput, { type: "search", ref: searchInputRef, name: _id, form: _id, showLabel: false, value: _searchValue, label: (_d = props.searchLabel) !== null && _d !== void 0 ? _d : DEFAULT_LABEL, placeholder: (_e = props.searchPlaceholder) !== null && _e !== void 0 ? _e : props.searchLabel, ariaDescribedBy: _hasNoOptions || props.showLoading
|
|
691
690
|
? _infoTextId
|
|
692
691
|
: undefined, onInput: (event) => handleSearch(event) }))) : null,
|
|
693
|
-
_hasNoOptions || props.showLoading ? (React.createElement(
|
|
692
|
+
_hasNoOptions || props.showLoading ? (React.createElement(DBInfotext, { id: _infoTextId, icon: props.showLoading ? "circular_arrows" : undefined, semantic: props.showLoading ? "informational" : "warning" }, (_f = (props.showLoading
|
|
693
|
+
? props.loadingText
|
|
694
|
+
: props.noResultsText)) !== null && _f !== void 0 ? _f : DEFAULT_MESSAGE)) : (React.createElement(React.Fragment, null,
|
|
694
695
|
React.createElement(React.Fragment, null,
|
|
695
696
|
selectAllEnabled ? (React.createElement("div", null,
|
|
696
697
|
React.createElement("div", { className: "db-checkbox db-custom-select-list-item" },
|
|
697
698
|
React.createElement("label", null,
|
|
698
699
|
React.createElement("input", { type: "checkbox", value: "select-all", ref: selectAllRef, form: _id, checked: selectAllChecked, onChange: (event) => handleSelectAll(event) }),
|
|
699
700
|
getSelectAllLabel())))) : null,
|
|
700
|
-
React.createElement(DBCustomSelectList, { multiple: getBoolean(props.multiple, "multiple"), label: (
|
|
701
|
+
React.createElement(DBCustomSelectList, { multiple: getBoolean(props.multiple, "multiple"), label: (_h = (_g = props.listLabel) !== null && _g !== void 0 ? _g : props.label) !== null && _h !== void 0 ? _h : DEFAULT_LABEL }, _options === null || _options === void 0 ? void 0 : _options.map((option) => (React.createElement(DBCustomSelectListItem, { type: props.multiple ? "checkbox" : "radio", showDivider: option.showDivider, icon: option.icon, isGroupTitle: option.isGroupTitle, groupTitle: getOptionLabel(option), name: _id, checked: getOptionChecked(option.value), disabled: option.disabled, value: option.value, onChange: (event) => handleSelect(option.value), key: getOptionKey(option, "custom-select-list-item-") }, !option.isGroupTitle ? (React.createElement(React.Fragment, null, getOptionLabel(option))) : null))))))),
|
|
701
702
|
React.createElement("div", null,
|
|
702
|
-
React.createElement(DBButton, { variant: "ghost", width: "full", icon: "cross", size: "small", name: _id, form: _id, onClick: (event) => handleClose(undefined, true) }, (
|
|
703
|
-
((
|
|
703
|
+
React.createElement(DBButton, { variant: "ghost", width: "full", icon: "cross", size: "small", name: _id, form: _id, onClick: (event) => handleClose(undefined, true) }, (_j = props.mobileCloseButtonText) !== null && _j !== void 0 ? _j : DEFAULT_CLOSE_BUTTON))))) : null),
|
|
704
|
+
((_k = props.showClearSelection) !== null && _k !== void 0 ? _k : true) && (_values === null || _values === void 0 ? void 0 : _values.length) ? (React.createElement(DBButton, { icon: "cross", variant: "ghost", size: "small", noText: true, name: _id, form: _id, onClick: (event) => handleClearAll(event) },
|
|
704
705
|
props.clearSelectionText,
|
|
705
706
|
React.createElement(DBTooltip, { placement: "top" }, props.clearSelectionText))) : null,
|
|
706
|
-
React.createElement("span", { className: "db-custom-select-placeholder", "aria-hidden": getBooleanAsString(true), id: _placeholderId }, (
|
|
707
|
+
React.createElement("span", { className: "db-custom-select-placeholder", "aria-hidden": getBooleanAsString(true), id: _placeholderId }, (_l = props.placeholder) !== null && _l !== void 0 ? _l : props.label),
|
|
707
708
|
stringPropVisible(props.message, props.showMessage) ? (React.createElement(DBInfotext, { size: "small", icon: props.messageIcon, id: _messageId }, props.message)) : null,
|
|
708
709
|
hasValidState() ? (React.createElement(DBInfotext, { size: "small", semantic: "successful", id: _validMessageId }, props.validMessage || DEFAULT_VALID_MESSAGE)) : null,
|
|
709
710
|
React.createElement(DBInfotext, { size: "small", semantic: "critical", id: _invalidMessageId }, _invalidMessage),
|
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { ClickEvent } from "../../shared/model";
|
|
3
|
-
declare const DBNotification: React.ForwardRefExoticComponent<Omit<React.HTMLAttributes<any>, "role" | "semantic" | "text" | keyof import("../../shared/model").GlobalProps | "icon" | "showIcon" |
|
|
4
|
-
animation?: boolean | string;
|
|
5
|
-
width?: import("../../shared/model").PopoverWidthType;
|
|
6
|
-
} & import("../../shared/model").DelayProps & import("../../shared/model").ShowIconProps & import("../../shared/model").TextProps & React.RefAttributes<any>>;
|
|
3
|
+
declare const DBNotification: React.ForwardRefExoticComponent<Omit<React.HTMLAttributes<any>, "role" | "semantic" | "text" | keyof import("../../shared/model").GlobalProps | "icon" | "showIcon" | keyof import("../../shared/model").PopoverProps | keyof import("../../shared/model").InnerCloseButtonProps | keyof import("./model").DBNotificationDefaultProps | keyof import("../../shared/model").CloseEventProps<ClickEvent<HTMLButtonElement>>> & import("./model").DBNotificationDefaultProps & import("../../shared/model").GlobalProps & import("../../shared/model").RoleProps & import("../../shared/model").CloseEventProps<ClickEvent<HTMLButtonElement>> & import("../../shared/model").IconProps & import("../../shared/model").SemanticProps & import("../../shared/model").InnerCloseButtonProps & import("../../shared/model").PopoverProps & import("../../shared/model").ShowIconProps & import("../../shared/model").TextProps & React.RefAttributes<any>>;
|
|
7
4
|
export default DBNotification;
|
|
@@ -1,6 +1,3 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
declare const DBPopover: React.ForwardRefExoticComponent<Omit<React.HTMLAttributes<any>, keyof import("../..").GlobalProps | "placement" | "
|
|
3
|
-
animation?: boolean | string;
|
|
4
|
-
width?: import("../..").PopoverWidthType;
|
|
5
|
-
} & import("../..").DelayProps & React.RefAttributes<any>>;
|
|
2
|
+
declare const DBPopover: React.ForwardRefExoticComponent<Omit<React.HTMLAttributes<any>, keyof import("../..").GlobalProps | "placement" | "spacing" | keyof import("../..").PopoverProps | keyof import("./model").DBPopoverDefaultProps | "gap"> & import("./model").DBPopoverDefaultProps & import("../..").GlobalProps & import("../..").SpacingProps & import("../..").PlacementProps & import("../..").GapProps & import("../..").PopoverProps & React.RefAttributes<any>>;
|
|
6
3
|
export default DBPopover;
|
|
@@ -26,7 +26,7 @@ function DBPopoverFn(props, component) {
|
|
|
26
26
|
const article = _ref.current.querySelector("article");
|
|
27
27
|
if (article) {
|
|
28
28
|
// This is a workaround for angular
|
|
29
|
-
utilsDelay(() => {
|
|
29
|
+
void utilsDelay(() => {
|
|
30
30
|
var _a;
|
|
31
31
|
handleFixedPopover(article, _ref.current, (_a = props.placement) !== null && _a !== void 0 ? _a : "bottom");
|
|
32
32
|
}, 1);
|
|
@@ -1,6 +1,3 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
declare const DBTooltip: React.ForwardRefExoticComponent<Omit<React.HTMLAttributes<any>, keyof import("../../shared/model").GlobalProps | "placement" | "emphasis" |
|
|
3
|
-
animation?: boolean | string;
|
|
4
|
-
width?: import("../../shared/model").PopoverWidthType;
|
|
5
|
-
} & import("../../shared/model").DelayProps & React.RefAttributes<any>>;
|
|
2
|
+
declare const DBTooltip: React.ForwardRefExoticComponent<Omit<React.HTMLAttributes<any>, keyof import("../../shared/model").GlobalProps | "placement" | "emphasis" | keyof import("./model").DBTooltipDefaultProps | keyof import("../../shared/model").PopoverProps> & import("./model").DBTooltipDefaultProps & import("../../shared/model").GlobalProps & import("../../shared/model").EmphasisProps & import("../../shared/model").PlacementProps & import("../../shared/model").PopoverProps & React.RefAttributes<any>>;
|
|
6
3
|
export default DBTooltip;
|
|
@@ -36,7 +36,7 @@ function DBTooltipFn(props, component) {
|
|
|
36
36
|
return;
|
|
37
37
|
if (_ref.current) {
|
|
38
38
|
// This is a workaround for angular
|
|
39
|
-
utilsDelay(() => {
|
|
39
|
+
void utilsDelay(() => {
|
|
40
40
|
var _a;
|
|
41
41
|
// Due to race conditions we need to check for _ref again
|
|
42
42
|
if (_ref.current) {
|
|
@@ -70,6 +70,7 @@ function DBTooltipFn(props, component) {
|
|
|
70
70
|
if (_ref.current && initialized && _id) {
|
|
71
71
|
const parent = getParent();
|
|
72
72
|
if (parent) {
|
|
73
|
+
handleAutoPlacement(parent);
|
|
73
74
|
["mouseenter", "focusin"].forEach((event) => {
|
|
74
75
|
parent.addEventListener(event, () => handleEnter(parent));
|
|
75
76
|
});
|
package/dist/index.d.ts
CHANGED
|
@@ -77,5 +77,3 @@ export * from './utils/document-scroll-listener';
|
|
|
77
77
|
export * from './utils/floating-components';
|
|
78
78
|
export * from './utils/index';
|
|
79
79
|
export * from './utils/navigation';
|
|
80
|
-
export * from "./components/loading-indicator";
|
|
81
|
-
export * from "./components/loading-indicator/model";
|
package/dist/index.js
CHANGED
|
@@ -77,5 +77,3 @@ export * from './utils/document-scroll-listener';
|
|
|
77
77
|
export * from './utils/floating-components';
|
|
78
78
|
export * from './utils/index';
|
|
79
79
|
export * from './utils/navigation';
|
|
80
|
-
export * from "./components/loading-indicator";
|
|
81
|
-
export * from "./components/loading-indicator/model";
|
package/dist/shared/model.d.ts
CHANGED
|
@@ -158,6 +158,10 @@ export type PopoverDelayType = (typeof PopoverDelayList)[number];
|
|
|
158
158
|
export declare const PopoverWidthList: readonly ["auto", "fixed"];
|
|
159
159
|
export type PopoverWidthType = (typeof PopoverWidthList)[number];
|
|
160
160
|
export type PopoverProps = {
|
|
161
|
+
/**
|
|
162
|
+
* Add a delay before showing the tooltip
|
|
163
|
+
*/
|
|
164
|
+
delay?: PopoverDelayType;
|
|
161
165
|
/**
|
|
162
166
|
* Disable animation
|
|
163
167
|
*/
|
|
@@ -166,12 +170,6 @@ export type PopoverProps = {
|
|
|
166
170
|
* Use fixed with for default max-width
|
|
167
171
|
*/
|
|
168
172
|
width?: PopoverWidthType;
|
|
169
|
-
} & DelayProps;
|
|
170
|
-
export type DelayProps = {
|
|
171
|
-
/**
|
|
172
|
-
* Add a delay before showing the component
|
|
173
|
-
*/
|
|
174
|
-
delay?: PopoverDelayType;
|
|
175
173
|
};
|
|
176
174
|
export type NameProps = {
|
|
177
175
|
/**
|
|
@@ -228,10 +228,54 @@ export const getFloatingProps = (element, parent, placement) => {
|
|
|
228
228
|
innerHeight
|
|
229
229
|
};
|
|
230
230
|
};
|
|
231
|
+
const MAX_ANCESTOR_DEPTH = 10;
|
|
232
|
+
const ancestorCache = new WeakMap();
|
|
233
|
+
const getAncestorHasCorrectedPlacement = (element) => {
|
|
234
|
+
if (ancestorCache.has(element)) {
|
|
235
|
+
return ancestorCache.get(element);
|
|
236
|
+
}
|
|
237
|
+
let current = element.parentElement;
|
|
238
|
+
let anchor = 0;
|
|
239
|
+
while (current && anchor < MAX_ANCESTOR_DEPTH) {
|
|
240
|
+
if (current.dataset['correctedPlacement']) {
|
|
241
|
+
ancestorCache.set(element, current);
|
|
242
|
+
return current;
|
|
243
|
+
}
|
|
244
|
+
current = current.parentElement;
|
|
245
|
+
anchor += 1;
|
|
246
|
+
}
|
|
247
|
+
ancestorCache.set(element, null);
|
|
248
|
+
return null;
|
|
249
|
+
};
|
|
231
250
|
export const handleFixedPopover = (element, parent, placement) => {
|
|
232
|
-
var _a;
|
|
233
|
-
const
|
|
234
|
-
const
|
|
251
|
+
var _a, _b;
|
|
252
|
+
const parentComputedStyles = getComputedStyle(parent);
|
|
253
|
+
const parentHasFloatingPosition = ['absolute', 'fixed'].includes(parentComputedStyles.position);
|
|
254
|
+
const ancestorWithCorrectedPlacement = getAncestorHasCorrectedPlacement(element);
|
|
255
|
+
const noFloatingAncestor = !ancestorWithCorrectedPlacement && !parentHasFloatingPosition;
|
|
256
|
+
const distance = (_b = (_a = getComputedStyle(element)) === null || _a === void 0 ? void 0 : _a.getPropertyValue('--db-popover-distance')) !== null && _b !== void 0 ? _b : '0px';
|
|
257
|
+
let { top, height, width, childHeight, childWidth, right, left, bottom, correctedPlacement, innerWidth, innerHeight } = getFloatingProps(element, parent, placement);
|
|
258
|
+
if (ancestorWithCorrectedPlacement) {
|
|
259
|
+
const ancestorRect = ancestorWithCorrectedPlacement.getBoundingClientRect();
|
|
260
|
+
left = Math.abs(left - ancestorRect.left);
|
|
261
|
+
right = (width + Math.abs(right - ancestorRect.right)) * 1.5; // We add a transform -50% later
|
|
262
|
+
top = Math.abs(top - ancestorRect.top);
|
|
263
|
+
bottom = (height + Math.abs(bottom - ancestorRect.bottom)) * 1.5; // We add a transform -50% later
|
|
264
|
+
}
|
|
265
|
+
if (parentHasFloatingPosition) {
|
|
266
|
+
/*
|
|
267
|
+
* If we have a floating element inside an element with position:absolute/fixed
|
|
268
|
+
* we need to calculate with relative values
|
|
269
|
+
* */
|
|
270
|
+
left = 0;
|
|
271
|
+
right = width;
|
|
272
|
+
top = 0;
|
|
273
|
+
bottom = height;
|
|
274
|
+
if (['auto', 'inherit', '0'].includes(parentComputedStyles.zIndex)) {
|
|
275
|
+
// We need the default zIndex for floating elements on the parent
|
|
276
|
+
parent.style.zIndex = '1';
|
|
277
|
+
}
|
|
278
|
+
}
|
|
235
279
|
// Tooltip arrow position
|
|
236
280
|
if (childWidth > width && (correctedPlacement.startsWith('bottom') || correctedPlacement.startsWith('top'))) {
|
|
237
281
|
const diff = width / 2 / childWidth * 100;
|
|
@@ -241,6 +285,9 @@ export const handleFixedPopover = (element, parent, placement) => {
|
|
|
241
285
|
else if (correctedPlacement.endsWith('end')) {
|
|
242
286
|
element.style.setProperty('--db-tooltip-arrow-inline-start', `${100 - diff}%`);
|
|
243
287
|
}
|
|
288
|
+
else {
|
|
289
|
+
element.style.setProperty('--db-tooltip-arrow-inline-start', `50%`);
|
|
290
|
+
}
|
|
244
291
|
}
|
|
245
292
|
if (childHeight > height && (correctedPlacement.startsWith('left') || correctedPlacement.startsWith('bottom'))) {
|
|
246
293
|
const diff = height / 2 / childHeight * 100;
|
|
@@ -250,6 +297,9 @@ export const handleFixedPopover = (element, parent, placement) => {
|
|
|
250
297
|
else if (correctedPlacement.endsWith('end')) {
|
|
251
298
|
element.style.setProperty('--db-tooltip-arrow-block-start', `${100 - diff}%`);
|
|
252
299
|
}
|
|
300
|
+
else {
|
|
301
|
+
element.style.setProperty('--db-tooltip-arrow-block-start', `50%`);
|
|
302
|
+
}
|
|
253
303
|
}
|
|
254
304
|
// Popover position
|
|
255
305
|
if (correctedPlacement === 'right' || correctedPlacement === 'left') {
|
|
@@ -259,11 +309,11 @@ export const handleFixedPopover = (element, parent, placement) => {
|
|
|
259
309
|
else if (correctedPlacement === 'right-start' || correctedPlacement === 'left-start') {
|
|
260
310
|
const end = top + childHeight;
|
|
261
311
|
element.style.insetBlockStart = `${top}px`;
|
|
262
|
-
element.style.insetBlockEnd = `${end > innerHeight ? innerHeight : end}px`;
|
|
312
|
+
element.style.insetBlockEnd = `${!parentHasFloatingPosition && end > innerHeight ? innerHeight : end}px`;
|
|
263
313
|
}
|
|
264
314
|
else if (correctedPlacement === 'right-end' || correctedPlacement === 'left-end') {
|
|
265
315
|
const start = bottom - childHeight;
|
|
266
|
-
element.style.insetBlockStart = `${start < 0 ? 0 : start}px`;
|
|
316
|
+
element.style.insetBlockStart = `${!parentHasFloatingPosition && start < 0 ? 0 : start}px`;
|
|
267
317
|
element.style.insetBlockEnd = `${bottom}px`;
|
|
268
318
|
}
|
|
269
319
|
else if (correctedPlacement === 'top' || correctedPlacement === 'bottom') {
|
|
@@ -273,32 +323,32 @@ export const handleFixedPopover = (element, parent, placement) => {
|
|
|
273
323
|
else if (correctedPlacement === 'top-start' || correctedPlacement === 'bottom-start') {
|
|
274
324
|
const end = left + childWidth;
|
|
275
325
|
element.style.insetInlineStart = `${left}px`;
|
|
276
|
-
element.style.insetInlineEnd = `${end > innerWidth ? innerWidth : end}px`;
|
|
326
|
+
element.style.insetInlineEnd = `${!parentHasFloatingPosition && end > innerWidth ? innerWidth : end}px`;
|
|
277
327
|
}
|
|
278
328
|
else if (correctedPlacement === 'top-end' || correctedPlacement === 'bottom-end') {
|
|
279
|
-
const start =
|
|
280
|
-
element.style.insetInlineStart = `${
|
|
281
|
-
element.style.insetInlineEnd = `${
|
|
329
|
+
const start = right - childWidth;
|
|
330
|
+
element.style.insetInlineStart = `${!parentHasFloatingPosition && start < 0 ? 0 : start}px`;
|
|
331
|
+
element.style.insetInlineEnd = `${right}px`;
|
|
282
332
|
}
|
|
283
333
|
if (correctedPlacement === null || correctedPlacement === void 0 ? void 0 : correctedPlacement.startsWith('right')) {
|
|
284
334
|
const end = right + childWidth;
|
|
285
335
|
element.style.insetInlineStart = `calc(${right}px + ${distance})`;
|
|
286
|
-
element.style.insetInlineEnd = `calc(${end > innerWidth ? innerWidth : end}px + ${distance})`;
|
|
336
|
+
element.style.insetInlineEnd = `calc(${noFloatingAncestor && end > innerWidth ? innerWidth : end}px + ${distance})`;
|
|
287
337
|
}
|
|
288
338
|
else if (correctedPlacement === null || correctedPlacement === void 0 ? void 0 : correctedPlacement.startsWith('left')) {
|
|
289
339
|
const start = left - childWidth;
|
|
290
|
-
element.style.insetInlineStart = `calc(${start < 0 ? 0 : start}px - ${distance})`;
|
|
340
|
+
element.style.insetInlineStart = `calc(${noFloatingAncestor && start < 0 ? 0 : start}px - ${distance})`;
|
|
291
341
|
element.style.insetInlineEnd = `calc(${right}px - ${distance})`;
|
|
292
342
|
}
|
|
293
343
|
else if (correctedPlacement === null || correctedPlacement === void 0 ? void 0 : correctedPlacement.startsWith('top')) {
|
|
294
344
|
const start = top - childHeight;
|
|
295
|
-
element.style.insetBlockStart = `calc(${start < 0 ? 0 : start}px - ${distance})`;
|
|
296
|
-
element.style.insetBlockEnd = `calc(${bottom}px - ${distance})`;
|
|
345
|
+
element.style.insetBlockStart = `calc(${noFloatingAncestor && start < 0 ? 0 : start}px - ${distance})`;
|
|
346
|
+
element.style.insetBlockEnd = `calc(${parentHasFloatingPosition ? start : bottom}px - ${distance})`;
|
|
297
347
|
}
|
|
298
348
|
else if (correctedPlacement === null || correctedPlacement === void 0 ? void 0 : correctedPlacement.startsWith('bottom')) {
|
|
299
349
|
const end = bottom + childHeight;
|
|
300
|
-
element.style.insetBlockStart = `calc(${bottom}px + ${distance})`;
|
|
301
|
-
element.style.insetBlockEnd = `calc(${end > innerHeight ? innerHeight : end}px + ${distance})`;
|
|
350
|
+
element.style.insetBlockStart = `calc(${parentHasFloatingPosition ? end : bottom}px + ${distance})`;
|
|
351
|
+
element.style.insetBlockEnd = `calc(${noFloatingAncestor && end > innerHeight ? innerHeight : end}px + ${distance})`;
|
|
302
352
|
}
|
|
303
353
|
element.style.position = 'fixed';
|
|
304
354
|
element.dataset['correctedPlacement'] = correctedPlacement;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@db-ux/react-core-components",
|
|
3
|
-
"version": "4.4.
|
|
3
|
+
"version": "4.4.1-floating-components-066d296",
|
|
4
4
|
"description": "React components for @db-ux/core-components",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
},
|
|
42
42
|
"sideEffects": false,
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@db-ux/core-components": "4.4.
|
|
45
|
-
"@db-ux/core-foundations": "4.4.
|
|
44
|
+
"@db-ux/core-components": "4.4.1-floating-components-066d296",
|
|
45
|
+
"@db-ux/core-foundations": "4.4.1-floating-components-066d296"
|
|
46
46
|
}
|
|
47
47
|
}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { PopoverDelayType, SizeType } from '../../../shared/model';
|
|
2
|
-
import { LoadingIndicatorStateType, LoadingIndicatorVariantType } from '../model';
|
|
3
|
-
export declare const indicators: {
|
|
4
|
-
variant: LoadingIndicatorVariantType;
|
|
5
|
-
progressText: string;
|
|
6
|
-
progressTextState: string;
|
|
7
|
-
label: string;
|
|
8
|
-
}[];
|
|
9
|
-
export declare const densities: {
|
|
10
|
-
value: string;
|
|
11
|
-
name: string;
|
|
12
|
-
}[];
|
|
13
|
-
export declare const indeterminateArray: {
|
|
14
|
-
value: boolean;
|
|
15
|
-
name: string;
|
|
16
|
-
}[];
|
|
17
|
-
export declare const sizes: {
|
|
18
|
-
value: SizeType;
|
|
19
|
-
name: string;
|
|
20
|
-
}[];
|
|
21
|
-
export declare const statesArray: {
|
|
22
|
-
value: LoadingIndicatorStateType;
|
|
23
|
-
name: string;
|
|
24
|
-
}[];
|
|
25
|
-
export declare const showLabels: {
|
|
26
|
-
value: boolean;
|
|
27
|
-
name: string;
|
|
28
|
-
}[];
|
|
29
|
-
export declare const showProgressTexts: {
|
|
30
|
-
value: boolean;
|
|
31
|
-
name: string;
|
|
32
|
-
}[];
|
|
33
|
-
export declare const overlays: {
|
|
34
|
-
value: boolean;
|
|
35
|
-
name: string;
|
|
36
|
-
}[];
|
|
37
|
-
export declare const delays: {
|
|
38
|
-
value: PopoverDelayType;
|
|
39
|
-
name: string;
|
|
40
|
-
}[];
|
|
41
|
-
export declare const buttonExamples: {
|
|
42
|
-
overlay: boolean;
|
|
43
|
-
name: string;
|
|
44
|
-
}[];
|
|
45
|
-
export type TimeoutStore = {
|
|
46
|
-
loadingState: LoadingIndicatorStateType;
|
|
47
|
-
onTimeoutFn: () => void;
|
|
48
|
-
getLabel: (loadingState: LoadingIndicatorStateType | string) => string;
|
|
49
|
-
};
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
export const indicators = [{
|
|
2
|
-
variant: 'inline',
|
|
3
|
-
progressText: '42 of 100',
|
|
4
|
-
progressTextState: '100 of 100',
|
|
5
|
-
label: 'Inline'
|
|
6
|
-
}, {
|
|
7
|
-
variant: 'onsite',
|
|
8
|
-
progressText: '42%',
|
|
9
|
-
progressTextState: '100%',
|
|
10
|
-
label: 'Onsite'
|
|
11
|
-
}, {
|
|
12
|
-
variant: 'progress-bar',
|
|
13
|
-
progressText: '42 of 100',
|
|
14
|
-
progressTextState: '100 of 100',
|
|
15
|
-
label: 'Progress'
|
|
16
|
-
}];
|
|
17
|
-
export const densities = [{
|
|
18
|
-
value: 'functional',
|
|
19
|
-
name: 'Functional'
|
|
20
|
-
}, {
|
|
21
|
-
value: 'regular',
|
|
22
|
-
name: '(Default) Regular'
|
|
23
|
-
}, {
|
|
24
|
-
value: 'expressive',
|
|
25
|
-
name: 'Expressive'
|
|
26
|
-
}];
|
|
27
|
-
export const indeterminateArray = [{
|
|
28
|
-
value: true,
|
|
29
|
-
name: '(Default) True'
|
|
30
|
-
}, {
|
|
31
|
-
value: false,
|
|
32
|
-
name: 'False'
|
|
33
|
-
}];
|
|
34
|
-
export const sizes = [{
|
|
35
|
-
value: 'small',
|
|
36
|
-
name: 'Small'
|
|
37
|
-
}, {
|
|
38
|
-
value: 'medium',
|
|
39
|
-
name: '(Default) Medium'
|
|
40
|
-
}];
|
|
41
|
-
export const statesArray = [{
|
|
42
|
-
value: 'inactive',
|
|
43
|
-
name: 'Inactive'
|
|
44
|
-
}, {
|
|
45
|
-
value: 'active',
|
|
46
|
-
name: 'Active'
|
|
47
|
-
}, {
|
|
48
|
-
value: 'successful',
|
|
49
|
-
name: 'Successful'
|
|
50
|
-
}, {
|
|
51
|
-
value: 'critical',
|
|
52
|
-
name: 'Critical'
|
|
53
|
-
}];
|
|
54
|
-
export const showLabels = [{
|
|
55
|
-
value: true,
|
|
56
|
-
name: '(Default) True'
|
|
57
|
-
}, {
|
|
58
|
-
value: false,
|
|
59
|
-
name: 'False'
|
|
60
|
-
}];
|
|
61
|
-
export const showProgressTexts = [{
|
|
62
|
-
value: true,
|
|
63
|
-
name: '(Default) True'
|
|
64
|
-
}, {
|
|
65
|
-
value: false,
|
|
66
|
-
name: 'False'
|
|
67
|
-
}];
|
|
68
|
-
export const overlays = [{
|
|
69
|
-
value: false,
|
|
70
|
-
name: '(Default) False'
|
|
71
|
-
}, {
|
|
72
|
-
value: true,
|
|
73
|
-
name: 'True'
|
|
74
|
-
}];
|
|
75
|
-
export const delays = [{
|
|
76
|
-
value: 'none',
|
|
77
|
-
name: '(Default) None'
|
|
78
|
-
}, {
|
|
79
|
-
value: 'slow',
|
|
80
|
-
name: 'Slow'
|
|
81
|
-
}, {
|
|
82
|
-
value: 'fast',
|
|
83
|
-
name: 'Fast'
|
|
84
|
-
}];
|
|
85
|
-
export const buttonExamples = [{
|
|
86
|
-
overlay: false,
|
|
87
|
-
name: 'Without overlay'
|
|
88
|
-
}, {
|
|
89
|
-
overlay: true,
|
|
90
|
-
name: 'With overlay'
|
|
91
|
-
}];
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default as DBLoadingIndicator } from "./loading-indicator";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default as DBLoadingIndicator } from "./loading-indicator";
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
declare const DBLoadingIndicator: React.ForwardRefExoticComponent<Omit<React.HTMLAttributes<any>, keyof import("../..").GlobalProps | "size" | "showLabel" | keyof import("./model").DBLoadingIndicatorDefaultProps | "delay"> & import("./model").DBLoadingIndicatorDefaultProps & import("../..").GlobalProps & import("../..").SizeProps & import("../..").ShowLabelProps & import("../..").DelayProps & React.RefAttributes<any>>;
|
|
3
|
-
export default DBLoadingIndicator;
|
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import * as React from "react";
|
|
3
|
-
import { filterPassingProps, getRootProps } from "../../utils/react";
|
|
4
|
-
import { useState, useRef, useEffect, forwardRef } from "react";
|
|
5
|
-
import { DEFAULT_ID } from "../../shared/constants";
|
|
6
|
-
import { cls, delay as delayFn, getBooleanAsString, uuid } from "../../utils";
|
|
7
|
-
function DBLoadingIndicatorFn(props, component) {
|
|
8
|
-
var _a, _b;
|
|
9
|
-
props = Object.assign({ indeterminate: true, variant: "inline", size: "medium", autoDisable: true }, props);
|
|
10
|
-
const _ref = component || useRef(undefined);
|
|
11
|
-
const [_id, set_id] = useState(() => DEFAULT_ID);
|
|
12
|
-
const [_loadingState, set_loadingState] = useState(() => "inactive");
|
|
13
|
-
const [_previousLoadingState, set_previousLoadingState] = useState(() => undefined);
|
|
14
|
-
const [_style, set_style] = useState(() => ({}));
|
|
15
|
-
const [initialized, setInitialized] = useState(() => false);
|
|
16
|
-
function getPercentage() {
|
|
17
|
-
if (props.indeterminate || !props.value || !props.max) {
|
|
18
|
-
return;
|
|
19
|
-
}
|
|
20
|
-
return `${(Number(props.value) / Number(props.max)).toFixed(2)}`;
|
|
21
|
-
}
|
|
22
|
-
function getRole() {
|
|
23
|
-
if (props.role) {
|
|
24
|
-
if (props.role === "none") {
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
return props.role;
|
|
28
|
-
}
|
|
29
|
-
return "status";
|
|
30
|
-
}
|
|
31
|
-
function handleParentDisabled() {
|
|
32
|
-
if (_ref.current && props.autoDisable && initialized) {
|
|
33
|
-
let parent = _ref.current.parentElement;
|
|
34
|
-
if (parent && parent.localName === "db-loading-indicator") {
|
|
35
|
-
parent = parent.parentElement;
|
|
36
|
-
}
|
|
37
|
-
if (parent && "disabled" in parent) {
|
|
38
|
-
parent.disabled = _loadingState !== "inactive";
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
function handleParentAria(remove) {
|
|
43
|
-
if (_ref.current && _id && initialized) {
|
|
44
|
-
let parent = _ref.current.parentElement;
|
|
45
|
-
if (parent && parent.localName === "db-loading-indicator") {
|
|
46
|
-
parent = parent.parentElement;
|
|
47
|
-
}
|
|
48
|
-
if (!parent)
|
|
49
|
-
return;
|
|
50
|
-
const isButton = (parent === null || parent === void 0 ? void 0 : parent.localName) === "button";
|
|
51
|
-
if (!(isButton || props.overlay))
|
|
52
|
-
return;
|
|
53
|
-
const ariaAttribute = isButton ? "aria-labelledby" : "aria-describedby";
|
|
54
|
-
const ariaLabelledBy = parent.getAttribute(ariaAttribute);
|
|
55
|
-
let labelledByElements = ariaLabelledBy ? ariaLabelledBy.split(",") : [];
|
|
56
|
-
if (remove || _loadingState === "inactive") {
|
|
57
|
-
if (labelledByElements.includes(_id)) {
|
|
58
|
-
labelledByElements = labelledByElements.filter((elementId) => elementId !== _id);
|
|
59
|
-
if (!isButton) {
|
|
60
|
-
parent.ariaBusy = null;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
else {
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
else {
|
|
68
|
-
if (!labelledByElements.includes(_id)) {
|
|
69
|
-
labelledByElements.push(_id);
|
|
70
|
-
}
|
|
71
|
-
if (!isButton) {
|
|
72
|
-
parent.ariaBusy = _loadingState === "active" ? "true" : null;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
if (labelledByElements.length) {
|
|
76
|
-
parent.setAttribute(ariaAttribute, labelledByElements.join(","));
|
|
77
|
-
}
|
|
78
|
-
else {
|
|
79
|
-
parent.removeAttribute(ariaAttribute);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
useEffect(() => {
|
|
84
|
-
set_id(props.id || "loading-indicator-" + uuid());
|
|
85
|
-
setInitialized(true);
|
|
86
|
-
}, []);
|
|
87
|
-
useEffect(() => {
|
|
88
|
-
handleParentDisabled();
|
|
89
|
-
}, [_ref.current, initialized, props.autoDisable, _loadingState]);
|
|
90
|
-
useEffect(() => {
|
|
91
|
-
handleParentAria(false);
|
|
92
|
-
}, [_ref.current, initialized, _loadingState, props.overlay, _id]);
|
|
93
|
-
useEffect(() => {
|
|
94
|
-
if (props.onTimeout) {
|
|
95
|
-
// Not merged if as workaround for angular
|
|
96
|
-
if (_loadingState !== "inactive" &&
|
|
97
|
-
_loadingState !== _previousLoadingState) {
|
|
98
|
-
set_previousLoadingState(_loadingState);
|
|
99
|
-
void delayFn(() => {
|
|
100
|
-
if (props.onTimeout) {
|
|
101
|
-
props.onTimeout(_loadingState);
|
|
102
|
-
}
|
|
103
|
-
}, _loadingState === "active" ? 5000 : 2000);
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
}, [_loadingState, props.onTimeout]);
|
|
107
|
-
useEffect(() => {
|
|
108
|
-
if (_loadingState === props.state)
|
|
109
|
-
return;
|
|
110
|
-
if (props.state) {
|
|
111
|
-
set_loadingState(props.state);
|
|
112
|
-
}
|
|
113
|
-
else if (props.indeterminate === undefined || props.indeterminate) {
|
|
114
|
-
set_loadingState("active");
|
|
115
|
-
}
|
|
116
|
-
else {
|
|
117
|
-
set_loadingState("inactive");
|
|
118
|
-
}
|
|
119
|
-
}, [props.state]);
|
|
120
|
-
useEffect(() => {
|
|
121
|
-
if (_ref.current) {
|
|
122
|
-
if (props.delay === "slow" || props.delay === "fast") {
|
|
123
|
-
void delayFn(() => {
|
|
124
|
-
if (_ref.current) {
|
|
125
|
-
_ref.current.dataset["delay"] = "";
|
|
126
|
-
}
|
|
127
|
-
}, props.delay === "slow" ? 500 : 250);
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
}, [_ref.current, props.delay]);
|
|
131
|
-
useEffect(() => {
|
|
132
|
-
set_style({
|
|
133
|
-
"--db-loading-indicator-percentage": getPercentage(),
|
|
134
|
-
});
|
|
135
|
-
}, [props.indeterminate, props.value, props.max]);
|
|
136
|
-
useEffect(() => {
|
|
137
|
-
return () => {
|
|
138
|
-
handleParentAria(true);
|
|
139
|
-
handleParentDisabled();
|
|
140
|
-
};
|
|
141
|
-
}, []);
|
|
142
|
-
return (React.createElement("div", Object.assign({ ref: _ref }, filterPassingProps(props, ["data-icon-variant", "data-icon-variant-before", "data-icon-variant-after", "data-icon-weight", "data-icon-weight-before", "data-icon-weight-after", "data-interactive", "data-force-mobile", "data-color", "data-container-color", "data-bg-color", "data-on-bg-color", "data-color-scheme", "data-font-size", "data-headline-size", "data-divider", "data-focus", "data-font", "autoDisable", "onTimeout"]), getRootProps(props, ["data-icon-variant", "data-icon-variant-before", "data-icon-variant-after", "data-icon-weight", "data-icon-weight-before", "data-icon-weight-after", "data-interactive", "data-force-mobile", "data-color", "data-container-color", "data-bg-color", "data-on-bg-color", "data-color-scheme", "data-font-size", "data-headline-size", "data-divider", "data-focus", "data-font"]), { className: cls("db-loading-indicator", props.className), style: _style, "data-indeterminate": getBooleanAsString(props.indeterminate), "data-size": props.size, "data-variant": props.variant, "data-delay": props.delay, "data-state": _loadingState, "data-overlay": getBooleanAsString(props.overlay) }),
|
|
143
|
-
props.variant !== "progress-bar" ? (React.createElement("svg", { className: "db-loading-indicator-circle", "aria-hidden": "true", viewBox: props.variant === "inline" ? "10 10 20 20" : "32 32 64 64" },
|
|
144
|
-
React.createElement("circle", { className: "db-loading-indicator-circle-track" }),
|
|
145
|
-
React.createElement("circle", { className: "db-loading-indicator-circle-segment" }))) : null,
|
|
146
|
-
React.createElement("div", { role: getRole() },
|
|
147
|
-
React.createElement("label", { "data-show-label": getBooleanAsString(props.showLabel), id: _id },
|
|
148
|
-
props.label ? React.createElement(React.Fragment, null, props.label) : React.createElement(React.Fragment, null, props.children),
|
|
149
|
-
React.createElement("progress", { value: props.indeterminate ? undefined : (_a = props.value) !== null && _a !== void 0 ? _a : 0, max: props.indeterminate ? undefined : (_b = props.max) !== null && _b !== void 0 ? _b : 100 }, props.indeterminate ? React.createElement(React.Fragment, null, undefined) : React.createElement(React.Fragment, null, props.progressText))),
|
|
150
|
-
!props.indeterminate ? (React.createElement("span", { "aria-hidden": "true", "data-show-progress-text": getBooleanAsString(props.showProgressText) }, props.progressText)) : null)));
|
|
151
|
-
}
|
|
152
|
-
const DBLoadingIndicator = forwardRef(DBLoadingIndicatorFn);
|
|
153
|
-
export default DBLoadingIndicator;
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { DelayProps, GlobalProps, GlobalState, InitializedState, ShowLabelProps, SizeProps } from '../../shared/model';
|
|
2
|
-
export declare const LoadingIndicatorVariantList: readonly ["progress-bar", "onsite", "inline"];
|
|
3
|
-
export type LoadingIndicatorVariantType = (typeof LoadingIndicatorVariantList)[number];
|
|
4
|
-
export declare const LoadingIndicatorStateList: readonly ["inactive", "active", "successful", "critical"];
|
|
5
|
-
export type LoadingIndicatorStateType = (typeof LoadingIndicatorStateList)[number];
|
|
6
|
-
export type DBLoadingIndicatorDefaultProps = {
|
|
7
|
-
indeterminate?: boolean | string;
|
|
8
|
-
label?: string;
|
|
9
|
-
max?: number | string;
|
|
10
|
-
progressText?: string;
|
|
11
|
-
/**
|
|
12
|
-
* Enables/disables the visibility of the progressText
|
|
13
|
-
*/
|
|
14
|
-
showProgressText?: boolean | string;
|
|
15
|
-
value?: string | number;
|
|
16
|
-
overlay?: boolean | string;
|
|
17
|
-
variant?: LoadingIndicatorVariantType;
|
|
18
|
-
state?: LoadingIndicatorStateType | string;
|
|
19
|
-
/**
|
|
20
|
-
* Disable the parent component (e.g. a DBButton) when loading indicator is inside it
|
|
21
|
-
*/
|
|
22
|
-
autoDisable?: boolean | string;
|
|
23
|
-
role?: 'alert' | 'status' | 'none';
|
|
24
|
-
/**
|
|
25
|
-
* Triggers after a timeout. For "active" after 5 seconds, for "successful" and "critical" after 2 seconds
|
|
26
|
-
*/
|
|
27
|
-
onTimeout?: (state?: LoadingIndicatorStateType | string) => void;
|
|
28
|
-
};
|
|
29
|
-
export type DBLoadingIndicatorProps = DBLoadingIndicatorDefaultProps & GlobalProps & SizeProps & ShowLabelProps & DelayProps;
|
|
30
|
-
export type DBLoadingIndicatorDefaultState = {
|
|
31
|
-
_loadingState?: LoadingIndicatorStateType | string;
|
|
32
|
-
_previousLoadingState?: LoadingIndicatorStateType | string;
|
|
33
|
-
_style: any;
|
|
34
|
-
getPercentage: () => string | undefined;
|
|
35
|
-
getRole: () => string | undefined;
|
|
36
|
-
handleParentAria: (remove: boolean) => void;
|
|
37
|
-
handleParentDisabled: () => void;
|
|
38
|
-
};
|
|
39
|
-
export type DBLoadingIndicatorState = DBLoadingIndicatorDefaultState & GlobalState & InitializedState;
|