@womp/kookie-ui 0.34.2 → 0.35.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/components.css +5 -3
- package/dist/cjs/components/alert-dialog.js +1 -1
- package/dist/cjs/components/alert-dialog.js.map +3 -3
- package/dist/cjs/components/command.d.ts.map +1 -1
- package/dist/cjs/components/command.js +1 -1
- package/dist/cjs/components/command.js.map +3 -3
- package/dist/cjs/components/dialog.js +1 -1
- package/dist/cjs/components/dialog.js.map +3 -3
- package/dist/cjs/components/index.js +2 -2
- package/dist/cjs/components/index.js.map +3 -3
- package/dist/cjs/components/navigator.d.ts +6 -1
- package/dist/cjs/components/navigator.d.ts.map +1 -1
- package/dist/cjs/components/navigator.js +1 -1
- package/dist/cjs/components/navigator.js.map +2 -2
- package/dist/cjs/components/sheet.js +1 -1
- package/dist/cjs/components/sheet.js.map +3 -3
- package/dist/cjs/helpers/index.d.ts +0 -1
- package/dist/cjs/helpers/index.d.ts.map +1 -1
- package/dist/cjs/helpers/index.js +3 -3
- package/dist/cjs/helpers/index.js.map +4 -4
- package/dist/cjs/hooks/index.d.ts +0 -2
- package/dist/cjs/hooks/index.d.ts.map +1 -1
- package/dist/cjs/hooks/index.js +3 -11
- package/dist/cjs/hooks/index.js.map +4 -4
- package/dist/cjs/hooks/use-body-pointer-events-cleanup.d.ts +6 -0
- package/dist/cjs/hooks/use-body-pointer-events-cleanup.d.ts.map +1 -1
- package/dist/cjs/hooks/use-body-pointer-events-cleanup.js +1 -1
- package/dist/cjs/hooks/use-body-pointer-events-cleanup.js.map +3 -3
- package/dist/cjs/index.js +3 -11
- package/dist/cjs/index.js.map +4 -4
- package/dist/cjs/props/index.d.ts +0 -1
- package/dist/cjs/props/index.d.ts.map +1 -1
- package/dist/cjs/props/index.js +1 -1
- package/dist/cjs/props/index.js.map +4 -4
- package/dist/esm/chunk-3RJVW6RK.js +3 -0
- package/dist/esm/{chunk-7VJF6EXN.js.map → chunk-3RJVW6RK.js.map} +3 -3
- package/dist/esm/chunk-LR4X7SVV.js +3 -0
- package/dist/esm/chunk-LR4X7SVV.js.map +7 -0
- package/dist/esm/{chunk-J7MIXG6M.js → chunk-QV66TN2A.js} +2 -2
- package/dist/esm/chunk-SR42NATX.js +3 -0
- package/dist/esm/chunk-SR42NATX.js.map +7 -0
- package/dist/esm/chunk-UH6CJXHY.js +3 -0
- package/dist/esm/chunk-UH6CJXHY.js.map +7 -0
- package/dist/esm/chunk-VRWZLGR7.js +2 -0
- package/dist/esm/chunk-XVN43IZL.js +3 -0
- package/dist/esm/chunk-XVN43IZL.js.map +7 -0
- package/dist/esm/components/alert-dialog.js +1 -1
- package/dist/esm/components/command.d.ts.map +1 -1
- package/dist/esm/components/command.js +1 -1
- package/dist/esm/components/dialog.js +1 -1
- package/dist/esm/components/index.js +1 -1
- package/dist/esm/components/navigator.d.ts +6 -1
- package/dist/esm/components/navigator.d.ts.map +1 -1
- package/dist/esm/components/navigator.js +1 -1
- package/dist/esm/components/sheet.js +1 -1
- package/dist/esm/helpers/index.d.ts +0 -1
- package/dist/esm/helpers/index.d.ts.map +1 -1
- package/dist/esm/helpers/index.js +1 -1
- package/dist/esm/helpers/index.js.map +2 -2
- package/dist/esm/hooks/index.d.ts +0 -2
- package/dist/esm/hooks/index.d.ts.map +1 -1
- package/dist/esm/hooks/index.js +1 -1
- package/dist/esm/hooks/use-body-pointer-events-cleanup.d.ts +6 -0
- package/dist/esm/hooks/use-body-pointer-events-cleanup.d.ts.map +1 -1
- package/dist/esm/hooks/use-body-pointer-events-cleanup.js +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/props/index.d.ts +0 -1
- package/dist/esm/props/index.d.ts.map +1 -1
- package/dist/esm/props/index.js +1 -1
- package/package.json +1 -1
- package/src/components/_internal/base-checkbox.css +0 -2
- package/src/components/_internal/base-sidebar-menu.css +0 -3
- package/src/components/_internal/base-sidebar.css +0 -2
- package/src/components/_internal/base-tab-list.css +0 -1
- package/src/components/accordion.css +0 -1
- package/src/components/alert-dialog.tsx +2 -2
- package/src/components/chatbar.css +0 -2
- package/src/components/command.tsx +16 -3
- package/src/components/dialog.tsx +2 -2
- package/src/components/navigator.tsx +14 -1
- package/src/components/notice.css +1 -1
- package/src/components/segmented-control.css +0 -3
- package/src/components/sidebar.css +2 -7
- package/src/components/text-area.css +0 -1
- package/src/components/virtual-menu.css +0 -1
- package/src/helpers/index.ts +0 -1
- package/src/hooks/index.ts +0 -2
- package/src/hooks/use-body-pointer-events-cleanup.ts +12 -0
- package/src/props/index.ts +0 -1
- package/styles.css +5 -3
- package/dist/cjs/helpers/map-prop-values.d.ts +0 -4
- package/dist/cjs/helpers/map-prop-values.d.ts.map +0 -1
- package/dist/cjs/helpers/map-prop-values.js +0 -2
- package/dist/cjs/helpers/map-prop-values.js.map +0 -7
- package/dist/cjs/hooks/use-live-announcer.d.ts +0 -6
- package/dist/cjs/hooks/use-live-announcer.d.ts.map +0 -1
- package/dist/cjs/hooks/use-live-announcer.js +0 -11
- package/dist/cjs/hooks/use-live-announcer.js.map +0 -7
- package/dist/cjs/hooks/use-toggle-state.d.ts +0 -37
- package/dist/cjs/hooks/use-toggle-state.d.ts.map +0 -1
- package/dist/cjs/hooks/use-toggle-state.js +0 -11
- package/dist/cjs/hooks/use-toggle-state.js.map +0 -7
- package/dist/cjs/props/shadow.props.d.ts +0 -24
- package/dist/cjs/props/shadow.props.d.ts.map +0 -1
- package/dist/cjs/props/shadow.props.js +0 -2
- package/dist/cjs/props/shadow.props.js.map +0 -7
- package/dist/esm/chunk-677CX2QF.js +0 -2
- package/dist/esm/chunk-677CX2QF.js.map +0 -7
- package/dist/esm/chunk-7VJF6EXN.js +0 -3
- package/dist/esm/chunk-AYKOOEZR.js +0 -2
- package/dist/esm/chunk-CAM66IXC.js +0 -3
- package/dist/esm/chunk-CAM66IXC.js.map +0 -7
- package/dist/esm/chunk-GZPB6MRQ.js +0 -3
- package/dist/esm/chunk-GZPB6MRQ.js.map +0 -7
- package/dist/esm/chunk-I5TPDYJO.js +0 -3
- package/dist/esm/chunk-I5TPDYJO.js.map +0 -7
- package/dist/esm/chunk-NZJRXZYX.js +0 -3
- package/dist/esm/chunk-NZJRXZYX.js.map +0 -7
- package/dist/esm/chunk-RIHTVZVJ.js +0 -3
- package/dist/esm/chunk-RIHTVZVJ.js.map +0 -7
- package/dist/esm/chunk-WTP2KIK3.js +0 -11
- package/dist/esm/chunk-WTP2KIK3.js.map +0 -7
- package/dist/esm/chunk-WYLIU3Q6.js +0 -2
- package/dist/esm/chunk-WYLIU3Q6.js.map +0 -7
- package/dist/esm/helpers/map-prop-values.d.ts +0 -4
- package/dist/esm/helpers/map-prop-values.d.ts.map +0 -1
- package/dist/esm/helpers/map-prop-values.js +0 -2
- package/dist/esm/helpers/map-prop-values.js.map +0 -7
- package/dist/esm/hooks/use-live-announcer.d.ts +0 -6
- package/dist/esm/hooks/use-live-announcer.d.ts.map +0 -1
- package/dist/esm/hooks/use-live-announcer.js +0 -3
- package/dist/esm/hooks/use-live-announcer.js.map +0 -7
- package/dist/esm/hooks/use-toggle-state.d.ts +0 -37
- package/dist/esm/hooks/use-toggle-state.d.ts.map +0 -1
- package/dist/esm/hooks/use-toggle-state.js +0 -3
- package/dist/esm/hooks/use-toggle-state.js.map +0 -7
- package/dist/esm/props/shadow.props.d.ts +0 -24
- package/dist/esm/props/shadow.props.d.ts.map +0 -1
- package/dist/esm/props/shadow.props.js +0 -2
- package/dist/esm/props/shadow.props.js.map +0 -7
- package/src/helpers/map-prop-values.ts +0 -16
- package/src/hooks/use-live-announcer.ts +0 -79
- package/src/hooks/use-toggle-state.ts +0 -72
- package/src/props/shadow.props.ts +0 -30
- /package/dist/esm/{chunk-J7MIXG6M.js.map → chunk-QV66TN2A.js.map} +0 -0
- /package/dist/esm/{chunk-AYKOOEZR.js.map → chunk-VRWZLGR7.js.map} +0 -0
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Reference counter to track how many components are using the live region.
|
|
5
|
-
* Only remove the live region when no components are using it.
|
|
6
|
-
*/
|
|
7
|
-
let liveRegionRefCount = 0;
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Hook for making live announcements to screen readers
|
|
11
|
-
* Creates a hidden aria-live region for announcing dynamic content changes
|
|
12
|
-
*/
|
|
13
|
-
export function useLiveAnnouncer() {
|
|
14
|
-
// Track the timeout so we can clean it up on unmount
|
|
15
|
-
const timeoutRef = React.useRef<ReturnType<typeof setTimeout> | undefined>(undefined);
|
|
16
|
-
|
|
17
|
-
// Create aria-live region if it doesn't exist
|
|
18
|
-
React.useEffect(() => {
|
|
19
|
-
let liveRegion = document.getElementById('kui-live-announcer');
|
|
20
|
-
|
|
21
|
-
if (!liveRegion) {
|
|
22
|
-
liveRegion = document.createElement('div');
|
|
23
|
-
liveRegion.id = 'kui-live-announcer';
|
|
24
|
-
liveRegion.setAttribute('aria-live', 'polite');
|
|
25
|
-
liveRegion.setAttribute('aria-atomic', 'true');
|
|
26
|
-
liveRegion.style.cssText = `
|
|
27
|
-
position: absolute;
|
|
28
|
-
left: -10000px;
|
|
29
|
-
width: 1px;
|
|
30
|
-
height: 1px;
|
|
31
|
-
overflow: hidden;
|
|
32
|
-
clip: rect(0, 0, 0, 0);
|
|
33
|
-
white-space: nowrap;
|
|
34
|
-
`;
|
|
35
|
-
document.body.appendChild(liveRegion);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
// Increment ref count when component mounts
|
|
39
|
-
liveRegionRefCount++;
|
|
40
|
-
|
|
41
|
-
return () => {
|
|
42
|
-
// Decrement ref count when component unmounts
|
|
43
|
-
liveRegionRefCount--;
|
|
44
|
-
|
|
45
|
-
// Clean up timeout on unmount
|
|
46
|
-
if (timeoutRef.current) {
|
|
47
|
-
clearTimeout(timeoutRef.current);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
// Only remove the live region if no components are using it
|
|
51
|
-
if (liveRegionRefCount === 0) {
|
|
52
|
-
const region = document.getElementById('kui-live-announcer');
|
|
53
|
-
if (region) {
|
|
54
|
-
region.remove();
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
|
-
}, []);
|
|
59
|
-
|
|
60
|
-
const announce = React.useCallback((message: string) => {
|
|
61
|
-
const liveRegion = document.getElementById('kui-live-announcer');
|
|
62
|
-
if (liveRegion) {
|
|
63
|
-
// Clear any pending timeout
|
|
64
|
-
if (timeoutRef.current) {
|
|
65
|
-
clearTimeout(timeoutRef.current);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
// Clear previous announcements
|
|
69
|
-
liveRegion.textContent = '';
|
|
70
|
-
|
|
71
|
-
// Add new announcement with a small delay to ensure it's announced
|
|
72
|
-
timeoutRef.current = setTimeout(() => {
|
|
73
|
-
liveRegion.textContent = message;
|
|
74
|
-
}, 100);
|
|
75
|
-
}
|
|
76
|
-
}, []);
|
|
77
|
-
|
|
78
|
-
return announce;
|
|
79
|
-
}
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { useLiveAnnouncer } from './use-live-announcer.js';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Options for the useToggleState hook
|
|
6
|
-
*/
|
|
7
|
-
interface UseToggleStateOptions {
|
|
8
|
-
/** Controlled pressed state */
|
|
9
|
-
pressed?: boolean;
|
|
10
|
-
/** Callback when pressed state changes */
|
|
11
|
-
onPressedChange?: (pressed: boolean) => void;
|
|
12
|
-
/** Function to get the accessible name for announcements */
|
|
13
|
-
getAccessibleName: () => string;
|
|
14
|
-
/** Component name for warning messages */
|
|
15
|
-
componentName: string;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Hook for shared toggle button state management.
|
|
20
|
-
* Provides accessibility announcements and controlled/uncontrolled warnings.
|
|
21
|
-
*
|
|
22
|
-
* @param options - Configuration options for the toggle state
|
|
23
|
-
* @returns Object containing the handlePressedChange callback
|
|
24
|
-
*
|
|
25
|
-
* @example
|
|
26
|
-
* ```tsx
|
|
27
|
-
* const getAccessibleName = React.useCallback(() => 'Toggle button', []);
|
|
28
|
-
*
|
|
29
|
-
* const { handlePressedChange } = useToggleState({
|
|
30
|
-
* pressed,
|
|
31
|
-
* onPressedChange,
|
|
32
|
-
* getAccessibleName,
|
|
33
|
-
* componentName: 'Toggle',
|
|
34
|
-
* });
|
|
35
|
-
* ```
|
|
36
|
-
*/
|
|
37
|
-
export function useToggleState({ pressed, onPressedChange, getAccessibleName, componentName }: UseToggleStateOptions) {
|
|
38
|
-
const announce = useLiveAnnouncer();
|
|
39
|
-
|
|
40
|
-
// Track if we've already warned about controlled without handler
|
|
41
|
-
const warnedRef = React.useRef(false);
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Memoized handler for state changes with accessibility announcements.
|
|
45
|
-
* Announces the new state immediately for screen readers.
|
|
46
|
-
*/
|
|
47
|
-
const handlePressedChange = React.useCallback(
|
|
48
|
-
(newPressed: boolean) => {
|
|
49
|
-
const accessibleName = getAccessibleName();
|
|
50
|
-
// Announce the state change for screen readers
|
|
51
|
-
announce(`${accessibleName} ${newPressed ? 'pressed' : 'unpressed'}`);
|
|
52
|
-
// Call the user's change handler
|
|
53
|
-
onPressedChange?.(newPressed);
|
|
54
|
-
},
|
|
55
|
-
[announce, onPressedChange, getAccessibleName],
|
|
56
|
-
);
|
|
57
|
-
|
|
58
|
-
// Development-only warning for controlled/uncontrolled pattern
|
|
59
|
-
// Only warns once to avoid console spam
|
|
60
|
-
React.useEffect(() => {
|
|
61
|
-
if (process.env.NODE_ENV === 'development' && pressed !== undefined && onPressedChange === undefined && !warnedRef.current) {
|
|
62
|
-
warnedRef.current = true;
|
|
63
|
-
console.warn(
|
|
64
|
-
`${componentName}: You provided a \`pressed\` prop without an \`onPressedChange\` handler. ` +
|
|
65
|
-
'This will result in a read-only toggle button. If you want the button to be interactive, ' +
|
|
66
|
-
'you should provide an `onPressedChange` handler.',
|
|
67
|
-
);
|
|
68
|
-
}
|
|
69
|
-
}, [pressed, onPressedChange, componentName]);
|
|
70
|
-
|
|
71
|
-
return { handlePressedChange };
|
|
72
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import type { PropDef, GetPropDefTypes } from './prop-def.js';
|
|
2
|
-
|
|
3
|
-
const shadowValues = ['1', '2', '3', '4', '5', '6'] as const;
|
|
4
|
-
|
|
5
|
-
const shadowPropDefs = {
|
|
6
|
-
/**
|
|
7
|
-
* Sets the CSS **box-shadow** property using design system shadow tokens.
|
|
8
|
-
* Supports shadow scale values and responsive objects.
|
|
9
|
-
*
|
|
10
|
-
* @example
|
|
11
|
-
* shadow="3"
|
|
12
|
-
* shadow={{ sm: '2', lg: '4' }}
|
|
13
|
-
*
|
|
14
|
-
* @link
|
|
15
|
-
* https://developer.mozilla.org/en-US/docs/Web/CSS/box-shadow
|
|
16
|
-
*/
|
|
17
|
-
shadow: {
|
|
18
|
-
type: 'enum',
|
|
19
|
-
className: 'kui-r-shadow',
|
|
20
|
-
values: shadowValues,
|
|
21
|
-
responsive: true,
|
|
22
|
-
},
|
|
23
|
-
} satisfies {
|
|
24
|
-
shadow: PropDef<(typeof shadowValues)[number]>;
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
type ShadowProps = GetPropDefTypes<typeof shadowPropDefs>;
|
|
28
|
-
|
|
29
|
-
export { shadowPropDefs };
|
|
30
|
-
export type { ShadowProps };
|
|
File without changes
|
|
File without changes
|