@codecademy/gamut 67.6.5-alpha.e8ee42.0 → 67.6.5

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 (31) hide show
  1. package/dist/ConnectedForm/ConnectedFormGroup.d.ts +2 -8
  2. package/dist/ConnectedForm/ConnectedFormGroup.js +1 -1
  3. package/dist/ConnectedForm/ConnectedInputs/ConnectedCheckbox.js +0 -2
  4. package/dist/Form/elements/FormGroupLabel.d.ts +2 -2
  5. package/dist/Form/elements/FormGroupLabel.js +3 -10
  6. package/dist/Form/inputs/Checkbox.d.ts +0 -7
  7. package/dist/Form/inputs/Checkbox.js +11 -27
  8. package/dist/Form/inputs/Radio.d.ts +5 -9
  9. package/dist/Form/inputs/Radio.js +10 -13
  10. package/dist/Form/styles/Radio-styles.d.ts +3 -0
  11. package/dist/Form/styles/Radio-styles.js +6 -0
  12. package/dist/Form/styles/shared-system-props.d.ts +0 -7
  13. package/dist/Form/styles/shared-system-props.js +0 -11
  14. package/dist/GridForm/GridFormInputGroup/GridFormRadioGroupInput/index.js +0 -2
  15. package/dist/GridForm/GridFormInputGroup/__fixtures__/renderers.d.ts +0 -4
  16. package/dist/GridForm/types.d.ts +2 -7
  17. package/dist/Tip/InfoTip/InfoTipButton.js +2 -5
  18. package/dist/Tip/InfoTip/elements.d.ts +12 -0
  19. package/dist/Tip/InfoTip/elements.js +9 -0
  20. package/dist/Tip/InfoTip/index.d.ts +2 -39
  21. package/dist/Tip/InfoTip/index.js +67 -50
  22. package/dist/Tip/__tests__/helpers.d.ts +26 -5
  23. package/dist/Tip/shared/FloatingTip.js +3 -3
  24. package/dist/Tip/shared/InlineTip.js +1 -4
  25. package/dist/Tip/shared/types.d.ts +1 -1
  26. package/dist/Tip/shared/utils.d.ts +0 -19
  27. package/dist/Tip/shared/utils.js +0 -104
  28. package/package.json +8 -8
  29. package/dist/Form/__tests__/testUtils.d.ts +0 -22
  30. package/dist/Tip/InfoTip/type-utils.d.ts +0 -35
  31. package/dist/Tip/InfoTip/type-utils.js +0 -72
