@womp/kookie-ui 0.34.2 → 0.35.0

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 (89) hide show
  1. package/components.css +5 -3
  2. package/dist/cjs/helpers/index.d.ts +0 -1
  3. package/dist/cjs/helpers/index.d.ts.map +1 -1
  4. package/dist/cjs/helpers/index.js +3 -3
  5. package/dist/cjs/helpers/index.js.map +4 -4
  6. package/dist/cjs/hooks/index.d.ts +0 -2
  7. package/dist/cjs/hooks/index.d.ts.map +1 -1
  8. package/dist/cjs/hooks/index.js +3 -11
  9. package/dist/cjs/hooks/index.js.map +4 -4
  10. package/dist/cjs/index.js +3 -11
  11. package/dist/cjs/index.js.map +4 -4
  12. package/dist/cjs/props/index.d.ts +0 -1
  13. package/dist/cjs/props/index.d.ts.map +1 -1
  14. package/dist/cjs/props/index.js +1 -1
  15. package/dist/cjs/props/index.js.map +4 -4
  16. package/dist/esm/chunk-VRWZLGR7.js +2 -0
  17. package/dist/esm/helpers/index.d.ts +0 -1
  18. package/dist/esm/helpers/index.d.ts.map +1 -1
  19. package/dist/esm/helpers/index.js +1 -1
  20. package/dist/esm/helpers/index.js.map +2 -2
  21. package/dist/esm/hooks/index.d.ts +0 -2
  22. package/dist/esm/hooks/index.d.ts.map +1 -1
  23. package/dist/esm/hooks/index.js +1 -1
  24. package/dist/esm/index.js +1 -1
  25. package/dist/esm/props/index.d.ts +0 -1
  26. package/dist/esm/props/index.d.ts.map +1 -1
  27. package/dist/esm/props/index.js +1 -1
  28. package/package.json +1 -1
  29. package/src/components/_internal/base-checkbox.css +0 -2
  30. package/src/components/_internal/base-sidebar-menu.css +0 -3
  31. package/src/components/_internal/base-sidebar.css +0 -2
  32. package/src/components/_internal/base-tab-list.css +0 -1
  33. package/src/components/accordion.css +0 -1
  34. package/src/components/chatbar.css +0 -2
  35. package/src/components/notice.css +1 -1
  36. package/src/components/segmented-control.css +0 -3
  37. package/src/components/sidebar.css +2 -7
  38. package/src/components/text-area.css +0 -1
  39. package/src/components/virtual-menu.css +0 -1
  40. package/src/helpers/index.ts +0 -1
  41. package/src/hooks/index.ts +0 -2
  42. package/src/props/index.ts +0 -1
  43. package/styles.css +5 -3
  44. package/dist/cjs/helpers/map-prop-values.d.ts +0 -4
  45. package/dist/cjs/helpers/map-prop-values.d.ts.map +0 -1
  46. package/dist/cjs/helpers/map-prop-values.js +0 -2
  47. package/dist/cjs/helpers/map-prop-values.js.map +0 -7
  48. package/dist/cjs/hooks/use-live-announcer.d.ts +0 -6
  49. package/dist/cjs/hooks/use-live-announcer.d.ts.map +0 -1
  50. package/dist/cjs/hooks/use-live-announcer.js +0 -11
  51. package/dist/cjs/hooks/use-live-announcer.js.map +0 -7
  52. package/dist/cjs/hooks/use-toggle-state.d.ts +0 -37
  53. package/dist/cjs/hooks/use-toggle-state.d.ts.map +0 -1
  54. package/dist/cjs/hooks/use-toggle-state.js +0 -11
  55. package/dist/cjs/hooks/use-toggle-state.js.map +0 -7
  56. package/dist/cjs/props/shadow.props.d.ts +0 -24
  57. package/dist/cjs/props/shadow.props.d.ts.map +0 -1
  58. package/dist/cjs/props/shadow.props.js +0 -2
  59. package/dist/cjs/props/shadow.props.js.map +0 -7
  60. package/dist/esm/chunk-677CX2QF.js +0 -2
  61. package/dist/esm/chunk-677CX2QF.js.map +0 -7
  62. package/dist/esm/chunk-AYKOOEZR.js +0 -2
  63. package/dist/esm/chunk-RIHTVZVJ.js +0 -3
  64. package/dist/esm/chunk-RIHTVZVJ.js.map +0 -7
  65. package/dist/esm/chunk-WTP2KIK3.js +0 -11
  66. package/dist/esm/chunk-WTP2KIK3.js.map +0 -7
  67. package/dist/esm/chunk-WYLIU3Q6.js +0 -2
  68. package/dist/esm/chunk-WYLIU3Q6.js.map +0 -7
  69. package/dist/esm/helpers/map-prop-values.d.ts +0 -4
  70. package/dist/esm/helpers/map-prop-values.d.ts.map +0 -1
  71. package/dist/esm/helpers/map-prop-values.js +0 -2
  72. package/dist/esm/helpers/map-prop-values.js.map +0 -7
  73. package/dist/esm/hooks/use-live-announcer.d.ts +0 -6
  74. package/dist/esm/hooks/use-live-announcer.d.ts.map +0 -1
  75. package/dist/esm/hooks/use-live-announcer.js +0 -3
  76. package/dist/esm/hooks/use-live-announcer.js.map +0 -7
  77. package/dist/esm/hooks/use-toggle-state.d.ts +0 -37
  78. package/dist/esm/hooks/use-toggle-state.d.ts.map +0 -1
  79. package/dist/esm/hooks/use-toggle-state.js +0 -3
  80. package/dist/esm/hooks/use-toggle-state.js.map +0 -7
  81. package/dist/esm/props/shadow.props.d.ts +0 -24
  82. package/dist/esm/props/shadow.props.d.ts.map +0 -1
  83. package/dist/esm/props/shadow.props.js +0 -2
  84. package/dist/esm/props/shadow.props.js.map +0 -7
  85. package/src/helpers/map-prop-values.ts +0 -16
  86. package/src/hooks/use-live-announcer.ts +0 -79
  87. package/src/hooks/use-toggle-state.ts +0 -72
  88. package/src/props/shadow.props.ts +0 -30
  89. /package/dist/esm/{chunk-AYKOOEZR.js.map → chunk-VRWZLGR7.js.map} +0 -0
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/props/shadow.props.ts"],
4
- "sourcesContent": ["import type { PropDef, GetPropDefTypes } from './prop-def.js';\n\nconst shadowValues = ['1', '2', '3', '4', '5', '6'] as const;\n\nconst shadowPropDefs = {\n /**\n * Sets the CSS **box-shadow** property using design system shadow tokens.\n * Supports shadow scale values and responsive objects.\n *\n * @example\n * shadow=\"3\"\n * shadow={{ sm: '2', lg: '4' }}\n *\n * @link\n * https://developer.mozilla.org/en-US/docs/Web/CSS/box-shadow\n */\n shadow: {\n type: 'enum',\n className: 'kui-r-shadow',\n values: shadowValues,\n responsive: true,\n },\n} satisfies {\n shadow: PropDef<(typeof shadowValues)[number]>;\n};\n\ntype ShadowProps = GetPropDefTypes<typeof shadowPropDefs>;\n\nexport { shadowPropDefs };\nexport type { ShadowProps };\n"],
5
- "mappings": "AAEA,IAAMA,EAAe,CAAC,IAAK,IAAK,IAAK,IAAK,IAAK,GAAG,EAE5CC,EAAiB,CAYrB,OAAQ,CACN,KAAM,OACN,UAAW,eACX,OAAQD,EACR,WAAY,EACd,CACF",
6
- "names": ["shadowValues", "shadowPropDefs"]
7
- }
@@ -1,2 +0,0 @@
1
- "use client";
2
- //# sourceMappingURL=chunk-AYKOOEZR.js.map
@@ -1,3 +0,0 @@
1
- "use client";
2
- import{a}from"./chunk-WTP2KIK3.js";import*as e from"react";function p({pressed:r,onPressedChange:n,getAccessibleName:o,componentName:d}){let t=a(),i=e.useRef(!1),c=e.useCallback(s=>{let u=o();t(`${u} ${s?"pressed":"unpressed"}`),n?.(s)},[t,n,o]);return e.useEffect(()=>{},[r,n,d]),{handlePressedChange:c}}export{p as a};
3
- //# sourceMappingURL=chunk-RIHTVZVJ.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/hooks/use-toggle-state.ts"],
4
- "sourcesContent": ["import * as React from 'react';\nimport { useLiveAnnouncer } from './use-live-announcer.js';\n\n/**\n * Options for the useToggleState hook\n */\ninterface UseToggleStateOptions {\n /** Controlled pressed state */\n pressed?: boolean;\n /** Callback when pressed state changes */\n onPressedChange?: (pressed: boolean) => void;\n /** Function to get the accessible name for announcements */\n getAccessibleName: () => string;\n /** Component name for warning messages */\n componentName: string;\n}\n\n/**\n * Hook for shared toggle button state management.\n * Provides accessibility announcements and controlled/uncontrolled warnings.\n *\n * @param options - Configuration options for the toggle state\n * @returns Object containing the handlePressedChange callback\n *\n * @example\n * ```tsx\n * const getAccessibleName = React.useCallback(() => 'Toggle button', []);\n *\n * const { handlePressedChange } = useToggleState({\n * pressed,\n * onPressedChange,\n * getAccessibleName,\n * componentName: 'Toggle',\n * });\n * ```\n */\nexport function useToggleState({ pressed, onPressedChange, getAccessibleName, componentName }: UseToggleStateOptions) {\n const announce = useLiveAnnouncer();\n\n // Track if we've already warned about controlled without handler\n const warnedRef = React.useRef(false);\n\n /**\n * Memoized handler for state changes with accessibility announcements.\n * Announces the new state immediately for screen readers.\n */\n const handlePressedChange = React.useCallback(\n (newPressed: boolean) => {\n const accessibleName = getAccessibleName();\n // Announce the state change for screen readers\n announce(`${accessibleName} ${newPressed ? 'pressed' : 'unpressed'}`);\n // Call the user's change handler\n onPressedChange?.(newPressed);\n },\n [announce, onPressedChange, getAccessibleName],\n );\n\n // Development-only warning for controlled/uncontrolled pattern\n // Only warns once to avoid console spam\n React.useEffect(() => {\n if (process.env.NODE_ENV === 'development' && pressed !== undefined && onPressedChange === undefined && !warnedRef.current) {\n warnedRef.current = true;\n console.warn(\n `${componentName}: You provided a \\`pressed\\` prop without an \\`onPressedChange\\` handler. ` +\n 'This will result in a read-only toggle button. If you want the button to be interactive, ' +\n 'you should provide an `onPressedChange` handler.',\n );\n }\n }, [pressed, onPressedChange, componentName]);\n\n return { handlePressedChange };\n}\n"],
5
- "mappings": ";mCAAA,UAAYA,MAAW,QAoChB,SAASC,EAAe,CAAE,QAAAC,EAAS,gBAAAC,EAAiB,kBAAAC,EAAmB,cAAAC,CAAc,EAA0B,CACpH,IAAMC,EAAWC,EAAiB,EAG5BC,EAAkB,SAAO,EAAK,EAM9BC,EAA4B,cAC/BC,GAAwB,CACvB,IAAMC,EAAiBP,EAAkB,EAEzCE,EAAS,GAAGK,CAAc,IAAID,EAAa,UAAY,WAAW,EAAE,EAEpEP,IAAkBO,CAAU,CAC9B,EACA,CAACJ,EAAUH,EAAiBC,CAAiB,CAC/C,EAIA,OAAM,YAAU,IAAM,CAStB,EAAG,CAACF,EAASC,EAAiBE,CAAa,CAAC,EAErC,CAAE,oBAAAI,CAAoB,CAC/B",
6
- "names": ["React", "useToggleState", "pressed", "onPressedChange", "getAccessibleName", "componentName", "announce", "useLiveAnnouncer", "warnedRef", "handlePressedChange", "newPressed", "accessibleName"]
7
- }
@@ -1,11 +0,0 @@
1
- "use client";
2
- import*as n from"react";var o=0;function r(){let i=n.useRef(void 0);return n.useEffect(()=>{let e=document.getElementById("kui-live-announcer");return e||(e=document.createElement("div"),e.id="kui-live-announcer",e.setAttribute("aria-live","polite"),e.setAttribute("aria-atomic","true"),e.style.cssText=`
3
- position: absolute;
4
- left: -10000px;
5
- width: 1px;
6
- height: 1px;
7
- overflow: hidden;
8
- clip: rect(0, 0, 0, 0);
9
- white-space: nowrap;
10
- `,document.body.appendChild(e)),o++,()=>{if(o--,i.current&&clearTimeout(i.current),o===0){let t=document.getElementById("kui-live-announcer");t&&t.remove()}}},[]),n.useCallback(e=>{let t=document.getElementById("kui-live-announcer");t&&(i.current&&clearTimeout(i.current),t.textContent="",i.current=setTimeout(()=>{t.textContent=e},100))},[])}export{r as a};
11
- //# sourceMappingURL=chunk-WTP2KIK3.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/hooks/use-live-announcer.ts"],
4
- "sourcesContent": ["import * as React from 'react';\n\n/**\n * Reference counter to track how many components are using the live region.\n * Only remove the live region when no components are using it.\n */\nlet liveRegionRefCount = 0;\n\n/**\n * Hook for making live announcements to screen readers\n * Creates a hidden aria-live region for announcing dynamic content changes\n */\nexport function useLiveAnnouncer() {\n // Track the timeout so we can clean it up on unmount\n const timeoutRef = React.useRef<ReturnType<typeof setTimeout> | undefined>(undefined);\n\n // Create aria-live region if it doesn't exist\n React.useEffect(() => {\n let liveRegion = document.getElementById('kui-live-announcer');\n\n if (!liveRegion) {\n liveRegion = document.createElement('div');\n liveRegion.id = 'kui-live-announcer';\n liveRegion.setAttribute('aria-live', 'polite');\n liveRegion.setAttribute('aria-atomic', 'true');\n liveRegion.style.cssText = `\n position: absolute;\n left: -10000px;\n width: 1px;\n height: 1px;\n overflow: hidden;\n clip: rect(0, 0, 0, 0);\n white-space: nowrap;\n `;\n document.body.appendChild(liveRegion);\n }\n\n // Increment ref count when component mounts\n liveRegionRefCount++;\n\n return () => {\n // Decrement ref count when component unmounts\n liveRegionRefCount--;\n\n // Clean up timeout on unmount\n if (timeoutRef.current) {\n clearTimeout(timeoutRef.current);\n }\n\n // Only remove the live region if no components are using it\n if (liveRegionRefCount === 0) {\n const region = document.getElementById('kui-live-announcer');\n if (region) {\n region.remove();\n }\n }\n };\n }, []);\n\n const announce = React.useCallback((message: string) => {\n const liveRegion = document.getElementById('kui-live-announcer');\n if (liveRegion) {\n // Clear any pending timeout\n if (timeoutRef.current) {\n clearTimeout(timeoutRef.current);\n }\n\n // Clear previous announcements\n liveRegion.textContent = '';\n\n // Add new announcement with a small delay to ensure it's announced\n timeoutRef.current = setTimeout(() => {\n liveRegion.textContent = message;\n }, 100);\n }\n }, []);\n\n return announce;\n}\n"],
5
- "mappings": ";AAAA,UAAYA,MAAW,QAMvB,IAAIC,EAAqB,EAMlB,SAASC,GAAmB,CAEjC,IAAMC,EAAmB,SAAkD,MAAS,EAGpF,OAAM,YAAU,IAAM,CACpB,IAAIC,EAAa,SAAS,eAAe,oBAAoB,EAE7D,OAAKA,IACHA,EAAa,SAAS,cAAc,KAAK,EACzCA,EAAW,GAAK,qBAChBA,EAAW,aAAa,YAAa,QAAQ,EAC7CA,EAAW,aAAa,cAAe,MAAM,EAC7CA,EAAW,MAAM,QAAU;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,QAS3B,SAAS,KAAK,YAAYA,CAAU,GAItCH,IAEO,IAAM,CAUX,GARAA,IAGIE,EAAW,SACb,aAAaA,EAAW,OAAO,EAI7BF,IAAuB,EAAG,CAC5B,IAAMI,EAAS,SAAS,eAAe,oBAAoB,EACvDA,GACFA,EAAO,OAAO,CAElB,CACF,CACF,EAAG,CAAC,CAAC,EAEkB,cAAaC,GAAoB,CACtD,IAAMF,EAAa,SAAS,eAAe,oBAAoB,EAC3DA,IAEED,EAAW,SACb,aAAaA,EAAW,OAAO,EAIjCC,EAAW,YAAc,GAGzBD,EAAW,QAAU,WAAW,IAAM,CACpCC,EAAW,YAAcE,CAC3B,EAAG,GAAG,EAEV,EAAG,CAAC,CAAC,CAGP",
6
- "names": ["React", "liveRegionRefCount", "useLiveAnnouncer", "timeoutRef", "liveRegion", "region", "message"]
7
- }
@@ -1,2 +0,0 @@
1
- function s(e,n){if(e!==void 0)return typeof e=="string"?n(e):Object.fromEntries(Object.entries(e).map(([t,i])=>[t,n(i)]))}export{s as a};
2
- //# sourceMappingURL=chunk-WYLIU3Q6.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/helpers/map-prop-values.ts"],
4
- "sourcesContent": ["import type { Responsive } from '../props/prop-def.js';\n\nfunction mapResponsiveProp<Input extends string, Output>(\n propValue: Responsive<Input> | undefined,\n mapValue: (value: Input) => Output\n): Responsive<Output> | undefined {\n if (propValue === undefined) return undefined;\n if (typeof propValue === 'string') {\n return mapValue(propValue);\n }\n return Object.fromEntries(\n Object.entries(propValue).map(([key, value]) => [key, mapValue(value)])\n );\n}\n\nexport { mapResponsiveProp };\n"],
5
- "mappings": "AAEA,SAASA,EACPC,EACAC,EACgC,CAChC,GAAID,IAAc,OAClB,OAAI,OAAOA,GAAc,SAChBC,EAASD,CAAS,EAEpB,OAAO,YACZ,OAAO,QAAQA,CAAS,EAAE,IAAI,CAAC,CAACE,EAAKC,CAAK,IAAM,CAACD,EAAKD,EAASE,CAAK,CAAC,CAAC,CACxE,CACF",
6
- "names": ["mapResponsiveProp", "propValue", "mapValue", "key", "value"]
7
- }
@@ -1,4 +0,0 @@
1
- import type { Responsive } from '../props/prop-def.js';
2
- declare function mapResponsiveProp<Input extends string, Output>(propValue: Responsive<Input> | undefined, mapValue: (value: Input) => Output): Responsive<Output> | undefined;
3
- export { mapResponsiveProp };
4
- //# sourceMappingURL=map-prop-values.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"map-prop-values.d.ts","sourceRoot":"","sources":["../../../src/helpers/map-prop-values.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAEvD,iBAAS,iBAAiB,CAAC,KAAK,SAAS,MAAM,EAAE,MAAM,EACrD,SAAS,EAAE,UAAU,CAAC,KAAK,CAAC,GAAG,SAAS,EACxC,QAAQ,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,MAAM,GACjC,UAAU,CAAC,MAAM,CAAC,GAAG,SAAS,CAQhC;AAED,OAAO,EAAE,iBAAiB,EAAE,CAAC"}
@@ -1,2 +0,0 @@
1
- import{a}from"../chunk-WYLIU3Q6.js";export{a as mapResponsiveProp};
2
- //# sourceMappingURL=map-prop-values.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": [],
4
- "sourcesContent": [],
5
- "mappings": "",
6
- "names": []
7
- }
@@ -1,6 +0,0 @@
1
- /**
2
- * Hook for making live announcements to screen readers
3
- * Creates a hidden aria-live region for announcing dynamic content changes
4
- */
5
- export declare function useLiveAnnouncer(): (message: string) => void;
6
- //# sourceMappingURL=use-live-announcer.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"use-live-announcer.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-live-announcer.ts"],"names":[],"mappings":"AAQA;;;GAGG;AACH,wBAAgB,gBAAgB,cA+Ce,MAAM,UAmBpD"}
@@ -1,3 +0,0 @@
1
- "use client";
2
- import{a}from"../chunk-WTP2KIK3.js";import"../chunk-VQPANPMI.js";export{a as useLiveAnnouncer};
3
- //# sourceMappingURL=use-live-announcer.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": [],
4
- "sourcesContent": [],
5
- "mappings": "",
6
- "names": []
7
- }
@@ -1,37 +0,0 @@
1
- /**
2
- * Options for the useToggleState hook
3
- */
4
- interface UseToggleStateOptions {
5
- /** Controlled pressed state */
6
- pressed?: boolean;
7
- /** Callback when pressed state changes */
8
- onPressedChange?: (pressed: boolean) => void;
9
- /** Function to get the accessible name for announcements */
10
- getAccessibleName: () => string;
11
- /** Component name for warning messages */
12
- componentName: string;
13
- }
14
- /**
15
- * Hook for shared toggle button state management.
16
- * Provides accessibility announcements and controlled/uncontrolled warnings.
17
- *
18
- * @param options - Configuration options for the toggle state
19
- * @returns Object containing the handlePressedChange callback
20
- *
21
- * @example
22
- * ```tsx
23
- * const getAccessibleName = React.useCallback(() => 'Toggle button', []);
24
- *
25
- * const { handlePressedChange } = useToggleState({
26
- * pressed,
27
- * onPressedChange,
28
- * getAccessibleName,
29
- * componentName: 'Toggle',
30
- * });
31
- * ```
32
- */
33
- export declare function useToggleState({ pressed, onPressedChange, getAccessibleName, componentName }: UseToggleStateOptions): {
34
- handlePressedChange: (newPressed: boolean) => void;
35
- };
36
- export {};
37
- //# sourceMappingURL=use-toggle-state.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"use-toggle-state.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-toggle-state.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,UAAU,qBAAqB;IAC7B,+BAA+B;IAC/B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,0CAA0C;IAC1C,eAAe,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;IAC7C,4DAA4D;IAC5D,iBAAiB,EAAE,MAAM,MAAM,CAAC;IAChC,0CAA0C;IAC1C,aAAa,EAAE,MAAM,CAAC;CACvB;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,cAAc,CAAC,EAAE,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,aAAa,EAAE,EAAE,qBAAqB;sCAWnG,OAAO;EAwBvB"}
@@ -1,3 +0,0 @@
1
- "use client";
2
- import{a}from"../chunk-RIHTVZVJ.js";import"../chunk-WTP2KIK3.js";import"../chunk-VQPANPMI.js";export{a as useToggleState};
3
- //# sourceMappingURL=use-toggle-state.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": [],
4
- "sourcesContent": [],
5
- "mappings": "",
6
- "names": []
7
- }
@@ -1,24 +0,0 @@
1
- import type { GetPropDefTypes } from './prop-def.js';
2
- declare const shadowPropDefs: {
3
- /**
4
- * Sets the CSS **box-shadow** property using design system shadow tokens.
5
- * Supports shadow scale values and responsive objects.
6
- *
7
- * @example
8
- * shadow="3"
9
- * shadow={{ sm: '2', lg: '4' }}
10
- *
11
- * @link
12
- * https://developer.mozilla.org/en-US/docs/Web/CSS/box-shadow
13
- */
14
- shadow: {
15
- type: "enum";
16
- className: string;
17
- values: readonly ["1", "2", "3", "4", "5", "6"];
18
- responsive: true;
19
- };
20
- };
21
- type ShadowProps = GetPropDefTypes<typeof shadowPropDefs>;
22
- export { shadowPropDefs };
23
- export type { ShadowProps };
24
- //# sourceMappingURL=shadow.props.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"shadow.props.d.ts","sourceRoot":"","sources":["../../../src/props/shadow.props.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAW,eAAe,EAAE,MAAM,eAAe,CAAC;AAI9D,QAAA,MAAM,cAAc;IAClB;;;;;;;;;;OAUG;;;;;;;CASJ,CAAC;AAEF,KAAK,WAAW,GAAG,eAAe,CAAC,OAAO,cAAc,CAAC,CAAC;AAE1D,OAAO,EAAE,cAAc,EAAE,CAAC;AAC1B,YAAY,EAAE,WAAW,EAAE,CAAC"}
@@ -1,2 +0,0 @@
1
- import{a}from"../chunk-677CX2QF.js";export{a as shadowPropDefs};
2
- //# sourceMappingURL=shadow.props.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": [],
4
- "sourcesContent": [],
5
- "mappings": "",
6
- "names": []
7
- }
@@ -1,16 +0,0 @@
1
- import type { Responsive } from '../props/prop-def.js';
2
-
3
- function mapResponsiveProp<Input extends string, Output>(
4
- propValue: Responsive<Input> | undefined,
5
- mapValue: (value: Input) => Output
6
- ): Responsive<Output> | undefined {
7
- if (propValue === undefined) return undefined;
8
- if (typeof propValue === 'string') {
9
- return mapValue(propValue);
10
- }
11
- return Object.fromEntries(
12
- Object.entries(propValue).map(([key, value]) => [key, mapValue(value)])
13
- );
14
- }
15
-
16
- export { mapResponsiveProp };
@@ -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 };