@db-ux/react-core-components 4.11.1 → 4.12.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.
- package/CHANGELOG.md +23 -0
- package/dist/components/accordion/accordion.d.ts +1 -1
- package/dist/components/accordion/accordion.js +83 -102
- package/dist/components/accordion/index.d.ts +1 -1
- package/dist/components/accordion/index.js +1 -0
- package/dist/components/accordion/model.d.ts +2 -2
- package/dist/components/accordion/model.js +2 -4
- package/dist/components/accordion-item/accordion-item.d.ts +2 -2
- package/dist/components/accordion-item/accordion-item.js +56 -89
- package/dist/components/accordion-item/index.d.ts +1 -1
- package/dist/components/accordion-item/index.js +1 -0
- package/dist/components/accordion-item/model.d.ts +1 -1
- package/dist/components/accordion-item/model.js +1 -0
- package/dist/components/badge/badge.d.ts +1 -1
- package/dist/components/badge/badge.js +28 -72
- package/dist/components/badge/index.d.ts +1 -1
- package/dist/components/badge/index.js +1 -0
- package/dist/components/badge/model.d.ts +1 -1
- package/dist/components/badge/model.js +1 -12
- package/dist/components/brand/brand.d.ts +1 -1
- package/dist/components/brand/brand.js +10 -60
- package/dist/components/brand/index.d.ts +1 -1
- package/dist/components/brand/index.js +1 -0
- package/dist/components/brand/model.d.ts +1 -1
- package/dist/components/brand/model.js +1 -0
- package/dist/components/button/button.d.ts +1 -1
- package/dist/components/button/button.js +19 -75
- package/dist/components/button/index.d.ts +1 -1
- package/dist/components/button/index.js +1 -0
- package/dist/components/button/model.d.ts +1 -1
- package/dist/components/button/model.js +2 -13
- package/dist/components/card/card.d.ts +1 -1
- package/dist/components/card/card.js +14 -65
- package/dist/components/card/index.d.ts +1 -1
- package/dist/components/card/index.js +1 -0
- package/dist/components/card/model.d.ts +1 -1
- package/dist/components/card/model.js +2 -8
- package/dist/components/checkbox/checkbox.d.ts +1 -1
- package/dist/components/checkbox/checkbox.js +143 -163
- package/dist/components/checkbox/index.d.ts +1 -1
- package/dist/components/checkbox/index.js +1 -0
- package/dist/components/checkbox/model.d.ts +1 -1
- package/dist/components/checkbox/model.js +1 -0
- package/dist/components/custom-button/custom-button.d.ts +1 -1
- package/dist/components/custom-button/custom-button.js +10 -65
- package/dist/components/custom-button/index.d.ts +1 -1
- package/dist/components/custom-button/index.js +1 -0
- package/dist/components/custom-button/model.d.ts +2 -2
- package/dist/components/custom-button/model.js +1 -0
- package/dist/components/custom-select/custom-select.d.ts +1 -1
- package/dist/components/custom-select/custom-select.js +688 -509
- package/dist/components/custom-select/index.d.ts +1 -1
- package/dist/components/custom-select/index.js +1 -0
- package/dist/components/custom-select/model.d.ts +4 -4
- package/dist/components/custom-select/model.js +1 -8
- package/dist/components/custom-select-dropdown/custom-select-dropdown.d.ts +1 -1
- package/dist/components/custom-select-dropdown/custom-select-dropdown.js +10 -62
- package/dist/components/custom-select-dropdown/index.d.ts +1 -1
- package/dist/components/custom-select-dropdown/index.js +1 -0
- package/dist/components/custom-select-dropdown/model.d.ts +1 -1
- package/dist/components/custom-select-dropdown/model.js +1 -8
- package/dist/components/custom-select-form-field/custom-select-form-field.d.ts +1 -1
- package/dist/components/custom-select-form-field/custom-select-form-field.js +9 -57
- package/dist/components/custom-select-form-field/index.d.ts +1 -1
- package/dist/components/custom-select-form-field/index.js +1 -0
- package/dist/components/custom-select-form-field/model.d.ts +1 -1
- package/dist/components/custom-select-form-field/model.js +1 -0
- package/dist/components/custom-select-list/custom-select-list.d.ts +1 -1
- package/dist/components/custom-select-list/custom-select-list.js +9 -60
- package/dist/components/custom-select-list/index.d.ts +1 -1
- package/dist/components/custom-select-list/index.js +1 -0
- package/dist/components/custom-select-list/model.d.ts +1 -1
- package/dist/components/custom-select-list/model.js +1 -0
- package/dist/components/custom-select-list-item/custom-select-list-item.d.ts +2 -2
- package/dist/components/custom-select-list-item/custom-select-list-item.js +28 -89
- package/dist/components/custom-select-list-item/index.d.ts +1 -1
- package/dist/components/custom-select-list-item/index.js +1 -0
- package/dist/components/custom-select-list-item/model.d.ts +1 -1
- package/dist/components/custom-select-list-item/model.js +1 -4
- package/dist/components/divider/divider.d.ts +1 -1
- package/dist/components/divider/divider.js +9 -60
- package/dist/components/divider/index.d.ts +1 -1
- package/dist/components/divider/index.js +1 -0
- package/dist/components/divider/model.d.ts +1 -1
- package/dist/components/divider/model.js +2 -4
- package/dist/components/drawer/drawer.d.ts +2 -2
- package/dist/components/drawer/drawer.js +109 -118
- package/dist/components/drawer/index.d.ts +1 -1
- package/dist/components/drawer/index.js +1 -0
- package/dist/components/drawer/model.d.ts +4 -1
- package/dist/components/drawer/model.js +4 -14
- package/dist/components/header/header.d.ts +1 -1
- package/dist/components/header/header.js +43 -143
- package/dist/components/header/index.d.ts +1 -1
- package/dist/components/header/index.js +1 -0
- package/dist/components/header/model.d.ts +1 -1
- package/dist/components/header/model.js +1 -0
- package/dist/components/icon/icon.d.ts +1 -1
- package/dist/components/icon/icon.js +9 -61
- package/dist/components/icon/index.d.ts +1 -1
- package/dist/components/icon/index.js +1 -0
- package/dist/components/icon/model.d.ts +1 -1
- package/dist/components/icon/model.js +1 -11
- package/dist/components/infotext/index.d.ts +1 -1
- package/dist/components/infotext/index.js +1 -0
- package/dist/components/infotext/infotext.d.ts +1 -1
- package/dist/components/infotext/infotext.js +9 -62
- package/dist/components/infotext/model.d.ts +1 -1
- package/dist/components/infotext/model.js +1 -0
- package/dist/components/input/index.d.ts +1 -1
- package/dist/components/input/index.js +1 -0
- package/dist/components/input/input.d.ts +1 -1
- package/dist/components/input/input.js +154 -198
- package/dist/components/input/model.d.ts +1 -1
- package/dist/components/input/model.js +5 -21
- package/dist/components/link/index.d.ts +1 -1
- package/dist/components/link/index.js +1 -0
- package/dist/components/link/link.d.ts +1 -1
- package/dist/components/link/link.js +9 -70
- package/dist/components/link/model.d.ts +1 -1
- package/dist/components/link/model.js +3 -8
- package/dist/components/navigation/index.d.ts +1 -1
- package/dist/components/navigation/index.js +1 -0
- package/dist/components/navigation/model.d.ts +1 -1
- package/dist/components/navigation/model.js +1 -0
- package/dist/components/navigation/navigation.d.ts +1 -1
- package/dist/components/navigation/navigation.js +9 -57
- package/dist/components/navigation-item/index.d.ts +1 -1
- package/dist/components/navigation-item/index.js +1 -0
- package/dist/components/navigation-item/model.d.ts +2 -2
- package/dist/components/navigation-item/model.js +1 -0
- package/dist/components/navigation-item/navigation-item.d.ts +1 -1
- package/dist/components/navigation-item/navigation-item.js +71 -117
- package/dist/components/notification/index.d.ts +1 -1
- package/dist/components/notification/index.js +1 -0
- package/dist/components/notification/model.d.ts +1 -1
- package/dist/components/notification/model.js +3 -12
- package/dist/components/notification/notification.d.ts +2 -2
- package/dist/components/notification/notification.js +23 -100
- package/dist/components/page/index.d.ts +1 -1
- package/dist/components/page/index.js +1 -0
- package/dist/components/page/model.d.ts +1 -1
- package/dist/components/page/model.js +2 -4
- package/dist/components/page/page.d.ts +1 -1
- package/dist/components/page/page.js +42 -74
- package/dist/components/popover/index.d.ts +1 -1
- package/dist/components/popover/index.js +1 -0
- package/dist/components/popover/model.d.ts +1 -1
- package/dist/components/popover/model.js +1 -0
- package/dist/components/popover/popover.d.ts +1 -1
- package/dist/components/popover/popover.js +119 -126
- package/dist/components/radio/index.d.ts +1 -1
- package/dist/components/radio/index.js +1 -0
- package/dist/components/radio/model.d.ts +1 -1
- package/dist/components/radio/model.js +1 -0
- package/dist/components/radio/radio.d.ts +1 -1
- package/dist/components/radio/radio.js +86 -124
- package/dist/components/section/index.d.ts +1 -1
- package/dist/components/section/index.js +1 -0
- package/dist/components/section/model.d.ts +1 -1
- package/dist/components/section/model.js +1 -0
- package/dist/components/section/section.d.ts +1 -1
- package/dist/components/section/section.js +9 -59
- package/dist/components/select/index.d.ts +1 -1
- package/dist/components/select/index.js +1 -0
- package/dist/components/select/model.d.ts +1 -1
- package/dist/components/select/model.js +1 -0
- package/dist/components/select/select.d.ts +1 -1
- package/dist/components/select/select.js +172 -188
- package/dist/components/stack/index.d.ts +1 -1
- package/dist/components/stack/index.js +1 -0
- package/dist/components/stack/model.d.ts +1 -1
- package/dist/components/stack/model.js +4 -14
- package/dist/components/stack/stack.d.ts +1 -1
- package/dist/components/stack/stack.js +9 -63
- package/dist/components/switch/index.d.ts +1 -1
- package/dist/components/switch/index.js +1 -0
- package/dist/components/switch/model.d.ts +1 -1
- package/dist/components/switch/model.js +1 -0
- package/dist/components/switch/switch.d.ts +1 -1
- package/dist/components/switch/switch.js +135 -182
- package/dist/components/tab-item/index.d.ts +1 -1
- package/dist/components/tab-item/index.js +1 -0
- package/dist/components/tab-item/model.d.ts +1 -1
- package/dist/components/tab-item/model.js +1 -0
- package/dist/components/tab-item/tab-item.d.ts +1 -1
- package/dist/components/tab-item/tab-item.js +72 -105
- package/dist/components/tab-list/index.d.ts +1 -1
- package/dist/components/tab-list/index.js +1 -0
- package/dist/components/tab-list/model.d.ts +1 -1
- package/dist/components/tab-list/model.js +1 -0
- package/dist/components/tab-list/tab-list.d.ts +1 -1
- package/dist/components/tab-list/tab-list.js +9 -60
- package/dist/components/tab-panel/index.d.ts +1 -1
- package/dist/components/tab-panel/index.js +1 -0
- package/dist/components/tab-panel/model.d.ts +1 -1
- package/dist/components/tab-panel/model.js +1 -0
- package/dist/components/tab-panel/tab-panel.d.ts +1 -1
- package/dist/components/tab-panel/tab-panel.js +10 -59
- package/dist/components/table/examples/data.d.ts +1 -1
- package/dist/components/table/examples/data.js +258 -0
- package/dist/components/table/index.d.ts +1 -1
- package/dist/components/table/index.js +1 -0
- package/dist/components/table/model.d.ts +2 -2
- package/dist/components/table/model.js +6 -28
- package/dist/components/table/table.d.ts +1 -1
- package/dist/components/table/table.js +77 -111
- package/dist/components/table-body/index.d.ts +1 -1
- package/dist/components/table-body/index.js +1 -0
- package/dist/components/table-body/model.d.ts +2 -2
- package/dist/components/table-body/model.js +1 -0
- package/dist/components/table-body/table-body.d.ts +1 -1
- package/dist/components/table-body/table-body.js +12 -64
- package/dist/components/table-caption/index.d.ts +1 -1
- package/dist/components/table-caption/index.js +1 -0
- package/dist/components/table-caption/model.d.ts +1 -1
- package/dist/components/table-caption/model.js +1 -0
- package/dist/components/table-caption/table-caption.d.ts +1 -1
- package/dist/components/table-caption/table-caption.js +9 -57
- package/dist/components/table-data-cell/index.d.ts +1 -1
- package/dist/components/table-data-cell/index.js +1 -0
- package/dist/components/table-data-cell/model.d.ts +1 -1
- package/dist/components/table-data-cell/model.js +1 -0
- package/dist/components/table-data-cell/table-data-cell.d.ts +1 -1
- package/dist/components/table-data-cell/table-data-cell.js +9 -62
- package/dist/components/table-footer/index.d.ts +1 -1
- package/dist/components/table-footer/index.js +1 -0
- package/dist/components/table-footer/model.d.ts +2 -2
- package/dist/components/table-footer/model.js +1 -0
- package/dist/components/table-footer/table-footer.d.ts +1 -1
- package/dist/components/table-footer/table-footer.js +12 -64
- package/dist/components/table-head/index.d.ts +1 -1
- package/dist/components/table-head/index.js +1 -0
- package/dist/components/table-head/model.d.ts +2 -2
- package/dist/components/table-head/model.js +1 -0
- package/dist/components/table-head/table-head.d.ts +1 -1
- package/dist/components/table-head/table-head.js +18 -71
- package/dist/components/table-header-cell/index.d.ts +1 -1
- package/dist/components/table-header-cell/index.js +1 -0
- package/dist/components/table-header-cell/model.d.ts +1 -1
- package/dist/components/table-header-cell/model.js +1 -9
- package/dist/components/table-header-cell/table-header-cell.d.ts +1 -1
- package/dist/components/table-header-cell/table-header-cell.js +9 -65
- package/dist/components/table-row/index.d.ts +1 -1
- package/dist/components/table-row/index.js +1 -0
- package/dist/components/table-row/model.d.ts +4 -4
- package/dist/components/table-row/model.js +1 -8
- package/dist/components/table-row/table-row.d.ts +1 -1
- package/dist/components/table-row/table-row.js +20 -127
- package/dist/components/tabs/index.d.ts +1 -1
- package/dist/components/tabs/index.js +1 -0
- package/dist/components/tabs/model.d.ts +3 -3
- package/dist/components/tabs/model.js +2 -4
- package/dist/components/tabs/tabs.d.ts +1 -1
- package/dist/components/tabs/tabs.js +170 -191
- package/dist/components/tag/index.d.ts +1 -1
- package/dist/components/tag/index.js +1 -0
- package/dist/components/tag/model.d.ts +1 -1
- package/dist/components/tag/model.js +1 -4
- package/dist/components/tag/tag.d.ts +1 -1
- package/dist/components/tag/tag.js +26 -91
- package/dist/components/textarea/index.d.ts +1 -1
- package/dist/components/textarea/index.js +1 -0
- package/dist/components/textarea/model.d.ts +1 -1
- package/dist/components/textarea/model.js +2 -13
- package/dist/components/textarea/textarea.d.ts +1 -1
- package/dist/components/textarea/textarea.js +139 -165
- package/dist/components/tooltip/index.d.ts +1 -1
- package/dist/components/tooltip/index.js +1 -0
- package/dist/components/tooltip/model.d.ts +1 -1
- package/dist/components/tooltip/model.js +1 -4
- package/dist/components/tooltip/tooltip.d.ts +1 -1
- package/dist/components/tooltip/tooltip.js +197 -160
- package/dist/index.d.ts +97 -97
- package/dist/index.js +97 -75
- package/dist/shared/constants.js +100 -32
- package/dist/shared/examples/index.js +4 -0
- package/dist/shared/figma.js +1 -0
- package/dist/shared/model.js +22 -77
- package/dist/shared/showcase/show-code-link.js +51 -0
- package/dist/utils/document-click-listener.js +29 -26
- package/dist/utils/document-scroll-listener.js +38 -30
- package/dist/utils/floating-components.js +404 -107
- package/dist/utils/form-components.js +71 -34
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.js +170 -49
- package/dist/utils/navigation.js +134 -68
- package/dist/utils/react.js +21 -10
- package/package.json +6 -9
|
@@ -1,35 +1,72 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
+
import { delay } from './index.js';
|
|
3
|
+
const specialNumberCharacters = ['.', ',', 'e', 'E', '+', '-'];
|
|
4
|
+
export const handleFrameworkEventAngular = (component, event, modelValue = 'value', lastValue) => {
|
|
5
|
+
const value = event.target[modelValue];
|
|
6
|
+
const type = event.target?.type;
|
|
7
|
+
if (!value && value !== '' && ['date', 'time', 'week', 'month', 'datetime-local'].includes(type)) {
|
|
8
|
+
// If value is empty and type date we skip `writingValue` function
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
if (type === 'number') {
|
|
12
|
+
if (event.type === 'input') {
|
|
13
|
+
if (specialNumberCharacters.includes(event.data) || specialNumberCharacters.some(specialCharacter => lastValue?.toString().includes(specialCharacter)) && event.inputType === 'deleteContentBackward') {
|
|
14
|
+
// Skip `writingValue` function if number type and input event
|
|
15
|
+
// and `.` or `,` or 'e', 'E', '+', '-' was typed
|
|
16
|
+
// or content was deleted but last number had a `.`
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
else if (event.type === 'change') {
|
|
21
|
+
// Skip `writingValue` function if number type and change event
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
component.propagateChange(value);
|
|
26
|
+
component.writeValue(value);
|
|
27
|
+
};
|
|
28
|
+
export const handleFrameworkEventVue = (emit, event, modelValue = 'value') => {
|
|
29
|
+
// TODO: Replace this with the solution out of https://github.com/BuilderIO/mitosis/issues/833 after this has been "solved"
|
|
30
|
+
emit(`update:${modelValue}`, event.target[modelValue]);
|
|
31
|
+
};
|
|
32
|
+
export const addResetEventListener = (element, resetFunction, signal) => {
|
|
33
|
+
if (element.form && !element._dbFormResetListenerAdded) {
|
|
34
|
+
element.form.addEventListener('reset', (event) => {
|
|
35
|
+
resetFunction(event);
|
|
36
|
+
}, {
|
|
37
|
+
signal
|
|
38
|
+
});
|
|
39
|
+
// Mark as added to avoid duplicate listeners
|
|
40
|
+
element._dbFormResetListenerAdded = true;
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
export const addCheckedResetEventListener = (element, props, resetFunction, signal) => {
|
|
44
|
+
addResetEventListener(element, (event) => {
|
|
45
|
+
void delay(() => {
|
|
46
|
+
const resetValue = props.checked ? props.checked : props.defaultChecked ? props.defaultChecked : element.checked;
|
|
47
|
+
const valueEvent = {
|
|
48
|
+
...event,
|
|
49
|
+
target: {
|
|
50
|
+
...event.target,
|
|
51
|
+
checked: resetValue
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
resetFunction(valueEvent);
|
|
55
|
+
}, 1);
|
|
56
|
+
}, signal);
|
|
57
|
+
};
|
|
58
|
+
export const addValueResetEventListener = (element, props, resetFunction, signal) => {
|
|
59
|
+
addResetEventListener(element, (event) => {
|
|
60
|
+
void delay(() => {
|
|
61
|
+
const resetValue = props.value ? props.value : props.defaultValue ? props.defaultValue : element.value;
|
|
62
|
+
const valueEvent = {
|
|
63
|
+
...event,
|
|
64
|
+
target: {
|
|
65
|
+
...event.target,
|
|
66
|
+
value: resetValue
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
resetFunction(valueEvent);
|
|
70
|
+
}, 1);
|
|
71
|
+
}, signal);
|
|
33
72
|
};
|
|
34
|
-
//#endregion
|
|
35
|
-
export { n as addCheckedResetEventListener, t as addResetEventListener, r as addValueResetEventListener };
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ClickEvent, GeneralKeyboardEvent } from '../shared/model';
|
|
1
|
+
import { ClickEvent, GeneralKeyboardEvent } from '../shared/model.js';
|
|
2
2
|
export declare const uuid: () => string;
|
|
3
3
|
export declare const addAttributeToChildren: (element: Element, attribute: {
|
|
4
4
|
key: string;
|
package/dist/utils/index.js
CHANGED
|
@@ -1,49 +1,170 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
1
|
+
export const uuid = () => {
|
|
2
|
+
if (typeof window !== 'undefined') {
|
|
3
|
+
if (window.crypto?.randomUUID) {
|
|
4
|
+
return window.crypto.randomUUID();
|
|
5
|
+
}
|
|
6
|
+
else if (window.crypto?.getRandomValues) {
|
|
7
|
+
return window.crypto.getRandomValues(new Uint32Array(3)).join('-');
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
return Math.random().toString().substring(2);
|
|
11
|
+
};
|
|
12
|
+
export const addAttributeToChildren = (element, attribute) => {
|
|
13
|
+
const children = element.children;
|
|
14
|
+
Object.values(children).forEach((child) => {
|
|
15
|
+
child.setAttribute(attribute.key, attribute.value);
|
|
16
|
+
if (child.children.length > 0) {
|
|
17
|
+
addAttributeToChildren(child, attribute);
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
export const cls = (...args) => {
|
|
22
|
+
let result = '';
|
|
23
|
+
for (const arg of args) {
|
|
24
|
+
if (arg) {
|
|
25
|
+
if (typeof arg === 'string') {
|
|
26
|
+
result += `${arg} `;
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
for (const key in arg) {
|
|
30
|
+
if (arg[key]) {
|
|
31
|
+
result += `${key} `;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return result.trim();
|
|
38
|
+
};
|
|
39
|
+
export const isArrayOfStrings = (value) => Array.isArray(value) && value.every(item => typeof item === 'string');
|
|
40
|
+
const appleOs = ['Mac', 'iPhone', 'iPad', 'iPod'];
|
|
41
|
+
export const hasVoiceOver = () => typeof window !== 'undefined' && appleOs.some(os => window.navigator.userAgent.includes(os));
|
|
42
|
+
/**
|
|
43
|
+
* Determines if the current browser is Safari running on an iOS device.
|
|
44
|
+
*
|
|
45
|
+
* This function checks the user agent string to verify both iOS platform
|
|
46
|
+
* (iPad, iPhone, or iPod) and Safari browser, excluding other browsers
|
|
47
|
+
* such as Chrome, Firefox, Opera, and Edge on iOS.
|
|
48
|
+
*
|
|
49
|
+
* @returns {boolean} `true` if the browser is Safari on iOS, otherwise `false`.
|
|
50
|
+
*/
|
|
51
|
+
export const isIOSSafari = () => {
|
|
52
|
+
if (typeof window === 'undefined' || typeof navigator === 'undefined')
|
|
53
|
+
return false;
|
|
54
|
+
const ua = navigator.userAgent;
|
|
55
|
+
// iOS detection
|
|
56
|
+
const isIOS = /iP(ad|hone|od)/.test(ua);
|
|
57
|
+
// Safari detection (not Chrome or Firefox on iOS)
|
|
58
|
+
const isSafari = !!ua.match(/Safari/) && !ua.match(/CriOS|FxiOS|OPiOS|EdgiOS/);
|
|
59
|
+
return isIOS && isSafari;
|
|
60
|
+
};
|
|
61
|
+
export const delay = (fn, ms) => new Promise(() => setTimeout(fn, ms));
|
|
62
|
+
/**
|
|
63
|
+
* Converts boolean-like inputs to "true" or "false" strings.
|
|
64
|
+
* Handles HTML-style boolean attributes where an empty string or the
|
|
65
|
+
* attribute's own name as value (e.g. noText="noText") should be treated as true.
|
|
66
|
+
* Some frameworks like Stencil do not add "true" as value for a prop
|
|
67
|
+
* if it is used in a framework like Angular e.g.: [disabled]="myDisabledProp"
|
|
68
|
+
* @param originBool Boolean or string value to convert
|
|
69
|
+
* @param propertyName The prop/attribute name — when originBool is a string equal
|
|
70
|
+
* to this name (case-insensitive), it is treated as true
|
|
71
|
+
*/
|
|
72
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
73
|
+
export const getBooleanAsString = (originBool, propertyName) => {
|
|
74
|
+
if (originBool === undefined || originBool === null)
|
|
75
|
+
return;
|
|
76
|
+
if (typeof originBool === 'string') {
|
|
77
|
+
return String(originBool === '' || originBool === 'true' || propertyName?.toLowerCase() === originBool.toLowerCase());
|
|
78
|
+
}
|
|
79
|
+
return String(originBool);
|
|
80
|
+
};
|
|
81
|
+
export const getBoolean = (originBool, propertyName) => {
|
|
82
|
+
if (originBool === undefined || originBool === null)
|
|
83
|
+
return;
|
|
84
|
+
if (typeof originBool === 'string') {
|
|
85
|
+
return Boolean(originBool === '' || originBool === 'true' || propertyName?.toLowerCase() === originBool.toLowerCase());
|
|
86
|
+
}
|
|
87
|
+
return Boolean(originBool);
|
|
88
|
+
};
|
|
89
|
+
export const getNumber = (originNumber, alternativeNumber) => {
|
|
90
|
+
if ((originNumber === undefined || originNumber === null) && (alternativeNumber === undefined || alternativeNumber === null)) {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
return Number(originNumber ?? alternativeNumber);
|
|
94
|
+
};
|
|
95
|
+
/**
|
|
96
|
+
* Retrieves the step value for an input element.
|
|
97
|
+
*
|
|
98
|
+
* The step attribute can be a number or the special string "any".
|
|
99
|
+
* https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/step
|
|
100
|
+
*
|
|
101
|
+
* @param step - The step value, which can be a number, string, or undefined.
|
|
102
|
+
* @returns The step value as a number or the string "any", or undefined.
|
|
103
|
+
*/
|
|
104
|
+
export const getStep = (step) => {
|
|
105
|
+
if (step === undefined || step === null) {
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
if (step === 'any') {
|
|
109
|
+
return 'any';
|
|
110
|
+
}
|
|
111
|
+
return Number(step);
|
|
112
|
+
};
|
|
113
|
+
/**
|
|
114
|
+
* Retrieves the input value based on the provided value and input type.
|
|
115
|
+
*
|
|
116
|
+
* If the input type is "number" or "range", the value is processed as a number.
|
|
117
|
+
* Otherwise, the value is returned as-is.
|
|
118
|
+
*
|
|
119
|
+
* @param value - The input value, which can be a number, string, or undefined.
|
|
120
|
+
* @param inputType - The type of the input, such as "number", "range", or other string types.
|
|
121
|
+
* @returns The processed input value as a string, number, or undefined.
|
|
122
|
+
*/
|
|
123
|
+
export const getInputValue = (value, inputType) => {
|
|
124
|
+
return inputType && ['number', 'range'].includes(inputType) ? getNumber(value) : value;
|
|
125
|
+
};
|
|
126
|
+
const toBool = (value) => typeof value === 'string' ? value !== 'false' : value;
|
|
127
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
128
|
+
export const getHideProp = (show) => {
|
|
129
|
+
if (show === undefined || show === null) {
|
|
130
|
+
return undefined;
|
|
131
|
+
}
|
|
132
|
+
return getBooleanAsString(!toBool(show), 'show');
|
|
133
|
+
};
|
|
134
|
+
export const stringPropVisible = (givenString, showString) => {
|
|
135
|
+
if (showString === undefined) {
|
|
136
|
+
return !!givenString;
|
|
137
|
+
}
|
|
138
|
+
return toBool(showString) && Boolean(givenString);
|
|
139
|
+
};
|
|
140
|
+
export const getSearchInput = (element) => element.querySelector(`input[type="search"]`);
|
|
141
|
+
export const getOptionKey = (option, prefix) => {
|
|
142
|
+
const key = option.id ?? option.value ?? uuid();
|
|
143
|
+
return `${prefix}${key}`;
|
|
144
|
+
};
|
|
145
|
+
export const isKeyboardEvent = (event) => event.key !== undefined;
|
|
146
|
+
/**
|
|
147
|
+
* Maps semantic values to appropriate ARIA roles for notifications
|
|
148
|
+
* @param semantic - The semantic type of the notification
|
|
149
|
+
* @param role - The aria role of the notification
|
|
150
|
+
* @param ariaLive - The aria-live of the notification
|
|
151
|
+
* @returns The appropriate ARIA role or undefined for default behavior
|
|
152
|
+
*/
|
|
153
|
+
export const getNotificationRole = ({ semantic, role, ariaLive }) => {
|
|
154
|
+
if (role) {
|
|
155
|
+
return role;
|
|
156
|
+
}
|
|
157
|
+
if (ariaLive) {
|
|
158
|
+
return 'article';
|
|
159
|
+
}
|
|
160
|
+
switch (semantic) {
|
|
161
|
+
case 'critical':
|
|
162
|
+
case 'warning':
|
|
163
|
+
return 'alert';
|
|
164
|
+
case 'informational':
|
|
165
|
+
case 'successful':
|
|
166
|
+
return 'status';
|
|
167
|
+
default:
|
|
168
|
+
return 'article';
|
|
169
|
+
}
|
|
170
|
+
};
|
package/dist/utils/navigation.js
CHANGED
|
@@ -1,69 +1,135 @@
|
|
|
1
|
-
import { handleDataOutside
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
1
|
+
import { handleDataOutside } from './floating-components.js';
|
|
2
|
+
export const isEventTargetNavigationItem = (event) => {
|
|
3
|
+
const { target } = event;
|
|
4
|
+
return Boolean(!target?.classList?.contains('db-navigation-item-expand-button') && target?.parentElement?.classList.contains('db-navigation-item'));
|
|
5
|
+
};
|
|
6
|
+
export class NavigationItemSafeTriangle {
|
|
7
|
+
element;
|
|
8
|
+
subNavigation;
|
|
9
|
+
parentSubNavigation = null;
|
|
10
|
+
triangleData;
|
|
11
|
+
initialized = false;
|
|
12
|
+
mouseX = 0;
|
|
13
|
+
mouseY = 0;
|
|
14
|
+
constructor(element, subNavigation) {
|
|
15
|
+
this.element = element;
|
|
16
|
+
this.subNavigation = subNavigation;
|
|
17
|
+
if (!this.element || !this.subNavigation) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
this.parentSubNavigation = this.element?.closest('.db-sub-navigation');
|
|
21
|
+
/*
|
|
22
|
+
* only initiate if:
|
|
23
|
+
* 1. item is not at root navigation level
|
|
24
|
+
* 2. item is not in the mobile navigation / within db-drawer
|
|
25
|
+
*/
|
|
26
|
+
if (this.parentSubNavigation && !this.element.closest('.db-drawer')) {
|
|
27
|
+
this.init();
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
init() {
|
|
31
|
+
const parentElementWidth = this.parentSubNavigation?.getBoundingClientRect().width ?? 0;
|
|
32
|
+
// the triangle has the width of the sub-navigation, current nav-item can be wider.
|
|
33
|
+
// so the width of the triangle must be adapted to a possibly wider nav-item.
|
|
34
|
+
this.element?.style.setProperty('--db-navigation-item-inline-size', `${parentElementWidth}px`);
|
|
35
|
+
this.initialized = true;
|
|
36
|
+
}
|
|
37
|
+
enableFollow() {
|
|
38
|
+
if (!this.initialized || this.triangleData || !this.element || !this.subNavigation) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
const dataOutsidePair = handleDataOutside(this.subNavigation);
|
|
42
|
+
const itemRect = this.element.getBoundingClientRect();
|
|
43
|
+
const parentElementWidth = this.parentSubNavigation?.getBoundingClientRect().width ?? 0;
|
|
44
|
+
this.triangleData = {
|
|
45
|
+
itemRect,
|
|
46
|
+
parentElementWidth,
|
|
47
|
+
subNavigationHeight: this.subNavigation.getBoundingClientRect().height,
|
|
48
|
+
padding: (parentElementWidth - itemRect.width) / 2,
|
|
49
|
+
outsideVX: dataOutsidePair.vx,
|
|
50
|
+
outsideVY: dataOutsidePair.vy
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
disableFollow() {
|
|
54
|
+
this.triangleData = undefined;
|
|
55
|
+
}
|
|
56
|
+
getTriangleTipX() {
|
|
57
|
+
if (!this.triangleData)
|
|
58
|
+
return 0;
|
|
59
|
+
if (this.triangleData.outsideVX === 'right') {
|
|
60
|
+
// vertical flipped triangle needs an inverted x pos
|
|
61
|
+
return this.triangleData.itemRect.width - this.mouseX;
|
|
62
|
+
}
|
|
63
|
+
// triangle stops shrinking from 75% x pos
|
|
64
|
+
return Math.min(this.mouseX, this.triangleData.itemRect.width * 0.75);
|
|
65
|
+
}
|
|
66
|
+
getTriangleTipY() {
|
|
67
|
+
if (!this.triangleData)
|
|
68
|
+
return 0;
|
|
69
|
+
// padding must be added to the y pos of the tip so that the y pos matches the cursor
|
|
70
|
+
const mouseYLimited = Math.max(Math.min(this.mouseY, this.triangleData.itemRect.height), 0) + this.triangleData.padding;
|
|
71
|
+
if (this.triangleData.outsideVY === 'bottom') {
|
|
72
|
+
// add offset to tip y pos to match corrected sub-navigation y pos
|
|
73
|
+
return mouseYLimited + (this.triangleData.subNavigationHeight - this.triangleData.padding * 2 - this.triangleData.itemRect.height);
|
|
74
|
+
}
|
|
75
|
+
return mouseYLimited;
|
|
76
|
+
}
|
|
77
|
+
hasMouseEnteredSubNavigation() {
|
|
78
|
+
if (!this.triangleData) {
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
const isSubNavigationOnLeftSide = this.triangleData.outsideVX === 'right';
|
|
82
|
+
if (isSubNavigationOnLeftSide && this.mouseX < -1 * this.triangleData.padding) {
|
|
83
|
+
return true;
|
|
84
|
+
}
|
|
85
|
+
if (!isSubNavigationOnLeftSide && this.mouseX > this.triangleData.parentElementWidth - this.triangleData.padding) {
|
|
86
|
+
return true;
|
|
87
|
+
}
|
|
88
|
+
return false;
|
|
89
|
+
}
|
|
90
|
+
getTriangleCoordinates(variant) {
|
|
91
|
+
if (!this.triangleData) {
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
if (variant === 'fill-gap') {
|
|
95
|
+
const itemHeight = `${this.triangleData.itemRect.height + 2 * this.triangleData.padding}px`;
|
|
96
|
+
const xStart = `${this.triangleData.parentElementWidth - this.triangleData.padding}px`;
|
|
97
|
+
return {
|
|
98
|
+
lb: `${xStart} ${itemHeight}`,
|
|
99
|
+
lt: `${xStart} 0`,
|
|
100
|
+
rt: '100% 0',
|
|
101
|
+
rb: `100% ${itemHeight}`
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
const tipX = this.getTriangleTipX();
|
|
105
|
+
const tipY = this.getTriangleTipY();
|
|
106
|
+
const lb = `${tipX}px ${tipY}px`;
|
|
107
|
+
const lt = `${tipX}px ${tipY}px`;
|
|
108
|
+
return {
|
|
109
|
+
lb,
|
|
110
|
+
lt,
|
|
111
|
+
rt: '100% 0',
|
|
112
|
+
rb: '100% 100%'
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
followByMouseEvent(event) {
|
|
116
|
+
if (!this.initialized || !this.triangleData || !this.element || !this.subNavigation) {
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
this.mouseX = event.clientX - this.triangleData.itemRect.left;
|
|
120
|
+
this.mouseY = event.clientY - this.triangleData.itemRect.top;
|
|
121
|
+
const isOverSubNavigation = this.hasMouseEnteredSubNavigation();
|
|
122
|
+
const coordinates = this.getTriangleCoordinates(isOverSubNavigation ? 'fill-gap' : 'safe-triangle');
|
|
123
|
+
if (!coordinates) {
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
this.element.style.setProperty('--db-navigation-item-clip-path', `polygon(${coordinates.lb}, ${coordinates.lt}, ${coordinates.rt}, ${coordinates.rb})`);
|
|
127
|
+
if (isOverSubNavigation) {
|
|
128
|
+
this.triangleData = undefined;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
export default {
|
|
133
|
+
isEventTargetNavigationItem,
|
|
134
|
+
NavigationItemSafeTriangle
|
|
67
135
|
};
|
|
68
|
-
//#endregion
|
|
69
|
-
export { n as NavigationItemSafeTriangle, t as isEventTargetNavigationItem };
|
package/dist/utils/react.js
CHANGED
|
@@ -1,10 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export
|
|
1
|
+
const reactHtmlAttributes = ['suppressHydrationWarning', 'suppressContentEditableWarning', 'translate', 'title', 'tabIndex', 'style', 'spellCheck', 'nonce', 'lang', 'hidden', 'draggable', 'dir', 'contextMenu', 'contentEditable', 'accessKey', 'is', 'inputMode', 'unselectable', 'security', 'results', 'vocab', 'typeof', 'rev', 'resource', 'rel', 'property', 'inlist', 'datatype', 'content', 'about', 'role', 'radioGroup', 'color',
|
|
2
|
+
// other attributes for button,input,etc.
|
|
3
|
+
'form', 'formAction', 'formEncType', 'formMethod', 'formNoValidate', 'formTarget', 'capture', 'dirName', 'download', 'ping'];
|
|
4
|
+
export const filterPassingProps = (props, propsPassingFilter) => Object.keys(props).filter(key => (key.startsWith('data-') || key.startsWith('aria-') || key.startsWith('default') || key.startsWith('auto') || key.startsWith('item') || key.startsWith('on') || reactHtmlAttributes.includes(key)) && !propsPassingFilter.includes(key)).reduce((obj, key) => {
|
|
5
|
+
return {
|
|
6
|
+
...obj,
|
|
7
|
+
[key]: props[key]
|
|
8
|
+
};
|
|
9
|
+
}, {});
|
|
10
|
+
export const getRootProps = (props, rooProps) => {
|
|
11
|
+
return Object.keys(props).filter(key => rooProps.includes(key)).reduce((obj, key) => {
|
|
12
|
+
return {
|
|
13
|
+
...obj,
|
|
14
|
+
[key]: props[key]
|
|
15
|
+
};
|
|
16
|
+
}, {});
|
|
17
|
+
};
|
|
18
|
+
export default {
|
|
19
|
+
getRootProps,
|
|
20
|
+
filterPassingProps
|
|
21
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@db-ux/react-core-components",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.12.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "React components for @db-ux/core-components",
|
|
6
6
|
"repository": {
|
|
@@ -17,20 +17,18 @@
|
|
|
17
17
|
"dist/"
|
|
18
18
|
],
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@db-ux/core-components": "4.
|
|
21
|
-
"@db-ux/core-foundations": "4.
|
|
20
|
+
"@db-ux/core-components": "4.12.1",
|
|
21
|
+
"@db-ux/core-foundations": "4.12.1"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
24
|
"@playwright/experimental-ct-react": "1.60.0",
|
|
25
25
|
"@types/react": "19.2.17",
|
|
26
|
-
"@vitejs/plugin-react": "6.0.2",
|
|
27
26
|
"cpr": "3.0.1",
|
|
28
27
|
"npm-run-all2": "9.0.2",
|
|
29
28
|
"playwright": "1.60.0",
|
|
30
29
|
"react": "19.2.7",
|
|
31
30
|
"react-dom": "19.2.7",
|
|
32
|
-
"typescript": "5.9.3"
|
|
33
|
-
"vite": "8.0.16"
|
|
31
|
+
"typescript": "5.9.3"
|
|
34
32
|
},
|
|
35
33
|
"publishConfig": {
|
|
36
34
|
"registry": "https://registry.npmjs.org/",
|
|
@@ -38,7 +36,7 @@
|
|
|
38
36
|
},
|
|
39
37
|
"sideEffects": false,
|
|
40
38
|
"scripts": {
|
|
41
|
-
"build": "npm-run-all
|
|
39
|
+
"build": "npm-run-all tsc mv:*",
|
|
42
40
|
"mv:agent": "cpr agent ../../build-outputs/react/agent --overwrite",
|
|
43
41
|
"mv:changelog": "cpr CHANGELOG.md ../../build-outputs/react/CHANGELOG.md --overwrite",
|
|
44
42
|
"mv:dist": "cpr dist ../../build-outputs/react/dist --overwrite",
|
|
@@ -49,7 +47,6 @@
|
|
|
49
47
|
"test:components": "playwright test --config playwright.config.ts",
|
|
50
48
|
"test:components:ui": "playwright test --config playwright.config.ts --ui",
|
|
51
49
|
"test:windows": "playwright test --config playwright.screen-reader.win.ts",
|
|
52
|
-
"tsc": "tsc --project . --sourceMap false"
|
|
53
|
-
"vite": "vite build"
|
|
50
|
+
"tsc": "tsc --project . --sourceMap false"
|
|
54
51
|
}
|
|
55
52
|
}
|