@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.
Files changed (289) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/dist/components/accordion/accordion.d.ts +1 -1
  3. package/dist/components/accordion/accordion.js +83 -102
  4. package/dist/components/accordion/index.d.ts +1 -1
  5. package/dist/components/accordion/index.js +1 -0
  6. package/dist/components/accordion/model.d.ts +2 -2
  7. package/dist/components/accordion/model.js +2 -4
  8. package/dist/components/accordion-item/accordion-item.d.ts +2 -2
  9. package/dist/components/accordion-item/accordion-item.js +56 -89
  10. package/dist/components/accordion-item/index.d.ts +1 -1
  11. package/dist/components/accordion-item/index.js +1 -0
  12. package/dist/components/accordion-item/model.d.ts +1 -1
  13. package/dist/components/accordion-item/model.js +1 -0
  14. package/dist/components/badge/badge.d.ts +1 -1
  15. package/dist/components/badge/badge.js +28 -72
  16. package/dist/components/badge/index.d.ts +1 -1
  17. package/dist/components/badge/index.js +1 -0
  18. package/dist/components/badge/model.d.ts +1 -1
  19. package/dist/components/badge/model.js +1 -12
  20. package/dist/components/brand/brand.d.ts +1 -1
  21. package/dist/components/brand/brand.js +10 -60
  22. package/dist/components/brand/index.d.ts +1 -1
  23. package/dist/components/brand/index.js +1 -0
  24. package/dist/components/brand/model.d.ts +1 -1
  25. package/dist/components/brand/model.js +1 -0
  26. package/dist/components/button/button.d.ts +1 -1
  27. package/dist/components/button/button.js +19 -75
  28. package/dist/components/button/index.d.ts +1 -1
  29. package/dist/components/button/index.js +1 -0
  30. package/dist/components/button/model.d.ts +1 -1
  31. package/dist/components/button/model.js +2 -13
  32. package/dist/components/card/card.d.ts +1 -1
  33. package/dist/components/card/card.js +14 -65
  34. package/dist/components/card/index.d.ts +1 -1
  35. package/dist/components/card/index.js +1 -0
  36. package/dist/components/card/model.d.ts +1 -1
  37. package/dist/components/card/model.js +2 -8
  38. package/dist/components/checkbox/checkbox.d.ts +1 -1
  39. package/dist/components/checkbox/checkbox.js +143 -163
  40. package/dist/components/checkbox/index.d.ts +1 -1
  41. package/dist/components/checkbox/index.js +1 -0
  42. package/dist/components/checkbox/model.d.ts +1 -1
  43. package/dist/components/checkbox/model.js +1 -0
  44. package/dist/components/custom-button/custom-button.d.ts +1 -1
  45. package/dist/components/custom-button/custom-button.js +10 -65
  46. package/dist/components/custom-button/index.d.ts +1 -1
  47. package/dist/components/custom-button/index.js +1 -0
  48. package/dist/components/custom-button/model.d.ts +2 -2
  49. package/dist/components/custom-button/model.js +1 -0
  50. package/dist/components/custom-select/custom-select.d.ts +1 -1
  51. package/dist/components/custom-select/custom-select.js +688 -509
  52. package/dist/components/custom-select/index.d.ts +1 -1
  53. package/dist/components/custom-select/index.js +1 -0
  54. package/dist/components/custom-select/model.d.ts +4 -4
  55. package/dist/components/custom-select/model.js +1 -8
  56. package/dist/components/custom-select-dropdown/custom-select-dropdown.d.ts +1 -1
  57. package/dist/components/custom-select-dropdown/custom-select-dropdown.js +10 -62
  58. package/dist/components/custom-select-dropdown/index.d.ts +1 -1
  59. package/dist/components/custom-select-dropdown/index.js +1 -0
  60. package/dist/components/custom-select-dropdown/model.d.ts +1 -1
  61. package/dist/components/custom-select-dropdown/model.js +1 -8
  62. package/dist/components/custom-select-form-field/custom-select-form-field.d.ts +1 -1
  63. package/dist/components/custom-select-form-field/custom-select-form-field.js +9 -57
  64. package/dist/components/custom-select-form-field/index.d.ts +1 -1
  65. package/dist/components/custom-select-form-field/index.js +1 -0
  66. package/dist/components/custom-select-form-field/model.d.ts +1 -1
  67. package/dist/components/custom-select-form-field/model.js +1 -0
  68. package/dist/components/custom-select-list/custom-select-list.d.ts +1 -1
  69. package/dist/components/custom-select-list/custom-select-list.js +9 -60
  70. package/dist/components/custom-select-list/index.d.ts +1 -1
  71. package/dist/components/custom-select-list/index.js +1 -0
  72. package/dist/components/custom-select-list/model.d.ts +1 -1
  73. package/dist/components/custom-select-list/model.js +1 -0
  74. package/dist/components/custom-select-list-item/custom-select-list-item.d.ts +2 -2
  75. package/dist/components/custom-select-list-item/custom-select-list-item.js +28 -89
  76. package/dist/components/custom-select-list-item/index.d.ts +1 -1
  77. package/dist/components/custom-select-list-item/index.js +1 -0
  78. package/dist/components/custom-select-list-item/model.d.ts +1 -1
  79. package/dist/components/custom-select-list-item/model.js +1 -4
  80. package/dist/components/divider/divider.d.ts +1 -1
  81. package/dist/components/divider/divider.js +9 -60
  82. package/dist/components/divider/index.d.ts +1 -1
  83. package/dist/components/divider/index.js +1 -0
  84. package/dist/components/divider/model.d.ts +1 -1
  85. package/dist/components/divider/model.js +2 -4
  86. package/dist/components/drawer/drawer.d.ts +2 -2
  87. package/dist/components/drawer/drawer.js +109 -118
  88. package/dist/components/drawer/index.d.ts +1 -1
  89. package/dist/components/drawer/index.js +1 -0
  90. package/dist/components/drawer/model.d.ts +4 -1
  91. package/dist/components/drawer/model.js +4 -14
  92. package/dist/components/header/header.d.ts +1 -1
  93. package/dist/components/header/header.js +43 -143
  94. package/dist/components/header/index.d.ts +1 -1
  95. package/dist/components/header/index.js +1 -0
  96. package/dist/components/header/model.d.ts +1 -1
  97. package/dist/components/header/model.js +1 -0
  98. package/dist/components/icon/icon.d.ts +1 -1
  99. package/dist/components/icon/icon.js +9 -61
  100. package/dist/components/icon/index.d.ts +1 -1
  101. package/dist/components/icon/index.js +1 -0
  102. package/dist/components/icon/model.d.ts +1 -1
  103. package/dist/components/icon/model.js +1 -11
  104. package/dist/components/infotext/index.d.ts +1 -1
  105. package/dist/components/infotext/index.js +1 -0
  106. package/dist/components/infotext/infotext.d.ts +1 -1
  107. package/dist/components/infotext/infotext.js +9 -62
  108. package/dist/components/infotext/model.d.ts +1 -1
  109. package/dist/components/infotext/model.js +1 -0
  110. package/dist/components/input/index.d.ts +1 -1
  111. package/dist/components/input/index.js +1 -0
  112. package/dist/components/input/input.d.ts +1 -1
  113. package/dist/components/input/input.js +154 -198
  114. package/dist/components/input/model.d.ts +1 -1
  115. package/dist/components/input/model.js +5 -21
  116. package/dist/components/link/index.d.ts +1 -1
  117. package/dist/components/link/index.js +1 -0
  118. package/dist/components/link/link.d.ts +1 -1
  119. package/dist/components/link/link.js +9 -70
  120. package/dist/components/link/model.d.ts +1 -1
  121. package/dist/components/link/model.js +3 -8
  122. package/dist/components/navigation/index.d.ts +1 -1
  123. package/dist/components/navigation/index.js +1 -0
  124. package/dist/components/navigation/model.d.ts +1 -1
  125. package/dist/components/navigation/model.js +1 -0
  126. package/dist/components/navigation/navigation.d.ts +1 -1
  127. package/dist/components/navigation/navigation.js +9 -57
  128. package/dist/components/navigation-item/index.d.ts +1 -1
  129. package/dist/components/navigation-item/index.js +1 -0
  130. package/dist/components/navigation-item/model.d.ts +2 -2
  131. package/dist/components/navigation-item/model.js +1 -0
  132. package/dist/components/navigation-item/navigation-item.d.ts +1 -1
  133. package/dist/components/navigation-item/navigation-item.js +71 -117
  134. package/dist/components/notification/index.d.ts +1 -1
  135. package/dist/components/notification/index.js +1 -0
  136. package/dist/components/notification/model.d.ts +1 -1
  137. package/dist/components/notification/model.js +3 -12
  138. package/dist/components/notification/notification.d.ts +2 -2
  139. package/dist/components/notification/notification.js +23 -100
  140. package/dist/components/page/index.d.ts +1 -1
  141. package/dist/components/page/index.js +1 -0
  142. package/dist/components/page/model.d.ts +1 -1
  143. package/dist/components/page/model.js +2 -4
  144. package/dist/components/page/page.d.ts +1 -1
  145. package/dist/components/page/page.js +42 -74
  146. package/dist/components/popover/index.d.ts +1 -1
  147. package/dist/components/popover/index.js +1 -0
  148. package/dist/components/popover/model.d.ts +1 -1
  149. package/dist/components/popover/model.js +1 -0
  150. package/dist/components/popover/popover.d.ts +1 -1
  151. package/dist/components/popover/popover.js +119 -126
  152. package/dist/components/radio/index.d.ts +1 -1
  153. package/dist/components/radio/index.js +1 -0
  154. package/dist/components/radio/model.d.ts +1 -1
  155. package/dist/components/radio/model.js +1 -0
  156. package/dist/components/radio/radio.d.ts +1 -1
  157. package/dist/components/radio/radio.js +86 -124
  158. package/dist/components/section/index.d.ts +1 -1
  159. package/dist/components/section/index.js +1 -0
  160. package/dist/components/section/model.d.ts +1 -1
  161. package/dist/components/section/model.js +1 -0
  162. package/dist/components/section/section.d.ts +1 -1
  163. package/dist/components/section/section.js +9 -59
  164. package/dist/components/select/index.d.ts +1 -1
  165. package/dist/components/select/index.js +1 -0
  166. package/dist/components/select/model.d.ts +1 -1
  167. package/dist/components/select/model.js +1 -0
  168. package/dist/components/select/select.d.ts +1 -1
  169. package/dist/components/select/select.js +172 -188
  170. package/dist/components/stack/index.d.ts +1 -1
  171. package/dist/components/stack/index.js +1 -0
  172. package/dist/components/stack/model.d.ts +1 -1
  173. package/dist/components/stack/model.js +4 -14
  174. package/dist/components/stack/stack.d.ts +1 -1
  175. package/dist/components/stack/stack.js +9 -63
  176. package/dist/components/switch/index.d.ts +1 -1
  177. package/dist/components/switch/index.js +1 -0
  178. package/dist/components/switch/model.d.ts +1 -1
  179. package/dist/components/switch/model.js +1 -0
  180. package/dist/components/switch/switch.d.ts +1 -1
  181. package/dist/components/switch/switch.js +135 -182
  182. package/dist/components/tab-item/index.d.ts +1 -1
  183. package/dist/components/tab-item/index.js +1 -0
  184. package/dist/components/tab-item/model.d.ts +1 -1
  185. package/dist/components/tab-item/model.js +1 -0
  186. package/dist/components/tab-item/tab-item.d.ts +1 -1
  187. package/dist/components/tab-item/tab-item.js +72 -105
  188. package/dist/components/tab-list/index.d.ts +1 -1
  189. package/dist/components/tab-list/index.js +1 -0
  190. package/dist/components/tab-list/model.d.ts +1 -1
  191. package/dist/components/tab-list/model.js +1 -0
  192. package/dist/components/tab-list/tab-list.d.ts +1 -1
  193. package/dist/components/tab-list/tab-list.js +9 -60
  194. package/dist/components/tab-panel/index.d.ts +1 -1
  195. package/dist/components/tab-panel/index.js +1 -0
  196. package/dist/components/tab-panel/model.d.ts +1 -1
  197. package/dist/components/tab-panel/model.js +1 -0
  198. package/dist/components/tab-panel/tab-panel.d.ts +1 -1
  199. package/dist/components/tab-panel/tab-panel.js +10 -59
  200. package/dist/components/table/examples/data.d.ts +1 -1
  201. package/dist/components/table/examples/data.js +258 -0
  202. package/dist/components/table/index.d.ts +1 -1
  203. package/dist/components/table/index.js +1 -0
  204. package/dist/components/table/model.d.ts +2 -2
  205. package/dist/components/table/model.js +6 -28
  206. package/dist/components/table/table.d.ts +1 -1
  207. package/dist/components/table/table.js +77 -111
  208. package/dist/components/table-body/index.d.ts +1 -1
  209. package/dist/components/table-body/index.js +1 -0
  210. package/dist/components/table-body/model.d.ts +2 -2
  211. package/dist/components/table-body/model.js +1 -0
  212. package/dist/components/table-body/table-body.d.ts +1 -1
  213. package/dist/components/table-body/table-body.js +12 -64
  214. package/dist/components/table-caption/index.d.ts +1 -1
  215. package/dist/components/table-caption/index.js +1 -0
  216. package/dist/components/table-caption/model.d.ts +1 -1
  217. package/dist/components/table-caption/model.js +1 -0
  218. package/dist/components/table-caption/table-caption.d.ts +1 -1
  219. package/dist/components/table-caption/table-caption.js +9 -57
  220. package/dist/components/table-data-cell/index.d.ts +1 -1
  221. package/dist/components/table-data-cell/index.js +1 -0
  222. package/dist/components/table-data-cell/model.d.ts +1 -1
  223. package/dist/components/table-data-cell/model.js +1 -0
  224. package/dist/components/table-data-cell/table-data-cell.d.ts +1 -1
  225. package/dist/components/table-data-cell/table-data-cell.js +9 -62
  226. package/dist/components/table-footer/index.d.ts +1 -1
  227. package/dist/components/table-footer/index.js +1 -0
  228. package/dist/components/table-footer/model.d.ts +2 -2
  229. package/dist/components/table-footer/model.js +1 -0
  230. package/dist/components/table-footer/table-footer.d.ts +1 -1
  231. package/dist/components/table-footer/table-footer.js +12 -64
  232. package/dist/components/table-head/index.d.ts +1 -1
  233. package/dist/components/table-head/index.js +1 -0
  234. package/dist/components/table-head/model.d.ts +2 -2
  235. package/dist/components/table-head/model.js +1 -0
  236. package/dist/components/table-head/table-head.d.ts +1 -1
  237. package/dist/components/table-head/table-head.js +18 -71
  238. package/dist/components/table-header-cell/index.d.ts +1 -1
  239. package/dist/components/table-header-cell/index.js +1 -0
  240. package/dist/components/table-header-cell/model.d.ts +1 -1
  241. package/dist/components/table-header-cell/model.js +1 -9
  242. package/dist/components/table-header-cell/table-header-cell.d.ts +1 -1
  243. package/dist/components/table-header-cell/table-header-cell.js +9 -65
  244. package/dist/components/table-row/index.d.ts +1 -1
  245. package/dist/components/table-row/index.js +1 -0
  246. package/dist/components/table-row/model.d.ts +4 -4
  247. package/dist/components/table-row/model.js +1 -8
  248. package/dist/components/table-row/table-row.d.ts +1 -1
  249. package/dist/components/table-row/table-row.js +20 -127
  250. package/dist/components/tabs/index.d.ts +1 -1
  251. package/dist/components/tabs/index.js +1 -0
  252. package/dist/components/tabs/model.d.ts +3 -3
  253. package/dist/components/tabs/model.js +2 -4
  254. package/dist/components/tabs/tabs.d.ts +1 -1
  255. package/dist/components/tabs/tabs.js +170 -191
  256. package/dist/components/tag/index.d.ts +1 -1
  257. package/dist/components/tag/index.js +1 -0
  258. package/dist/components/tag/model.d.ts +1 -1
  259. package/dist/components/tag/model.js +1 -4
  260. package/dist/components/tag/tag.d.ts +1 -1
  261. package/dist/components/tag/tag.js +26 -91
  262. package/dist/components/textarea/index.d.ts +1 -1
  263. package/dist/components/textarea/index.js +1 -0
  264. package/dist/components/textarea/model.d.ts +1 -1
  265. package/dist/components/textarea/model.js +2 -13
  266. package/dist/components/textarea/textarea.d.ts +1 -1
  267. package/dist/components/textarea/textarea.js +139 -165
  268. package/dist/components/tooltip/index.d.ts +1 -1
  269. package/dist/components/tooltip/index.js +1 -0
  270. package/dist/components/tooltip/model.d.ts +1 -1
  271. package/dist/components/tooltip/model.js +1 -4
  272. package/dist/components/tooltip/tooltip.d.ts +1 -1
  273. package/dist/components/tooltip/tooltip.js +197 -160
  274. package/dist/index.d.ts +97 -97
  275. package/dist/index.js +97 -75
  276. package/dist/shared/constants.js +100 -32
  277. package/dist/shared/examples/index.js +4 -0
  278. package/dist/shared/figma.js +1 -0
  279. package/dist/shared/model.js +22 -77
  280. package/dist/shared/showcase/show-code-link.js +51 -0
  281. package/dist/utils/document-click-listener.js +29 -26
  282. package/dist/utils/document-scroll-listener.js +38 -30
  283. package/dist/utils/floating-components.js +404 -107
  284. package/dist/utils/form-components.js +71 -34
  285. package/dist/utils/index.d.ts +1 -1
  286. package/dist/utils/index.js +170 -49
  287. package/dist/utils/navigation.js +134 -68
  288. package/dist/utils/react.js +21 -10
  289. package/package.json +6 -9
