@gooddata/sdk-ui-kit 10.29.0-alpha.3 → 10.29.0-alpha.31

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 (57) hide show
  1. package/esm/@ui/UiChip/UiChip.d.ts +2 -1
  2. package/esm/@ui/UiChip/UiChip.d.ts.map +1 -1
  3. package/esm/@ui/UiChip/UiChip.js +8 -7
  4. package/esm/@ui/UiChip/UiChip.js.map +1 -1
  5. package/esm/@ui/UiFocusTrap/UiFocusTrap.d.ts +4 -0
  6. package/esm/@ui/UiFocusTrap/UiFocusTrap.d.ts.map +1 -1
  7. package/esm/@ui/UiFocusTrap/UiFocusTrap.js +13 -34
  8. package/esm/@ui/UiFocusTrap/UiFocusTrap.js.map +1 -1
  9. package/esm/@ui/UiMenu/UiMenu.d.ts.map +1 -1
  10. package/esm/@ui/UiMenu/UiMenu.js +4 -3
  11. package/esm/@ui/UiMenu/UiMenu.js.map +1 -1
  12. package/esm/@ui/hooks/useListWithActionsKeyboardNavigation.d.ts +2 -1
  13. package/esm/@ui/hooks/useListWithActionsKeyboardNavigation.d.ts.map +1 -1
  14. package/esm/@ui/hooks/useListWithActionsKeyboardNavigation.js +24 -9
  15. package/esm/@ui/hooks/useListWithActionsKeyboardNavigation.js.map +1 -1
  16. package/esm/AddButton/AddButton.d.ts +1 -0
  17. package/esm/AddButton/AddButton.d.ts.map +1 -1
  18. package/esm/AddButton/AddButton.js +4 -4
  19. package/esm/AddButton/AddButton.js.map +1 -1
  20. package/esm/Datepicker/Datepicker.d.ts.map +1 -1
  21. package/esm/Datepicker/Datepicker.js +3 -2
  22. package/esm/Datepicker/Datepicker.js.map +1 -1
  23. package/esm/Header/HeaderChatButton.d.ts.map +1 -1
  24. package/esm/Header/HeaderChatButton.js +3 -1
  25. package/esm/Header/HeaderChatButton.js.map +1 -1
  26. package/esm/RecurrenceForm/DateTime.d.ts +1 -0
  27. package/esm/RecurrenceForm/DateTime.d.ts.map +1 -1
  28. package/esm/RecurrenceForm/DateTime.js +2 -2
  29. package/esm/RecurrenceForm/DateTime.js.map +1 -1
  30. package/esm/RecurrenceForm/Recurrence.d.ts.map +1 -1
  31. package/esm/RecurrenceForm/Recurrence.js +2 -2
  32. package/esm/RecurrenceForm/Recurrence.js.map +1 -1
  33. package/esm/RecurrenceForm/RecurrenceForm.d.ts +1 -0
  34. package/esm/RecurrenceForm/RecurrenceForm.d.ts.map +1 -1
  35. package/esm/RecurrenceForm/RecurrenceForm.js +2 -2
  36. package/esm/RecurrenceForm/RecurrenceForm.js.map +1 -1
  37. package/esm/RecurrenceForm/RepeatTypeSelect.d.ts +1 -0
  38. package/esm/RecurrenceForm/RepeatTypeSelect.d.ts.map +1 -1
  39. package/esm/RecurrenceForm/RepeatTypeSelect.js +9 -3
  40. package/esm/RecurrenceForm/RepeatTypeSelect.js.map +1 -1
  41. package/esm/Timepicker/Timepicker.d.ts.map +1 -1
  42. package/esm/Timepicker/Timepicker.js +7 -1
  43. package/esm/Timepicker/Timepicker.js.map +1 -1
  44. package/esm/sdk-ui-kit.d.ts +63 -6
  45. package/esm/utils/domUtilities.d.ts +1 -1
  46. package/esm/utils/domUtilities.d.ts.map +1 -1
  47. package/esm/utils/domUtilities.js +4 -3
  48. package/esm/utils/domUtilities.js.map +1 -1
  49. package/esm/utils/events.d.ts +27 -0
  50. package/esm/utils/events.d.ts.map +1 -1
  51. package/esm/utils/events.js +33 -0
  52. package/esm/utils/events.js.map +1 -1
  53. package/esm/utils/useAutofocusOnMount.d.ts +20 -3
  54. package/esm/utils/useAutofocusOnMount.d.ts.map +1 -1
  55. package/esm/utils/useAutofocusOnMount.js +31 -24
  56. package/esm/utils/useAutofocusOnMount.js.map +1 -1
  57. package/package.json +8 -8