@@ -15,108 +15,4 @@ export const escapeKeyPressHandler = event => {
15
15
  export const isElementVisible = element => {
16
16
  if (!(element instanceof HTMLElement)) return false;
17
17
  return element.checkVisibility?.() ?? true;
18
- };
19
-
20
- /**
21
- * Check if a floating element (modal, dialog, popover, overlay, etc.) is actually open and blocking.
22
- *
23
- * A floating element is considered "open" and blocking if:
24
- * 1. It's a <dialog> element with the open attribute (always blocking per HTML spec), OR
25
- * 2. It has role="alertdialog" (always blocking per ARIA spec), OR
26
- * 3. It has role="dialog" AND:
27
- * - It's not aria-hidden="true", AND
28
- * - It doesn't have aria-expanded="false" (for collapsible dialogs), AND
29
- * - It's actually visible (not just in DOM), AND
30
- * - It has aria-modal="true" (indicates blocking modal per ARIA spec)
31
- *
32
- * Non-blocking popovers and collapsible dialogs without aria-modal="true" are not considered
33
- * blocking and should not prevent InfoTip from closing.
34
- *
35
- * @param element - The DOM element to check
36
- * @returns `true` if the floating element is actually open and blocking, `false` otherwise
37
- */
38
- export const isFloatingElementOpen = element => {
39
- if (!isElementVisible(element)) return false;
40
-
41
- /**
42
- * Native <dialog> elements are always blocking when open.
43
- * Per HTML spec, dialog elements with the open attribute are modal.
44
- */
45
- if (element instanceof HTMLDialogElement) {
46
- return element.open === true;
47
- }
48
-
49
- /**
50
- * Elements with role="dialog" or role="alertdialog".
51
- * Per ARIA spec, role="alertdialog" is always modal (blocking).
52
- * role="dialog" requires aria-modal="true" to be blocking.
53
- */
54
- const role = element.getAttribute('role');
55
- if (role !== 'dialog' && role !== 'alertdialog') {
56
- return false;
57
- }
58
-
59
- /**
60
- * Cache attribute values to avoid multiple DOM reads.
61
- * Check aria-hidden first as it's a common exclusion case.
62
- */
63
- const ariaHidden = element.getAttribute('aria-hidden');
64
- if (ariaHidden === 'true') {
65
- return false;
66
- }
67
-
68
- /**
69
- * Check for collapsible dialogs (like help menus).
70
- * If aria-expanded exists and is false, the dialog is closed.
71
- * These dialogs stay in DOM but are collapsed when closed.
72
- */
73
- const ariaExpanded = element.getAttribute('aria-expanded');
74
- if (ariaExpanded === 'false') {
75
- return false;
76
- }
77
-
78
- /**
79
- * Per ARIA spec, role="alertdialog" is always modal (blocking).
80
- * At this point, we've already verified:
81
- * - The element is visible (not hidden via CSS)
82
- * - It's not aria-hidden="true"
83
- * - It's not aria-expanded="false"
84
- * So if it's an alertdialog, it's open and blocking.
85
- * Handle alertdialog here to avoid expensive DOM queries for dialog elements.
86
- */
87
- if (role === 'alertdialog') {
88
- return true;
89
- }
90
-
91
- /**
92
- * For role="dialog", check if any child button with aria-expanded indicates the dialog is closed.
93
- * Some dialogs use a toggle button pattern where the button's aria-expanded
94
- * reflects the dialog's state.
95
- * Only perform this expensive querySelector operation after all other checks pass.
96
- */
97
- const toggleButton = element.querySelector('button[aria-expanded], [role="button"][aria-expanded]');
98
- if (toggleButton && toggleButton.getAttribute('aria-expanded') === 'false') {
99
- return false;
100
- }
101
-
102
- /**
103
- * For role="dialog", check aria-modal attribute.
104
- * aria-modal="true" indicates a blocking modal (Modal, Dialog).
105
- * aria-modal="false" or absence indicates non-blocking.
106
- */
107
- const ariaModal = element.getAttribute('aria-modal');
108
- if (ariaModal === 'true') {
109
- return true;
110
- }
111
- if (ariaModal === 'false') {
112
- // Explicitly non-modal, should not block
113
- return false;
114
- }
115
-
116
- /**
117
- * Elements with role="dialog" but without aria-modal="true" are non-blocking.
118
- * These include collapsible dialogs (help menus) and popovers (Popover, InfoTip, Tooltip)
119
- * that use role="dialog". They should not prevent InfoTip from closing.
120
- */
121
- return false;
122
18
  };
package/package.json CHANGED
@@ -1,21 +1,21 @@
1
1
  {
2
2
  "name": "@codecademy/gamut",
3
3
  "description": "Styleguide & Component library for Codecademy",
4
- "version": "67.6.5-alpha.e8ee42.0",
4
+ "version": "67.6.5",
5
5
  "author": "Codecademy Engineering <dev@codecademy.com>",
6
6
  "dependencies": {
7
- "@codecademy/gamut-icons": "9.54.1",
8
- "@codecademy/gamut-illustrations": "0.58.1",
9
- "@codecademy/gamut-patterns": "0.10.20",
10
- "@codecademy/gamut-styles": "17.11.1",
11
- "@codecademy/variance": "0.25.1",
7
+ "@codecademy/gamut-icons": "9.54.2",
8
+ "@codecademy/gamut-illustrations": "0.58.2",
9
+ "@codecademy/gamut-patterns": "0.10.21",
10
+ "@codecademy/gamut-styles": "17.11.2",
11
+ "@codecademy/variance": "0.25.2",
12
12
  "@types/marked": "^4.0.8",
13
13
  "@vidstack/react": "^1.12.12",
14
14
  "classnames": "^2.2.5",
15
15
  "framer-motion": "^11.18.0",
16
16
  "html-to-react": "^1.6.0",
17
17
  "invariant": "^2.2.4",
18
- "lodash": "^4.17.5",
18
+ "lodash": "^4.17.23",
19
19
  "marked": "^4.3.0",
20
20
  "polished": "^4.1.2",
21
21
  "react-aria-components": "1.8.0",
@@ -56,5 +56,5 @@
56
56
  "dist/**/[A-Z]**/[A-Z]*.js",
57
57
  "dist/**/[A-Z]**/index.js"
58
58
  ],
59
- "gitHead": "5ef55ea7ef11d41315e8ad8b462ab14565d43fb7"
59
+ "gitHead": "dba147a168af471002f2f97b74eea97204bd843f"
60
60
  }
@@ -1,22 +0,0 @@
1
- import { RenderResult } from '@testing-library/react';
2
- /**
3
- * Creates and appends an external label element to the test container.
4
- * This is useful for testing ariaLabelledby functionality where an InfoTip
5
- * references an external label element.
6
- *
7
- * @param view - The render result from testing-library
8
- * @param id - The ID of the external label element (used in ariaLabelledby)
9
- * @param text - The text content of the external label
10
- * @returns The created span element
11
- *
12
- * @example
13
- * ```ts
14
- * const { view } = renderView({
15
- * infotip: { info, ariaLabelledby: 'external-label-id' },
16
- * });
17
- *
18
- * createExternalLabel(view, 'external-label-id', 'External Label');
19
- * view.getByRole('button', { name: 'External Label' });
20
- * ```
21
- */
22
- export declare const createExternalLabel: (view: RenderResult, id: string, text: string) => HTMLSpanElement;
@@ -1,35 +0,0 @@
1
- import type { InfoTipBaseProps, InfoTipProps } from './index';
2
- type InfoTipAriaLabel = InfoTipBaseProps & {
3
- ariaLabel?: string;
4
- ariaLabelledby?: never;
5
- };
6
- type InfoTipAriaLabelledby = InfoTipBaseProps & {
7
- ariaLabel?: never;
8
- ariaLabelledby?: string;
9
- };
10
- type InfoTipPropsAriaWithFallback = InfoTipBaseProps & {
11
- ariaLabel?: never;
12
- ariaLabelledby?: never;
13
- };
14
- /**
15
- * InfoTip props that allow both ariaLabel and ariaLabelledby to be optional.
16
- * Used in components that automatically provide ariaLabelledby when neither is provided.
17
- */
18
- export type InfoTipSubComponentProps = InfoTipAriaLabel | InfoTipAriaLabelledby | InfoTipPropsAriaWithFallback;
19
- export declare const createInfoTipProps: (props: InfoTipSubComponentProps, fallbackAriaLabelledby?: string) => {
20
- infotipProps: InfoTipProps;
21
- shouldLabelInfoTip: boolean;
22
- };
23
- /**
24
- * Hook to handle infotip props and accessibility labeling.
25
- * Extracts the common pattern used by Radio, Checkbox, and FormGroupLabel components.
26
- *
27
- * @param infotip - Optional infotip subcomponent props
28
- * @returns Object containing infotipProps, labelId, and shouldLabelInfoTip flag
29
- */
30
- export declare const useInfotipProps: (infotip?: InfoTipSubComponentProps) => {
31
- infotipProps: InfoTipProps | undefined;
32
- labelId: string;
33
- shouldLabelInfoTip: boolean;
34
- };
35
- export {};
@@ -1,72 +0,0 @@
1
- import { useId } from 'react';
2
-
3
- /**
4
- * InfoTip props that allow both ariaLabel and ariaLabelledby to be optional.
5
- * Used in components that automatically provide ariaLabelledby when neither is provided.
6
- */
7
-
8
- export const createInfoTipProps = (props, fallbackAriaLabelledby) => {
9
- const {
10
- ariaLabel,
11
- ariaLabelledby,
12
- ...rest
13
- } = props;
14
- const hasAriaLabel = ariaLabel !== undefined;
15
- const hasAriaLabelledby = ariaLabelledby !== undefined;
16
- if (hasAriaLabel) {
17
- return {
18
- infotipProps: {
19
- ...rest,
20
- ariaLabel
21
- },
22
- shouldLabelInfoTip: false
23
- };
24
- }
25
- if (hasAriaLabelledby) {
26
- return {
27
- infotipProps: {
28
- ...rest,
29
- ariaLabelledby
30
- },
31
- shouldLabelInfoTip: false
32
- };
33
- }
34
- if (fallbackAriaLabelledby) {
35
- return {
36
- infotipProps: {
37
- ...rest,
38
- ariaLabelledby: fallbackAriaLabelledby
39
- },
40
- shouldLabelInfoTip: true
41
- };
42
- }
43
- return {
44
- infotipProps: {
45
- ...rest
46
- },
47
- shouldLabelInfoTip: false
48
- };
49
- };
50
-
51
- /**
52
- * Hook to handle infotip props and accessibility labeling.
53
- * Extracts the common pattern used by Radio, Checkbox, and FormGroupLabel components.
54
- *
55
- * @param infotip - Optional infotip subcomponent props
56
- * @returns Object containing infotipProps, labelId, and shouldLabelInfoTip flag
57
- */
58
- export const useInfotipProps = infotip => {
59
- const labelId = useId();
60
- const {
61
- infotipProps,
62
- shouldLabelInfoTip
63
- } = infotip ? createInfoTipProps(infotip, labelId) : {
64
- infotipProps: undefined,
65
- shouldLabelInfoTip: false
66
- };
67
- return {
68
- infotipProps,
69
- labelId,
70
- shouldLabelInfoTip
71
- };
72
- };