@@ -1,35 +1,72 @@
1
- import { delay as e } from "./index.js";
2
- //#region src/utils/form-components.ts
3
- var t = (e, t, n) => {
4
- e.form && !e._dbFormResetListenerAdded && (e.form.addEventListener("reset", (e) => {
5
- t(e);
6
- }, { signal: n }), e._dbFormResetListenerAdded = !0);
7
- }, n = (n, r, i, a) => {
8
- t(n, (t) => {
9
- e(() => {
10
- let e = r.checked ? r.checked : r.defaultChecked ? r.defaultChecked : n.checked;
11
- i({
12
- ...t,
13
- target: {
14
- ...t.target,
15
- checked: e
16
- }
17
- });
18
- }, 1);
19
- }, a);
20
- }, r = (n, r, i, a) => {
21
- t(n, (t) => {
22
- e(() => {
23
- let e = r.value ? r.value : r.defaultValue ? r.defaultValue : n.value;
24
- i({
25
- ...t,
26
- target: {
27
- ...t.target,
28
- value: e
29
- }
30
- });
31
- }, 1);
32
- }, a);
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 };
@@ -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;
@@ -1,49 +1,170 @@
1
- //#region src/utils/index.ts
2
- var e = () => {
3
- if (typeof window < "u") {
4
- if (window.crypto?.randomUUID) return window.crypto.randomUUID();
5
- if (window.crypto?.getRandomValues) return window.crypto.getRandomValues(new Uint32Array(3)).join("-");
6
- }
7
- return Math.random().toString().substring(2);
8
- }, t = (e, n) => {
9
- let r = e.children;
10
- Object.values(r).forEach((e) => {
11
- e.setAttribute(n.key, n.value), e.children.length > 0 && t(e, n);
12
- });
13
- }, n = (...e) => {
14
- let t = "";
15
- for (let n of e) if (n) if (typeof n == "string") t += `${n} `;
16
- else for (let e in n) n[e] && (t += `${e} `);
17
- return t.trim();
18
- }, r = (e) => Array.isArray(e) && e.every((e) => typeof e == "string"), i = [
19
- "Mac",
20
- "iPhone",
21
- "iPad",
22
- "iPod"
23
- ], a = () => typeof window < "u" && i.some((e) => window.navigator.userAgent.includes(e)), o = () => {
24
- if (typeof window > "u" || typeof navigator > "u") return !1;
25
- let e = navigator.userAgent, t = /iP(ad|hone|od)/.test(e), n = !!e.match(/Safari/) && !e.match(/CriOS|FxiOS|OPiOS|EdgiOS/);
26
- return t && n;
27
- }, s = (e, t) => new Promise(() => setTimeout(e, t)), c = (e, t) => {
28
- if (e != null) return String(typeof e == "string" ? e === "" || e === "true" || t?.toLowerCase() === e.toLowerCase() : e);
29
- }, l = (e, t) => {
30
- if (e != null) return typeof e == "string" ? e === "" || e === "true" || t?.toLowerCase() === e.toLowerCase() : !!e;
31
- }, u = (e, t) => {
32
- if (!(e == null && t == null)) return Number(e ?? t);
33
- }, d = (e) => {
34
- if (e != null) return e === "any" ? "any" : Number(e);
35
- }, f = (e, t) => t && ["number", "range"].includes(t) ? u(e) : e, p = (e) => typeof e == "string" ? e !== "false" : e, m = (e) => {
36
- if (e != null) return c(!p(e), "show");
37
- }, h = (e, t) => (t === void 0 || p(t)) && !!e, g = (e) => e.querySelector("input[type=\"search\"]"), _ = (t, n) => `${n}${t.id ?? t.value ?? e()}`, v = (e) => e.key !== void 0, y = ({ semantic: e, role: t, ariaLive: n }) => {
38
- if (t) return t;
39
- if (n) return "article";
40
- switch (e) {
41
- case "critical":
42
- case "warning": return "alert";
43
- case "informational":
44
- case "successful": return "status";
45
- default: return "article";
46
- }
47
- };
48
- //#endregion
49
- export { t as addAttributeToChildren, n as cls, s as delay, l as getBoolean, c as getBooleanAsString, m as getHideProp, f as getInputValue, y as getNotificationRole, u as getNumber, _ as getOptionKey, g as getSearchInput, d as getStep, a as hasVoiceOver, r as isArrayOfStrings, o as isIOSSafari, v as isKeyboardEvent, h as stringPropVisible, e as uuid };
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
+ };
@@ -1,69 +1,135 @@
1
- import { handleDataOutside as e } from "./floating-components.js";
2
- //#region src/utils/navigation.ts
3
- var t = (e) => {
4
- let { target: t } = e;
5
- return !!(!t?.classList?.contains("db-navigation-item-expand-button") && t?.parentElement?.classList.contains("db-navigation-item"));
6
- }, n = class {
7
- constructor(e, t) {
8
- this.parentSubNavigation = null, this.initialized = !1, this.mouseX = 0, this.mouseY = 0, this.element = e, this.subNavigation = t, !(!this.element || !this.subNavigation) && (this.parentSubNavigation = this.element?.closest(".db-sub-navigation"), this.parentSubNavigation && !this.element.closest(".db-drawer") && this.init());
9
- }
10
- init() {
11
- let e = this.parentSubNavigation?.getBoundingClientRect().width ?? 0;
12
- this.element?.style.setProperty("--db-navigation-item-inline-size", `${e}px`), this.initialized = !0;
13
- }
14
- enableFollow() {
15
- if (!this.initialized || this.triangleData || !this.element || !this.subNavigation) return;
16
- let t = e(this.subNavigation), n = this.element.getBoundingClientRect(), r = this.parentSubNavigation?.getBoundingClientRect().width ?? 0;
17
- this.triangleData = {
18
- itemRect: n,
19
- parentElementWidth: r,
20
- subNavigationHeight: this.subNavigation.getBoundingClientRect().height,
21
- padding: (r - n.width) / 2,
22
- outsideVX: t.vx,
23
- outsideVY: t.vy
24
- };
25
- }
26
- disableFollow() {
27
- this.triangleData = void 0;
28
- }
29
- getTriangleTipX() {
30
- return this.triangleData ? this.triangleData.outsideVX === "right" ? this.triangleData.itemRect.width - this.mouseX : Math.min(this.mouseX, this.triangleData.itemRect.width * .75) : 0;
31
- }
32
- getTriangleTipY() {
33
- if (!this.triangleData) return 0;
34
- let e = Math.max(Math.min(this.mouseY, this.triangleData.itemRect.height), 0) + this.triangleData.padding;
35
- return this.triangleData.outsideVY === "bottom" ? e + (this.triangleData.subNavigationHeight - this.triangleData.padding * 2 - this.triangleData.itemRect.height) : e;
36
- }
37
- hasMouseEnteredSubNavigation() {
38
- if (!this.triangleData) return !1;
39
- let e = this.triangleData.outsideVX === "right";
40
- return !!(e && this.mouseX < -1 * this.triangleData.padding || !e && this.mouseX > this.triangleData.parentElementWidth - this.triangleData.padding);
41
- }
42
- getTriangleCoordinates(e) {
43
- if (!this.triangleData) return;
44
- if (e === "fill-gap") {
45
- let e = `${this.triangleData.itemRect.height + 2 * this.triangleData.padding}px`, t = `${this.triangleData.parentElementWidth - this.triangleData.padding}px`;
46
- return {
47
- lb: `${t} ${e}`,
48
- lt: `${t} 0`,
49
- rt: "100% 0",
50
- rb: `100% ${e}`
51
- };
52
- }
53
- let t = this.getTriangleTipX(), n = this.getTriangleTipY();
54
- return {
55
- lb: `${t}px ${n}px`,
56
- lt: `${t}px ${n}px`,
57
- rt: "100% 0",
58
- rb: "100% 100%"
59
- };
60
- }
61
- followByMouseEvent(e) {
62
- if (!this.initialized || !this.triangleData || !this.element || !this.subNavigation) return;
63
- this.mouseX = e.clientX - this.triangleData.itemRect.left, this.mouseY = e.clientY - this.triangleData.itemRect.top;
64
- let t = this.hasMouseEnteredSubNavigation(), n = this.getTriangleCoordinates(t ? "fill-gap" : "safe-triangle");
65
- n && (this.element.style.setProperty("--db-navigation-item-clip-path", `polygon(${n.lb}, ${n.lt}, ${n.rt}, ${n.rb})`), t && (this.triangleData = void 0));
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 };
@@ -1,10 +1,21 @@
1
- //#region src/utils/react.ts
2
- var e = /* @__PURE__ */ "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.form.formAction.formEncType.formMethod.formNoValidate.formTarget.capture.dirName.download.ping".split("."), t = (t, n) => Object.keys(t).filter((t) => (t.startsWith("data-") || t.startsWith("aria-") || t.startsWith("default") || t.startsWith("auto") || t.startsWith("item") || t.startsWith("on") || e.includes(t)) && !n.includes(t)).reduce((e, n) => ({
3
- ...e,
4
- [n]: t[n]
5
- }), {}), n = (e, t) => Object.keys(e).filter((e) => t.includes(e)).reduce((t, n) => ({
6
- ...t,
7
- [n]: e[n]
8
- }), {});
9
- //#endregion
10
- export { t as filterPassingProps, n as getRootProps };
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.11.1",
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.11.1",
21
- "@db-ux/core-foundations": "4.11.1"
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 --parallel tsc vite --sequential mv:*",
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
  }