@@ -1,51 +1,58 @@
1
1
  // (C) 2025 GoodData Corporation
2
2
  import React from "react";
3
- import { getFocusableElements, isElementFocusable } from "./domUtilities.js";
3
+ import { getFocusableElements, isElementFocusable, isElementTextInput } from "./domUtilities.js";
4
4
  /**
5
- * Focuses the element when it mounts.
5
+ * Provides a ref that will autofocus the element when it is mounted, or when `refocusKey` changes.
6
6
  *
7
7
  * @internal
8
8
  */
9
- export const useAutofocusOnMount = () => {
9
+ export const useAutofocusOnMountRef = ({ isDisabled, refocusKey } = {}) => {
10
10
  const [element, setElement] = React.useState(null);
11
- const hasFiredRef = React.useRef(false);
11
+ useAutofocusOnMount(element, { isDisabled, refocusKey });
12
+ return React.useCallback((node) => {
13
+ setElement(node);
14
+ }, []);
15
+ };
16
+ /**
17
+ * Focuses the element on mount or when `refocusKey` changes.
18
+ *
19
+ * @internal
20
+ */
21
+ export const useAutofocusOnMount = (element, { isDisabled, refocusKey } = {}) => {
12
22
  // If the element is outside of the viewport, calling focus() will not work.
13
23
  // This can happen for example with floating elements, that are repositioned after they mount
14
24
  React.useEffect(() => {
15
- if (!element || element.contains(document.activeElement)) {
25
+ const elementToFocus = getElementToFocus(element);
26
+ if (isDisabled || !elementToFocus) {
16
27
  return undefined;
17
28
  }
18
- const observer = new IntersectionObserver(() => {
19
- if (!element) {
29
+ const observer = new IntersectionObserver(([{ target }]) => {
30
+ if (target.contains(document.activeElement) || isElementTextInput(document.activeElement)) {
31
+ observer.disconnect();
20
32
  return;
21
33
  }
22
- const elementToFocus = isElementFocusable(element)
23
- ? element
24
- : getFocusableElements(element).firstElement;
25
34
  // Focusing a newly created element sometimes fails if not done through requestAnimationFrame()
26
35
  window.requestAnimationFrame(() => {
27
- elementToFocus.focus();
28
- if (document.activeElement === elementToFocus) {
36
+ target.focus();
37
+ if (document.activeElement === target) {
29
38
  observer.disconnect();
30
39
  }
31
40
  });
32
41
  });
33
- observer.observe(element);
42
+ observer.observe(elementToFocus);
34
43
  return () => observer.disconnect();
35
- }, [element]);
36
- return React.useCallback((node) => {
37
- if (hasFiredRef.current || !node) {
38
- return;
39
- }
40
- hasFiredRef.current = true;
41
- setElement(node);
42
- }, []);
44
+ }, [refocusKey, isDisabled, element]);
43
45
  };
46
+ function getElementToFocus(element) {
47
+ return isElementFocusable(element) ? element : getFocusableElements(element).firstElement;
48
+ }
44
49
  /**
50
+ * Wrapper that focuses the first focusable child when it mounts, or when `refocusKey` changes.
51
+ *
45
52
  * @internal
46
53
  */
47
- export const AutofocusOnMount = ({ ...props }) => {
48
- const ref = useAutofocusOnMount();
49
- return React.createElement("div", { ref: ref, ...props });
54
+ export const AutofocusOnMount = ({ isDisabled, refocusKey, children }) => {
55
+ const ref = useAutofocusOnMountRef({ isDisabled, refocusKey });
56
+ return (React.createElement("div", { ref: ref, style: { display: "contents" } }, children));
50
57
  };
51
58
  //# sourceMappingURL=useAutofocusOnMount.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useAutofocusOnMount.js","sourceRoot":"","sources":["../../src/utils/useAutofocusOnMount.tsx"],"names":[],"mappings":"AAAA,gCAAgC;AAEhC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAE7E;;;;GAIG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,GAAG,EAAE;IACpC,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAqB,IAAI,CAAC,CAAC;IAEvE,MAAM,WAAW,GAAG,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAExC,4EAA4E;IAC5E,6FAA6F;IAC7F,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACjB,IAAI,CAAC,OAAO,IAAI,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,aAAa,CAAC,EAAE,CAAC;YACvD,OAAO,SAAS,CAAC;QACrB,CAAC;QAED,MAAM,QAAQ,GAAG,IAAI,oBAAoB,CAAC,GAAG,EAAE;YAC3C,IAAI,CAAC,OAAO,EAAE,CAAC;gBACX,OAAO;YACX,CAAC;YAED,MAAM,cAAc,GAAG,kBAAkB,CAAC,OAAO,CAAC;gBAC9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,CAAC;YACL,CAAC,CAAC,CAAC;QACP,CAAC,CAAC,CAAC;QAEH,QAAQ,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;QAEjC,OAAO,GAAG,EAAE,CAAC,QAAQ,CAAC,UAAU,EAAE,CAAC;IACvC,CAAC,EAAE,CAAC,UAAU,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC,CAAC;AAC1C,CAAC,CAAC;AAEF,SAAS,iBAAiB,CAAC,OAAuC;IAC9D,OAAO,kBAAkB,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAC,YAAY,CAAC;AAC9F,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAIzB,CAAC,EAAE,UAAU,EAAE,UAAU,EAAE,QAAQ,EAAE,EAAE,EAAE;IACzC,MAAM,GAAG,GAAG,sBAAsB,CAAC,EAAE,UAAU,EAAE,UAAU,EAAE,CAAC,CAAC;IAE/D,OAAO,CACH,6BAAK,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE,IACxC,QAAQ,CACP,CACT,CAAC;AACN,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gooddata/sdk-ui-kit",
3
- "version": "10.29.0-alpha.3",
3
+ "version": "10.29.0-alpha.31",
4
4
  "description": "GoodData SDK - UI Building Components",
5
5
  "repository": {
6
6
  "type": "git",
@@ -75,11 +75,11 @@
75
75
  "@codemirror/autocomplete": "^6.18.6",
76
76
  "@lezer/highlight": "~1.2.1",
77
77
  "@codemirror/commands": "~6.8.1",
78
- "@gooddata/sdk-backend-spi": "10.29.0-alpha.3",
79
- "@gooddata/sdk-ui": "10.29.0-alpha.3",
80
- "@gooddata/util": "10.29.0-alpha.3",
81
- "@gooddata/sdk-ui-theme-provider": "10.29.0-alpha.3",
82
- "@gooddata/sdk-model": "10.29.0-alpha.3"
78
+ "@gooddata/sdk-backend-spi": "10.29.0-alpha.31",
79
+ "@gooddata/sdk-ui": "10.29.0-alpha.31",
80
+ "@gooddata/sdk-model": "10.29.0-alpha.31",
81
+ "@gooddata/sdk-ui-theme-provider": "10.29.0-alpha.31",
82
+ "@gooddata/util": "10.29.0-alpha.31"
83
83
  },
84
84
  "peerDependencies": {
85
85
  "react": "^16.10.0 || ^17.0.0 || ^18.0.0",
@@ -137,8 +137,8 @@
137
137
  "typescript": "5.3.3",
138
138
  "vitest": "3.0.8",
139
139
  "vitest-dom": "0.1.1",
140
- "@gooddata/reference-workspace": "10.29.0-alpha.3",
141
- "@gooddata/sdk-backend-mockingbird": "10.29.0-alpha.3"
140
+ "@gooddata/sdk-backend-mockingbird": "10.29.0-alpha.31",
141
+ "@gooddata/reference-workspace": "10.29.0-alpha.31"
142
142
  },
143
143
  "scripts": {
144
144
  "clean": "rm -rf ci dist esm coverage styles/css *.log tsconfig.tsbuildinfo",