@fpkit/acss 0.5.13 → 0.6.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/libs/{chunk-PQ2K3BM6.cjs → chunk-2NRIP6RB.cjs} +3 -3
- package/libs/chunk-33PNJ4LO.cjs +15 -0
- package/libs/chunk-33PNJ4LO.cjs.map +1 -0
- package/libs/chunk-4BZKFPEC.cjs +17 -0
- package/libs/chunk-4BZKFPEC.cjs.map +1 -0
- package/libs/{chunk-772NRB75.js → chunk-5QD3DWFI.js} +2 -2
- package/libs/chunk-6SAHIYCZ.js +7 -0
- package/libs/chunk-6SAHIYCZ.js.map +1 -0
- package/libs/{chunk-3MKLDCKQ.cjs → chunk-6WTC4JXH.cjs} +3 -3
- package/libs/chunk-75QHTLFO.js +7 -0
- package/libs/chunk-75QHTLFO.js.map +1 -0
- package/libs/{chunk-ZANSFMTD.js → chunk-7XPFW7CB.js} +3 -3
- package/libs/chunk-BFK62VX5.js +5 -0
- package/libs/chunk-BFK62VX5.js.map +1 -0
- package/libs/{chunk-ROZI23GS.cjs → chunk-DKTHCQ5P.cjs} +4 -4
- package/libs/chunk-E2AJURUW.cjs +13 -0
- package/libs/chunk-E2AJURUW.cjs.map +1 -0
- package/libs/{chunk-L75OQKEI.cjs → chunk-ENTCUJ3A.cjs} +3 -3
- package/libs/chunk-ENTCUJ3A.cjs.map +1 -0
- package/libs/chunk-F5EYMVQM.js +10 -0
- package/libs/chunk-F5EYMVQM.js.map +1 -0
- package/libs/chunk-FVROL3V5.js +9 -0
- package/libs/chunk-FVROL3V5.js.map +1 -0
- package/libs/chunk-GT77BX4L.cjs +17 -0
- package/libs/chunk-GT77BX4L.cjs.map +1 -0
- package/libs/chunk-GUJSMQ3V.cjs +16 -0
- package/libs/chunk-GUJSMQ3V.cjs.map +1 -0
- package/libs/chunk-HHLNOC5T.js +7 -0
- package/libs/chunk-HHLNOC5T.js.map +1 -0
- package/libs/chunk-HRRHPLER.js +8 -0
- package/libs/chunk-HRRHPLER.js.map +1 -0
- package/libs/chunk-IEB64SWY.js +8 -0
- package/libs/chunk-IEB64SWY.js.map +1 -0
- package/libs/{chunk-NGTJDDFO.js → chunk-IQ76HGVP.js} +2 -2
- package/libs/chunk-IRLFZ3OL.js +9 -0
- package/libs/chunk-IRLFZ3OL.js.map +1 -0
- package/libs/{chunk-JJ43O4Y5.js → chunk-KK47SYZI.js} +2 -2
- package/libs/chunk-O3JIHC5M.cjs +15 -0
- package/libs/chunk-O3JIHC5M.cjs.map +1 -0
- package/libs/chunk-O5XAJ7BY.cjs +18 -0
- package/libs/chunk-O5XAJ7BY.cjs.map +1 -0
- package/libs/chunk-OVWLQYMK.js +10 -0
- package/libs/chunk-OVWLQYMK.js.map +1 -0
- package/libs/chunk-PNWIRCG3.cjs +7 -0
- package/libs/chunk-PNWIRCG3.cjs.map +1 -0
- package/libs/{chunk-D4YLRWAO.cjs → chunk-QVW6W76L.cjs} +6 -6
- package/libs/chunk-T4T6GWYQ.cjs +17 -0
- package/libs/chunk-T4T6GWYQ.cjs.map +1 -0
- package/libs/chunk-TON2YGMD.cjs +9 -0
- package/libs/chunk-TON2YGMD.cjs.map +1 -0
- package/libs/chunk-UEPAWMDF.js +8 -0
- package/libs/chunk-UEPAWMDF.js.map +1 -0
- package/libs/{chunk-LT5KZ2QW.cjs → chunk-US2I5GI7.cjs} +3 -3
- package/libs/{chunk-B7F5FS6D.cjs → chunk-W2UIN7EV.cjs} +3 -3
- package/libs/{chunk-P2DC76ZZ.cjs → chunk-W5TKWBFC.cjs} +3 -3
- package/libs/chunk-WXBFBWYF.cjs +16 -0
- package/libs/chunk-WXBFBWYF.cjs.map +1 -0
- package/libs/{chunk-VUH3FXGJ.js → chunk-X3JCTEPD.js} +5 -5
- package/libs/chunk-X5LGFCWG.js +9 -0
- package/libs/chunk-X5LGFCWG.js.map +1 -0
- package/libs/{chunk-5M57K4SW.js → chunk-Y2PFDELK.js} +2 -2
- package/libs/{chunk-ETFLFC2S.js → chunk-ZFJ4U45S.js} +2 -2
- package/libs/{component-props-a8a2f97e.d.ts → component-props-67d978a2.d.ts} +4 -4
- package/libs/components/alert/alert.css +1 -1
- package/libs/components/alert/alert.css.map +1 -1
- package/libs/components/alert/alert.min.css +2 -2
- package/libs/components/breadcrumbs/breadcrumb.cjs +6 -6
- package/libs/components/breadcrumbs/breadcrumb.d.cts +11 -11
- package/libs/components/breadcrumbs/breadcrumb.d.ts +11 -11
- package/libs/components/breadcrumbs/breadcrumb.js +3 -3
- package/libs/components/button.cjs +6 -4
- package/libs/components/button.d.cts +97 -4
- package/libs/components/button.d.ts +97 -4
- package/libs/components/button.js +4 -2
- package/libs/components/card.cjs +7 -7
- package/libs/components/card.d.cts +14 -14
- package/libs/components/card.d.ts +14 -14
- package/libs/components/card.js +2 -2
- package/libs/components/dialog/dialog.cjs +9 -7
- package/libs/components/dialog/dialog.d.cts +3 -3
- package/libs/components/dialog/dialog.d.ts +3 -3
- package/libs/components/dialog/dialog.js +7 -5
- package/libs/components/form/fields.cjs +4 -4
- package/libs/components/form/fields.d.cts +16 -7
- package/libs/components/form/fields.d.ts +16 -7
- package/libs/components/form/fields.js +2 -2
- package/libs/components/form/inputs.cjs +6 -4
- package/libs/components/form/inputs.d.cts +50 -2
- package/libs/components/form/inputs.d.ts +50 -2
- package/libs/components/form/inputs.js +4 -2
- package/libs/components/form/textarea.cjs +5 -4
- package/libs/components/form/textarea.d.cts +32 -23
- package/libs/components/form/textarea.d.ts +32 -23
- package/libs/components/form/textarea.js +3 -2
- package/libs/components/heading/heading.cjs +3 -3
- package/libs/components/heading/heading.d.cts +2 -2
- package/libs/components/heading/heading.d.ts +2 -2
- package/libs/components/heading/heading.js +2 -2
- package/libs/components/icons/icon.cjs +4 -4
- package/libs/components/icons/icon.d.cts +38 -38
- package/libs/components/icons/icon.d.ts +38 -38
- package/libs/components/icons/icon.js +2 -2
- package/libs/components/link/link.cjs +4 -4
- package/libs/components/link/link.css +1 -1
- package/libs/components/link/link.css.map +1 -1
- package/libs/components/link/link.d.cts +3 -19
- package/libs/components/link/link.d.ts +3 -19
- package/libs/components/link/link.js +2 -2
- package/libs/components/link/link.min.css +2 -2
- package/libs/components/list/list.cjs +5 -5
- package/libs/components/list/list.css +1 -0
- package/libs/components/list/list.css.map +1 -0
- package/libs/components/list/list.d.cts +120 -33
- package/libs/components/list/list.d.ts +120 -33
- package/libs/components/list/list.js +2 -2
- package/libs/components/list/list.min.css +3 -0
- package/libs/components/modal.cjs +6 -4
- package/libs/components/modal.d.cts +8 -8
- package/libs/components/modal.d.ts +8 -8
- package/libs/components/modal.js +5 -3
- package/libs/components/nav/nav.cjs +7 -7
- package/libs/components/nav/nav.css +1 -1
- package/libs/components/nav/nav.css.map +1 -1
- package/libs/components/nav/nav.d.cts +550 -34
- package/libs/components/nav/nav.d.ts +550 -34
- package/libs/components/nav/nav.js +3 -3
- package/libs/components/nav/nav.min.css +2 -2
- package/libs/components/popover/popover.d.cts +5 -5
- package/libs/components/popover/popover.d.ts +5 -5
- package/libs/components/tables/table.cjs +5 -5
- package/libs/components/tables/table.d.cts +8 -8
- package/libs/components/tables/table.d.ts +8 -8
- package/libs/components/tables/table.js +2 -2
- package/libs/components/tag/tag.css +1 -1
- package/libs/components/tag/tag.css.map +1 -1
- package/libs/components/tag/tag.min.css +2 -2
- package/libs/components/text/text.cjs +5 -5
- package/libs/components/text/text.d.cts +5 -5
- package/libs/components/text/text.d.ts +5 -5
- package/libs/components/text/text.js +2 -2
- package/libs/form.types-d25ebfac.d.ts +233 -0
- package/libs/{heading-3648c538.d.ts → heading-7446cb46.d.ts} +8 -8
- package/libs/hooks.cjs +9 -4
- package/libs/hooks.d.cts +137 -3
- package/libs/hooks.d.ts +137 -3
- package/libs/hooks.js +4 -3
- package/libs/icons.cjs +3 -3
- package/libs/icons.d.cts +2 -2
- package/libs/icons.d.ts +2 -2
- package/libs/icons.js +2 -2
- package/libs/index.cjs +53 -51
- package/libs/index.cjs.map +1 -1
- package/libs/index.css +1 -1
- package/libs/index.css.map +1 -1
- package/libs/index.d.cts +338 -49
- package/libs/index.d.ts +338 -49
- package/libs/index.js +24 -22
- package/libs/index.js.map +1 -1
- package/libs/link-5192f411.d.ts +323 -0
- package/libs/list.types-d26de310.d.ts +245 -0
- package/libs/{ui-645f95b5.d.ts → ui-d01b50d4.d.ts} +16 -12
- package/package.json +4 -6
- package/src/components/alert/alert.scss +1 -4
- package/src/components/breadcrumbs/breadcrumb.tsx +4 -1
- package/src/components/buttons/README.mdx +102 -1
- package/src/components/buttons/button.stories.tsx +106 -0
- package/src/components/buttons/button.tsx +82 -52
- package/src/components/dialog/dialog-a11y-review.md +653 -0
- package/src/components/form/README.mdx +725 -43
- package/src/components/form/WCAG-REVIEW.md +654 -0
- package/src/components/form/fields.tsx +10 -1
- package/src/components/form/form.stories.tsx +604 -23
- package/src/components/form/form.tsx +204 -63
- package/src/components/form/form.types.ts +378 -0
- package/src/components/form/input.stories.tsx +71 -3
- package/src/components/form/inputs.tsx +159 -67
- package/src/components/form/select.tsx +122 -66
- package/src/components/form/textarea.tsx +120 -73
- package/src/components/fp.tsx +86 -11
- package/src/components/link/README.mdx +923 -0
- package/src/components/link/link.scss +79 -26
- package/src/components/link/link.stories.tsx +383 -30
- package/src/components/link/link.test.tsx +677 -0
- package/src/components/link/link.tsx +163 -57
- package/src/components/link/link.types.ts +261 -0
- package/src/components/list/README.mdx +764 -0
- package/src/components/list/list.scss +285 -0
- package/src/components/list/list.stories.tsx +514 -27
- package/src/components/list/list.test.tsx +554 -0
- package/src/components/list/list.tsx +153 -51
- package/src/components/list/list.types.ts +255 -0
- package/src/components/nav/ACCESSIBILITY.md +649 -0
- package/src/components/nav/README.mdx +782 -0
- package/src/components/nav/nav.scss +37 -4
- package/src/components/nav/nav.stories.tsx +44 -6
- package/src/components/nav/nav.tsx +302 -51
- package/src/components/nav/nav.types.ts +308 -0
- package/src/components/tag/README.mdx +426 -0
- package/src/components/tag/tag.scss +101 -27
- package/src/components/tag/tag.stories.tsx +384 -10
- package/src/components/tag/tag.test.tsx +210 -0
- package/src/components/tag/tag.tsx +106 -9
- package/src/components/tag/tag.types.ts +107 -0
- package/src/components/ui.tsx +8 -3
- package/src/hooks/use-disabled-state.test.tsx +536 -0
- package/src/hooks/use-disabled-state.ts +246 -0
- package/src/hooks/useDisabledState.md +393 -0
- package/src/hooks.ts +6 -0
- package/src/index.scss +2 -0
- package/src/index.ts +2 -1
- package/src/sass/_globals.scss +2 -7
- package/src/styles/alert/alert.css +1 -3
- package/src/styles/alert/alert.css.map +1 -1
- package/src/styles/index.css +461 -81
- package/src/styles/index.css.map +1 -1
- package/src/styles/link/link.css +45 -28
- package/src/styles/link/link.css.map +1 -1
- package/src/styles/list/list.css +214 -0
- package/src/styles/list/list.css.map +1 -0
- package/src/styles/nav/nav.css +32 -6
- package/src/styles/nav/nav.css.map +1 -1
- package/src/styles/tag/tag.css +113 -35
- package/src/styles/tag/tag.css.map +1 -1
- package/src/styles/utilities/_disabled.scss +58 -0
- package/src/types/shared.ts +43 -6
- package/src/utils/accessibility.ts +109 -0
- package/libs/chunk-2LTJ7HHX.cjs +0 -18
- package/libs/chunk-2LTJ7HHX.cjs.map +0 -1
- package/libs/chunk-2Y7W75TT.js +0 -9
- package/libs/chunk-2Y7W75TT.js.map +0 -1
- package/libs/chunk-5S4ORA4C.cjs +0 -15
- package/libs/chunk-5S4ORA4C.cjs.map +0 -1
- package/libs/chunk-AHDJGCG5.cjs +0 -15
- package/libs/chunk-AHDJGCG5.cjs.map +0 -1
- package/libs/chunk-BHRQBJRY.js +0 -8
- package/libs/chunk-BHRQBJRY.js.map +0 -1
- package/libs/chunk-GZ4QFPRY.js +0 -9
- package/libs/chunk-GZ4QFPRY.js.map +0 -1
- package/libs/chunk-IYUN2EW3.cjs +0 -15
- package/libs/chunk-IYUN2EW3.cjs.map +0 -1
- package/libs/chunk-J32EZPYD.cjs +0 -15
- package/libs/chunk-J32EZPYD.cjs.map +0 -1
- package/libs/chunk-KUKIVRC2.js +0 -7
- package/libs/chunk-KUKIVRC2.js.map +0 -1
- package/libs/chunk-L75OQKEI.cjs.map +0 -1
- package/libs/chunk-M5RRNTVX.cjs +0 -15
- package/libs/chunk-M5RRNTVX.cjs.map +0 -1
- package/libs/chunk-OK5QEIMD.cjs +0 -17
- package/libs/chunk-OK5QEIMD.cjs.map +0 -1
- package/libs/chunk-P7TTEYCD.js +0 -7
- package/libs/chunk-P7TTEYCD.js.map +0 -1
- package/libs/chunk-QLZWHAMK.js +0 -8
- package/libs/chunk-QLZWHAMK.js.map +0 -1
- package/libs/chunk-RIVUMPOG.js +0 -8
- package/libs/chunk-RIVUMPOG.js.map +0 -1
- package/libs/chunk-S7BABR7Z.cjs +0 -13
- package/libs/chunk-S7BABR7Z.cjs.map +0 -1
- package/libs/chunk-SMYRLO3E.js +0 -8
- package/libs/chunk-SMYRLO3E.js.map +0 -1
- package/libs/chunk-TYRCEX2L.js +0 -8
- package/libs/chunk-TYRCEX2L.js.map +0 -1
- package/libs/chunk-XBA562WW.js +0 -8
- package/libs/chunk-XBA562WW.js.map +0 -1
- package/libs/chunk-XTQKWY7W.cjs +0 -32
- package/libs/chunk-XTQKWY7W.cjs.map +0 -1
- package/libs/inputs-f3a216db.d.ts +0 -45
- /package/libs/{chunk-PQ2K3BM6.cjs.map → chunk-2NRIP6RB.cjs.map} +0 -0
- /package/libs/{chunk-772NRB75.js.map → chunk-5QD3DWFI.js.map} +0 -0
- /package/libs/{chunk-3MKLDCKQ.cjs.map → chunk-6WTC4JXH.cjs.map} +0 -0
- /package/libs/{chunk-ZANSFMTD.js.map → chunk-7XPFW7CB.js.map} +0 -0
- /package/libs/{chunk-ROZI23GS.cjs.map → chunk-DKTHCQ5P.cjs.map} +0 -0
- /package/libs/{chunk-NGTJDDFO.js.map → chunk-IQ76HGVP.js.map} +0 -0
- /package/libs/{chunk-JJ43O4Y5.js.map → chunk-KK47SYZI.js.map} +0 -0
- /package/libs/{chunk-D4YLRWAO.cjs.map → chunk-QVW6W76L.cjs.map} +0 -0
- /package/libs/{chunk-LT5KZ2QW.cjs.map → chunk-US2I5GI7.cjs.map} +0 -0
- /package/libs/{chunk-B7F5FS6D.cjs.map → chunk-W2UIN7EV.cjs.map} +0 -0
- /package/libs/{chunk-P2DC76ZZ.cjs.map → chunk-W5TKWBFC.cjs.map} +0 -0
- /package/libs/{chunk-VUH3FXGJ.js.map → chunk-X3JCTEPD.js.map} +0 -0
- /package/libs/{chunk-5M57K4SW.js.map → chunk-Y2PFDELK.js.map} +0 -0
- /package/libs/{chunk-ETFLFC2S.js.map → chunk-ZFJ4U45S.js.map} +0 -0
package/libs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/images/img.tsx","../src/components/text-to-speech/TextToSpeech.tsx","../src/components/text-to-speech/useTextToSpeech.tsx","../src/components/text-to-speech/views/TextToSpeechControls.tsx","../src/components/layout/landmarks.tsx","../src/components/badge/badge.tsx","../src/components/tag/tag.tsx","../src/components/details/details.tsx"],"names":["React","useMemo","Img","src","alt","width","height","styles","loading","placeholder","fetchpriority","decoding","srcSet","sizes","onError","onLoad","props","defaultPlaceholder","w","h","svg","fallbackPlaceholder","ui_default","e","useState","useEffect","useTextToSpeech","initialVoice","availableVoices","setAvailableVoices","currentVoice","setCurrentVoice","isSpeaking","setIsSpeaking","isPaused","setIsPaused","utterance","setUtterance","updateVoices","voices","googleVoice","voice","englishVoice","text","options","onEnd","TTSButtonComponent","children","onClick","TTSButton","TextToSpeechControls","label","onSpeak","onPause","onResume","onCancel","icon_default","TextToSpeechControls_default","TextToSpeech","initialText","showTextInput","pitch","rate","language","speak","pause","resume","cancel","getAvailableLanguages","setText","handleSpeak","handleEnd","handleChange","textarea_default","Landmarks","Header","id","headerBackground","classes","Main","Footer","Aside","Section","Article","Badge","variant","Tag","elm","role","useCallback","Details","summary","icon","ariaLabel","name","open","onPointerDown","onToggle","ref","handlePointerDown","handleToggle"],"mappings":"w2BAC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C,EAAM,OAAQjF,EAAS,GAAGS,GAC1C+B,CACH,EAIJuC,GAAI,YAAc,MCvBlB,OAAOtF,GAAS,eAAAyF,MAAmB,QAoD5B,IAAMC,GAAU1F,EAAM,WAC3B,CACE,CACE,QAAA2F,EACA,KAAAC,EACA,OAAArF,EACA,QAAAuE,EACA,UAAAe,EACA,KAAAC,EACA,KAAAC,EACA,cAAAC,EACA,SAAAC,EACA,SAAAlD,EACA,GAAG/B,CACL,EACAkF,IACG,CAEH,IAAMC,EAAoBV,EACvBlE,GAAuC,CACtCyE,IAAgBzE,CAA2C,CAC7D,EACA,CAACyE,CAAa,CAChB,EAEMI,EAAeX,EAClBlE,GAAgD,CAC/C0E,IAAW1E,CAAC,CACd,EACA,CAAC0E,CAAQ,CACX,EAEA,OACEjG,EAAA,cAACsB,EAAA,CACC,GAAG,UACH,OAAQf,EACR,QAASuE,EACT,SAAUsB,EACV,IAAKF,EACL,KAAMH,EACN,aAAYF,EACZ,KAAMC,EACL,GAAG9E,GAEJhB,EAAA,cAACsB,EAAA,CAAG,GAAG,UAAU,cAAe6E,GAC7BP,EACAD,CACH,EACA3F,EAAA,cAACsB,EAAA,CAAG,GAAG,WAAWyB,CAAS,CAC7B,CAEJ,CACF,EAEA2C,GAAQ,YAAc","sourcesContent":["import UI from \"../ui\";\nimport React, { useMemo } from \"react\";\nimport type { ImgProps } from \"./img.types\";\n\n/**\n * Img - A semantic image component with accessibility and performance best practices.\n *\n * This component wraps the native `<img>` element with enhanced features:\n * - **Responsive images** via optional srcset/sizes\n * - **Lazy loading** by default for performance\n * - **Error handling** with configurable fallback placeholders\n * - **Type safety** with full TypeScript support\n *\n * ## Accessibility Patterns (WCAG 2.1 AA)\n *\n * ### Decorative Images\n * Images that are purely visual decoration should use an empty alt attribute.\n * These images are typically borders, patterns, or visual separators.\n *\n * @example\n * ```tsx\n * // ✅ GOOD: Decorative border image\n * <Img src=\"/decorative-border.png\" alt=\"\" />\n *\n * // ✅ GOOD: Background pattern\n * <Img src=\"/pattern.svg\" alt=\"\" loading=\"eager\" />\n * ```\n *\n * ### Semantic Images\n * Images that convey information must have descriptive alt text that explains\n * the content and purpose of the image.\n *\n * @example\n * ```tsx\n * // ✅ GOOD: Informative image with descriptive alt\n * <Img\n * src=\"/sales-chart.png\"\n * alt=\"Sales chart showing 30% revenue growth in Q4 2024\"\n * />\n *\n * // ✅ GOOD: Product photo with context\n * <Img\n * src=\"/laptop.jpg\"\n * alt=\"Silver MacBook Pro 14-inch on wooden desk\"\n * />\n * ```\n *\n * ## Performance Optimization\n *\n * ### Lazy Loading\n * By default, images use lazy loading to improve page load performance.\n * Only use `loading=\"eager\"` for above-the-fold images.\n *\n * @example\n * ```tsx\n * // ✅ GOOD: Lazy load below-the-fold image\n * <Img src=\"/photo.jpg\" alt=\"Photo\" />\n *\n * // ✅ GOOD: Eager load hero image\n * <Img\n * src=\"/hero.jpg\"\n * alt=\"Hero banner\"\n * loading=\"eager\"\n * fetchpriority=\"high\"\n * />\n * ```\n *\n * ### Responsive Images\n * Use srcset and sizes for responsive images to serve appropriate image sizes\n * based on viewport width, improving performance and bandwidth usage.\n *\n * @example\n * ```tsx\n * // ✅ GOOD: Responsive image with multiple sizes\n * <Img\n * src=\"/photo.jpg\"\n * srcSet=\"/photo-320w.jpg 320w, /photo-640w.jpg 640w, /photo-1024w.jpg 1024w\"\n * sizes=\"(max-width: 640px) 100vw, (max-width: 1024px) 50vw, 800px\"\n * alt=\"Responsive image adapts to viewport\"\n * />\n * ```\n *\n * ## Error Handling\n *\n * @example\n * ```tsx\n * // ✅ GOOD: Custom placeholder on error\n * <Img\n * src=\"/photo.jpg\"\n * placeholder=\"/fallback.png\"\n * alt=\"User profile photo\"\n * />\n *\n * // ✅ GOOD: Custom error handler\n * <Img\n * src=\"/photo.jpg\"\n * onError={(e) => {\n * console.error('Image failed to load')\n * logToAnalytics('image_error', { src: e.currentTarget.src })\n * }}\n * alt=\"Photo\"\n * />\n * ```\n *\n * @param {ImgProps} props - Component props extending native img attributes\n * @returns {React.ReactElement} Image element with enhanced functionality\n *\n * @see {@link ImgProps} for complete prop documentation\n * @see https://www.w3.org/WAI/WCAG21/Understanding/non-text-content.html\n */\nexport const Img = ({\n src = \"//\",\n alt,\n width = 480,\n height,\n styles,\n loading = \"lazy\",\n placeholder,\n fetchpriority = \"low\",\n decoding = \"auto\",\n srcSet,\n sizes,\n onError,\n onLoad,\n ...props\n}: ImgProps) => {\n /**\n * Generates a performant, responsive SVG gradient placeholder.\n * Uses data URI to avoid network requests and memoizes based on dimensions.\n * The SVG uses viewBox for perfect scaling at any size.\n *\n * Features:\n * - Zero network requests (works offline)\n * - ~900 bytes vs. 5-10KB external image\n * - Responsive with viewBox\n * - Attractive gradient (indigo → purple → pink)\n * - Dimension text for debugging\n */\n const defaultPlaceholder = useMemo(() => {\n const w = typeof width === \"number\" ? width : 480;\n const h = typeof height === \"number\" ? height : Math.round(w * 0.75);\n\n // Responsive SVG with attractive gradient and dimension text\n const svg = `<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 ${w} ${h}\">\n <defs>\n <linearGradient id=\"grad-${w}-${h}\" x1=\"0%\" y1=\"0%\" x2=\"100%\" y2=\"100%\">\n <stop offset=\"0%\" style=\"stop-color:#6366f1;stop-opacity:1\" />\n <stop offset=\"50%\" style=\"stop-color:#8b5cf6;stop-opacity:1\" />\n <stop offset=\"100%\" style=\"stop-color:#ec4899;stop-opacity:1\" />\n </linearGradient>\n </defs>\n <rect width=\"${w}\" height=\"${h}\" fill=\"url(#grad-${w}-${h})\"/>\n <circle cx=\"${w * 0.15}\" cy=\"${h * 0.2}\" r=\"${Math.min(w, h) * 0.08}\" fill=\"rgba(255,255,255,0.2)\"/>\n <path d=\"M0,${h * 0.75} Q${w * 0.25},${h * 0.65} ${w * 0.5},${h * 0.75} T${w},${h * 0.75} L${w},${h} L0,${h} Z\" fill=\"rgba(0,0,0,0.15)\"/>\n <text x=\"50%\" y=\"50%\" dominant-baseline=\"middle\" text-anchor=\"middle\" font-family=\"system-ui,-apple-system,sans-serif\" font-size=\"${Math.max(16, Math.min(w, h) * 0.05)}\" font-weight=\"500\" fill=\"rgba(255,255,255,0.9)\">${w}×${h}</text>\n </svg>`;\n\n return `data:image/svg+xml,${encodeURIComponent(svg)}`;\n }, [width, height]);\n\n const fallbackPlaceholder = placeholder ?? defaultPlaceholder;\n\n /**\n * Handles image load errors.\n * Calls custom error handler if provided, then applies fallback placeholder.\n * The custom handler can prevent the default fallback by calling e.preventDefault().\n */\n const handleImgError = (\n e: React.SyntheticEvent<HTMLImageElement, Event>\n ): void => {\n // Call custom error handler first (for logging, analytics, etc.)\n if (onError) {\n onError(e);\n }\n\n // Apply fallback unless preventDefault() was called\n if (!e.defaultPrevented) {\n // Avoid infinite error loop by checking if already showing placeholder\n if (e.currentTarget.src !== fallbackPlaceholder) {\n e.currentTarget.src = fallbackPlaceholder;\n }\n }\n };\n\n /**\n * Handles successful image load.\n * Calls custom load handler if provided.\n */\n const handleImgLoad = (\n e: React.SyntheticEvent<HTMLImageElement, Event>\n ): void => {\n onLoad?.(e);\n };\n\n return (\n <UI\n as=\"img\"\n src={src}\n alt={alt}\n width={width}\n height={height || \"auto\"}\n loading={loading}\n style={styles}\n srcSet={srcSet}\n sizes={sizes}\n onError={handleImgError}\n onLoad={handleImgLoad}\n decoding={decoding}\n {...props}\n {...(fetchpriority && { fetchpriority })}\n />\n );\n};\n\nexport default Img;\nImg.displayName = \"Img\";\n","import React, { useState, ChangeEvent, useEffect } from 'react'\nimport { useTextToSpeech } from './useTextToSpeech'\nimport Textarea from '#components/form/textarea.jsx'\nimport TextToSpeechControls from './views/TextToSpeechControls'\n\n/**\n * Props for the TextToSpeechComponent.\n * @interface TextToSpeechComponentProps\n */\ninterface TextToSpeechComponentProps {\n /** Initial text to be spoken. Defaults to an empty string. */\n initialText?: string\n /** Whether to show the text input field. Defaults to true. */\n showTextInput?: boolean\n /** The voice to be used for speech synthesis. */\n voice?: SpeechSynthesisVoice | undefined\n /** The pitch of the voice. Defaults to 1. */\n pitch?: number\n /** The rate of speech. Defaults to 1. */\n rate?: number\n /** The language to be used for speech synthesis. */\n language?: string\n /** Player label */\n label?: string | React.ReactNode\n /** Callback function to be called when speech ends. */\n onEnd?: () => void\n}\n\n/**\n * A component that converts text to speech using the Web Speech API.\n * @param {TextToSpeechComponentProps} props - The props for the component.\n * @returns {JSX.Element} The rendered TextToSpeechComponent.\n */\nexport const TextToSpeech: React.FC<TextToSpeechComponentProps> = ({\n initialText = '',\n showTextInput = false,\n voice,\n pitch = 1,\n rate = 1,\n language,\n label,\n onEnd,\n}) => {\n const {\n speak,\n pause,\n resume,\n cancel,\n isSpeaking,\n isPaused,\n getAvailableLanguages,\n availableVoices,\n } = useTextToSpeech()\n const [text, setText] = useState<string>(initialText)\n console.log(getAvailableLanguages())\n\n useEffect(() => {\n setText(initialText)\n }, [initialText])\n\n const handleSpeak = (): void => {\n if (text.trim() !== '') {\n speak(text, { voice, pitch, rate }, handleEnd)\n }\n }\n\n const handleChange = (e: ChangeEvent<HTMLTextAreaElement>): void => {\n setText(e.target.value)\n }\n\n const handleEnd = (): void => {\n if (onEnd) {\n onEnd()\n }\n }\n\n return (\n <>\n {showTextInput && <Textarea value={text} onChange={handleChange} />}\n <TextToSpeechControls\n label={label}\n isSpeaking={isSpeaking}\n isPaused={isPaused}\n onSpeak={handleSpeak}\n onPause={pause}\n onResume={resume}\n onCancel={cancel}\n />\n </>\n )\n}\n\nexport default TextToSpeech\nTextToSpeech.displayName = 'TextToSpeechComponent'\n","import { useState, useEffect } from 'react'\n\n/**\n * Options for configuring speech synthesis.\n * @interface SpeechOptions\n */\ninterface SpeechOptions {\n /** The language for speech synthesis (e.g., 'en-US') */\n lang?: string\n\n /** The pitch of the voice (0 to 2) */\n pitch?: number\n /** The speed of the voice (0.1 to 10) */\n rate?: number\n\n /** The voice to use for speech synthesis */\n voice?: SpeechSynthesisVoice\n}\n/**\n * Custom hook to handle text-to-speech functionality.\n *\n * @param {SpeechSynthesisVoice} [initialVoice] - The initial voice to use for speech synthesis.\n * @returns {Object} An object containing methods to control speech synthesis and state variables.\n */\nexport const useTextToSpeech = (initialVoice?: SpeechSynthesisVoice) => {\n const [availableVoices, setAvailableVoices] = useState<\n SpeechSynthesisVoice[]\n >([])\n const [currentVoice, setCurrentVoice] = useState<\n SpeechSynthesisVoice | undefined\n >(initialVoice)\n\n const [isSpeaking, setIsSpeaking] = useState<boolean>(false)\n const [isPaused, setIsPaused] = useState<boolean>(false)\n const [utterance, setUtterance] = useState<SpeechSynthesisUtterance | null>(\n null,\n )\n\n useEffect(() => {\n const updateVoices = () => {\n const voices = window.speechSynthesis.getVoices()\n setAvailableVoices(voices)\n\n // Set default voice to Google US English if available\n const googleVoice = voices.find(\n (voice) => voice.name === 'Google US English',\n )\n if (googleVoice) {\n setCurrentVoice(googleVoice)\n } else {\n // Fallback to the first English voice if Google voice is not available\n const englishVoice = voices.find((voice) =>\n voice.lang.startsWith('en-'),\n )\n if (englishVoice) {\n setCurrentVoice(englishVoice)\n }\n }\n }\n\n updateVoices()\n window.speechSynthesis.onvoiceschanged = updateVoices\n\n return () => {\n window.speechSynthesis.onvoiceschanged = null\n }\n }, [])\n\n /**\n * Gets the list of available languages for speech synthesis.\n * @returns {string[]} An array of available language codes.\n */\n const getAvailableLanguages = () => {\n return [...new Set(availableVoices.map((voice) => voice.lang))]\n }\n\n /**\n * Initiates speech synthesis for the given text.\n *\n * @param {string} text - The text to be spoken.\n * @param {SpeechOptions} [options={}] - Options for speech synthesis.\n * @param {Function} [onEnd] - Callback function to be called when speech ends.\n */\n const speak = (\n text: string,\n options: SpeechOptions = {},\n onEnd?: () => void,\n ) => {\n const utterance = new SpeechSynthesisUtterance(text)\n\n utterance.lang = options.lang ?? 'en-US'\n utterance.pitch = options.pitch ?? 1\n utterance.rate = options.rate ?? 1\n utterance.voice = currentVoice ?? options.voice ?? null\n\n utterance.onend = () => {\n setIsSpeaking(false)\n setIsPaused(false)\n if (onEnd) {\n onEnd()\n }\n }\n\n if ('speechSynthesis' in window) {\n window.speechSynthesis.speak(utterance)\n setUtterance(utterance)\n setIsSpeaking(true)\n setIsPaused(false)\n } else {\n console.error('Speech synthesis not supported')\n // Handle the error appropriately\n }\n }\n\n /**\n * Changes the current voice used for speech synthesis.\n * @param {SpeechSynthesisVoice} voice - The new voice to use.\n */\n const changeVoice = (voice: SpeechSynthesisVoice) => {\n setCurrentVoice(voice)\n }\n\n /**\n * Pauses the ongoing speech synthesis.\n */\n const pause = () => {\n if (isSpeaking && !isPaused) {\n window.speechSynthesis.pause()\n setIsPaused(true)\n }\n }\n\n /**\n * Resumes the paused speech synthesis.\n */\n const resume = () => {\n if (isSpeaking && isPaused) {\n window.speechSynthesis.resume()\n setIsPaused(false)\n }\n }\n\n /**\n * Cancels the ongoing speech synthesis.\n */\n const cancel = () => {\n if (isSpeaking) {\n window.speechSynthesis.cancel()\n setIsSpeaking(false)\n setIsPaused(false)\n }\n }\n\n return {\n /** Initiates speech synthesis for the given text */\n speak,\n /** Pauses the ongoing speech synthesis */\n pause,\n /** Resumes the paused speech synthesis */\n resume,\n /** Cancels the ongoing speech synthesis */\n cancel,\n /** Indicates whether speech synthesis is currently active */\n isSpeaking,\n /** Indicates whether speech synthesis is currently paused */\n isPaused,\n /** Array of available voices for speech synthesis */\n availableVoices,\n /** Changes the current voice used for speech synthesis */\n changeVoice,\n /** The currently selected voice for speech synthesis */\n currentVoice,\n /** Gets the list of available languages for speech synthesis */\n getAvailableLanguages,\n }\n}\n","import React from 'react'\nimport Icon from '#components/icons/icon'\nimport UI from '#components/ui'\nimport { FC } from 'react'\n\n/**\n * Props for the TextToSpeechControls component.\n * @interface TextToSpeechControlsProps\n */\ninterface TextToSpeechControlsProps {\n /** Optional label for the controls */\n label?: string | React.ReactNode\n /** Indicates if the text-to-speech is currently speaking */\n isSpeaking: boolean\n /** Indicates if the text-to-speech is paused */\n isPaused: boolean\n /** Function to start speaking */\n onSpeak: () => void\n /** Function to pause speaking */\n onPause: () => void\n /** Function to resume speaking */\n onResume: () => void\n /** Function to cancel speaking */\n onCancel: () => void\n}\n\n/**\n * TTSButtonComponent props\n * @interface TTSButtonComponentProps\n */\ninterface TTSButtonComponentProps {\n /** The content of the button */\n children: React.ReactNode\n /** Function to call when the button is clicked */\n onClick: () => void\n}\n\n/**\n * TTSButtonComponent is a reusable button component for text-to-speech controls.\n * @param {TTSButtonComponentProps} props - The component props\n * @returns {React.ReactElement} The rendered button\n */\nexport const TTSButtonComponent: React.FC<TTSButtonComponentProps> = ({\n children,\n onClick,\n}) => {\n return (\n <UI\n as=\"button\"\n type=\"button\"\n className=\"tts-border\"\n data-btn=\"sm text pill\"\n onClick={onClick}\n >\n {children}\n </UI>\n )\n}\n\nexport const TTSButton = React.memo(TTSButtonComponent)\n\n/**\n * TextToSpeechControlsComponent interface extends FC<TextToSpeechControlsProps>\n * and includes a TTSButton property.\n * @interface TextToSpeechControlsComponent\n * @extends {FC<TextToSpeechControlsProps>}\n */\ninterface TextToSpeechControlsComponent extends FC<TextToSpeechControlsProps> {\n /** The TTSButton component used within TextToSpeechControls */\n TTSButton: typeof TTSButton\n}\n\n/**\n * TextToSpeechControls component provides a user interface for controlling text-to-speech functionality.\n * @param {TextToSpeechControlsProps} props - The component props\n * @returns {React.ReactElement} The rendered TextToSpeechControls component\n */\nconst TextToSpeechControls: TextToSpeechControlsComponent = ({\n label,\n isSpeaking,\n isPaused,\n onSpeak,\n onPause,\n onResume,\n onCancel,\n}) => {\n const iconSize = 16\n\n return (\n <UI as=\"div\" data-tts>\n {label && <p>{label}</p>}\n {!isSpeaking && (\n <TTSButton aria-label=\"Speak\" onClick={onSpeak}>\n <Icon.PlaySolid size={iconSize} />\n </TTSButton>\n )}\n {isSpeaking && !isPaused && (\n <TTSButton aria-label=\"Pause\" onClick={onPause}>\n <Icon.PauseSolid size={iconSize} />\n </TTSButton>\n )}\n {isPaused && (\n <TTSButton aria-label=\"Resume\" onClick={onResume}>\n <Icon.ResumeSolid size={iconSize} />\n </TTSButton>\n )}\n <TTSButton aria-label=\"Stop\" onClick={onCancel}>\n <Icon.StopSolid size={iconSize} />\n </TTSButton>\n </UI>\n )\n}\n\nTextToSpeechControls.displayName = 'TextToSpeechControls'\nTextToSpeechControls.TTSButton = TTSButton\n\nexport default TextToSpeechControls\n","import UI from '../ui'\nimport React, { ReactNode } from 'react'\n\ntype ComponentProps = React.ComponentProps<typeof UI>\n\n/**\n * Renders children elements without any wrapping component.\n * Can be used as a placeholder when no semantic landmark is needed.\n */\nexport const Landmarks = (children?: React.FC) => <>{children}</>\n\ntype HeaderProps = {\n headerBackground?: ReactNode\n} & ComponentProps\n/**\n * Header component.\n *\n * Renders a header landmark with a section child.\n *\n * @param children - The content to render inside the header.\n * @param styles - Optional styles object.\n * @param props - Other props.\n */\nexport const Header = ({\n id,\n children,\n headerBackground,\n styles,\n classes,\n ...props\n}: HeaderProps) => {\n return (\n <UI as=\"header\" id={id} styles={styles} className={classes} {...props}>\n {headerBackground}\n <UI as=\"section\">{children}</UI>\n </UI>\n )\n}\n\n/**\n * Main component.\n *\n * Renders a main landmark.\n *\n * @param children - The content to render inside the main element.\n * @param styles - Optional styles object.\n * @param props - Other props.\n */\nexport const Main = ({\n id,\n children,\n styles,\n classes,\n ...props\n}: ComponentProps) => {\n return (\n <UI as=\"main\" id={id} styles={styles} {...props} className={classes}>\n {children}\n </UI>\n )\n}\n\n/**\n * Footer component that renders a footer element with a section element inside.\n * @param {ReactNode} children - Child elements to render inside the section element.\n * @param styles - CSS styles to apply to the footer element.\n * @param props - Additional props to pass to the footer element.\n * @returns A React component that renders a footer element with a section element inside.\n */\nexport const Footer = ({\n id,\n classes,\n children,\n styles = {},\n ...props\n}: ComponentProps) => {\n return (\n <UI as=\"footer\" id={id} className={classes} styles={styles} {...props}>\n <UI as=\"section\">{children || 'Copyright © 2022'}</UI>\n </UI>\n )\n}\n\nexport const Aside = ({\n id,\n children,\n styles = {},\n classes,\n ...props\n}: ComponentProps) => {\n return (\n <UI as=\"aside\" id={id} styles={styles} className={classes} {...props}>\n <UI as=\"section\">{children}</UI>\n </UI>\n )\n}\n\n/**\n * Section component that renders a section element.\n *\n * @param children - Child elements to render inside the section.\n * @param styles - CSS styles to apply to the section.\n * @param props - Other props.\n */\nexport const Section = ({\n id,\n children,\n styles,\n classes,\n ...props\n}: ComponentProps) => {\n return (\n <UI as=\"section\" id={id} styles={styles} className={classes} {...props}>\n {children}\n </UI>\n )\n}\n\n/**\n * Article component renders an HTML <article> element.\n *\n * @param children - Child elements to render inside the article.\n * @param styles - CSS styles to apply to the article.\n * @param props - Additional props to pass to the article element.\n */\nexport const Article = ({\n id,\n children,\n\n styles,\n classes,\n ...props\n}: ComponentProps) => {\n return (\n <UI as=\"article\" id={id} styles={styles} className={classes} {...props}>\n {children}\n </UI>\n )\n}\n\nexport default Landmarks\n\nLandmarks.displayName = 'Landmarks'\nLandmarks.Header = Header\nLandmarks.Main = Main\nLandmarks.Footer = Footer\nLandmarks.Aside = Aside\nLandmarks.Section = Section\nLandmarks.Article = Article\n","import UI from '#components/ui'\nimport React from 'react'\n\n/**\n * Props for the Badge component\n *\n * @property {React.ReactNode} children - Content to display inside the badge (typically numbers or short text)\n * @property {string} [id] - Optional HTML id attribute for the badge element\n * @property {React.CSSProperties} [styles] - Inline styles to apply to the badge\n * @property {string} [classes] - CSS class names to apply to the badge\n * @property {'rounded'} [variant] - Visual variant of the badge. Use 'rounded' for circular badges (fixed size with ellipsis for overflow)\n * @property {string} [aria-label] - Accessible label for screen readers. Required for icon-only or number-only badges\n * @property {'status' | 'note'} [role] - ARIA role for the badge. Defaults to 'status' for dynamic content\n */\nexport type BadgeProps = {\n /**\n * Content to display inside the badge (typically numbers or short text)\n */\n children?: React.ReactNode\n /**\n * Visual variant of the badge\n * - 'rounded': Circular badge style\n */\n variant?: 'rounded'\n} & React.ComponentProps<typeof UI>\n\n/**\n * Badge - A small label component for displaying status, counts, or notifications\n *\n * The Badge component is used to display supplementary information alongside other content,\n * such as notification counts, status indicators, or labels. It renders as a semantic `<sup>`\n * element with a nested `<span>` required for the component's styling architecture.\n *\n * ## Styling Architecture\n *\n * The Badge uses a nested structure (`<sup><span>content</span></sup>`) which is required\n * for the SCSS styling system. The outer `<sup>` element provides positioning context,\n * while the inner `<span>` receives the visual styling (background, padding, border-radius).\n *\n * ## Rounded Variant Behavior\n *\n * The `rounded` variant creates a perfect circular badge with fixed dimensions (1.5625rem).\n * Content that exceeds the available space will be truncated with an ellipsis (...).\n * **Best practice**: Format large numbers yourself (e.g., pass \"99+\" instead of \"999\").\n *\n * ## Accessibility Considerations\n *\n * - **Semantic HTML**: Uses `<sup>` (superscript) element for proper positioning context\n * - **ARIA Role**: Defaults to `role=\"status\"` for dynamic badges (e.g., unread counts)\n * - **Accessible Names**: For icon-only or number-only badges, provide an `aria-label`\n * to give context (e.g., \"3 unread messages\" instead of just \"3\")\n * - **Live Regions**: The `role=\"status\"` makes badges announce updates to screen readers\n *\n * @param {BadgeProps} props - Component props\n * @returns {React.ReactElement} A Badge component\n *\n * @example\n * // Basic badge with notification count\n * <p>\n * Messages\n * <Badge aria-label=\"3 unread messages\">3</Badge>\n * </p>\n *\n * @example\n * // Rounded badge variant (perfect circle)\n * <p>\n * Notifications\n * <Badge variant=\"rounded\" aria-label=\"99 or more notifications\">99+</Badge>\n * </p>\n *\n * @example\n * // Status badge with custom styling\n * <p>\n * Active Users\n * <Badge styles={{ backgroundColor: 'green', color: 'white' }}>21</Badge>\n * </p>\n *\n * @example\n * // ✅ GOOD: Accessible badge with descriptive label and formatted content\n * <Badge variant=\"rounded\" aria-label=\"12 items in cart\">12</Badge>\n *\n * @example\n * // ✅ GOOD: Large numbers formatted by developer\n * <Badge variant=\"rounded\" aria-label=\"More than 99 notifications\">99+</Badge>\n *\n * @example\n * // ❌ BAD: Number-only badge without context for screen readers\n * <Badge>12</Badge>\n */\nexport const Badge = ({ id, styles, classes, children, variant, ...props }: BadgeProps) => {\n // Build data-badge attribute for variant styling\n const dataBadge = variant ? variant : undefined\n\n return (\n <UI\n as=\"sup\"\n id={id}\n styles={styles}\n className={classes}\n data-badge={dataBadge}\n role=\"status\"\n {...props}\n >\n <UI as=\"span\">{children}</UI>\n </UI>\n )\n}\n\nBadge.displayName = 'Badge'\nexport default Badge\n","import React from 'react'\nimport UI from '#components/ui'\n\nexport type TagProps = {\n /** HTML element to display the badge as span or p */\n elm?: 'span' | 'p'\n /** Aria role for the component - conditional */\n role: 'note' | 'status'\n} & React.ComponentProps<typeof UI>\n\nexport const Tag = ({\n elm = 'span',\n role = 'note',\n children,\n styles,\n ...props\n}: TagProps) => {\n return (\n <UI as={elm} role={role} styles={styles} {...props}>\n {children}\n </UI>\n )\n}\nexport default Tag\nTag.displayName = 'Tag'\n","import UI from \"#components/ui\";\nimport React, { useCallback } from \"react\";\nimport type { DetailsProps } from \"./details.types\";\n\n/**\n * Details - A progressive disclosure component using native HTML `<details>` element.\n *\n * This component wraps the native `<details>` and `<summary>` elements to provide\n * an accessible, semantic way to show and hide content. It supports accordion behavior\n * through the `name` attribute and includes proper keyboard navigation out of the box.\n *\n * ## Key Features:\n * - **Semantic HTML**: Uses native `<details>` for built-in accessibility\n * - **Keyboard Support**: Space/Enter to toggle, fully accessible by default\n * - **Accordion Mode**: Group multiple details with `name` for exclusive expansion\n * - **Customizable**: Supports icons, custom styles, and event handlers\n *\n * ## Accessibility:\n * - ✅ WCAG 2.1 AA compliant using semantic HTML\n * - ✅ Native keyboard support (Space, Enter)\n * - ✅ Screen reader compatible (announced as \"disclosure\" or \"expandable\")\n * - ✅ Focus indicators automatically applied via CSS\n * - ✅ `aria-expanded` managed automatically by browser\n *\n * @example\n * ```tsx\n * // Basic usage\n * <Details summary=\"Click to expand\">\n * <p>Hidden content here</p>\n * </Details>\n * ```\n *\n * @example\n * ```tsx\n * // With icon and custom styling\n * <Details\n * summary=\"Shipping Information\"\n * icon={<ChevronDownIcon />}\n * classes=\"custom-details\"\n * onToggle={(e) => console.log('Open:', e.currentTarget.open)}\n * >\n * <p>Ships within 2-3 business days</p>\n * </Details>\n * ```\n *\n * @example\n * ```tsx\n * // Accordion mode - only one open at a time\n * <Details name=\"faq\" summary=\"Question 1\">Answer 1</Details>\n * <Details name=\"faq\" summary=\"Question 2\">Answer 2</Details>\n * <Details name=\"faq\" summary=\"Question 3\">Answer 3</Details>\n * ```\n */\nexport const Details = React.forwardRef<HTMLDetailsElement, DetailsProps>(\n (\n {\n summary,\n icon,\n styles,\n classes,\n ariaLabel,\n name,\n open,\n onPointerDown,\n onToggle,\n children,\n ...props\n },\n ref\n ) => {\n // Memoize callbacks to prevent unnecessary re-renders of child components\n const handlePointerDown = useCallback(\n (e: React.PointerEvent<HTMLElement>) => {\n onPointerDown?.(e as React.PointerEvent<HTMLDetailsElement>);\n },\n [onPointerDown]\n );\n\n const handleToggle = useCallback(\n (e: React.SyntheticEvent<HTMLDetailsElement>) => {\n onToggle?.(e);\n },\n [onToggle]\n );\n\n return (\n <UI\n as=\"details\"\n styles={styles}\n classes={classes}\n onToggle={handleToggle}\n ref={ref}\n open={open}\n aria-label={ariaLabel}\n name={name}\n {...props}\n >\n <UI as=\"summary\" onPointerDown={handlePointerDown}>\n {icon}\n {summary}\n </UI>\n <UI as=\"section\">{children}</UI>\n </UI>\n );\n }\n);\n\nDetails.displayName = \"Details\";\n\nexport default Details;\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/components/images/img.tsx","../src/components/text-to-speech/TextToSpeech.tsx","../src/components/text-to-speech/useTextToSpeech.tsx","../src/components/text-to-speech/views/TextToSpeechControls.tsx","../src/components/layout/landmarks.tsx","../src/components/badge/badge.tsx","../src/components/tag/tag.tsx","../src/components/details/details.tsx"],"names":["React","useMemo","Img","src","alt","width","height","styles","loading","placeholder","fetchpriority","decoding","srcSet","sizes","onError","onLoad","props","defaultPlaceholder","w","h","svg","fallbackPlaceholder","ui_default","e","useState","useEffect","useTextToSpeech","initialVoice","availableVoices","setAvailableVoices","currentVoice","setCurrentVoice","isSpeaking","setIsSpeaking","isPaused","setIsPaused","utterance","setUtterance","updateVoices","voices","googleVoice","voice","englishVoice","text","options","onEnd","TTSButtonComponent","children","onClick","TTSButton","TextToSpeechControls","label","onSpeak","onPause","onResume","onCancel","icon_default","TextToSpeechControls_default","TextToSpeech","initialText","showTextInput","pitch","rate","language","speak","pause","resume","cancel","getAvailableLanguages","setText","handleSpeak","handleEnd","handleChange","textarea_default","Landmarks","Header","id","headerBackground","classes","Main","Footer","Aside","Section","Article","Badge","variant","Tag","elm","role","useCallback","Details","summary","icon","ariaLabel","name","open","onPointerDown","onToggle","ref","handlePointerDown","handleToggle"],"mappings":"g6BACA,OAAOA,IAAS,WAAAC,OAAe,QA6GxB,IAAMC,EAAM,CAAC,CAClB,IAAAC,EAAM,KACN,IAAAC,EACA,MAAAC,EAAQ,IACR,OAAAC,EACA,OAAAC,EACA,QAAAC,EAAU,OACV,YAAAC,EACA,cAAAC,EAAgB,MAChB,SAAAC,EAAW,OACX,OAAAC,EACA,MAAAC,EACA,QAAAC,EACA,OAAAC,EACA,GAAGC,CACL,IAAgB,CAad,IAAMC,EAAqBhB,GAAQ,IAAM,CACvC,IAAMiB,EAAI,OAAOb,GAAU,SAAWA,EAAQ,IACxCc,EAAI,OAAOb,GAAW,SAAWA,EAAS,KAAK,MAAMY,EAAI,GAAI,EAG7DE,EAAM,wDAAwDF,CAAC,IAAIC,CAAC;AAAA;AAAA,mCAE3CD,CAAC,IAAIC,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAMpBD,CAAC,aAAaC,CAAC,qBAAqBD,CAAC,IAAIC,CAAC;AAAA,oBAC3CD,EAAI,GAAI,SAASC,EAAI,EAAG,QAAQ,KAAK,IAAID,EAAGC,CAAC,EAAI,GAAI;AAAA,oBACrDA,EAAI,GAAI,KAAKD,EAAI,GAAI,IAAIC,EAAI,GAAI,IAAID,EAAI,EAAG,IAAIC,EAAI,GAAI,KAAKD,CAAC,IAAIC,EAAI,GAAI,KAAKD,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I from \"../ui\";\nimport React, { useMemo } from \"react\";\nimport type { ImgProps } from \"./img.types\";\n\n/**\n * Img - A semantic image component with accessibility and performance best practices.\n *\n * This component wraps the native `<img>` element with enhanced features:\n * - **Responsive images** via optional srcset/sizes\n * - **Lazy loading** by default for performance\n * - **Error handling** with configurable fallback placeholders\n * - **Type safety** with full TypeScript support\n *\n * ## Accessibility Patterns (WCAG 2.1 AA)\n *\n * ### Decorative Images\n * Images that are purely visual decoration should use an empty alt attribute.\n * These images are typically borders, patterns, or visual separators.\n *\n * @example\n * ```tsx\n * // ✅ GOOD: Decorative border image\n * <Img src=\"/decorative-border.png\" alt=\"\" />\n *\n * // ✅ GOOD: Background pattern\n * <Img src=\"/pattern.svg\" alt=\"\" loading=\"eager\" />\n * ```\n *\n * ### Semantic Images\n * Images that convey information must have descriptive alt text that explains\n * the content and purpose of the image.\n *\n * @example\n * ```tsx\n * // ✅ GOOD: Informative image with descriptive alt\n * <Img\n * src=\"/sales-chart.png\"\n * alt=\"Sales chart showing 30% revenue growth in Q4 2024\"\n * />\n *\n * // ✅ GOOD: Product photo with context\n * <Img\n * src=\"/laptop.jpg\"\n * alt=\"Silver MacBook Pro 14-inch on wooden desk\"\n * />\n * ```\n *\n * ## Performance Optimization\n *\n * ### Lazy Loading\n * By default, images use lazy loading to improve page load performance.\n * Only use `loading=\"eager\"` for above-the-fold images.\n *\n * @example\n * ```tsx\n * // ✅ GOOD: Lazy load below-the-fold image\n * <Img src=\"/photo.jpg\" alt=\"Photo\" />\n *\n * // ✅ GOOD: Eager load hero image\n * <Img\n * src=\"/hero.jpg\"\n * alt=\"Hero banner\"\n * loading=\"eager\"\n * fetchpriority=\"high\"\n * />\n * ```\n *\n * ### Responsive Images\n * Use srcset and sizes for responsive images to serve appropriate image sizes\n * based on viewport width, improving performance and bandwidth usage.\n *\n * @example\n * ```tsx\n * // ✅ GOOD: Responsive image with multiple sizes\n * <Img\n * src=\"/photo.jpg\"\n * srcSet=\"/photo-320w.jpg 320w, /photo-640w.jpg 640w, /photo-1024w.jpg 1024w\"\n * sizes=\"(max-width: 640px) 100vw, (max-width: 1024px) 50vw, 800px\"\n * alt=\"Responsive image adapts to viewport\"\n * />\n * ```\n *\n * ## Error Handling\n *\n * @example\n * ```tsx\n * // ✅ GOOD: Custom placeholder on error\n * <Img\n * src=\"/photo.jpg\"\n * placeholder=\"/fallback.png\"\n * alt=\"User profile photo\"\n * />\n *\n * // ✅ GOOD: Custom error handler\n * <Img\n * src=\"/photo.jpg\"\n * onError={(e) => {\n * console.error('Image failed to load')\n * logToAnalytics('image_error', { src: e.currentTarget.src })\n * }}\n * alt=\"Photo\"\n * />\n * ```\n *\n * @param {ImgProps} props - Component props extending native img attributes\n * @returns {React.ReactElement} Image element with enhanced functionality\n *\n * @see {@link ImgProps} for complete prop documentation\n * @see https://www.w3.org/WAI/WCAG21/Understanding/non-text-content.html\n */\nexport const Img = ({\n src = \"//\",\n alt,\n width = 480,\n height,\n styles,\n loading = \"lazy\",\n placeholder,\n fetchpriority = \"low\",\n decoding = \"auto\",\n srcSet,\n sizes,\n onError,\n onLoad,\n ...props\n}: ImgProps) => {\n /**\n * Generates a performant, responsive SVG gradient placeholder.\n * Uses data URI to avoid network requests and memoizes based on dimensions.\n * The SVG uses viewBox for perfect scaling at any size.\n *\n * Features:\n * - Zero network requests (works offline)\n * - ~900 bytes vs. 5-10KB external image\n * - Responsive with viewBox\n * - Attractive gradient (indigo → purple → pink)\n * - Dimension text for debugging\n */\n const defaultPlaceholder = useMemo(() => {\n const w = typeof width === \"number\" ? width : 480;\n const h = typeof height === \"number\" ? height : Math.round(w * 0.75);\n\n // Responsive SVG with attractive gradient and dimension text\n const svg = `<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 ${w} ${h}\">\n <defs>\n <linearGradient id=\"grad-${w}-${h}\" x1=\"0%\" y1=\"0%\" x2=\"100%\" y2=\"100%\">\n <stop offset=\"0%\" style=\"stop-color:#6366f1;stop-opacity:1\" />\n <stop offset=\"50%\" style=\"stop-color:#8b5cf6;stop-opacity:1\" />\n <stop offset=\"100%\" style=\"stop-color:#ec4899;stop-opacity:1\" />\n </linearGradient>\n </defs>\n <rect width=\"${w}\" height=\"${h}\" fill=\"url(#grad-${w}-${h})\"/>\n <circle cx=\"${w * 0.15}\" cy=\"${h * 0.2}\" r=\"${Math.min(w, h) * 0.08}\" fill=\"rgba(255,255,255,0.2)\"/>\n <path d=\"M0,${h * 0.75} Q${w * 0.25},${h * 0.65} ${w * 0.5},${h * 0.75} T${w},${h * 0.75} L${w},${h} L0,${h} Z\" fill=\"rgba(0,0,0,0.15)\"/>\n <text x=\"50%\" y=\"50%\" dominant-baseline=\"middle\" text-anchor=\"middle\" font-family=\"system-ui,-apple-system,sans-serif\" font-size=\"${Math.max(16, Math.min(w, h) * 0.05)}\" font-weight=\"500\" fill=\"rgba(255,255,255,0.9)\">${w}×${h}</text>\n </svg>`;\n\n return `data:image/svg+xml,${encodeURIComponent(svg)}`;\n }, [width, height]);\n\n const fallbackPlaceholder = placeholder ?? defaultPlaceholder;\n\n /**\n * Handles image load errors.\n * Calls custom error handler if provided, then applies fallback placeholder.\n * The custom handler can prevent the default fallback by calling e.preventDefault().\n */\n const handleImgError = (\n e: React.SyntheticEvent<HTMLImageElement, Event>\n ): void => {\n // Call custom error handler first (for logging, analytics, etc.)\n if (onError) {\n onError(e);\n }\n\n // Apply fallback unless preventDefault() was called\n if (!e.defaultPrevented) {\n // Avoid infinite error loop by checking if already showing placeholder\n if (e.currentTarget.src !== fallbackPlaceholder) {\n e.currentTarget.src = fallbackPlaceholder;\n }\n }\n };\n\n /**\n * Handles successful image load.\n * Calls custom load handler if provided.\n */\n const handleImgLoad = (\n e: React.SyntheticEvent<HTMLImageElement, Event>\n ): void => {\n onLoad?.(e);\n };\n\n return (\n <UI\n as=\"img\"\n src={src}\n alt={alt}\n width={width}\n height={height || \"auto\"}\n loading={loading}\n style={styles}\n srcSet={srcSet}\n sizes={sizes}\n onError={handleImgError}\n onLoad={handleImgLoad}\n decoding={decoding}\n {...props}\n {...(fetchpriority && { fetchpriority })}\n />\n );\n};\n\nexport default Img;\nImg.displayName = \"Img\";\n","import React, { useState, ChangeEvent, useEffect } from 'react'\nimport { useTextToSpeech } from './useTextToSpeech'\nimport Textarea from '#components/form/textarea.jsx'\nimport TextToSpeechControls from './views/TextToSpeechControls'\n\n/**\n * Props for the TextToSpeechComponent.\n * @interface TextToSpeechComponentProps\n */\ninterface TextToSpeechComponentProps {\n /** Initial text to be spoken. Defaults to an empty string. */\n initialText?: string\n /** Whether to show the text input field. Defaults to true. */\n showTextInput?: boolean\n /** The voice to be used for speech synthesis. */\n voice?: SpeechSynthesisVoice | undefined\n /** The pitch of the voice. Defaults to 1. */\n pitch?: number\n /** The rate of speech. Defaults to 1. */\n rate?: number\n /** The language to be used for speech synthesis. */\n language?: string\n /** Player label */\n label?: string | React.ReactNode\n /** Callback function to be called when speech ends. */\n onEnd?: () => void\n}\n\n/**\n * A component that converts text to speech using the Web Speech API.\n * @param {TextToSpeechComponentProps} props - The props for the component.\n * @returns {JSX.Element} The rendered TextToSpeechComponent.\n */\nexport const TextToSpeech: React.FC<TextToSpeechComponentProps> = ({\n initialText = '',\n showTextInput = false,\n voice,\n pitch = 1,\n rate = 1,\n language,\n label,\n onEnd,\n}) => {\n const {\n speak,\n pause,\n resume,\n cancel,\n isSpeaking,\n isPaused,\n getAvailableLanguages,\n availableVoices,\n } = useTextToSpeech()\n const [text, setText] = useState<string>(initialText)\n console.log(getAvailableLanguages())\n\n useEffect(() => {\n setText(initialText)\n }, [initialText])\n\n const handleSpeak = (): void => {\n if (text.trim() !== '') {\n speak(text, { voice, pitch, rate }, handleEnd)\n }\n }\n\n const handleChange = (e: ChangeEvent<HTMLTextAreaElement>): void => {\n setText(e.target.value)\n }\n\n const handleEnd = (): void => {\n if (onEnd) {\n onEnd()\n }\n }\n\n return (\n <>\n {showTextInput && <Textarea value={text} onChange={handleChange} />}\n <TextToSpeechControls\n label={label}\n isSpeaking={isSpeaking}\n isPaused={isPaused}\n onSpeak={handleSpeak}\n onPause={pause}\n onResume={resume}\n onCancel={cancel}\n />\n </>\n )\n}\n\nexport default TextToSpeech\nTextToSpeech.displayName = 'TextToSpeechComponent'\n","import { useState, useEffect } from 'react'\n\n/**\n * Options for configuring speech synthesis.\n * @interface SpeechOptions\n */\ninterface SpeechOptions {\n /** The language for speech synthesis (e.g., 'en-US') */\n lang?: string\n\n /** The pitch of the voice (0 to 2) */\n pitch?: number\n /** The speed of the voice (0.1 to 10) */\n rate?: number\n\n /** The voice to use for speech synthesis */\n voice?: SpeechSynthesisVoice\n}\n/**\n * Custom hook to handle text-to-speech functionality.\n *\n * @param {SpeechSynthesisVoice} [initialVoice] - The initial voice to use for speech synthesis.\n * @returns {Object} An object containing methods to control speech synthesis and state variables.\n */\nexport const useTextToSpeech = (initialVoice?: SpeechSynthesisVoice) => {\n const [availableVoices, setAvailableVoices] = useState<\n SpeechSynthesisVoice[]\n >([])\n const [currentVoice, setCurrentVoice] = useState<\n SpeechSynthesisVoice | undefined\n >(initialVoice)\n\n const [isSpeaking, setIsSpeaking] = useState<boolean>(false)\n const [isPaused, setIsPaused] = useState<boolean>(false)\n const [utterance, setUtterance] = useState<SpeechSynthesisUtterance | null>(\n null,\n )\n\n useEffect(() => {\n const updateVoices = () => {\n const voices = window.speechSynthesis.getVoices()\n setAvailableVoices(voices)\n\n // Set default voice to Google US English if available\n const googleVoice = voices.find(\n (voice) => voice.name === 'Google US English',\n )\n if (googleVoice) {\n setCurrentVoice(googleVoice)\n } else {\n // Fallback to the first English voice if Google voice is not available\n const englishVoice = voices.find((voice) =>\n voice.lang.startsWith('en-'),\n )\n if (englishVoice) {\n setCurrentVoice(englishVoice)\n }\n }\n }\n\n updateVoices()\n window.speechSynthesis.onvoiceschanged = updateVoices\n\n return () => {\n window.speechSynthesis.onvoiceschanged = null\n }\n }, [])\n\n /**\n * Gets the list of available languages for speech synthesis.\n * @returns {string[]} An array of available language codes.\n */\n const getAvailableLanguages = () => {\n return [...new Set(availableVoices.map((voice) => voice.lang))]\n }\n\n /**\n * Initiates speech synthesis for the given text.\n *\n * @param {string} text - The text to be spoken.\n * @param {SpeechOptions} [options={}] - Options for speech synthesis.\n * @param {Function} [onEnd] - Callback function to be called when speech ends.\n */\n const speak = (\n text: string,\n options: SpeechOptions = {},\n onEnd?: () => void,\n ) => {\n const utterance = new SpeechSynthesisUtterance(text)\n\n utterance.lang = options.lang ?? 'en-US'\n utterance.pitch = options.pitch ?? 1\n utterance.rate = options.rate ?? 1\n utterance.voice = currentVoice ?? options.voice ?? null\n\n utterance.onend = () => {\n setIsSpeaking(false)\n setIsPaused(false)\n if (onEnd) {\n onEnd()\n }\n }\n\n if ('speechSynthesis' in window) {\n window.speechSynthesis.speak(utterance)\n setUtterance(utterance)\n setIsSpeaking(true)\n setIsPaused(false)\n } else {\n console.error('Speech synthesis not supported')\n // Handle the error appropriately\n }\n }\n\n /**\n * Changes the current voice used for speech synthesis.\n * @param {SpeechSynthesisVoice} voice - The new voice to use.\n */\n const changeVoice = (voice: SpeechSynthesisVoice) => {\n setCurrentVoice(voice)\n }\n\n /**\n * Pauses the ongoing speech synthesis.\n */\n const pause = () => {\n if (isSpeaking && !isPaused) {\n window.speechSynthesis.pause()\n setIsPaused(true)\n }\n }\n\n /**\n * Resumes the paused speech synthesis.\n */\n const resume = () => {\n if (isSpeaking && isPaused) {\n window.speechSynthesis.resume()\n setIsPaused(false)\n }\n }\n\n /**\n * Cancels the ongoing speech synthesis.\n */\n const cancel = () => {\n if (isSpeaking) {\n window.speechSynthesis.cancel()\n setIsSpeaking(false)\n setIsPaused(false)\n }\n }\n\n return {\n /** Initiates speech synthesis for the given text */\n speak,\n /** Pauses the ongoing speech synthesis */\n pause,\n /** Resumes the paused speech synthesis */\n resume,\n /** Cancels the ongoing speech synthesis */\n cancel,\n /** Indicates whether speech synthesis is currently active */\n isSpeaking,\n /** Indicates whether speech synthesis is currently paused */\n isPaused,\n /** Array of available voices for speech synthesis */\n availableVoices,\n /** Changes the current voice used for speech synthesis */\n changeVoice,\n /** The currently selected voice for speech synthesis */\n currentVoice,\n /** Gets the list of available languages for speech synthesis */\n getAvailableLanguages,\n }\n}\n","import React from 'react'\nimport Icon from '#components/icons/icon'\nimport UI from '#components/ui'\nimport { FC } from 'react'\n\n/**\n * Props for the TextToSpeechControls component.\n * @interface TextToSpeechControlsProps\n */\ninterface TextToSpeechControlsProps {\n /** Optional label for the controls */\n label?: string | React.ReactNode\n /** Indicates if the text-to-speech is currently speaking */\n isSpeaking: boolean\n /** Indicates if the text-to-speech is paused */\n isPaused: boolean\n /** Function to start speaking */\n onSpeak: () => void\n /** Function to pause speaking */\n onPause: () => void\n /** Function to resume speaking */\n onResume: () => void\n /** Function to cancel speaking */\n onCancel: () => void\n}\n\n/**\n * TTSButtonComponent props\n * @interface TTSButtonComponentProps\n */\ninterface TTSButtonComponentProps {\n /** The content of the button */\n children: React.ReactNode\n /** Function to call when the button is clicked */\n onClick: () => void\n}\n\n/**\n * TTSButtonComponent is a reusable button component for text-to-speech controls.\n * @param {TTSButtonComponentProps} props - The component props\n * @returns {React.ReactElement} The rendered button\n */\nexport const TTSButtonComponent: React.FC<TTSButtonComponentProps> = ({\n children,\n onClick,\n}) => {\n return (\n <UI\n as=\"button\"\n type=\"button\"\n className=\"tts-border\"\n data-btn=\"sm text pill\"\n onClick={onClick}\n >\n {children}\n </UI>\n )\n}\n\nexport const TTSButton = React.memo(TTSButtonComponent)\n\n/**\n * TextToSpeechControlsComponent interface extends FC<TextToSpeechControlsProps>\n * and includes a TTSButton property.\n * @interface TextToSpeechControlsComponent\n * @extends {FC<TextToSpeechControlsProps>}\n */\ninterface TextToSpeechControlsComponent extends FC<TextToSpeechControlsProps> {\n /** The TTSButton component used within TextToSpeechControls */\n TTSButton: typeof TTSButton\n}\n\n/**\n * TextToSpeechControls component provides a user interface for controlling text-to-speech functionality.\n * @param {TextToSpeechControlsProps} props - The component props\n * @returns {React.ReactElement} The rendered TextToSpeechControls component\n */\nconst TextToSpeechControls: TextToSpeechControlsComponent = ({\n label,\n isSpeaking,\n isPaused,\n onSpeak,\n onPause,\n onResume,\n onCancel,\n}) => {\n const iconSize = 16\n\n return (\n <UI as=\"div\" data-tts>\n {label && <p>{label}</p>}\n {!isSpeaking && (\n <TTSButton aria-label=\"Speak\" onClick={onSpeak}>\n <Icon.PlaySolid size={iconSize} />\n </TTSButton>\n )}\n {isSpeaking && !isPaused && (\n <TTSButton aria-label=\"Pause\" onClick={onPause}>\n <Icon.PauseSolid size={iconSize} />\n </TTSButton>\n )}\n {isPaused && (\n <TTSButton aria-label=\"Resume\" onClick={onResume}>\n <Icon.ResumeSolid size={iconSize} />\n </TTSButton>\n )}\n <TTSButton aria-label=\"Stop\" onClick={onCancel}>\n <Icon.StopSolid size={iconSize} />\n </TTSButton>\n </UI>\n )\n}\n\nTextToSpeechControls.displayName = 'TextToSpeechControls'\nTextToSpeechControls.TTSButton = TTSButton\n\nexport default TextToSpeechControls\n","import UI from '../ui'\nimport React, { ReactNode } from 'react'\n\ntype ComponentProps = React.ComponentProps<typeof UI>\n\n/**\n * Renders children elements without any wrapping component.\n * Can be used as a placeholder when no semantic landmark is needed.\n */\nexport const Landmarks = (children?: React.FC) => <>{children}</>\n\ntype HeaderProps = {\n headerBackground?: ReactNode\n} & ComponentProps\n/**\n * Header component.\n *\n * Renders a header landmark with a section child.\n *\n * @param children - The content to render inside the header.\n * @param styles - Optional styles object.\n * @param props - Other props.\n */\nexport const Header = ({\n id,\n children,\n headerBackground,\n styles,\n classes,\n ...props\n}: HeaderProps) => {\n return (\n <UI as=\"header\" id={id} styles={styles} className={classes} {...props}>\n {headerBackground}\n <UI as=\"section\">{children}</UI>\n </UI>\n )\n}\n\n/**\n * Main component.\n *\n * Renders a main landmark.\n *\n * @param children - The content to render inside the main element.\n * @param styles - Optional styles object.\n * @param props - Other props.\n */\nexport const Main = ({\n id,\n children,\n styles,\n classes,\n ...props\n}: ComponentProps) => {\n return (\n <UI as=\"main\" id={id} styles={styles} {...props} className={classes}>\n {children}\n </UI>\n )\n}\n\n/**\n * Footer component that renders a footer element with a section element inside.\n * @param {ReactNode} children - Child elements to render inside the section element.\n * @param styles - CSS styles to apply to the footer element.\n * @param props - Additional props to pass to the footer element.\n * @returns A React component that renders a footer element with a section element inside.\n */\nexport const Footer = ({\n id,\n classes,\n children,\n styles = {},\n ...props\n}: ComponentProps) => {\n return (\n <UI as=\"footer\" id={id} className={classes} styles={styles} {...props}>\n <UI as=\"section\">{children || 'Copyright © 2022'}</UI>\n </UI>\n )\n}\n\nexport const Aside = ({\n id,\n children,\n styles = {},\n classes,\n ...props\n}: ComponentProps) => {\n return (\n <UI as=\"aside\" id={id} styles={styles} className={classes} {...props}>\n <UI as=\"section\">{children}</UI>\n </UI>\n )\n}\n\n/**\n * Section component that renders a section element.\n *\n * @param children - Child elements to render inside the section.\n * @param styles - CSS styles to apply to the section.\n * @param props - Other props.\n */\nexport const Section = ({\n id,\n children,\n styles,\n classes,\n ...props\n}: ComponentProps) => {\n return (\n <UI as=\"section\" id={id} styles={styles} className={classes} {...props}>\n {children}\n </UI>\n )\n}\n\n/**\n * Article component renders an HTML <article> element.\n *\n * @param children - Child elements to render inside the article.\n * @param styles - CSS styles to apply to the article.\n * @param props - Additional props to pass to the article element.\n */\nexport const Article = ({\n id,\n children,\n\n styles,\n classes,\n ...props\n}: ComponentProps) => {\n return (\n <UI as=\"article\" id={id} styles={styles} className={classes} {...props}>\n {children}\n </UI>\n )\n}\n\nexport default Landmarks\n\nLandmarks.displayName = 'Landmarks'\nLandmarks.Header = Header\nLandmarks.Main = Main\nLandmarks.Footer = Footer\nLandmarks.Aside = Aside\nLandmarks.Section = Section\nLandmarks.Article = Article\n","import UI from '#components/ui'\nimport React from 'react'\n\n/**\n * Props for the Badge component\n *\n * @property {React.ReactNode} children - Content to display inside the badge (typically numbers or short text)\n * @property {string} [id] - Optional HTML id attribute for the badge element\n * @property {React.CSSProperties} [styles] - Inline styles to apply to the badge\n * @property {string} [classes] - CSS class names to apply to the badge\n * @property {'rounded'} [variant] - Visual variant of the badge. Use 'rounded' for circular badges (fixed size with ellipsis for overflow)\n * @property {string} [aria-label] - Accessible label for screen readers. Required for icon-only or number-only badges\n * @property {'status' | 'note'} [role] - ARIA role for the badge. Defaults to 'status' for dynamic content\n */\nexport type BadgeProps = {\n /**\n * Content to display inside the badge (typically numbers or short text)\n */\n children?: React.ReactNode\n /**\n * Visual variant of the badge\n * - 'rounded': Circular badge style\n */\n variant?: 'rounded'\n} & React.ComponentProps<typeof UI>\n\n/**\n * Badge - A small label component for displaying status, counts, or notifications\n *\n * The Badge component is used to display supplementary information alongside other content,\n * such as notification counts, status indicators, or labels. It renders as a semantic `<sup>`\n * element with a nested `<span>` required for the component's styling architecture.\n *\n * ## Styling Architecture\n *\n * The Badge uses a nested structure (`<sup><span>content</span></sup>`) which is required\n * for the SCSS styling system. The outer `<sup>` element provides positioning context,\n * while the inner `<span>` receives the visual styling (background, padding, border-radius).\n *\n * ## Rounded Variant Behavior\n *\n * The `rounded` variant creates a perfect circular badge with fixed dimensions (1.5625rem).\n * Content that exceeds the available space will be truncated with an ellipsis (...).\n * **Best practice**: Format large numbers yourself (e.g., pass \"99+\" instead of \"999\").\n *\n * ## Accessibility Considerations\n *\n * - **Semantic HTML**: Uses `<sup>` (superscript) element for proper positioning context\n * - **ARIA Role**: Defaults to `role=\"status\"` for dynamic badges (e.g., unread counts)\n * - **Accessible Names**: For icon-only or number-only badges, provide an `aria-label`\n * to give context (e.g., \"3 unread messages\" instead of just \"3\")\n * - **Live Regions**: The `role=\"status\"` makes badges announce updates to screen readers\n *\n * @param {BadgeProps} props - Component props\n * @returns {React.ReactElement} A Badge component\n *\n * @example\n * // Basic badge with notification count\n * <p>\n * Messages\n * <Badge aria-label=\"3 unread messages\">3</Badge>\n * </p>\n *\n * @example\n * // Rounded badge variant (perfect circle)\n * <p>\n * Notifications\n * <Badge variant=\"rounded\" aria-label=\"99 or more notifications\">99+</Badge>\n * </p>\n *\n * @example\n * // Status badge with custom styling\n * <p>\n * Active Users\n * <Badge styles={{ backgroundColor: 'green', color: 'white' }}>21</Badge>\n * </p>\n *\n * @example\n * // ✅ GOOD: Accessible badge with descriptive label and formatted content\n * <Badge variant=\"rounded\" aria-label=\"12 items in cart\">12</Badge>\n *\n * @example\n * // ✅ GOOD: Large numbers formatted by developer\n * <Badge variant=\"rounded\" aria-label=\"More than 99 notifications\">99+</Badge>\n *\n * @example\n * // ❌ BAD: Number-only badge without context for screen readers\n * <Badge>12</Badge>\n */\nexport const Badge = ({ id, styles, classes, children, variant, ...props }: BadgeProps) => {\n // Build data-badge attribute for variant styling\n const dataBadge = variant ? variant : undefined\n\n return (\n <UI\n as=\"sup\"\n id={id}\n styles={styles}\n className={classes}\n data-badge={dataBadge}\n role=\"status\"\n {...props}\n >\n <UI as=\"span\">{children}</UI>\n </UI>\n )\n}\n\nBadge.displayName = 'Badge'\nexport default Badge\n","import React from 'react'\nimport UI from '#components/ui'\nimport type { TagProps, TagVariant } from './tag.types'\n\n/**\n * Tag - A small inline label component for displaying status, versions, or environment indicators\n *\n * The Tag component is used to highlight supplementary information such as release stages\n * (alpha, beta, stable), environment indicators (production), or version labels. It renders\n * as either a `<span>` (inline) or `<p>` (block) element with semantic ARIA roles.\n *\n * ## Design Philosophy\n *\n * Tags serve as visual and semantic indicators that:\n * - Communicate the state or stage of features, releases, or environments\n * - Provide quick visual scanning through color-coded variants\n * - Maintain accessibility through proper ARIA roles and labels\n *\n * ## Styling Architecture\n *\n * The Tag component uses CSS custom properties (CSS variables) for theming and styling,\n * allowing for easy customization through the `data-tag` attribute. Each variant\n * (alpha, beta, stable, production) applies predefined color schemes defined in SCSS.\n *\n * ## Accessibility Considerations (WCAG 2.1 AA Compliance)\n *\n * - **Semantic Roles**: Uses `role=\"note\"` for static tags or `role=\"status\"` for dynamic content\n * - `role=\"note\"`: Read once by screen readers, suitable for static labels (default)\n * - `role=\"status\"`: Announces updates to screen readers, use for changing status indicators\n * - **Color Independence**: Don't rely solely on color to convey meaning - include text labels\n * - **Text Alternatives**: For icon-only tags, provide `aria-label` for screen reader context\n * - **Contrast Ratios**: All variants meet WCAG AA contrast requirements (4.5:1 for normal text)\n * - **Live Regions**: When using `role=\"status\"`, tag becomes a live region for accessibility\n *\n * ## When to Use Each Role\n *\n * **Use `role=\"note\"` (default) when:**\n * - Displaying static version numbers (e.g., \"v2.1.0\")\n * - Showing fixed environment indicators (e.g., \"Beta Feature\")\n * - Labeling unchanging content categories\n *\n * **Use `role=\"status\"` when:**\n * - Indicating real-time status that may change (e.g., \"Processing\" → \"Complete\")\n * - Displaying live build/deployment states\n * - Showing dynamic feature flags that toggle\n *\n * @param {TagProps} props - Component props\n * @returns {React.ReactElement} A Tag component\n *\n * @example\n * // Basic tag with beta variant (default inline span)\n * <Tag variant=\"beta\">Beta</Tag>\n *\n * @example\n * // Production environment indicator as block element\n * <Tag elm=\"p\" variant=\"production\">Production Environment</Tag>\n *\n * @example\n * // Dynamic status tag with live updates\n * <Tag role=\"status\" variant=\"stable\">\n * {isDeployed ? 'Deployed' : 'Deploying...'}\n * </Tag>\n *\n * @example\n * // Tag with custom styling and accessibility label\n * <Tag\n * variant=\"alpha\"\n * aria-label=\"Alpha version - may contain bugs\"\n * styles={{ fontSize: '0.75rem' }}\n * >\n * Alpha\n * </Tag>\n *\n * @example\n * // ✅ GOOD: Clear text content with variant for visual enhancement\n * <Tag variant=\"stable\">v2.0 Stable</Tag>\n *\n * @example\n * // ✅ GOOD: Dynamic status with proper role\n * <Tag role=\"status\" variant=\"production\">{deploymentStatus}</Tag>\n *\n * @example\n * // ✅ GOOD: Accessible tag with descriptive label\n * <Tag variant=\"beta\" aria-label=\"Beta feature - feedback welcome\">\n * Beta\n * </Tag>\n *\n * @example\n * // ❌ BAD: Relying only on color without text\n * <Tag variant=\"production\" aria-label=\"Production\" />\n *\n * @example\n * // ❌ BAD: Using status role for static content\n * <Tag role=\"status\" variant=\"stable\">v1.0</Tag>\n */\nexport const Tag = ({\n elm = 'span',\n role = 'note',\n variant,\n children,\n styles,\n ...props\n}: TagProps) => {\n // Map variant to data-tag attribute for SCSS styling\n const dataTag = variant ? variant : undefined\n\n return (\n <UI\n as={elm}\n role={role}\n data-tag={dataTag}\n styles={styles}\n {...props}\n >\n {children}\n </UI>\n )\n}\n\nTag.displayName = 'Tag'\nexport default Tag\nexport type { TagProps, TagVariant }\n","import UI from \"#components/ui\";\nimport React, { useCallback } from \"react\";\nimport type { DetailsProps } from \"./details.types\";\n\n/**\n * Details - A progressive disclosure component using native HTML `<details>` element.\n *\n * This component wraps the native `<details>` and `<summary>` elements to provide\n * an accessible, semantic way to show and hide content. It supports accordion behavior\n * through the `name` attribute and includes proper keyboard navigation out of the box.\n *\n * ## Key Features:\n * - **Semantic HTML**: Uses native `<details>` for built-in accessibility\n * - **Keyboard Support**: Space/Enter to toggle, fully accessible by default\n * - **Accordion Mode**: Group multiple details with `name` for exclusive expansion\n * - **Customizable**: Supports icons, custom styles, and event handlers\n *\n * ## Accessibility:\n * - ✅ WCAG 2.1 AA compliant using semantic HTML\n * - ✅ Native keyboard support (Space, Enter)\n * - ✅ Screen reader compatible (announced as \"disclosure\" or \"expandable\")\n * - ✅ Focus indicators automatically applied via CSS\n * - ✅ `aria-expanded` managed automatically by browser\n *\n * @example\n * ```tsx\n * // Basic usage\n * <Details summary=\"Click to expand\">\n * <p>Hidden content here</p>\n * </Details>\n * ```\n *\n * @example\n * ```tsx\n * // With icon and custom styling\n * <Details\n * summary=\"Shipping Information\"\n * icon={<ChevronDownIcon />}\n * classes=\"custom-details\"\n * onToggle={(e) => console.log('Open:', e.currentTarget.open)}\n * >\n * <p>Ships within 2-3 business days</p>\n * </Details>\n * ```\n *\n * @example\n * ```tsx\n * // Accordion mode - only one open at a time\n * <Details name=\"faq\" summary=\"Question 1\">Answer 1</Details>\n * <Details name=\"faq\" summary=\"Question 2\">Answer 2</Details>\n * <Details name=\"faq\" summary=\"Question 3\">Answer 3</Details>\n * ```\n */\nexport const Details = React.forwardRef<HTMLDetailsElement, DetailsProps>(\n (\n {\n summary,\n icon,\n styles,\n classes,\n ariaLabel,\n name,\n open,\n onPointerDown,\n onToggle,\n children,\n ...props\n },\n ref\n ) => {\n // Memoize callbacks to prevent unnecessary re-renders of child components\n const handlePointerDown = useCallback(\n (e: React.PointerEvent<HTMLElement>) => {\n onPointerDown?.(e as React.PointerEvent<HTMLDetailsElement>);\n },\n [onPointerDown]\n );\n\n const handleToggle = useCallback(\n (e: React.SyntheticEvent<HTMLDetailsElement>) => {\n onToggle?.(e);\n },\n [onToggle]\n );\n\n return (\n <UI\n as=\"details\"\n styles={styles}\n classes={classes}\n onToggle={handleToggle}\n ref={ref}\n open={open}\n aria-label={ariaLabel}\n name={name}\n {...props}\n >\n <UI as=\"summary\" onPointerDown={handlePointerDown}>\n {icon}\n {summary}\n </UI>\n <UI as=\"section\">{children}</UI>\n </UI>\n );\n }\n);\n\nDetails.displayName = \"Details\";\n\nexport default Details;\n"]}
|
|
@@ -0,0 +1,323 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { U as UI } from './ui-d01b50d4.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Props for the Link component.
|
|
6
|
+
*
|
|
7
|
+
* The Link component renders accessible anchor elements with enhanced security,
|
|
8
|
+
* styling variants, and WCAG 2.1 AA compliance. It supports both traditional
|
|
9
|
+
* text links and button-styled links for call-to-action scenarios.
|
|
10
|
+
*
|
|
11
|
+
* ## Accessibility Considerations
|
|
12
|
+
*
|
|
13
|
+
* - External links automatically include `rel="noopener noreferrer"` for security
|
|
14
|
+
* - Links should have descriptive text or `aria-label` for screen readers
|
|
15
|
+
* - Focus indicators must meet WCAG 2.4.7 contrast requirements (3:1 minimum)
|
|
16
|
+
* - Button-styled links maintain semantic `<a>` element for proper navigation
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```tsx
|
|
20
|
+
* // Basic link
|
|
21
|
+
* <Link href="/about">About Us</Link>
|
|
22
|
+
*
|
|
23
|
+
* // External link with prefetch
|
|
24
|
+
* <Link href="https://example.com" target="_blank" prefetch>
|
|
25
|
+
* Visit Example
|
|
26
|
+
* </Link>
|
|
27
|
+
*
|
|
28
|
+
* // Button-styled link
|
|
29
|
+
* <Link href="/signup" btnStyle="primary">
|
|
30
|
+
* <b>Sign Up Now</b>
|
|
31
|
+
* </Link>
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
type LinkProps = {
|
|
35
|
+
/**
|
|
36
|
+
* The URL that the hyperlink points to.
|
|
37
|
+
* Can be relative or absolute, internal or external.
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```tsx
|
|
41
|
+
* href="/products"
|
|
42
|
+
* href="https://example.com"
|
|
43
|
+
* href="mailto:hello@example.com"
|
|
44
|
+
* href="tel:+1234567890"
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
href?: string;
|
|
48
|
+
/**
|
|
49
|
+
* Where to display the linked URL.
|
|
50
|
+
*
|
|
51
|
+
* - `_self` (default): Current browsing context
|
|
52
|
+
* - `_blank`: New tab/window (automatically adds security attributes)
|
|
53
|
+
* - `_parent`: Parent browsing context
|
|
54
|
+
* - `_top`: Top-level browsing context
|
|
55
|
+
*
|
|
56
|
+
* Note: When `target="_blank"`, `rel="noopener noreferrer"` is automatically
|
|
57
|
+
* added for security unless explicitly overridden.
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* ```tsx
|
|
61
|
+
* target="_blank" // Opens in new tab with security
|
|
62
|
+
* ```
|
|
63
|
+
*/
|
|
64
|
+
target?: string;
|
|
65
|
+
/**
|
|
66
|
+
* Relationship between current document and linked URL.
|
|
67
|
+
*
|
|
68
|
+
* Common values:
|
|
69
|
+
* - `noopener`: Prevents window.opener access (security)
|
|
70
|
+
* - `noreferrer`: Prevents referrer header (privacy)
|
|
71
|
+
* - `nofollow`: Hints search engines not to follow (SEO)
|
|
72
|
+
* - `prefetch`: Hints to prefetch the resource (performance)
|
|
73
|
+
*
|
|
74
|
+
* Note: For `target="_blank"`, this component automatically merges
|
|
75
|
+
* `noopener noreferrer` with any user-provided values for security.
|
|
76
|
+
*
|
|
77
|
+
* @example
|
|
78
|
+
* ```tsx
|
|
79
|
+
* rel="nofollow noopener"
|
|
80
|
+
* rel="author"
|
|
81
|
+
* ```
|
|
82
|
+
*/
|
|
83
|
+
rel?: string;
|
|
84
|
+
/**
|
|
85
|
+
* Content to display inside the link.
|
|
86
|
+
*
|
|
87
|
+
* For accessibility, ensure link text is descriptive and meaningful.
|
|
88
|
+
* Avoid generic text like "click here" or "read more" without context.
|
|
89
|
+
*
|
|
90
|
+
* @example
|
|
91
|
+
* ```tsx
|
|
92
|
+
* // ✅ Good: Descriptive link text
|
|
93
|
+
* <Link href="/products">View all products</Link>
|
|
94
|
+
*
|
|
95
|
+
* // ❌ Bad: Generic link text without context
|
|
96
|
+
* <Link href="/products">Click here</Link>
|
|
97
|
+
*
|
|
98
|
+
* // ✅ Good: Icon with accessible label
|
|
99
|
+
* <Link href="/home" aria-label="Return to homepage">
|
|
100
|
+
* <HomeIcon aria-hidden="true" />
|
|
101
|
+
* </Link>
|
|
102
|
+
* ```
|
|
103
|
+
*/
|
|
104
|
+
children: React.ReactNode;
|
|
105
|
+
/**
|
|
106
|
+
* Inline CSS styles to apply to the link element.
|
|
107
|
+
* Can be used to override CSS custom properties.
|
|
108
|
+
*
|
|
109
|
+
* @example
|
|
110
|
+
* ```tsx
|
|
111
|
+
* styles={{
|
|
112
|
+
* '--link-color': '#ff0000',
|
|
113
|
+
* '--link-decoration': 'underline',
|
|
114
|
+
* }}
|
|
115
|
+
* ```
|
|
116
|
+
*/
|
|
117
|
+
styles?: React.CSSProperties;
|
|
118
|
+
/**
|
|
119
|
+
* Hints to the browser to prefetch the linked resource.
|
|
120
|
+
*
|
|
121
|
+
* When `true` and `target="_blank"`, adds `rel="prefetch"` along with
|
|
122
|
+
* security attributes. This can improve perceived performance but should
|
|
123
|
+
* be used judiciously as it consumes bandwidth.
|
|
124
|
+
*
|
|
125
|
+
* Note: Browser support varies. Modern browsers may ignore this hint.
|
|
126
|
+
*
|
|
127
|
+
* @default false
|
|
128
|
+
* @example
|
|
129
|
+
* ```tsx
|
|
130
|
+
* <Link href="/next-page" prefetch>Next Page</Link>
|
|
131
|
+
* ```
|
|
132
|
+
*/
|
|
133
|
+
prefetch?: boolean;
|
|
134
|
+
/**
|
|
135
|
+
* Applies button-like styling to the link.
|
|
136
|
+
*
|
|
137
|
+
* When set, the link renders with button styling including padding,
|
|
138
|
+
* borders, and hover effects while maintaining semantic anchor behavior.
|
|
139
|
+
*
|
|
140
|
+
* Common values:
|
|
141
|
+
* - `"btn"`: Standard button styling
|
|
142
|
+
* - `"pill"`: Rounded pill button styling
|
|
143
|
+
*
|
|
144
|
+
* Alternative: Wrap children in `<b>` or `<i>` tags for automatic styling:
|
|
145
|
+
* - `<b>`: Applies button styling
|
|
146
|
+
* - `<i>`: Applies pill styling
|
|
147
|
+
*
|
|
148
|
+
* @example
|
|
149
|
+
* ```tsx
|
|
150
|
+
* // Using btnStyle prop
|
|
151
|
+
* <Link href="/signup" btnStyle="btn">Sign Up</Link>
|
|
152
|
+
*
|
|
153
|
+
* // Using child wrapper (automatic detection)
|
|
154
|
+
* <Link href="/signup"><b>Sign Up</b></Link>
|
|
155
|
+
* <Link href="/signup"><i>Pill Button</i></Link>
|
|
156
|
+
* ```
|
|
157
|
+
*/
|
|
158
|
+
btnStyle?: string;
|
|
159
|
+
/**
|
|
160
|
+
* Event handler called when the link is clicked or activated.
|
|
161
|
+
*
|
|
162
|
+
* **Recommended for most use cases**, especially analytics and tracking.
|
|
163
|
+
* This event fires for:
|
|
164
|
+
* - Mouse clicks
|
|
165
|
+
* - Touch/tap interactions
|
|
166
|
+
* - Keyboard activation (Enter key)
|
|
167
|
+
* - Assistive technology activation
|
|
168
|
+
*
|
|
169
|
+
* Use `onClick` when you need to track ALL user activations, including
|
|
170
|
+
* keyboard users. This ensures full accessibility coverage.
|
|
171
|
+
*
|
|
172
|
+
* @param event - The mouse event
|
|
173
|
+
* @example
|
|
174
|
+
* ```tsx
|
|
175
|
+
* // ✅ RECOMMENDED: onClick tracks all activation methods
|
|
176
|
+
* <Link
|
|
177
|
+
* href="/products"
|
|
178
|
+
* onClick={(e) => {
|
|
179
|
+
* trackEvent('link_click', { href: '/products' });
|
|
180
|
+
* }}
|
|
181
|
+
* >
|
|
182
|
+
* Products
|
|
183
|
+
* </Link>
|
|
184
|
+
* ```
|
|
185
|
+
*/
|
|
186
|
+
onClick?: (event: React.MouseEvent<HTMLAnchorElement>) => void;
|
|
187
|
+
/**
|
|
188
|
+
* Event handler called when a pointer device button is pressed on the link.
|
|
189
|
+
*
|
|
190
|
+
* Use this for specific pointer interactions like:
|
|
191
|
+
* - Drag-and-drop detection
|
|
192
|
+
* - Touch gesture recognition
|
|
193
|
+
* - Distinguishing input types (mouse vs touch vs pen)
|
|
194
|
+
* - Providing early visual feedback before click completes
|
|
195
|
+
*
|
|
196
|
+
* **⚠️ Accessibility Note**: Unlike `onClick`, this does NOT fire for
|
|
197
|
+
* keyboard activation (Enter key). If you need to track all user interactions
|
|
198
|
+
* including keyboard users, use `onClick` instead.
|
|
199
|
+
*
|
|
200
|
+
* @param event - The pointer event
|
|
201
|
+
* @example
|
|
202
|
+
* ```tsx
|
|
203
|
+
* // Use onPointerDown for pointer-specific interactions
|
|
204
|
+
* <Link
|
|
205
|
+
* href="/products"
|
|
206
|
+
* onPointerDown={(e) => {
|
|
207
|
+
* // Distinguish between mouse (2), touch (5), and pen (3)
|
|
208
|
+
* console.log('Pointer type:', e.pointerType);
|
|
209
|
+
* }}
|
|
210
|
+
* >
|
|
211
|
+
* Products
|
|
212
|
+
* </Link>
|
|
213
|
+
* ```
|
|
214
|
+
*
|
|
215
|
+
* @example
|
|
216
|
+
* ```tsx
|
|
217
|
+
* // ✅ Use both handlers together for comprehensive tracking
|
|
218
|
+
* <Link
|
|
219
|
+
* href="/products"
|
|
220
|
+
* onClick={(e) => trackAllActivations(e)}
|
|
221
|
+
* onPointerDown={(e) => provideFeedback(e)}
|
|
222
|
+
* >
|
|
223
|
+
* Products
|
|
224
|
+
* </Link>
|
|
225
|
+
* ```
|
|
226
|
+
*/
|
|
227
|
+
onPointerDown?: (event: React.PointerEvent<HTMLAnchorElement>) => void;
|
|
228
|
+
} & React.ComponentProps<typeof UI> & React.ComponentPropsWithoutRef<"a">;
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* Link - A semantic, accessible anchor component with enhanced security and styling.
|
|
232
|
+
*
|
|
233
|
+
* The Link component renders accessible `<a>` elements with automatic security
|
|
234
|
+
* attributes for external links, customizable styling variants, and full WCAG 2.1
|
|
235
|
+
* AA compliance. It supports traditional text links, button-styled links, and
|
|
236
|
+
* programmatic focus management via ref forwarding.
|
|
237
|
+
*
|
|
238
|
+
* ## Features
|
|
239
|
+
*
|
|
240
|
+
* - 🔒 **Automatic Security**: External links get `rel="noopener noreferrer"`
|
|
241
|
+
* - ♿ **WCAG 2.1 AA Compliant**: Accessible focus indicators and semantic HTML
|
|
242
|
+
* - 🎨 **Flexible Styling**: Text links, button links, and pill variants
|
|
243
|
+
* - ⚡ **Performance**: Optional prefetch hints for faster navigation
|
|
244
|
+
* - 🎯 **Ref Forwarding**: Direct DOM access for focus management and scroll
|
|
245
|
+
* - 🧪 **Type-Safe**: Full TypeScript support with comprehensive prop types
|
|
246
|
+
*
|
|
247
|
+
* ## Accessibility
|
|
248
|
+
*
|
|
249
|
+
* - ✅ Semantic `<a>` element for proper keyboard navigation
|
|
250
|
+
* - ✅ Focus indicators meet WCAG 2.4.7 (3:1 contrast ratio)
|
|
251
|
+
* - ✅ Screen readers announce link purpose and destination
|
|
252
|
+
* - ✅ External links include security attributes automatically
|
|
253
|
+
* - ✅ Supports `aria-label` for icon-only or ambiguous links
|
|
254
|
+
* - ✅ Ref forwarding enables skip-link patterns
|
|
255
|
+
*
|
|
256
|
+
* @example
|
|
257
|
+
* // Basic internal link
|
|
258
|
+
* <Link href="/about">About Us</Link>
|
|
259
|
+
*
|
|
260
|
+
* @example
|
|
261
|
+
* // External link with automatic security
|
|
262
|
+
* <Link href="https://example.com" target="_blank">
|
|
263
|
+
* Visit Example
|
|
264
|
+
* </Link>
|
|
265
|
+
*
|
|
266
|
+
* @example
|
|
267
|
+
* // Button-styled call-to-action link
|
|
268
|
+
* <Link href="/signup">
|
|
269
|
+
* <b>Get Started</b>
|
|
270
|
+
* </Link>
|
|
271
|
+
*
|
|
272
|
+
* @example
|
|
273
|
+
* // Icon-only link with accessible label
|
|
274
|
+
* <Link href="/settings" aria-label="Open settings">
|
|
275
|
+
* <SettingsIcon aria-hidden="true" />
|
|
276
|
+
* </Link>
|
|
277
|
+
*
|
|
278
|
+
* @example
|
|
279
|
+
* // Analytics tracking with onClick (includes keyboard users)
|
|
280
|
+
* <Link
|
|
281
|
+
* href="/products"
|
|
282
|
+
* onClick={(e) => trackEvent('link_click', { href: '/products' })}
|
|
283
|
+
* >
|
|
284
|
+
* Browse Products
|
|
285
|
+
* </Link>
|
|
286
|
+
*
|
|
287
|
+
* @example
|
|
288
|
+
* // Skip link with ref forwarding for focus management
|
|
289
|
+
* const mainRef = useRef<HTMLAnchorElement>(null);
|
|
290
|
+
*
|
|
291
|
+
* <Link ref={mainRef} href="#main-content">
|
|
292
|
+
* Skip to main content
|
|
293
|
+
* </Link>
|
|
294
|
+
*
|
|
295
|
+
* @example
|
|
296
|
+
* // Custom styled link with CSS variables
|
|
297
|
+
* <Link
|
|
298
|
+
* href="/products"
|
|
299
|
+
* styles={{
|
|
300
|
+
* '--link-color': '#0066cc',
|
|
301
|
+
* '--link-decoration': 'underline',
|
|
302
|
+
* }}
|
|
303
|
+
* >
|
|
304
|
+
* Browse Products
|
|
305
|
+
* </Link>
|
|
306
|
+
*
|
|
307
|
+
* @example
|
|
308
|
+
* // ✅ GOOD: Descriptive link text
|
|
309
|
+
* <Link href="/docs/installation">
|
|
310
|
+
* Read installation guide
|
|
311
|
+
* </Link>
|
|
312
|
+
*
|
|
313
|
+
* @example
|
|
314
|
+
* // ❌ BAD: Generic link text (poor for screen readers)
|
|
315
|
+
* <Link href="/docs/installation">
|
|
316
|
+
* Click here
|
|
317
|
+
* </Link>
|
|
318
|
+
*
|
|
319
|
+
* @see {@link LinkProps} for complete prop documentation
|
|
320
|
+
*/
|
|
321
|
+
declare const Link: React.ForwardRefExoticComponent<Omit<LinkProps, "ref"> & React.RefAttributes<HTMLAnchorElement>>;
|
|
322
|
+
|
|
323
|
+
export { Link as L, LinkProps as a };
|