@fpkit/acss 0.5.12 → 0.5.13
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/README.md +89 -0
- package/libs/{chunk-DV56L5YX.cjs → chunk-2LTJ7HHX.cjs} +4 -4
- package/libs/{chunk-EQ67LF46.js → chunk-2Y7W75TT.js} +3 -3
- package/libs/{chunk-KKLTUJFB.cjs → chunk-3MKLDCKQ.cjs} +5 -5
- package/libs/chunk-3MKLDCKQ.cjs.map +1 -0
- package/libs/{chunk-X3EVB7VS.cjs → chunk-5S4ORA4C.cjs} +3 -3
- package/libs/{chunk-O6QZBB6G.js → chunk-772NRB75.js} +5 -5
- package/libs/chunk-772NRB75.js.map +1 -0
- package/libs/{chunk-6BVXFW7U.cjs → chunk-AHDJGCG5.cjs} +3 -3
- package/libs/{chunk-E3XP6BEX.cjs → chunk-B7F5FS6D.cjs} +3 -3
- package/libs/chunk-D4YLRWAO.cjs +18 -0
- package/libs/chunk-D4YLRWAO.cjs.map +1 -0
- package/libs/chunk-ETFLFC2S.js +10 -0
- package/libs/chunk-ETFLFC2S.js.map +1 -0
- package/libs/chunk-GZ4QFPRY.js +9 -0
- package/libs/chunk-GZ4QFPRY.js.map +1 -0
- package/libs/{chunk-LHVJKDMA.cjs → chunk-J32EZPYD.cjs} +3 -3
- package/libs/chunk-JJ43O4Y5.js +8 -0
- package/libs/chunk-JJ43O4Y5.js.map +1 -0
- package/libs/chunk-KUKIVRC2.js +7 -0
- package/libs/chunk-KUKIVRC2.js.map +1 -0
- package/libs/chunk-L75OQKEI.cjs +13 -0
- package/libs/chunk-L75OQKEI.cjs.map +1 -0
- package/libs/{chunk-LL7HTLMS.cjs → chunk-M5RRNTVX.cjs} +3 -3
- package/libs/{chunk-LIQJ7ZZR.js → chunk-NGTJDDFO.js} +2 -2
- package/libs/chunk-OK5QEIMD.cjs +17 -0
- package/libs/chunk-OK5QEIMD.cjs.map +1 -0
- package/libs/chunk-P2DC76ZZ.cjs +18 -0
- package/libs/chunk-P2DC76ZZ.cjs.map +1 -0
- package/libs/chunk-PQ2K3BM6.cjs +17 -0
- package/libs/chunk-PQ2K3BM6.cjs.map +1 -0
- package/libs/{chunk-QCMV4VQZ.js → chunk-QLZWHAMK.js} +2 -2
- package/libs/{chunk-BIP2NY53.js → chunk-RIVUMPOG.js} +2 -2
- package/libs/{chunk-ICCKQ2GC.cjs → chunk-ROZI23GS.cjs} +4 -4
- package/libs/{chunk-NHYXGV3L.js → chunk-SMYRLO3E.js} +2 -2
- package/libs/{chunk-5ZM4XL44.js → chunk-TYRCEX2L.js} +2 -2
- package/libs/chunk-VUH3FXGJ.js +11 -0
- package/libs/chunk-VUH3FXGJ.js.map +1 -0
- package/libs/{chunk-PPOOBUOS.js → chunk-XBA562WW.js} +2 -2
- package/libs/{chunk-QVV34QEH.cjs → chunk-XTQKWY7W.cjs} +3 -3
- package/libs/{chunk-YWOYVRFT.js → chunk-ZANSFMTD.js} +3 -3
- 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/badge/badge.css +1 -1
- package/libs/components/badge/badge.css.map +1 -1
- package/libs/components/badge/badge.min.css +2 -2
- package/libs/components/breadcrumbs/breadcrumb.cjs +9 -5
- package/libs/components/breadcrumbs/breadcrumb.d.cts +271 -32
- package/libs/components/breadcrumbs/breadcrumb.d.ts +271 -32
- package/libs/components/breadcrumbs/breadcrumb.js +3 -3
- package/libs/components/button.cjs +4 -4
- package/libs/components/button.d.cts +2 -2
- package/libs/components/button.d.ts +2 -2
- package/libs/components/button.js +2 -2
- package/libs/components/buttons/button.css +1 -1
- package/libs/components/buttons/button.css.map +1 -1
- package/libs/components/buttons/button.min.css +2 -2
- package/libs/components/card.cjs +7 -7
- package/libs/components/card.d.cts +277 -33
- package/libs/components/card.d.ts +277 -33
- package/libs/components/card.js +2 -2
- package/libs/components/cards/card.css +1 -1
- package/libs/components/cards/card.css.map +1 -1
- package/libs/components/cards/card.min.css +2 -2
- package/libs/components/details/details.css +1 -1
- package/libs/components/details/details.css.map +1 -1
- package/libs/components/details/details.min.css +2 -2
- package/libs/components/dialog/dialog.cjs +7 -7
- package/libs/components/dialog/dialog.css +1 -1
- package/libs/components/dialog/dialog.css.map +1 -1
- package/libs/components/dialog/dialog.d.cts +88 -34
- package/libs/components/dialog/dialog.d.ts +88 -34
- package/libs/components/dialog/dialog.js +5 -5
- package/libs/components/dialog/dialog.min.css +2 -2
- package/libs/components/form/fields.cjs +4 -4
- package/libs/components/form/fields.d.cts +2 -2
- package/libs/components/form/fields.d.ts +2 -2
- package/libs/components/form/fields.js +2 -2
- package/libs/components/form/textarea.cjs +4 -4
- package/libs/components/form/textarea.d.cts +2 -2
- package/libs/components/form/textarea.d.ts +2 -2
- package/libs/components/form/textarea.js +2 -2
- package/libs/components/heading/heading.cjs +3 -3
- package/libs/components/heading/heading.d.cts +3 -14
- package/libs/components/heading/heading.d.ts +3 -14
- package/libs/components/heading/heading.js +2 -2
- package/libs/components/icons/icon.cjs +4 -4
- package/libs/components/icons/icon.d.cts +148 -4
- package/libs/components/icons/icon.d.ts +148 -4
- package/libs/components/icons/icon.js +2 -2
- package/libs/components/images/img.css +1 -1
- package/libs/components/images/img.css.map +1 -1
- package/libs/components/images/img.min.css +2 -2
- package/libs/components/link/link.cjs +4 -4
- package/libs/components/link/link.d.cts +2 -2
- package/libs/components/link/link.d.ts +2 -2
- package/libs/components/link/link.js +2 -2
- package/libs/components/list/list.cjs +5 -5
- package/libs/components/list/list.d.cts +3 -3
- package/libs/components/list/list.d.ts +3 -3
- package/libs/components/list/list.js +2 -2
- package/libs/components/modal.cjs +4 -4
- package/libs/components/modal.js +3 -3
- package/libs/components/nav/nav.cjs +7 -7
- package/libs/components/nav/nav.d.cts +2 -2
- package/libs/components/nav/nav.d.ts +2 -2
- package/libs/components/nav/nav.js +3 -3
- package/libs/components/text/text.cjs +5 -5
- package/libs/components/text/text.d.cts +2 -2
- package/libs/components/text/text.d.ts +2 -2
- package/libs/components/text/text.js +2 -2
- package/libs/heading-3648c538.d.ts +250 -0
- package/libs/hooks.cjs +7 -0
- package/libs/hooks.d.cts +5 -0
- package/libs/hooks.d.ts +5 -0
- package/libs/hooks.js +3 -0
- package/libs/icons.cjs +3 -3
- package/libs/icons.d.cts +1 -1
- package/libs/icons.d.ts +1 -1
- package/libs/icons.js +2 -2
- package/libs/index.cjs +112 -91
- 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 +515 -31
- package/libs/index.d.ts +515 -31
- package/libs/index.js +31 -19
- package/libs/index.js.map +1 -1
- package/libs/ui-645f95b5.d.ts +285 -0
- package/package.json +2 -83
- package/src/components/README-UI.mdx +416 -0
- package/src/components/alert/ACCESSIBILITY.md +319 -0
- package/src/components/alert/README.mdx +475 -19
- package/src/components/alert/alert.scss +113 -6
- package/src/components/alert/alert.stories.tsx +372 -0
- package/src/components/alert/alert.test.tsx +762 -0
- package/src/components/alert/alert.tsx +331 -66
- package/src/components/alert/views/alert-actions.tsx +13 -0
- package/src/components/alert/views/alert-content.tsx +17 -0
- package/src/components/alert/views/alert-icon.tsx +53 -0
- package/src/components/alert/views/alert-screen-reader-text.tsx +30 -0
- package/src/components/alert/views/alert-title.tsx +23 -0
- package/src/components/alert/views/alert-view.tsx +158 -0
- package/src/components/alert/views/index.ts +12 -0
- package/src/components/badge/badge.mdx +186 -49
- package/src/components/badge/badge.scss +20 -2
- package/src/components/badge/badge.stories.tsx +160 -14
- package/src/components/badge/badge.test.tsx +179 -0
- package/src/components/badge/badge.tsx +97 -4
- package/src/components/breadcrumbs/README.mdx +364 -45
- package/src/components/breadcrumbs/__snapshots__/breadcrumb.test.tsx.snap +152 -0
- package/src/components/breadcrumbs/breadcrumb.stories.tsx +7 -3
- package/src/components/breadcrumbs/breadcrumb.test.tsx +490 -0
- package/src/components/breadcrumbs/breadcrumb.tsx +427 -170
- package/src/components/buttons/button.scss +34 -31
- package/src/components/buttons/button.stories.tsx +35 -0
- package/src/components/cards/README.mdx +657 -0
- package/src/components/cards/card.scss +22 -0
- package/src/components/cards/card.stories.tsx +167 -5
- package/src/components/cards/card.test.tsx +360 -20
- package/src/components/cards/card.tsx +200 -79
- package/src/components/cards/card.types.ts +135 -0
- package/src/components/cards/card.utils.ts +79 -0
- package/src/components/details/ACCESSIBILITY-REVIEW-LIVE.md +1050 -0
- package/src/components/details/ACCESSIBILITY-REVIEW.md +502 -0
- package/src/components/details/README.mdx +437 -69
- package/src/components/details/details.scss +16 -7
- package/src/components/details/details.test.tsx +385 -0
- package/src/components/details/details.tsx +101 -69
- package/src/components/details/details.types.ts +76 -0
- package/src/components/dialog/README.mdx +513 -110
- package/src/components/dialog/dialog-modal.tsx +79 -56
- package/src/components/dialog/dialog.scss +53 -3
- package/src/components/dialog/dialog.stories.tsx +10 -7
- package/src/components/dialog/dialog.test.tsx +450 -0
- package/src/components/dialog/dialog.tsx +69 -59
- package/src/components/dialog/dialog.types.ts +133 -0
- package/src/components/dialog/views/dialog-footer.tsx +54 -11
- package/src/components/dialog/views/dialog-header.tsx +20 -15
- package/src/components/heading/heading.stories.tsx +44 -4
- package/src/components/heading/heading.tsx +89 -23
- package/src/components/icons/README.mdx +332 -0
- package/src/components/icons/icon.stories.tsx +74 -1
- package/src/components/icons/icon.tsx +89 -1
- package/src/components/icons/types.ts +47 -0
- package/src/components/images/README.mdx +340 -24
- package/src/components/images/img.scss +19 -3
- package/src/components/images/img.stories.tsx +424 -15
- package/src/components/images/img.test.tsx +354 -25
- package/src/components/images/img.tsx +186 -63
- package/src/components/images/img.types.ts +211 -0
- package/src/components/title/MIGRATION.md +199 -0
- package/src/components/title/README.md +326 -0
- package/src/components/title/README.mdx +452 -0
- package/src/components/title/title.stories.tsx +393 -0
- package/src/components/title/title.test.tsx +251 -0
- package/src/components/title/title.tsx +219 -0
- package/src/components/ui.stories.tsx +894 -0
- package/src/components/ui.test.tsx +559 -0
- package/src/components/ui.tsx +266 -15
- package/src/components/word-count/README.md +240 -0
- package/src/hooks.ts +1 -0
- package/src/index.ts +10 -2
- package/src/sass/_properties.scss +1 -0
- package/src/styles/alert/alert.css +94 -4
- package/src/styles/alert/alert.css.map +1 -1
- package/src/styles/badge/badge.css +20 -2
- package/src/styles/badge/badge.css.map +1 -1
- package/src/styles/buttons/button.css +31 -31
- package/src/styles/buttons/button.css.map +1 -1
- package/src/styles/cards/card.css +16 -0
- package/src/styles/cards/card.css.map +1 -1
- package/src/styles/details/details.css +19 -8
- package/src/styles/details/details.css.map +1 -1
- package/src/styles/dialog/dialog.css +43 -2
- package/src/styles/dialog/dialog.css.map +1 -1
- package/src/styles/images/img.css +15 -3
- package/src/styles/images/img.css.map +1 -1
- package/src/styles/index.css +240 -51
- package/src/styles/index.css.map +1 -1
- package/src/test/setup.d.ts +9 -0
- package/src/test/setup.ts +53 -1
- package/libs/chunk-6TE5QEVE.cjs +0 -13
- package/libs/chunk-6TE5QEVE.cjs.map +0 -1
- package/libs/chunk-7K76RW2A.cjs +0 -18
- package/libs/chunk-7K76RW2A.cjs.map +0 -1
- package/libs/chunk-BSPKFLO4.js +0 -8
- package/libs/chunk-BSPKFLO4.js.map +0 -1
- package/libs/chunk-BV5CLH44.cjs +0 -18
- package/libs/chunk-BV5CLH44.cjs.map +0 -1
- package/libs/chunk-DKGJHKGW.js +0 -9
- package/libs/chunk-DKGJHKGW.js.map +0 -1
- package/libs/chunk-ECLD37WN.cjs +0 -16
- package/libs/chunk-ECLD37WN.cjs.map +0 -1
- package/libs/chunk-HYBZBN4G.js +0 -8
- package/libs/chunk-HYBZBN4G.js.map +0 -1
- package/libs/chunk-KKLTUJFB.cjs.map +0 -1
- package/libs/chunk-M5QL5TAE.cjs +0 -14
- package/libs/chunk-M5QL5TAE.cjs.map +0 -1
- package/libs/chunk-NE6YXTMC.js +0 -7
- package/libs/chunk-NE6YXTMC.js.map +0 -1
- package/libs/chunk-O6QZBB6G.js.map +0 -1
- package/libs/chunk-SXVZSWX6.js +0 -11
- package/libs/chunk-SXVZSWX6.js.map +0 -1
- package/libs/ui-9a6f9f8d.d.ts +0 -24
- package/src/components/cards/README.md +0 -80
- package/src/components/dialog/hooks/useClickOutside.ts +0 -33
- /package/libs/{chunk-DV56L5YX.cjs.map → chunk-2LTJ7HHX.cjs.map} +0 -0
- /package/libs/{chunk-EQ67LF46.js.map → chunk-2Y7W75TT.js.map} +0 -0
- /package/libs/{chunk-X3EVB7VS.cjs.map → chunk-5S4ORA4C.cjs.map} +0 -0
- /package/libs/{chunk-6BVXFW7U.cjs.map → chunk-AHDJGCG5.cjs.map} +0 -0
- /package/libs/{chunk-E3XP6BEX.cjs.map → chunk-B7F5FS6D.cjs.map} +0 -0
- /package/libs/{chunk-LHVJKDMA.cjs.map → chunk-J32EZPYD.cjs.map} +0 -0
- /package/libs/{chunk-LL7HTLMS.cjs.map → chunk-M5RRNTVX.cjs.map} +0 -0
- /package/libs/{chunk-LIQJ7ZZR.js.map → chunk-NGTJDDFO.js.map} +0 -0
- /package/libs/{chunk-QCMV4VQZ.js.map → chunk-QLZWHAMK.js.map} +0 -0
- /package/libs/{chunk-BIP2NY53.js.map → chunk-RIVUMPOG.js.map} +0 -0
- /package/libs/{chunk-ICCKQ2GC.cjs.map → chunk-ROZI23GS.cjs.map} +0 -0
- /package/libs/{chunk-NHYXGV3L.js.map → chunk-SMYRLO3E.js.map} +0 -0
- /package/libs/{chunk-5ZM4XL44.js.map → chunk-TYRCEX2L.js.map} +0 -0
- /package/libs/{chunk-PPOOBUOS.js.map → chunk-XBA562WW.js.map} +0 -0
- /package/libs/{chunk-QVV34QEH.cjs.map → chunk-XTQKWY7W.cjs.map} +0 -0
- /package/libs/{chunk-YWOYVRFT.js.map → chunk-ZANSFMTD.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/tag/tag.tsx","../src/components/details/details.tsx"],"names":["React","Img","src","alt","width","height","styles","loading","placeholder","fetchpriority","decoding","imgLoaded","imgError","props","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","Tag","elm","role","Details","summary","icon","ariaLabel","name","open","onPointerDown","onToggle","ref","defaultStyles","onPointerDownCallback"],"mappings":"s1BACA,OAAOA,MAAW,QAwCX,IAAMC,EAAM,CAAC,CAClB,IAAAC,EAAM,KACN,IAAAC,EACA,MAAAC,EAAQ,IACR,OAAAC,EACA,OAAAC,EACA,QAAAC,EAAU,OACV,YAAAC,EAAc,+BAA+BJ,CAAK,oBAClD,cAAAK,EAAgB,MAChB,SAAAC,EAAW,OACX,UAAAC,EACA,SAAAC,EACA,GAAGC,CACL,IAoBIb,EAAA,cAACc,EAAA,CACC,GAAG,MACH,IAAKZ,EACL,IAAKC,EACL,MAAOC,EACP,OAAQC,GAAU,OAClB,QAASE,EACT,MAAOD,EACP,QA1BFS,GACS,CACT,GAAIH,EAAU,CACZA,IAAWG,CAAC,EACZ,MACF,CACIA,EAAE,cAAc,MAAQP,IAC1BO,EAAE,cAAc,IAAMP,EAE1B,EAkBI,OAfFO,GACS,CACTJ,IAAYI,CAAC,CACf,EAaI,cAAeN,EACf,SAAUC,EACT,GAAGG,EACN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EACL,GAAGtE,GAEJb,EAAA,cAACc,EAAA,CAAG,GAAG,UAAU,cAAe2E,GAC7BR,EACAD,CACH,EACAhF,EAAA,cAACc,EAAA,CAAG,GAAG,WAAWyB,CAAS,CAC7B,CAEJ,EAGAwC,GAAQ,YAAc","sourcesContent":["import UI from '../ui'\nimport React from 'react'\n/*\n * ImageProps interface\n *\n * Extends ComponentProps and defines additional props for the Img component.\n *\n * @property {string} [src] - The image source URL\n * @property {string} alt - Required alt text for image accessibility\n * @property {number} width - Required width of image\n * @property {number} [height] - Optional height of image\n * @property {\"eager\" | \"lazy\"} [loading=\"lazy\"] - Loading behavior\n * @property {string} [placeholder] - Fallback placeholder image\n * @property {\"high\" | \"low\"} [fetchpriority=\"low\"] - Image fetch priority\n * @property {\"sync\" | \"async\" | \"auto\"} [decoding=\"auto\"] - Decode setting\n * @property {function} [imgError] - Error callback\n * @property {function} [imgLoaded] - Loaded callback\n */\nexport type ImageProps = React.ComponentProps<'img'> &\n React.ComponentProps<typeof UI>\n\n/*\n * Img component\n *\n * Renders an <img> element with custom props.\n *\n * @param {string} src - The image source URL.\n * @param {string} alt - The alt text for the image.\n * @param {number} [width=480] - The width of the image.\n * @param {number} [height] - The height of the image.\n * @param {Object} [styles] - Additional CSS styles to apply.\n * @param {boolean} [renderStyles=true] - Whether to render the default styles.\n * @param {\"eager\" | \"lazy\"} [loading=\"lazy\"] - The loading attribute.\n * @param {string} [placeholder] - A placeholder image URL.\n * @param {\"high\" | \"low\"} [fetchpriority=\"low\"] - The fetchpriority attribute.\n * @param {\"sync\" | \"async\" | \"auto\"} [decoding=\"auto\"] - The decoding attribute.\n * @param {function} [imgLoaded] - Callback when image loads successfully.\n * @param {function} [imgError] - Callback when image errors.\n *\n * @returns {JSX.Element} The Img component.\n */\nexport const Img = ({\n src = '//',\n alt,\n width = 480,\n height,\n styles,\n loading = 'lazy',\n placeholder = `https://via.placeholder.com/${width}?text=PLACEHOLDER`,\n fetchpriority = 'low',\n decoding = 'auto',\n imgLoaded,\n imgError,\n ...props\n}: ImageProps) => {\n const handleImgError = (\n e: React.SyntheticEvent<HTMLImageElement, Event>,\n ): void => {\n if (imgError) {\n imgError?.(e)\n return\n }\n if (e.currentTarget.src !== placeholder) {\n e.currentTarget.src = placeholder\n }\n }\n\n const handleImgLoad = (\n e: React.SyntheticEvent<HTMLImageElement, Event>,\n ): void => {\n imgLoaded?.(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 onError={handleImgError}\n onLoad={handleImgLoad}\n fetchPriority={fetchpriority}\n decoding={decoding}\n {...props}\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 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 from \"react\";\n\ntype DetailsProps = {\n /**\n * The summary text shown for the details.\n * Required.\n */\n summary: React.ReactNode;\n\n /**\n * The aria-label element for accessibility.\n */\n ariaLabel: string;\n} & React.ComponentProps<\"details\"> &\n Partial<React.ComponentProps<typeof UI>>;\n\n/**3\n * Details component props interface.\n *\n * @param {React.CSSProperties} [styles] - CSS styles object.\n * @param {string} [classes] - Classnames string.\n * @param {boolean} [open] - Whether the details is open.\n * @param {(e: React.PointerEvent<HTMLDetailsElement>) => void} [onToggle] - onToggle callback.\n * @param {(e: React.PointerEvent<HTMLDetailsElement>) => void} [onPointerDown] - onPointerDown callback.\n * @param {ReactNode} children - The content inside the details.\n * @param {string} [ariaLabel] - aria-label for accessibility.\n * @param {React.Ref<any>} [ref] - Ref object.\n * @param {Object} props - Other props.\n */\nexport const Details = ({\n summary,\n icon,\n styles,\n classes,\n ariaLabel,\n name,\n open,\n onPointerDown,\n onToggle,\n children,\n ref,\n ...props\n}: DetailsProps) => {\n const defaultStyles: React.CSSProperties = { ...styles };\n\n const onPointerDownCallback = (e: React.PointerEvent<HTMLDetailsElement>) => {\n if (onPointerDown) onPointerDown?.(e);\n if (onPointerDown) onPointerDown?.(e);\n };\n\n const onToggleCallback = (e: React.PointerEvent<HTMLDetailsElement>) => {\n if (onToggle) onPointerDown?.(e);\n };\n return (\n <UI\n as=\"details\"\n style={defaultStyles}\n className={classes}\n onToggle={onToggleCallback}\n ref={ref}\n open={open}\n aria-label={ariaLabel || \"Details dropdown\"}\n // aria-roledescription=\"detail accordion\"\n name={name}\n {...props}\n >\n <UI as=\"summary\" onPointerDown={onPointerDownCallback}>\n {icon}\n {summary}\n </UI>\n <UI as=\"section\">{children}</UI>\n </UI>\n );\n};\n\nexport default Details;\nDetails.displayName = \"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":"w2BACA,OAAOA,IAAS,WAAAC,OAAe,QA6GxB,IAAMC,EAAM,CAAC,CACl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AAc,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"]}
|
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
import React__default from 'react';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Extracts the appropriate ref type for a given element type.
|
|
5
|
+
*
|
|
6
|
+
* This utility type ensures that refs are properly typed based on the element
|
|
7
|
+
* being rendered. For example, a button element receives HTMLButtonElement ref.
|
|
8
|
+
*
|
|
9
|
+
* @typeParam C - The HTML element type (e.g., 'button', 'div', 'a')
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* type ButtonRef = PolymorphicRef<'button'>; // React.Ref<HTMLButtonElement>
|
|
13
|
+
* type DivRef = PolymorphicRef<'div'>; // React.Ref<HTMLDivElement>
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
type PolymorphicRef<C extends React__default.ElementType> = React__default.ComponentPropsWithRef<C>["ref"];
|
|
17
|
+
/**
|
|
18
|
+
* Defines the 'as' prop that determines which HTML element to render.
|
|
19
|
+
*
|
|
20
|
+
* This is the core prop that enables polymorphic behavior, allowing components
|
|
21
|
+
* to render as any valid React element type while maintaining type safety.
|
|
22
|
+
*
|
|
23
|
+
* @typeParam C - The HTML element type to render
|
|
24
|
+
* @example
|
|
25
|
+
* ```typescript
|
|
26
|
+
* <UI as="button">Click me</UI>
|
|
27
|
+
* <UI as="a" href="/home">Link</UI>
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
type AsProp<C extends React__default.ElementType> = {
|
|
31
|
+
as?: C;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Identifies props that should be omitted to prevent type conflicts.
|
|
35
|
+
*
|
|
36
|
+
* This type ensures that our custom props don't conflict with native element
|
|
37
|
+
* props by calculating which keys need to be omitted from the native props.
|
|
38
|
+
*
|
|
39
|
+
* @typeParam C - The HTML element type
|
|
40
|
+
* @typeParam P - The custom props to merge
|
|
41
|
+
*/
|
|
42
|
+
type PropsToOmit<C extends React__default.ElementType, P> = keyof (AsProp<C> & P);
|
|
43
|
+
/**
|
|
44
|
+
* Merges custom props with native element props while preventing conflicts.
|
|
45
|
+
*
|
|
46
|
+
* This creates a union of our custom props and the native props for the chosen
|
|
47
|
+
* element, omitting any conflicting keys to ensure type safety.
|
|
48
|
+
*
|
|
49
|
+
* @typeParam C - The HTML element type
|
|
50
|
+
* @typeParam Props - The custom props to add
|
|
51
|
+
* @example
|
|
52
|
+
* ```typescript
|
|
53
|
+
* // For a button, this merges custom props with HTMLButtonElement props
|
|
54
|
+
* type ButtonProps = PolymorphicComponentProp<'button', { variant?: string }>;
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
type PolymorphicComponentProp<C extends React__default.ElementType, Props = {}> = React__default.PropsWithChildren<Props & AsProp<C>> & Omit<React__default.ComponentPropsWithoutRef<C>, PropsToOmit<C, Props>>;
|
|
58
|
+
/**
|
|
59
|
+
* Extends PolymorphicComponentProp to include properly-typed ref support.
|
|
60
|
+
*
|
|
61
|
+
* This is the final type in the polymorphic type chain, adding ref forwarding
|
|
62
|
+
* with the correct ref type for the chosen element. The ref is properly typed
|
|
63
|
+
* to match the element being rendered, enabling focus management and direct
|
|
64
|
+
* DOM access for accessibility features like programmatic focus control.
|
|
65
|
+
*
|
|
66
|
+
* @typeParam C - The HTML element type
|
|
67
|
+
* @typeParam Props - The custom props to add
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* ```typescript
|
|
71
|
+
* // Using ref for focus management (important for accessibility)
|
|
72
|
+
* const buttonRef = useRef<HTMLButtonElement>(null);
|
|
73
|
+
* useEffect(() => {
|
|
74
|
+
* // Programmatically focus for keyboard navigation
|
|
75
|
+
* buttonRef.current?.focus();
|
|
76
|
+
* }, []);
|
|
77
|
+
*
|
|
78
|
+
* return <UI as="button" ref={buttonRef}>Accessible Button</UI>;
|
|
79
|
+
* ```
|
|
80
|
+
*/
|
|
81
|
+
type PolymorphicComponentPropWithRef<C extends React__default.ElementType, Props = {}> = PolymorphicComponentProp<C, Props> & {
|
|
82
|
+
ref?: PolymorphicRef<C>;
|
|
83
|
+
};
|
|
84
|
+
/**
|
|
85
|
+
* Props for the UI component, extending polymorphic props with style and class support.
|
|
86
|
+
*
|
|
87
|
+
* The UI component automatically forwards all ARIA attributes and native HTML props
|
|
88
|
+
* to the rendered element, ensuring full accessibility support. This includes:
|
|
89
|
+
* - `aria-label`, `aria-labelledby` - Accessible names for screen readers
|
|
90
|
+
* - `aria-describedby` - Additional descriptive text references
|
|
91
|
+
* - `aria-expanded`, `aria-controls` - Interactive widget states
|
|
92
|
+
* - `role` - Semantic role override when needed
|
|
93
|
+
* - All other ARIA attributes and HTML props
|
|
94
|
+
*
|
|
95
|
+
* @typeParam C - The HTML element type to render
|
|
96
|
+
* @property {boolean} [renderStyles] - Reserved for future use. Currently has no effect.
|
|
97
|
+
* Styles are always rendered regardless of this prop value.
|
|
98
|
+
* @property {React.CSSProperties} [styles] - Inline styles to apply (overrides defaultStyles)
|
|
99
|
+
* @property {React.CSSProperties} [defaultStyles] - Base styles that can be overridden by styles prop
|
|
100
|
+
* @property {string} [classes] - CSS class names to apply to the element
|
|
101
|
+
* @property {string} [id] - HTML id attribute
|
|
102
|
+
* @property {React.ReactNode} [children] - Child elements to render
|
|
103
|
+
*
|
|
104
|
+
* @example
|
|
105
|
+
* ```typescript
|
|
106
|
+
* // All ARIA attributes are automatically forwarded
|
|
107
|
+
* <UI as="button" aria-label="Close dialog" aria-expanded={isOpen}>
|
|
108
|
+
* <CloseIcon />
|
|
109
|
+
* </UI>
|
|
110
|
+
* ```
|
|
111
|
+
*/
|
|
112
|
+
type UIProps<C extends React__default.ElementType> = PolymorphicComponentPropWithRef<C, {
|
|
113
|
+
/** @deprecated Reserved for future use. Currently has no effect. Styles are always rendered. */
|
|
114
|
+
renderStyles?: boolean;
|
|
115
|
+
styles?: React__default.CSSProperties;
|
|
116
|
+
defaultStyles?: React__default.CSSProperties;
|
|
117
|
+
classes?: string;
|
|
118
|
+
id?: string;
|
|
119
|
+
children?: React__default.ReactNode;
|
|
120
|
+
}>;
|
|
121
|
+
/**
|
|
122
|
+
* UI Component function signature.
|
|
123
|
+
*
|
|
124
|
+
* Defines the polymorphic component that can render as any HTML element while
|
|
125
|
+
* maintaining full TypeScript type safety for element-specific props.
|
|
126
|
+
*
|
|
127
|
+
* @typeParam C - The HTML element type to render (defaults to 'div')
|
|
128
|
+
* @param {UIProps<C>} props - Component props including 'as', styles, and native element props
|
|
129
|
+
* @returns {React.ReactElement} A React element of the specified type
|
|
130
|
+
* @example
|
|
131
|
+
* ```typescript
|
|
132
|
+
* <UI as="button" onClick={handler}>Button</UI>
|
|
133
|
+
* <UI as="a" href="/link">Link</UI>
|
|
134
|
+
* <UI>Default div</UI>
|
|
135
|
+
* ```
|
|
136
|
+
*/
|
|
137
|
+
type UIComponent = (<C extends React__default.ElementType = "div">(props: UIProps<C>) => React__default.ReactElement | any) & {
|
|
138
|
+
displayName?: string;
|
|
139
|
+
};
|
|
140
|
+
/**
|
|
141
|
+
* UI - A polymorphic React component that can render as any HTML element.
|
|
142
|
+
*
|
|
143
|
+
* The UI component is a foundational primitive used throughout fpkit to create
|
|
144
|
+
* flexible, type-safe components. It implements the polymorphic component pattern,
|
|
145
|
+
* allowing a single component to render as different HTML elements while maintaining
|
|
146
|
+
* full TypeScript type safety for element-specific props.
|
|
147
|
+
*
|
|
148
|
+
* ## Accessibility Considerations
|
|
149
|
+
*
|
|
150
|
+
* The UI component forwards all ARIA attributes and native HTML props, placing
|
|
151
|
+
* accessibility responsibility on the consumer. When creating interactive elements,
|
|
152
|
+
* you MUST ensure WCAG 2.1 AA compliance:
|
|
153
|
+
*
|
|
154
|
+
* - **Accessible Names**: All interactive elements need an accessible name via
|
|
155
|
+
* `aria-label`, `aria-labelledby`, or visible text content
|
|
156
|
+
* - **Semantic HTML**: Prefer semantic elements (`button`, `a`, `nav`) over
|
|
157
|
+
* generic containers (`div`, `span`) with ARIA roles when possible
|
|
158
|
+
* - **Focus Indicators**: Ensure focus indicators meet WCAG 2.4.7 (3:1 contrast)
|
|
159
|
+
* - **Keyboard Support**: Interactive elements must be keyboard accessible
|
|
160
|
+
*
|
|
161
|
+
* @typeParam C - The HTML element type to render (e.g., 'button', 'div', 'a')
|
|
162
|
+
*
|
|
163
|
+
* @param {C} [as='div'] - The HTML element type to render. Defaults to 'div'.
|
|
164
|
+
* @param {React.CSSProperties} [styles] - Inline styles to apply. Overrides defaultStyles.
|
|
165
|
+
* @param {string} [classes] - CSS class names to apply to the element.
|
|
166
|
+
* @param {React.CSSProperties} [defaultStyles] - Base styles that can be overridden by styles prop.
|
|
167
|
+
* @param {React.ReactNode} [children] - Child elements to render inside the component.
|
|
168
|
+
* @param {PolymorphicRef<C>} [ref] - Forwarded ref with proper typing for the element type.
|
|
169
|
+
* @param {boolean} [renderStyles] - Reserved for future use. Currently has no effect.
|
|
170
|
+
*
|
|
171
|
+
* @returns {React.ReactElement} A React element of the specified type with merged props.
|
|
172
|
+
*
|
|
173
|
+
* @example
|
|
174
|
+
* // Basic usage - renders as div
|
|
175
|
+
* <UI>Hello World</UI>
|
|
176
|
+
*
|
|
177
|
+
* @example
|
|
178
|
+
* // Polymorphic rendering - renders as button with type-safe props
|
|
179
|
+
* <UI as="button" onClick={handleClick} disabled>
|
|
180
|
+
* Click me
|
|
181
|
+
* </UI>
|
|
182
|
+
*
|
|
183
|
+
* @example
|
|
184
|
+
* // ✅ GOOD: Accessible button with aria-label for icon-only button
|
|
185
|
+
* <UI as="button" aria-label="Close dialog" onClick={handleClose}>
|
|
186
|
+
* <CloseIcon />
|
|
187
|
+
* </UI>
|
|
188
|
+
*
|
|
189
|
+
* @example
|
|
190
|
+
* // ✅ GOOD: Accessible link with descriptive text
|
|
191
|
+
* <UI as="a" href="/products">
|
|
192
|
+
* View all products
|
|
193
|
+
* </UI>
|
|
194
|
+
*
|
|
195
|
+
* @example
|
|
196
|
+
* // ✅ GOOD: Interactive element with proper role and keyboard support
|
|
197
|
+
* <UI
|
|
198
|
+
* as="div"
|
|
199
|
+
* role="button"
|
|
200
|
+
* tabIndex={0}
|
|
201
|
+
* aria-label="Toggle menu"
|
|
202
|
+
* onClick={handleToggle}
|
|
203
|
+
* onKeyDown={(e) => e.key === 'Enter' && handleToggle()}
|
|
204
|
+
* >
|
|
205
|
+
* Menu
|
|
206
|
+
* </UI>
|
|
207
|
+
*
|
|
208
|
+
* @example
|
|
209
|
+
* // ❌ BAD: Button without accessible name (screen readers can't identify it)
|
|
210
|
+
* <UI as="button" onClick={handleClose}>
|
|
211
|
+
* <CloseIcon />
|
|
212
|
+
* </UI>
|
|
213
|
+
*
|
|
214
|
+
* @example
|
|
215
|
+
* // ❌ BAD: Non-semantic div with click handler (not keyboard accessible)
|
|
216
|
+
* <UI as="div" onClick={handleClick}>
|
|
217
|
+
* Click me
|
|
218
|
+
* </UI>
|
|
219
|
+
*
|
|
220
|
+
* @example
|
|
221
|
+
* // ✅ GOOD: Custom focus indicator with WCAG 2.4.7 compliant contrast
|
|
222
|
+
* <UI
|
|
223
|
+
* as="button"
|
|
224
|
+
* styles={{
|
|
225
|
+
* outline: '2px solid transparent',
|
|
226
|
+
* outlineOffset: '2px',
|
|
227
|
+
* }}
|
|
228
|
+
* classes="focus:outline-blue-500"
|
|
229
|
+
* >
|
|
230
|
+
* Accessible Button
|
|
231
|
+
* </UI>
|
|
232
|
+
*
|
|
233
|
+
* @example
|
|
234
|
+
* // Style merging - defaultStyles provide base, styles override
|
|
235
|
+
* <UI
|
|
236
|
+
* as="span"
|
|
237
|
+
* defaultStyles={{ padding: '0.5rem', color: 'blue' }}
|
|
238
|
+
* styles={{ color: 'red' }}
|
|
239
|
+
* >
|
|
240
|
+
* Red text with padding
|
|
241
|
+
* </UI>
|
|
242
|
+
*
|
|
243
|
+
* @example
|
|
244
|
+
* // Ref forwarding for focus management
|
|
245
|
+
* const buttonRef = useRef<HTMLButtonElement>(null);
|
|
246
|
+
* useEffect(() => {
|
|
247
|
+
* // Programmatically focus for keyboard navigation
|
|
248
|
+
* buttonRef.current?.focus();
|
|
249
|
+
* }, []);
|
|
250
|
+
* <UI as="button" ref={buttonRef}>Auto-focused Button</UI>
|
|
251
|
+
*
|
|
252
|
+
* @example
|
|
253
|
+
* // Building accessible higher-level components with TypeScript
|
|
254
|
+
* interface AccessibleButtonProps extends React.ComponentPropsWithoutRef<'button'> {
|
|
255
|
+
* variant?: 'primary' | 'secondary';
|
|
256
|
+
* // Require either aria-label or children for accessibility
|
|
257
|
+
* 'aria-label'?: string;
|
|
258
|
+
* children?: React.ReactNode;
|
|
259
|
+
* }
|
|
260
|
+
*
|
|
261
|
+
* const AccessibleButton = React.forwardRef<HTMLButtonElement, AccessibleButtonProps>(
|
|
262
|
+
* ({ variant = 'primary', ...props }, ref) => {
|
|
263
|
+
* // Runtime check: ensure accessible name is provided
|
|
264
|
+
* if (!props['aria-label'] && !props.children) {
|
|
265
|
+
* console.warn('AccessibleButton requires either aria-label or children');
|
|
266
|
+
* }
|
|
267
|
+
*
|
|
268
|
+
* return (
|
|
269
|
+
* <UI
|
|
270
|
+
* as="button"
|
|
271
|
+
* ref={ref}
|
|
272
|
+
* defaultStyles={{
|
|
273
|
+
* padding: '0.5rem 1rem',
|
|
274
|
+
* borderRadius: '0.25rem',
|
|
275
|
+
* backgroundColor: variant === 'primary' ? '#007bff' : '#6c757d',
|
|
276
|
+
* }}
|
|
277
|
+
* {...props}
|
|
278
|
+
* />
|
|
279
|
+
* );
|
|
280
|
+
* }
|
|
281
|
+
* );
|
|
282
|
+
*/
|
|
283
|
+
declare const UI: UIComponent;
|
|
284
|
+
|
|
285
|
+
export { UI as U };
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@fpkit/acss",
|
|
3
3
|
"description": "A lightweight React UI library for building modern and accessible components that leverage CSS custom properties for reactive Styles.",
|
|
4
4
|
"private": false,
|
|
5
|
-
"version": "0.5.
|
|
5
|
+
"version": "0.5.13",
|
|
6
6
|
"engines": {
|
|
7
7
|
"node": ">=20.9.0",
|
|
8
8
|
"npm": ">=8.0.0"
|
|
@@ -11,7 +11,6 @@
|
|
|
11
11
|
"start": "run-p package:watch sass:watch",
|
|
12
12
|
"dev": "vite --open",
|
|
13
13
|
"build": "run-s package sass build:sass build:css",
|
|
14
|
-
"build:components": "tsup --config tsup.components.config.cjs",
|
|
15
14
|
"package": "tsc && tsup --dts",
|
|
16
15
|
"package:watch": "tsc && tsup --watch --dts",
|
|
17
16
|
"build::css": "postcss ./libs/components/**/*.css --base libs/components/ --use autoprefixer -d ./libs/components/ --ext min.css",
|
|
@@ -82,86 +81,6 @@
|
|
|
82
81
|
"require": "./libs/index.cjs",
|
|
83
82
|
"default": "./libs/index.js"
|
|
84
83
|
},
|
|
85
|
-
"./button": {
|
|
86
|
-
"import": "./libs/components/button.js",
|
|
87
|
-
"require": "./libs/components/button.cjs",
|
|
88
|
-
"default": "./libs/components/button.js"
|
|
89
|
-
},
|
|
90
|
-
"./card": {
|
|
91
|
-
"import": "./libs/components/card.js",
|
|
92
|
-
"require": "./libs/components/card.cjs",
|
|
93
|
-
"default": "./libs/components/card.js"
|
|
94
|
-
},
|
|
95
|
-
"./modal": {
|
|
96
|
-
"import": "./libs/components/modal.js",
|
|
97
|
-
"require": "./libs/components/modal.cjs",
|
|
98
|
-
"default": "./libs/components/modal.js"
|
|
99
|
-
},
|
|
100
|
-
"./input": {
|
|
101
|
-
"import": "./libs/components/input.js",
|
|
102
|
-
"require": "./libs/components/input.cjs",
|
|
103
|
-
"default": "./libs/components/input.js"
|
|
104
|
-
},
|
|
105
|
-
"./link": {
|
|
106
|
-
"import": "./libs/components/link.js",
|
|
107
|
-
"require": "./libs/components/link.cjs",
|
|
108
|
-
"default": "./libs/components/link.js"
|
|
109
|
-
},
|
|
110
|
-
"./list": {
|
|
111
|
-
"import": "./libs/components/list.js",
|
|
112
|
-
"require": "./libs/components/list.cjs",
|
|
113
|
-
"default": "./libs/components/list.js"
|
|
114
|
-
},
|
|
115
|
-
"./icon": {
|
|
116
|
-
"import": "./libs/components/icon.js",
|
|
117
|
-
"require": "./libs/components/icon.cjs",
|
|
118
|
-
"default": "./libs/components/icon.js"
|
|
119
|
-
},
|
|
120
|
-
"./table": {
|
|
121
|
-
"import": "./libs/components/table.js",
|
|
122
|
-
"require": "./libs/components/table.cjs",
|
|
123
|
-
"default": "./libs/components/table.js"
|
|
124
|
-
},
|
|
125
|
-
"./dialog": {
|
|
126
|
-
"import": "./libs/components/dialog.js",
|
|
127
|
-
"require": "./libs/components/dialog.cjs",
|
|
128
|
-
"default": "./libs/components/dialog.js"
|
|
129
|
-
},
|
|
130
|
-
"./nav": {
|
|
131
|
-
"import": "./libs/components/nav.js",
|
|
132
|
-
"require": "./libs/components/nav.cjs",
|
|
133
|
-
"default": "./libs/components/nav.js"
|
|
134
|
-
},
|
|
135
|
-
"./popover": {
|
|
136
|
-
"import": "./libs/components/popover.js",
|
|
137
|
-
"require": "./libs/components/popover.cjs",
|
|
138
|
-
"default": "./libs/components/popover.js"
|
|
139
|
-
},
|
|
140
|
-
"./text": {
|
|
141
|
-
"import": "./libs/components/text.js",
|
|
142
|
-
"require": "./libs/components/text.cjs",
|
|
143
|
-
"default": "./libs/components/text.js"
|
|
144
|
-
},
|
|
145
|
-
"./heading": {
|
|
146
|
-
"import": "./libs/components/heading.js",
|
|
147
|
-
"require": "./libs/components/heading.cjs",
|
|
148
|
-
"default": "./libs/components/heading.js"
|
|
149
|
-
},
|
|
150
|
-
"./breadcrumb": {
|
|
151
|
-
"import": "./libs/components/breadcrumb.js",
|
|
152
|
-
"require": "./libs/components/breadcrumb.cjs",
|
|
153
|
-
"default": "./libs/components/breadcrumb.js"
|
|
154
|
-
},
|
|
155
|
-
"./textarea": {
|
|
156
|
-
"import": "./libs/components/textarea.js",
|
|
157
|
-
"require": "./libs/components/textarea.cjs",
|
|
158
|
-
"default": "./libs/components/textarea.js"
|
|
159
|
-
},
|
|
160
|
-
"./field": {
|
|
161
|
-
"import": "./libs/components/field.js",
|
|
162
|
-
"require": "./libs/components/field.cjs",
|
|
163
|
-
"default": "./libs/components/field.js"
|
|
164
|
-
},
|
|
165
84
|
"./hooks": {
|
|
166
85
|
"import": "./libs/hooks.js",
|
|
167
86
|
"require": "./libs/hooks.cjs",
|
|
@@ -208,5 +127,5 @@
|
|
|
208
127
|
"publishConfig": {
|
|
209
128
|
"access": "public"
|
|
210
129
|
},
|
|
211
|
-
"gitHead": "
|
|
130
|
+
"gitHead": "00db2b908b9aa637e99c401861de87d43b7009d6"
|
|
212
131
|
}
|