@flavia-dev/a11y-ui-kit-react 0.1.6 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/a11y-ui-kit-react.css +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +8 -44
- package/dist/index.js +173 -174
- package/dist/index.js.map +1 -1
- package/package.json +41 -8
|
@@ -1 +1 @@
|
|
|
1
|
-
.
|
|
1
|
+
._button_f4jhn_2{position:relative;display:inline-flex;align-items:center;justify-content:center;gap:.5rem;font-family:inherit;font-weight:600;line-height:1.5;border:none;border-radius:.5rem;cursor:pointer;transition:all .2s ease;text-decoration:none;white-space:nowrap}._button_f4jhn_2:focus-visible{outline:3px solid #3b82f6;outline-offset:2px}._button_f4jhn_2[aria-disabled=true],._disabled_f4jhn_26{cursor:not-allowed;opacity:.6;pointer-events:none}._primary_f4jhn_33{background-color:#3b82f6;color:#fff}._primary_f4jhn_33:hover:not([aria-disabled=true]):not(._disabled_f4jhn_26){background-color:#2563eb}._primary_f4jhn_33:active:not([aria-disabled=true]):not(._disabled_f4jhn_26){background-color:#1d4ed8}._secondary_f4jhn_46{background-color:#64748b;color:#fff}._secondary_f4jhn_46:hover:not([aria-disabled=true]):not(._disabled_f4jhn_26){background-color:#475569}._secondary_f4jhn_46:active:not([aria-disabled=true]):not(._disabled_f4jhn_26){background-color:#334155}._danger_f4jhn_59{background-color:#ef4444;color:#fff}._danger_f4jhn_59:hover:not([aria-disabled=true]):not(._disabled_f4jhn_26){background-color:#dc2626}._danger_f4jhn_59:active:not([aria-disabled=true]):not(._disabled_f4jhn_26){background-color:#b91c1c}._small_f4jhn_73{padding:.5rem 1rem;font-size:.875rem}._medium_f4jhn_78{padding:.625rem 1.25rem;font-size:1rem}._large_f4jhn_83{padding:.75rem 1.5rem;font-size:1.125rem}._fullWidth_f4jhn_89{width:100%}._loading_f4jhn_94{pointer-events:none}._loadingContainer_f4jhn_98{display:inline-flex;align-items:center;gap:.5rem}._spinner_f4jhn_104{display:inline-block;width:1em;height:1em;border:2px solid currentColor;border-right-color:transparent;border-radius:50%;animation:_spin_f4jhn_104 .75s linear infinite}@keyframes _spin_f4jhn_104{to{transform:rotate(360deg)}}._srOnly_f4jhn_121{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border-width:0}._inputWrapper_kbgao_2{display:inline-flex;flex-direction:column;gap:.25rem}._inputWrapper_kbgao_2._fullWidth_kbgao_8{width:100%}._label_kbgao_13{font-size:.875rem;font-weight:500;color:#374151;margin-bottom:.25rem}._label_kbgao_13._required_kbgao_20:after{content:""}._requiredIndicator_kbgao_24{color:#dc2626;margin-left:.25rem}._input_kbgao_2{font-family:inherit;font-size:1rem;line-height:1.5;color:#1f2937;background-color:#fff;border:1px solid #6b7280;border-radius:.375rem;transition:all .2s ease;outline:none}._input_kbgao_2:focus{border-color:#3b82f6;box-shadow:0 0 0 3px #3b82f61a}._input_kbgao_2:focus-visible{outline:2px solid #3b82f6;outline-offset:2px}._small_kbgao_53{padding:.375rem .75rem;font-size:.875rem}._medium_kbgao_58{padding:.5rem .875rem;font-size:1rem}._large_kbgao_63{padding:.625rem 1rem;font-size:1.125rem}._input_kbgao_2._error_kbgao_69{border-color:#dc2626}._input_kbgao_2._error_kbgao_69:focus{border-color:#dc2626;box-shadow:0 0 0 3px #dc26261a}._input_kbgao_2._disabled_kbgao_78,._input_kbgao_2:disabled{background-color:#f3f4f6;color:#6b7280;cursor:not-allowed;opacity:.8}._fullWidth_kbgao_8{width:100%}._helperText_kbgao_91,._errorText_kbgao_92{font-size:.875rem;margin-top:.25rem}._helperText_kbgao_91{color:#6b7280}._errorText_kbgao_92{color:#dc2626;font-weight:500}._visuallyHidden_kbgao_107{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border-width:0}._checkboxWrapper_lv2u7_1{display:flex;flex-direction:column;gap:.25rem}._inputGroup_lv2u7_7{display:flex;align-items:center;gap:.5rem}._checkbox_lv2u7_1{appearance:none;-webkit-appearance:none;margin:0;width:1.25rem;height:1.25rem;flex-shrink:0;border:2px solid #6b7280;border-radius:.25rem;background-color:#fff;cursor:pointer;transition:all .2s ease-in-out;position:relative}._checkbox_lv2u7_1:focus-visible{outline:3px solid #3b82f6;outline-offset:2px}._checkbox_lv2u7_1:checked{background-color:#3b82f6;border-color:#3b82f6}._checkbox_lv2u7_1:checked:after{content:"";position:absolute;left:.3rem;top:.05rem;width:.35rem;height:.7rem;border:solid #ffffff;border-width:0 2.5px 2.5px 0;transform:rotate(45deg)}._checkbox_lv2u7_1._indeterminate_lv2u7_49{background-color:#3b82f6;border-color:#3b82f6}._checkbox_lv2u7_1._indeterminate_lv2u7_49:after{content:"";position:absolute;left:50%;top:50%;transform:translate(-50%,-50%);width:.65rem;height:.15rem;background-color:#fff;border-radius:1px}._checkbox_lv2u7_1:not(:disabled):hover{border-color:#3b82f6}._checkbox_lv2u7_1:disabled{cursor:not-allowed;opacity:.5;background-color:#f3f4f6}._checkbox_lv2u7_1._error_lv2u7_76{border-color:#ef4444;border-width:2.5px}._checkbox_lv2u7_1._small_lv2u7_81{width:1rem;height:1rem}._checkbox_lv2u7_1._small_lv2u7_81:checked:after{left:.25rem;top:.03rem;width:.25rem;height:.5rem;border-width:0 2px 2px 0}._checkbox_lv2u7_1._large_lv2u7_94{width:1.5rem;height:1.5rem}._checkbox_lv2u7_1._large_lv2u7_94:checked:after{left:.4rem;top:.08rem;width:.45rem;height:.85rem;border-width:0 3px 3px 0}._checkbox_lv2u7_1._small_lv2u7_81._indeterminate_lv2u7_49:after{width:.5rem;height:.125rem}._checkbox_lv2u7_1._large_lv2u7_94._indeterminate_lv2u7_49:after{width:.8rem;height:.175rem}._label_lv2u7_117{font-size:1rem;line-height:1.5;color:#374151;cursor:pointer;-webkit-user-select:none;user-select:none}._label_lv2u7_117._disabled_lv2u7_125{cursor:not-allowed;opacity:.5}._requiredIndicator_lv2u7_130{color:#ef4444;font-weight:600}._helperText_lv2u7_135{font-size:.875rem;line-height:1.25rem;color:#6b7280;margin-left:1.75rem}._errorText_lv2u7_142{font-size:.875rem;line-height:1.25rem;color:#dc2626;margin-left:1.75rem;font-weight:500}
|
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),b=require("react"),T="_button_f4jhn_2",q="_disabled_f4jhn_26",C="_primary_f4jhn_33",B="_secondary_f4jhn_46",R="_danger_f4jhn_59",w="_small_f4jhn_73",D="_medium_f4jhn_78",O="_large_f4jhn_83",G="_fullWidth_f4jhn_89",H="_loading_f4jhn_94",E="_loadingContainer_f4jhn_98",F="_spinner_f4jhn_104",K="_spin_f4jhn_104",S="_srOnly_f4jhn_121",d={button:T,disabled:q,primary:C,secondary:B,danger:R,small:w,medium:D,large:O,fullWidth:G,loading:H,loadingContainer:E,spinner:F,spin:K,srOnly:S},$=b.forwardRef(({variant:m="primary",size:f="medium",children:o,disabled:l=!1,loading:s=!1,fullWidth:t=!1,className:c,type:_="button",onClick:h,...x},j)=>{const u=l||s,p=r=>{if(u){r.preventDefault();return}h?.(r)},g=r=>{u&&(r.key==="Enter"||r.key===" ")&&r.preventDefault()},i=[d.button,d[m],d[f],s&&d.loading,t&&d.fullWidth,u&&d.disabled,c].filter(Boolean).join(" ");return e.jsxs("button",{ref:j,type:_,className:i,"aria-disabled":u,"aria-busy":s||void 0,onClick:p,onKeyDown:g,...x,children:[s&&e.jsxs("span",{role:"status","aria-live":"polite",className:d.loadingContainer,children:[e.jsx("span",{className:d.spinner,"aria-hidden":"true"}),e.jsx("span",{className:d.srOnly,children:"Loading..."})]}),e.jsx("span",{"aria-hidden":s||void 0,children:o})]})});$.displayName="Button";const L="_inputWrapper_kbgao_2",M="_fullWidth_kbgao_8",P="_label_kbgao_13",z="_required_kbgao_20",A="_requiredIndicator_kbgao_24",J="_input_kbgao_2",Q="_small_kbgao_53",U="_medium_kbgao_58",V="_large_kbgao_63",X="_error_kbgao_69",Y="_disabled_kbgao_78",Z="_helperText_kbgao_91",ee="_errorText_kbgao_92",se="_visuallyHidden_kbgao_107",n={inputWrapper:L,fullWidth:M,label:P,required:z,requiredIndicator:A,input:J,small:Q,medium:U,large:V,error:X,disabled:Y,helperText:Z,errorText:ee,visuallyHidden:se},I=b.forwardRef(({label:m,type:f="text",size:o="medium",error:l,helperText:s,fullWidth:t=!1,hideLabel:c=!1,required:_=!1,disabled:h=!1,className:x,id:j,...u},p)=>{const g=b.useId(),i=j||g,r=l?`${i}-error`:void 0,v=s?`${i}-helper`:void 0,k=[r,v].filter(Boolean).join(" ")||void 0,y=[n.input,n[o],l&&n.error,h&&n.disabled,t&&n.fullWidth,x].filter(Boolean).join(" "),N=[n.label,c&&n.visuallyHidden,_&&n.required].filter(Boolean).join(" ");return e.jsxs("div",{className:`${n.inputWrapper} ${t?n.fullWidth:""}`,children:[e.jsxs("label",{htmlFor:i,className:N,children:[m,_&&e.jsxs("span",{className:n.requiredIndicator,"aria-label":"required",children:[" ","*"]})]}),e.jsx("input",{ref:p,id:i,type:f,className:y,required:_,disabled:h,"aria-invalid":l?!0:void 0,"aria-describedby":k,"aria-required":_||void 0,...u}),s&&!l&&e.jsx("span",{id:v,className:n.helperText,children:s}),l&&e.jsx("span",{id:r,className:n.errorText,role:"alert",children:l})]})});I.displayName="Input";const ne="_checkboxWrapper_lv2u7_1",ae="_inputGroup_lv2u7_7",le="_checkbox_lv2u7_1",re="_indeterminate_lv2u7_49",ie="_error_lv2u7_76",oe="_small_lv2u7_81",te="_large_lv2u7_94",de="_label_lv2u7_117",ce="_disabled_lv2u7_125",_e="_requiredIndicator_lv2u7_130",ue="_helperText_lv2u7_135",pe="_errorText_lv2u7_142",a={checkboxWrapper:ne,inputGroup:ae,checkbox:le,indeterminate:re,error:ie,small:oe,large:te,label:de,disabled:ce,requiredIndicator:_e,helperText:ue,errorText:pe},W=b.forwardRef(({label:m,size:f="medium",error:o,helperText:l,disabled:s=!1,required:t=!1,indeterminate:c=!1,className:_,id:h,...x},j)=>{const u=b.useRef(null),p=j||u,g=b.useId(),i=h||g,r=o?`${i}-error`:void 0,v=l?`${i}-helper`:void 0,k=[r,v].filter(Boolean).join(" ")||void 0;b.useEffect(()=>{p.current&&(p.current.indeterminate=c)},[c,p]);const y=[a.checkbox,a[f],o&&a.error,s&&a.disabled,c&&a.indeterminate,_].filter(Boolean).join(" "),N=[a.label,s&&a.disabled,t&&a.required].filter(Boolean).join(" ");return e.jsxs("div",{className:a.checkboxWrapper,children:[e.jsxs("div",{className:a.inputGroup,children:[e.jsx("input",{ref:p,id:i,type:"checkbox",className:y,disabled:s,required:t,"aria-invalid":o?!0:void 0,"aria-describedby":k,"aria-required":t||void 0,"aria-checked":c?"mixed":void 0,...x}),e.jsxs("label",{htmlFor:i,className:N,children:[m,t&&e.jsxs("span",{className:a.requiredIndicator,"aria-label":"required",children:[" ","*"]})]})]}),l&&!o&&e.jsx("span",{id:v,className:a.helperText,children:l}),o&&e.jsx("span",{id:r,className:a.errorText,role:"alert",children:o})]})});W.displayName="Checkbox";exports.Button=$;exports.Checkbox=W;exports.Input=I;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../src/atoms/Button/Button.tsx","../src/atoms/Input/Input.tsx","../src/atoms/Checkbox/Checkbox.tsx"],"sourcesContent":["// src/atoms/Button/Button.tsx\nimport React from \"react\";\nimport styles from \"./Button.module.css\";\n\nexport interface ButtonProps\n extends React.ButtonHTMLAttributes<HTMLButtonElement> {\n variant?: \"primary\" | \"secondary\" | \"danger\";\n size?: \"small\" | \"medium\" | \"large\";\n children: React.ReactNode;\n loading?: boolean;\n fullWidth?: boolean;\n}\n\n/**\n * Accessible button component following WCAG 2.1 AA standards\n *\n * Features:\n * - Native <button> element for semantic HTML\n * - Full keyboard support (Tab, Enter, Space)\n * - Screen reader announcements for loading state\n * - Visible focus indicator\n * - Color contrast compliant\n *\n * @example\n * ```tsx\n * <Button variant=\"primary\" onClick={handleClick}>\n * Click me\n * </Button>\n *\n * <Button loading disabled>\n * Submitting...\n * </Button>\n * ```\n */\nexport const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(\n (\n {\n variant = \"primary\",\n size = \"medium\",\n children,\n disabled = false,\n loading = false,\n fullWidth = false,\n className,\n type = \"button\",\n onClick,\n ...props\n },\n ref\n ) => {\n const isDisabled = disabled || loading;\n\n // Handle click with disabled check (prevents action but keeps focusable)\n const handleClick = (event: React.MouseEvent<HTMLButtonElement>) => {\n if (isDisabled) {\n event.preventDefault();\n return;\n }\n onClick?.(event);\n };\n\n // Handle keyboard events to prevent action when disabled\n const handleKeyDown = (event: React.KeyboardEvent<HTMLButtonElement>) => {\n if (isDisabled && (event.key === \"Enter\" || event.key === \" \")) {\n event.preventDefault();\n }\n };\n\n const classNames = [\n styles.button,\n styles[variant],\n styles[size],\n loading && styles.loading,\n fullWidth && styles.fullWidth,\n isDisabled && styles.disabled,\n className,\n ]\n .filter(Boolean)\n .join(\" \");\n\n return (\n <button\n ref={ref}\n type={type}\n className={classNames}\n aria-disabled={isDisabled}\n aria-busy={loading || undefined}\n onClick={handleClick}\n onKeyDown={handleKeyDown}\n {...props}\n >\n {loading && (\n <span\n role=\"status\"\n aria-live=\"polite\"\n className={styles.loadingContainer}\n >\n <span className={styles.spinner} aria-hidden=\"true\" />\n <span className={styles.srOnly}>Loading...</span>\n </span>\n )}\n <span aria-hidden={loading || undefined}>{children}</span>\n </button>\n );\n }\n);\n\nButton.displayName = \"Button\";\n","import React, { useId } from \"react\";\nimport styles from \"./Input.module.css\";\n\nexport interface InputProps\n extends Omit<React.InputHTMLAttributes<HTMLInputElement>, \"size\"> {\n /**\n * Input label (required for accessibility)\n */\n label: string;\n\n /**\n * Input type\n * @default \"text\"\n */\n type?: \"text\" | \"email\" | \"password\" | \"tel\" | \"url\" | \"search\" | \"number\";\n\n /**\n * Input size\n * @default \"medium\"\n */\n size?: \"small\" | \"medium\" | \"large\";\n\n /**\n * Error message (when present, input is marked as invalid)\n */\n error?: string;\n\n /**\n * Helper text (additional description)\n */\n helperText?: string;\n\n /**\n * Full width input\n * @default false\n */\n fullWidth?: boolean;\n\n /**\n * Hide label visually but keep it for screen readers\n * @default false\n */\n hideLabel?: boolean;\n}\n\n/**\n * Accessible Input component following WCAG 2.1 AA standards\n *\n * Features:\n * - Native <input> element for semantic HTML\n * - Proper label association via htmlFor\n * - Error states with aria-invalid and aria-describedby\n * - Helper text support\n * - Visible focus indicator\n * - Required indicator\n *\n * @example\n * ```tsx\n * <Input\n * label=\"Email\"\n * type=\"email\"\n * required\n * error=\"Invalid email address\"\n * helperText=\"We'll never share your email\"\n * />\n * ```\n */\nexport const Input = React.forwardRef<HTMLInputElement, InputProps>(\n (\n {\n label,\n type = \"text\",\n size = \"medium\",\n error,\n helperText,\n fullWidth = false,\n hideLabel = false,\n required = false,\n disabled = false,\n className,\n id: providedId,\n ...props\n },\n ref\n ) => {\n // Generate unique IDs for accessibility\n const generatedId = useId();\n const id = providedId || generatedId;\n const errorId = error ? `${id}-error` : undefined;\n const helperTextId = helperText ? `${id}-helper` : undefined;\n\n // Build aria-describedby\n const describedBy = [errorId, helperTextId].filter(Boolean).join(\" \") || undefined;\n\n const inputClasses = [\n styles.input,\n styles[size],\n error && styles.error,\n disabled && styles.disabled,\n fullWidth && styles.fullWidth,\n className,\n ]\n .filter(Boolean)\n .join(\" \");\n\n const labelClasses = [\n styles.label,\n hideLabel && styles.visuallyHidden,\n required && styles.required,\n ]\n .filter(Boolean)\n .join(\" \");\n\n return (\n <div className={`${styles.inputWrapper} ${fullWidth ? styles.fullWidth : \"\"}`}>\n <label htmlFor={id} className={labelClasses}>\n {label}\n {required && <span className={styles.requiredIndicator} aria-label=\"required\"> *</span>}\n </label>\n\n <input\n ref={ref}\n id={id}\n type={type}\n className={inputClasses}\n required={required}\n disabled={disabled}\n aria-invalid={error ? true : undefined}\n aria-describedby={describedBy}\n aria-required={required || undefined}\n {...props}\n />\n\n {helperText && !error && (\n <span id={helperTextId} className={styles.helperText}>\n {helperText}\n </span>\n )}\n\n {error && (\n <span id={errorId} className={styles.errorText} role=\"alert\">\n {error}\n </span>\n )}\n </div>\n );\n }\n);\n\nInput.displayName = \"Input\";\n","import React, { useId } from \"react\";\nimport styles from \"./Checkbox.module.css\";\n\nexport interface CheckboxProps\n extends Omit<React.InputHTMLAttributes<HTMLInputElement>, \"size\" | \"type\"> {\n /**\n * Checkbox label (required for accessibility)\n */\n label: string;\n\n /**\n * Checkbox size\n * @default \"medium\"\n */\n size?: \"small\" | \"medium\" | \"large\";\n\n /**\n * Error message (when present, checkbox is marked as invalid)\n */\n error?: string;\n\n /**\n * Helper text (additional description)\n */\n helperText?: string;\n}\n\n/**\n * Accessible Checkbox component following WCAG 2.1 AA standards\n *\n * Features:\n * - Native <input type=\"checkbox\"> element for semantic HTML\n * - Proper label association via htmlFor\n * - Space key toggles checked state (native behavior)\n * - Error states with aria-invalid and aria-describedby\n * - Helper text support\n * - Visible focus indicator\n * - Required indicator\n *\n * @example\n * ```tsx\n * <Checkbox label=\"I agree to terms\" required />\n *\n * <Checkbox\n * label=\"Subscribe to newsletter\"\n * checked={isChecked}\n * onChange={(e) => setIsChecked(e.target.checked)}\n * error=\"This field is required\"\n * />\n * ```\n */\nexport const Checkbox = React.forwardRef<HTMLInputElement, CheckboxProps>(\n (\n {\n label,\n size = \"medium\",\n error,\n helperText,\n disabled = false,\n required = false,\n className,\n id: providedId,\n ...props\n },\n ref\n ) => {\n // Generate unique IDs for accessibility\n const generatedId = useId();\n const id = providedId || generatedId;\n const errorId = error ? `${id}-error` : undefined;\n const helperTextId = helperText ? `${id}-helper` : undefined;\n\n // Build aria-describedby\n const describedBy =\n [errorId, helperTextId].filter(Boolean).join(\" \") || undefined;\n\n const checkboxClasses = [\n styles.checkbox,\n styles[size],\n error && styles.error,\n disabled && styles.disabled,\n className,\n ]\n .filter(Boolean)\n .join(\" \");\n\n const labelClasses = [\n styles.label,\n disabled && styles.disabled,\n required && styles.required,\n ]\n .filter(Boolean)\n .join(\" \");\n\n return (\n <div className={styles.checkboxWrapper}>\n <div className={styles.inputGroup}>\n <input\n ref={ref}\n id={id}\n type=\"checkbox\"\n className={checkboxClasses}\n disabled={disabled}\n required={required}\n aria-invalid={error ? true : undefined}\n aria-describedby={describedBy}\n aria-required={required || undefined}\n {...props}\n />\n\n <label htmlFor={id} className={labelClasses}>\n {label}\n {required && (\n <span className={styles.requiredIndicator} aria-label=\"required\">\n {\" \"}\n *\n </span>\n )}\n </label>\n </div>\n\n {helperText && !error && (\n <span id={helperTextId} className={styles.helperText}>\n {helperText}\n </span>\n )}\n\n {error && (\n <span id={errorId} className={styles.errorText} role=\"alert\">\n {error}\n </span>\n )}\n </div>\n );\n }\n);\n\nCheckbox.displayName = \"Checkbox\";\n"],"names":["Button","React","variant","size","children","disabled","loading","fullWidth","className","type","onClick","props","ref","isDisabled","handleClick","event","handleKeyDown","classNames","styles","jsxs","jsx","Input","label","error","helperText","hideLabel","required","providedId","generatedId","useId","id","errorId","helperTextId","describedBy","inputClasses","labelClasses","Checkbox","checkboxClasses"],"mappings":"olBAkCaA,EAASC,EAAM,WAC1B,CACE,CACE,QAAAC,EAAU,UACV,KAAAC,EAAO,SACP,SAAAC,EACA,SAAAC,EAAW,GACX,QAAAC,EAAU,GACV,UAAAC,EAAY,GACZ,UAAAC,EACA,KAAAC,EAAO,SACP,QAAAC,EACA,GAAGC,CAAA,EAELC,IACG,CACH,MAAMC,EAAaR,GAAYC,EAGzBQ,EAAeC,GAA+C,CAClE,GAAIF,EAAY,CACdE,EAAM,eAAA,EACN,MACF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ms/Input/Input.tsx","../src/atoms/Checkbox/Checkbox.tsx"],"sourcesContent":["// src/atoms/Button/Button.tsx\nimport React from 'react';\nimport styles from './Button.module.css';\n\nexport interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {\n variant?: 'primary' | 'secondary' | 'danger';\n size?: 'small' | 'medium' | 'large';\n children: React.ReactNode;\n loading?: boolean;\n fullWidth?: boolean;\n}\n\n/**\n * Accessible button component following WCAG 2.1 AA standards\n *\n * Features:\n * - Native <button> element for semantic HTML\n * - Full keyboard support (Tab, Enter, Space)\n * - Screen reader announcements for loading state\n * - Visible focus indicator\n * - Color contrast compliant\n *\n * @example\n * ```tsx\n * <Button variant=\"primary\" onClick={handleClick}>\n * Click me\n * </Button>\n *\n * <Button loading disabled>\n * Submitting...\n * </Button>\n * ```\n */\nexport const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(\n (\n {\n variant = 'primary',\n size = 'medium',\n children,\n disabled = false,\n loading = false,\n fullWidth = false,\n className,\n type = 'button',\n onClick,\n ...props\n },\n ref\n ) => {\n const isDisabled = disabled || loading;\n\n // Handle click with disabled check (prevents action but keeps focusable)\n const handleClick = (event: React.MouseEvent<HTMLButtonElement>) => {\n if (isDisabled) {\n event.preventDefault();\n return;\n }\n onClick?.(event);\n };\n\n // Handle keyboard events to prevent action when disabled\n const handleKeyDown = (event: React.KeyboardEvent<HTMLButtonElement>) => {\n if (isDisabled && (event.key === 'Enter' || event.key === ' ')) {\n event.preventDefault();\n }\n };\n\n const classNames = [\n styles.button,\n styles[variant],\n styles[size],\n loading && styles.loading,\n fullWidth && styles.fullWidth,\n isDisabled && styles.disabled,\n className,\n ]\n .filter(Boolean)\n .join(' ');\n\n return (\n <button\n ref={ref}\n type={type}\n className={classNames}\n aria-disabled={isDisabled}\n aria-busy={loading || undefined}\n onClick={handleClick}\n onKeyDown={handleKeyDown}\n {...props}\n >\n {loading && (\n <span role=\"status\" aria-live=\"polite\" className={styles.loadingContainer}>\n <span className={styles.spinner} aria-hidden=\"true\" />\n <span className={styles.srOnly}>Loading...</span>\n </span>\n )}\n <span aria-hidden={loading || undefined}>{children}</span>\n </button>\n );\n }\n);\n\nButton.displayName = 'Button';\n","import React, { useId } from 'react';\nimport styles from './Input.module.css';\n\nexport interface InputProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'size'> {\n /**\n * Input label (required for accessibility)\n */\n label: string;\n\n /**\n * Input type\n * @default \"text\"\n */\n type?: 'text' | 'email' | 'password' | 'tel' | 'url' | 'search' | 'number';\n\n /**\n * Input size\n * @default \"medium\"\n */\n size?: 'small' | 'medium' | 'large';\n\n /**\n * Error message (when present, input is marked as invalid)\n */\n error?: string;\n\n /**\n * Helper text (additional description)\n */\n helperText?: string;\n\n /**\n * Full width input\n * @default false\n */\n fullWidth?: boolean;\n\n /**\n * Hide label visually but keep it for screen readers\n * @default false\n */\n hideLabel?: boolean;\n}\n\n/**\n * Accessible Input component following WCAG 2.1 AA standards\n *\n * Features:\n * - Native <input> element for semantic HTML\n * - Proper label association via htmlFor\n * - Error states with aria-invalid and aria-describedby\n * - Helper text support\n * - Visible focus indicator\n * - Required indicator\n *\n * @example\n * ```tsx\n * <Input\n * label=\"Email\"\n * type=\"email\"\n * required\n * error=\"Invalid email address\"\n * helperText=\"We'll never share your email\"\n * />\n * ```\n */\nexport const Input = React.forwardRef<HTMLInputElement, InputProps>(\n (\n {\n label,\n type = 'text',\n size = 'medium',\n error,\n helperText,\n fullWidth = false,\n hideLabel = false,\n required = false,\n disabled = false,\n className,\n id: providedId,\n ...props\n },\n ref\n ) => {\n // Generate unique IDs for accessibility\n const generatedId = useId();\n const id = providedId || generatedId;\n const errorId = error ? `${id}-error` : undefined;\n const helperTextId = helperText ? `${id}-helper` : undefined;\n\n // Build aria-describedby\n const describedBy = [errorId, helperTextId].filter(Boolean).join(' ') || undefined;\n\n const inputClasses = [\n styles.input,\n styles[size],\n error && styles.error,\n disabled && styles.disabled,\n fullWidth && styles.fullWidth,\n className,\n ]\n .filter(Boolean)\n .join(' ');\n\n const labelClasses = [\n styles.label,\n hideLabel && styles.visuallyHidden,\n required && styles.required,\n ]\n .filter(Boolean)\n .join(' ');\n\n return (\n <div className={`${styles.inputWrapper} ${fullWidth ? styles.fullWidth : ''}`}>\n <label htmlFor={id} className={labelClasses}>\n {label}\n {required && (\n <span className={styles.requiredIndicator} aria-label=\"required\">\n {' '}\n *\n </span>\n )}\n </label>\n\n <input\n ref={ref}\n id={id}\n type={type}\n className={inputClasses}\n required={required}\n disabled={disabled}\n aria-invalid={error ? true : undefined}\n aria-describedby={describedBy}\n aria-required={required || undefined}\n {...props}\n />\n\n {helperText && !error && (\n <span id={helperTextId} className={styles.helperText}>\n {helperText}\n </span>\n )}\n\n {error && (\n <span id={errorId} className={styles.errorText} role=\"alert\">\n {error}\n </span>\n )}\n </div>\n );\n }\n);\n\nInput.displayName = 'Input';\n","import React, { useId, useEffect, useRef } from 'react';\nimport styles from './Checkbox.module.css';\n\nexport interface CheckboxProps extends Omit<\n React.InputHTMLAttributes<HTMLInputElement>,\n 'size' | 'type'\n> {\n label: string;\n size?: 'small' | 'medium' | 'large';\n error?: string;\n helperText?: string;\n indeterminate?: boolean;\n}\n\nexport const Checkbox = React.forwardRef<HTMLInputElement, CheckboxProps>(\n (\n {\n label,\n size = 'medium',\n error,\n helperText,\n disabled = false,\n required = false,\n indeterminate = false,\n className,\n id: providedId,\n ...props\n },\n ref\n ) => {\n const internalRef = useRef<HTMLInputElement>(null);\n const checkboxRef = (ref as React.RefObject<HTMLInputElement>) || internalRef;\n\n const generatedId = useId();\n const id = providedId || generatedId;\n const errorId = error ? `${id}-error` : undefined;\n const helperTextId = helperText ? `${id}-helper` : undefined;\n\n const describedBy = [errorId, helperTextId].filter(Boolean).join(' ') || undefined;\n\n useEffect(() => {\n if (checkboxRef.current) {\n checkboxRef.current.indeterminate = indeterminate;\n }\n }, [indeterminate, checkboxRef]);\n\n const checkboxClasses = [\n styles.checkbox,\n styles[size],\n error && styles.error,\n disabled && styles.disabled,\n indeterminate && styles.indeterminate,\n className,\n ]\n .filter(Boolean)\n .join(' ');\n\n const labelClasses = [styles.label, disabled && styles.disabled, required && styles.required]\n .filter(Boolean)\n .join(' ');\n\n return (\n <div className={styles.checkboxWrapper}>\n <div className={styles.inputGroup}>\n <input\n ref={checkboxRef}\n id={id}\n type=\"checkbox\"\n className={checkboxClasses}\n disabled={disabled}\n required={required}\n aria-invalid={error ? true : undefined}\n aria-describedby={describedBy}\n aria-required={required || undefined}\n aria-checked={indeterminate ? 'mixed' : undefined}\n {...props}\n />\n\n <label htmlFor={id} className={labelClasses}>\n {label}\n {required && (\n <span className={styles.requiredIndicator} aria-label=\"required\">\n {' '}\n *\n </span>\n )}\n </label>\n </div>\n\n {helperText && !error && (\n <span id={helperTextId} className={styles.helperText}>\n {helperText}\n </span>\n )}\n\n {error && (\n <span id={errorId} className={styles.errorText} role=\"alert\">\n {error}\n </span>\n )}\n </div>\n );\n }\n);\n\nCheckbox.displayName = 'Checkbox';\n"],"names":["Button","React","variant","size","children","disabled","loading","fullWidth","className","type","onClick","props","ref","isDisabled","handleClick","event","handleKeyDown","classNames","styles","jsxs","jsx","Input","label","error","helperText","hideLabel","required","providedId","generatedId","useId","id","errorId","helperTextId","describedBy","inputClasses","labelClasses","Checkbox","indeterminate","internalRef","useRef","checkboxRef","useEffect","checkboxClasses"],"mappings":"olBAiCaA,EAASC,EAAM,WAC1B,CACE,CACE,QAAAC,EAAU,UACV,KAAAC,EAAO,SACP,SAAAC,EACA,SAAAC,EAAW,GACX,QAAAC,EAAU,GACV,UAAAC,EAAY,GACZ,UAAAC,EACA,KAAAC,EAAO,SACP,QAAAC,EACA,GAAGC,CAAA,EAELC,IACG,CACH,MAAMC,EAAaR,GAAYC,EAGzBQ,EAAeC,GAA+C,CAClE,GAAIF,EAAY,CACdE,EAAM,eAAA,EACN,MACF,CACAL,IAAUK,CAAK,CACjB,EAGMC,EAAiBD,GAAkD,CACnEF,IAAeE,EAAM,MAA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A,IAAC,OAAA,CAAK,GAAIW,EAAS,UAAWb,EAAO,UAAW,KAAK,QAClD,SAAAK,CAAA,CACH,CAAA,EAEJ,CAEJ,CACF,EAEAa,EAAS,YAAc"}
|
package/dist/index.d.ts
CHANGED
|
@@ -24,57 +24,21 @@ import { default as default_2 } from 'react';
|
|
|
24
24
|
export declare const Button: default_2.ForwardRefExoticComponent<ButtonProps & default_2.RefAttributes<HTMLButtonElement>>;
|
|
25
25
|
|
|
26
26
|
export declare interface ButtonProps extends default_2.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
27
|
-
variant?:
|
|
28
|
-
size?:
|
|
27
|
+
variant?: 'primary' | 'secondary' | 'danger';
|
|
28
|
+
size?: 'small' | 'medium' | 'large';
|
|
29
29
|
children: default_2.ReactNode;
|
|
30
30
|
loading?: boolean;
|
|
31
31
|
fullWidth?: boolean;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
/**
|
|
35
|
-
* Accessible Checkbox component following WCAG 2.1 AA standards
|
|
36
|
-
*
|
|
37
|
-
* Features:
|
|
38
|
-
* - Native <input type="checkbox"> element for semantic HTML
|
|
39
|
-
* - Proper label association via htmlFor
|
|
40
|
-
* - Space key toggles checked state (native behavior)
|
|
41
|
-
* - Error states with aria-invalid and aria-describedby
|
|
42
|
-
* - Helper text support
|
|
43
|
-
* - Visible focus indicator
|
|
44
|
-
* - Required indicator
|
|
45
|
-
*
|
|
46
|
-
* @example
|
|
47
|
-
* ```tsx
|
|
48
|
-
* <Checkbox label="I agree to terms" required />
|
|
49
|
-
*
|
|
50
|
-
* <Checkbox
|
|
51
|
-
* label="Subscribe to newsletter"
|
|
52
|
-
* checked={isChecked}
|
|
53
|
-
* onChange={(e) => setIsChecked(e.target.checked)}
|
|
54
|
-
* error="This field is required"
|
|
55
|
-
* />
|
|
56
|
-
* ```
|
|
57
|
-
*/
|
|
58
34
|
export declare const Checkbox: default_2.ForwardRefExoticComponent<CheckboxProps & default_2.RefAttributes<HTMLInputElement>>;
|
|
59
35
|
|
|
60
|
-
export declare interface CheckboxProps extends Omit<default_2.InputHTMLAttributes<HTMLInputElement>,
|
|
61
|
-
/**
|
|
62
|
-
* Checkbox label (required for accessibility)
|
|
63
|
-
*/
|
|
36
|
+
export declare interface CheckboxProps extends Omit<default_2.InputHTMLAttributes<HTMLInputElement>, 'size' | 'type'> {
|
|
64
37
|
label: string;
|
|
65
|
-
|
|
66
|
-
* Checkbox size
|
|
67
|
-
* @default "medium"
|
|
68
|
-
*/
|
|
69
|
-
size?: "small" | "medium" | "large";
|
|
70
|
-
/**
|
|
71
|
-
* Error message (when present, checkbox is marked as invalid)
|
|
72
|
-
*/
|
|
38
|
+
size?: 'small' | 'medium' | 'large';
|
|
73
39
|
error?: string;
|
|
74
|
-
/**
|
|
75
|
-
* Helper text (additional description)
|
|
76
|
-
*/
|
|
77
40
|
helperText?: string;
|
|
41
|
+
indeterminate?: boolean;
|
|
78
42
|
}
|
|
79
43
|
|
|
80
44
|
/**
|
|
@@ -101,7 +65,7 @@ export declare interface CheckboxProps extends Omit<default_2.InputHTMLAttribute
|
|
|
101
65
|
*/
|
|
102
66
|
export declare const Input: default_2.ForwardRefExoticComponent<InputProps & default_2.RefAttributes<HTMLInputElement>>;
|
|
103
67
|
|
|
104
|
-
export declare interface InputProps extends Omit<default_2.InputHTMLAttributes<HTMLInputElement>,
|
|
68
|
+
export declare interface InputProps extends Omit<default_2.InputHTMLAttributes<HTMLInputElement>, 'size'> {
|
|
105
69
|
/**
|
|
106
70
|
* Input label (required for accessibility)
|
|
107
71
|
*/
|
|
@@ -110,12 +74,12 @@ export declare interface InputProps extends Omit<default_2.InputHTMLAttributes<H
|
|
|
110
74
|
* Input type
|
|
111
75
|
* @default "text"
|
|
112
76
|
*/
|
|
113
|
-
type?:
|
|
77
|
+
type?: 'text' | 'email' | 'password' | 'tel' | 'url' | 'search' | 'number';
|
|
114
78
|
/**
|
|
115
79
|
* Input size
|
|
116
80
|
* @default "medium"
|
|
117
81
|
*/
|
|
118
|
-
size?:
|
|
82
|
+
size?: 'small' | 'medium' | 'large';
|
|
119
83
|
/**
|
|
120
84
|
* Error message (when present, input is marked as invalid)
|
|
121
85
|
*/
|
package/dist/index.js
CHANGED
|
@@ -1,218 +1,217 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import $, { useId as
|
|
3
|
-
const
|
|
4
|
-
button:
|
|
5
|
-
disabled:
|
|
6
|
-
primary:
|
|
7
|
-
secondary:
|
|
8
|
-
danger:
|
|
9
|
-
small:
|
|
10
|
-
medium:
|
|
11
|
-
large:
|
|
12
|
-
fullWidth:
|
|
13
|
-
loading:
|
|
14
|
-
loadingContainer:
|
|
15
|
-
spinner:
|
|
16
|
-
spin:
|
|
17
|
-
srOnly:
|
|
18
|
-
},
|
|
1
|
+
import { jsxs as d, jsx as c } from "react/jsx-runtime";
|
|
2
|
+
import $, { useId as I, useRef as W, useEffect as T } from "react";
|
|
3
|
+
const C = "_button_f4jhn_2", q = "_disabled_f4jhn_26", B = "_primary_f4jhn_33", R = "_secondary_f4jhn_46", w = "_danger_f4jhn_59", D = "_small_f4jhn_73", G = "_medium_f4jhn_78", H = "_large_f4jhn_83", O = "_fullWidth_f4jhn_89", E = "_loading_f4jhn_94", F = "_loadingContainer_f4jhn_98", K = "_spinner_f4jhn_104", L = "_spin_f4jhn_104", z = "_srOnly_f4jhn_121", t = {
|
|
4
|
+
button: C,
|
|
5
|
+
disabled: q,
|
|
6
|
+
primary: B,
|
|
7
|
+
secondary: R,
|
|
8
|
+
danger: w,
|
|
9
|
+
small: D,
|
|
10
|
+
medium: G,
|
|
11
|
+
large: H,
|
|
12
|
+
fullWidth: O,
|
|
13
|
+
loading: E,
|
|
14
|
+
loadingContainer: F,
|
|
15
|
+
spinner: K,
|
|
16
|
+
spin: L,
|
|
17
|
+
srOnly: z
|
|
18
|
+
}, A = $.forwardRef(
|
|
19
19
|
({
|
|
20
|
-
variant:
|
|
21
|
-
size:
|
|
22
|
-
children:
|
|
23
|
-
disabled:
|
|
20
|
+
variant: m = "primary",
|
|
21
|
+
size: f = "medium",
|
|
22
|
+
children: o,
|
|
23
|
+
disabled: l = !1,
|
|
24
24
|
loading: e = !1,
|
|
25
|
-
fullWidth:
|
|
26
|
-
className:
|
|
27
|
-
type:
|
|
28
|
-
onClick:
|
|
29
|
-
...
|
|
30
|
-
},
|
|
31
|
-
const
|
|
32
|
-
if (
|
|
33
|
-
|
|
25
|
+
fullWidth: i = !1,
|
|
26
|
+
className: _,
|
|
27
|
+
type: u = "button",
|
|
28
|
+
onClick: h,
|
|
29
|
+
...v
|
|
30
|
+
}, g) => {
|
|
31
|
+
const p = l || e, b = (r) => {
|
|
32
|
+
if (p) {
|
|
33
|
+
r.preventDefault();
|
|
34
34
|
return;
|
|
35
35
|
}
|
|
36
|
-
|
|
37
|
-
},
|
|
38
|
-
|
|
39
|
-
},
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
e &&
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
36
|
+
h?.(r);
|
|
37
|
+
}, k = (r) => {
|
|
38
|
+
p && (r.key === "Enter" || r.key === " ") && r.preventDefault();
|
|
39
|
+
}, s = [
|
|
40
|
+
t.button,
|
|
41
|
+
t[m],
|
|
42
|
+
t[f],
|
|
43
|
+
e && t.loading,
|
|
44
|
+
i && t.fullWidth,
|
|
45
|
+
p && t.disabled,
|
|
46
|
+
_
|
|
47
47
|
].filter(Boolean).join(" ");
|
|
48
|
-
return /* @__PURE__ */
|
|
48
|
+
return /* @__PURE__ */ d(
|
|
49
49
|
"button",
|
|
50
50
|
{
|
|
51
|
-
ref:
|
|
52
|
-
type:
|
|
53
|
-
className:
|
|
54
|
-
"aria-disabled":
|
|
51
|
+
ref: g,
|
|
52
|
+
type: u,
|
|
53
|
+
className: s,
|
|
54
|
+
"aria-disabled": p,
|
|
55
55
|
"aria-busy": e || void 0,
|
|
56
|
-
onClick:
|
|
57
|
-
onKeyDown:
|
|
58
|
-
...
|
|
56
|
+
onClick: b,
|
|
57
|
+
onKeyDown: k,
|
|
58
|
+
...v,
|
|
59
59
|
children: [
|
|
60
|
-
e && /* @__PURE__ */
|
|
61
|
-
"span",
|
|
62
|
-
{
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
className: c.loadingContainer,
|
|
66
|
-
children: [
|
|
67
|
-
/* @__PURE__ */ o("span", { className: c.spinner, "aria-hidden": "true" }),
|
|
68
|
-
/* @__PURE__ */ o("span", { className: c.srOnly, children: "Loading..." })
|
|
69
|
-
]
|
|
70
|
-
}
|
|
71
|
-
),
|
|
72
|
-
/* @__PURE__ */ o("span", { "aria-hidden": e || void 0, children: n })
|
|
60
|
+
e && /* @__PURE__ */ d("span", { role: "status", "aria-live": "polite", className: t.loadingContainer, children: [
|
|
61
|
+
/* @__PURE__ */ c("span", { className: t.spinner, "aria-hidden": "true" }),
|
|
62
|
+
/* @__PURE__ */ c("span", { className: t.srOnly, children: "Loading..." })
|
|
63
|
+
] }),
|
|
64
|
+
/* @__PURE__ */ c("span", { "aria-hidden": e || void 0, children: o })
|
|
73
65
|
]
|
|
74
66
|
}
|
|
75
67
|
);
|
|
76
68
|
}
|
|
77
69
|
);
|
|
78
|
-
|
|
79
|
-
const
|
|
80
|
-
inputWrapper:
|
|
81
|
-
fullWidth:
|
|
82
|
-
label:
|
|
83
|
-
required:
|
|
84
|
-
requiredIndicator:
|
|
85
|
-
input:
|
|
86
|
-
small:
|
|
87
|
-
medium:
|
|
88
|
-
large:
|
|
89
|
-
error:
|
|
90
|
-
disabled:
|
|
91
|
-
helperText:
|
|
92
|
-
errorText:
|
|
93
|
-
visuallyHidden:
|
|
94
|
-
},
|
|
70
|
+
A.displayName = "Button";
|
|
71
|
+
const J = "_inputWrapper_kbgao_2", M = "_fullWidth_kbgao_8", P = "_label_kbgao_13", Q = "_required_kbgao_20", S = "_requiredIndicator_kbgao_24", U = "_input_kbgao_2", V = "_small_kbgao_53", X = "_medium_kbgao_58", Y = "_large_kbgao_63", Z = "_error_kbgao_69", ee = "_disabled_kbgao_78", ae = "_helperText_kbgao_91", ne = "_errorText_kbgao_92", le = "_visuallyHidden_kbgao_107", a = {
|
|
72
|
+
inputWrapper: J,
|
|
73
|
+
fullWidth: M,
|
|
74
|
+
label: P,
|
|
75
|
+
required: Q,
|
|
76
|
+
requiredIndicator: S,
|
|
77
|
+
input: U,
|
|
78
|
+
small: V,
|
|
79
|
+
medium: X,
|
|
80
|
+
large: Y,
|
|
81
|
+
error: Z,
|
|
82
|
+
disabled: ee,
|
|
83
|
+
helperText: ae,
|
|
84
|
+
errorText: ne,
|
|
85
|
+
visuallyHidden: le
|
|
86
|
+
}, re = $.forwardRef(
|
|
95
87
|
({
|
|
96
|
-
label:
|
|
97
|
-
type:
|
|
98
|
-
size:
|
|
99
|
-
error:
|
|
88
|
+
label: m,
|
|
89
|
+
type: f = "text",
|
|
90
|
+
size: o = "medium",
|
|
91
|
+
error: l,
|
|
100
92
|
helperText: e,
|
|
101
|
-
fullWidth:
|
|
102
|
-
hideLabel:
|
|
103
|
-
required:
|
|
104
|
-
disabled:
|
|
105
|
-
className:
|
|
106
|
-
id:
|
|
107
|
-
...
|
|
108
|
-
},
|
|
109
|
-
const
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
].filter(Boolean).join(" "),
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
93
|
+
fullWidth: i = !1,
|
|
94
|
+
hideLabel: _ = !1,
|
|
95
|
+
required: u = !1,
|
|
96
|
+
disabled: h = !1,
|
|
97
|
+
className: v,
|
|
98
|
+
id: g,
|
|
99
|
+
...p
|
|
100
|
+
}, b) => {
|
|
101
|
+
const k = I(), s = g || k, r = l ? `${s}-error` : void 0, x = e ? `${s}-helper` : void 0, y = [r, x].filter(Boolean).join(" ") || void 0, j = [
|
|
102
|
+
a.input,
|
|
103
|
+
a[o],
|
|
104
|
+
l && a.error,
|
|
105
|
+
h && a.disabled,
|
|
106
|
+
i && a.fullWidth,
|
|
107
|
+
v
|
|
108
|
+
].filter(Boolean).join(" "), N = [
|
|
109
|
+
a.label,
|
|
110
|
+
_ && a.visuallyHidden,
|
|
111
|
+
u && a.required
|
|
120
112
|
].filter(Boolean).join(" ");
|
|
121
|
-
return /* @__PURE__ */
|
|
122
|
-
/* @__PURE__ */
|
|
123
|
-
|
|
124
|
-
|
|
113
|
+
return /* @__PURE__ */ d("div", { className: `${a.inputWrapper} ${i ? a.fullWidth : ""}`, children: [
|
|
114
|
+
/* @__PURE__ */ d("label", { htmlFor: s, className: N, children: [
|
|
115
|
+
m,
|
|
116
|
+
u && /* @__PURE__ */ d("span", { className: a.requiredIndicator, "aria-label": "required", children: [
|
|
117
|
+
" ",
|
|
118
|
+
"*"
|
|
119
|
+
] })
|
|
125
120
|
] }),
|
|
126
|
-
/* @__PURE__ */
|
|
121
|
+
/* @__PURE__ */ c(
|
|
127
122
|
"input",
|
|
128
123
|
{
|
|
129
|
-
ref:
|
|
130
|
-
id:
|
|
131
|
-
type:
|
|
132
|
-
className:
|
|
133
|
-
required:
|
|
134
|
-
disabled:
|
|
135
|
-
"aria-invalid":
|
|
136
|
-
"aria-describedby":
|
|
137
|
-
"aria-required":
|
|
138
|
-
...
|
|
124
|
+
ref: b,
|
|
125
|
+
id: s,
|
|
126
|
+
type: f,
|
|
127
|
+
className: j,
|
|
128
|
+
required: u,
|
|
129
|
+
disabled: h,
|
|
130
|
+
"aria-invalid": l ? !0 : void 0,
|
|
131
|
+
"aria-describedby": y,
|
|
132
|
+
"aria-required": u || void 0,
|
|
133
|
+
...p
|
|
139
134
|
}
|
|
140
135
|
),
|
|
141
|
-
e && !
|
|
142
|
-
|
|
136
|
+
e && !l && /* @__PURE__ */ c("span", { id: x, className: a.helperText, children: e }),
|
|
137
|
+
l && /* @__PURE__ */ c("span", { id: r, className: a.errorText, role: "alert", children: l })
|
|
143
138
|
] });
|
|
144
139
|
}
|
|
145
140
|
);
|
|
146
|
-
|
|
147
|
-
const
|
|
148
|
-
checkboxWrapper:
|
|
149
|
-
inputGroup:
|
|
150
|
-
checkbox:
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
141
|
+
re.displayName = "Input";
|
|
142
|
+
const se = "_checkboxWrapper_lv2u7_1", oe = "_inputGroup_lv2u7_7", ie = "_checkbox_lv2u7_1", te = "_indeterminate_lv2u7_49", de = "_error_lv2u7_76", ce = "_small_lv2u7_81", _e = "_large_lv2u7_94", ue = "_label_lv2u7_117", pe = "_disabled_lv2u7_125", be = "_requiredIndicator_lv2u7_130", he = "_helperText_lv2u7_135", me = "_errorText_lv2u7_142", n = {
|
|
143
|
+
checkboxWrapper: se,
|
|
144
|
+
inputGroup: oe,
|
|
145
|
+
checkbox: ie,
|
|
146
|
+
indeterminate: te,
|
|
147
|
+
error: de,
|
|
148
|
+
small: ce,
|
|
149
|
+
large: _e,
|
|
150
|
+
label: ue,
|
|
151
|
+
disabled: pe,
|
|
152
|
+
requiredIndicator: be,
|
|
153
|
+
helperText: he,
|
|
154
|
+
errorText: me
|
|
155
|
+
}, fe = $.forwardRef(
|
|
160
156
|
({
|
|
161
|
-
label:
|
|
162
|
-
size:
|
|
163
|
-
error:
|
|
164
|
-
helperText:
|
|
157
|
+
label: m,
|
|
158
|
+
size: f = "medium",
|
|
159
|
+
error: o,
|
|
160
|
+
helperText: l,
|
|
165
161
|
disabled: e = !1,
|
|
166
|
-
required:
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
162
|
+
required: i = !1,
|
|
163
|
+
indeterminate: _ = !1,
|
|
164
|
+
className: u,
|
|
165
|
+
id: h,
|
|
166
|
+
...v
|
|
167
|
+
}, g) => {
|
|
168
|
+
const p = W(null), b = g || p, k = I(), s = h || k, r = o ? `${s}-error` : void 0, x = l ? `${s}-helper` : void 0, y = [r, x].filter(Boolean).join(" ") || void 0;
|
|
169
|
+
T(() => {
|
|
170
|
+
b.current && (b.current.indeterminate = _);
|
|
171
|
+
}, [_, b]);
|
|
172
|
+
const j = [
|
|
173
|
+
n.checkbox,
|
|
174
|
+
n[f],
|
|
175
|
+
o && n.error,
|
|
176
|
+
e && n.disabled,
|
|
177
|
+
_ && n.indeterminate,
|
|
178
|
+
u
|
|
179
|
+
].filter(Boolean).join(" "), N = [n.label, e && n.disabled, i && n.required].filter(Boolean).join(" ");
|
|
180
|
+
return /* @__PURE__ */ d("div", { className: n.checkboxWrapper, children: [
|
|
181
|
+
/* @__PURE__ */ d("div", { className: n.inputGroup, children: [
|
|
182
|
+
/* @__PURE__ */ c(
|
|
185
183
|
"input",
|
|
186
184
|
{
|
|
187
|
-
ref:
|
|
188
|
-
id:
|
|
185
|
+
ref: b,
|
|
186
|
+
id: s,
|
|
189
187
|
type: "checkbox",
|
|
190
|
-
className:
|
|
188
|
+
className: j,
|
|
191
189
|
disabled: e,
|
|
192
|
-
required:
|
|
193
|
-
"aria-invalid":
|
|
194
|
-
"aria-describedby":
|
|
195
|
-
"aria-required":
|
|
196
|
-
|
|
190
|
+
required: i,
|
|
191
|
+
"aria-invalid": o ? !0 : void 0,
|
|
192
|
+
"aria-describedby": y,
|
|
193
|
+
"aria-required": i || void 0,
|
|
194
|
+
"aria-checked": _ ? "mixed" : void 0,
|
|
195
|
+
...v
|
|
197
196
|
}
|
|
198
197
|
),
|
|
199
|
-
/* @__PURE__ */
|
|
200
|
-
|
|
201
|
-
|
|
198
|
+
/* @__PURE__ */ d("label", { htmlFor: s, className: N, children: [
|
|
199
|
+
m,
|
|
200
|
+
i && /* @__PURE__ */ d("span", { className: n.requiredIndicator, "aria-label": "required", children: [
|
|
202
201
|
" ",
|
|
203
202
|
"*"
|
|
204
203
|
] })
|
|
205
204
|
] })
|
|
206
205
|
] }),
|
|
207
|
-
|
|
208
|
-
|
|
206
|
+
l && !o && /* @__PURE__ */ c("span", { id: x, className: n.helperText, children: l }),
|
|
207
|
+
o && /* @__PURE__ */ c("span", { id: r, className: n.errorText, role: "alert", children: o })
|
|
209
208
|
] });
|
|
210
209
|
}
|
|
211
210
|
);
|
|
212
|
-
|
|
211
|
+
fe.displayName = "Checkbox";
|
|
213
212
|
export {
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
213
|
+
A as Button,
|
|
214
|
+
fe as Checkbox,
|
|
215
|
+
re as Input
|
|
217
216
|
};
|
|
218
217
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/atoms/Button/Button.tsx","../src/atoms/Input/Input.tsx","../src/atoms/Checkbox/Checkbox.tsx"],"sourcesContent":["// src/atoms/Button/Button.tsx\nimport React from \"react\";\nimport styles from \"./Button.module.css\";\n\nexport interface ButtonProps\n extends React.ButtonHTMLAttributes<HTMLButtonElement> {\n variant?: \"primary\" | \"secondary\" | \"danger\";\n size?: \"small\" | \"medium\" | \"large\";\n children: React.ReactNode;\n loading?: boolean;\n fullWidth?: boolean;\n}\n\n/**\n * Accessible button component following WCAG 2.1 AA standards\n *\n * Features:\n * - Native <button> element for semantic HTML\n * - Full keyboard support (Tab, Enter, Space)\n * - Screen reader announcements for loading state\n * - Visible focus indicator\n * - Color contrast compliant\n *\n * @example\n * ```tsx\n * <Button variant=\"primary\" onClick={handleClick}>\n * Click me\n * </Button>\n *\n * <Button loading disabled>\n * Submitting...\n * </Button>\n * ```\n */\nexport const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(\n (\n {\n variant = \"primary\",\n size = \"medium\",\n children,\n disabled = false,\n loading = false,\n fullWidth = false,\n className,\n type = \"button\",\n onClick,\n ...props\n },\n ref\n ) => {\n const isDisabled = disabled || loading;\n\n // Handle click with disabled check (prevents action but keeps focusable)\n const handleClick = (event: React.MouseEvent<HTMLButtonElement>) => {\n if (isDisabled) {\n event.preventDefault();\n return;\n }\n onClick?.(event);\n };\n\n // Handle keyboard events to prevent action when disabled\n const handleKeyDown = (event: React.KeyboardEvent<HTMLButtonElement>) => {\n if (isDisabled && (event.key === \"Enter\" || event.key === \" \")) {\n event.preventDefault();\n }\n };\n\n const classNames = [\n styles.button,\n styles[variant],\n styles[size],\n loading && styles.loading,\n fullWidth && styles.fullWidth,\n isDisabled && styles.disabled,\n className,\n ]\n .filter(Boolean)\n .join(\" \");\n\n return (\n <button\n ref={ref}\n type={type}\n className={classNames}\n aria-disabled={isDisabled}\n aria-busy={loading || undefined}\n onClick={handleClick}\n onKeyDown={handleKeyDown}\n {...props}\n >\n {loading && (\n <span\n role=\"status\"\n aria-live=\"polite\"\n className={styles.loadingContainer}\n >\n <span className={styles.spinner} aria-hidden=\"true\" />\n <span className={styles.srOnly}>Loading...</span>\n </span>\n )}\n <span aria-hidden={loading || undefined}>{children}</span>\n </button>\n );\n }\n);\n\nButton.displayName = \"Button\";\n","import React, { useId } from \"react\";\nimport styles from \"./Input.module.css\";\n\nexport interface InputProps\n extends Omit<React.InputHTMLAttributes<HTMLInputElement>, \"size\"> {\n /**\n * Input label (required for accessibility)\n */\n label: string;\n\n /**\n * Input type\n * @default \"text\"\n */\n type?: \"text\" | \"email\" | \"password\" | \"tel\" | \"url\" | \"search\" | \"number\";\n\n /**\n * Input size\n * @default \"medium\"\n */\n size?: \"small\" | \"medium\" | \"large\";\n\n /**\n * Error message (when present, input is marked as invalid)\n */\n error?: string;\n\n /**\n * Helper text (additional description)\n */\n helperText?: string;\n\n /**\n * Full width input\n * @default false\n */\n fullWidth?: boolean;\n\n /**\n * Hide label visually but keep it for screen readers\n * @default false\n */\n hideLabel?: boolean;\n}\n\n/**\n * Accessible Input component following WCAG 2.1 AA standards\n *\n * Features:\n * - Native <input> element for semantic HTML\n * - Proper label association via htmlFor\n * - Error states with aria-invalid and aria-describedby\n * - Helper text support\n * - Visible focus indicator\n * - Required indicator\n *\n * @example\n * ```tsx\n * <Input\n * label=\"Email\"\n * type=\"email\"\n * required\n * error=\"Invalid email address\"\n * helperText=\"We'll never share your email\"\n * />\n * ```\n */\nexport const Input = React.forwardRef<HTMLInputElement, InputProps>(\n (\n {\n label,\n type = \"text\",\n size = \"medium\",\n error,\n helperText,\n fullWidth = false,\n hideLabel = false,\n required = false,\n disabled = false,\n className,\n id: providedId,\n ...props\n },\n ref\n ) => {\n // Generate unique IDs for accessibility\n const generatedId = useId();\n const id = providedId || generatedId;\n const errorId = error ? `${id}-error` : undefined;\n const helperTextId = helperText ? `${id}-helper` : undefined;\n\n // Build aria-describedby\n const describedBy = [errorId, helperTextId].filter(Boolean).join(\" \") || undefined;\n\n const inputClasses = [\n styles.input,\n styles[size],\n error && styles.error,\n disabled && styles.disabled,\n fullWidth && styles.fullWidth,\n className,\n ]\n .filter(Boolean)\n .join(\" \");\n\n const labelClasses = [\n styles.label,\n hideLabel && styles.visuallyHidden,\n required && styles.required,\n ]\n .filter(Boolean)\n .join(\" \");\n\n return (\n <div className={`${styles.inputWrapper} ${fullWidth ? styles.fullWidth : \"\"}`}>\n <label htmlFor={id} className={labelClasses}>\n {label}\n {required && <span className={styles.requiredIndicator} aria-label=\"required\"> *</span>}\n </label>\n\n <input\n ref={ref}\n id={id}\n type={type}\n className={inputClasses}\n required={required}\n disabled={disabled}\n aria-invalid={error ? true : undefined}\n aria-describedby={describedBy}\n aria-required={required || undefined}\n {...props}\n />\n\n {helperText && !error && (\n <span id={helperTextId} className={styles.helperText}>\n {helperText}\n </span>\n )}\n\n {error && (\n <span id={errorId} className={styles.errorText} role=\"alert\">\n {error}\n </span>\n )}\n </div>\n );\n }\n);\n\nInput.displayName = \"Input\";\n","import React, { useId } from \"react\";\nimport styles from \"./Checkbox.module.css\";\n\nexport interface CheckboxProps\n extends Omit<React.InputHTMLAttributes<HTMLInputElement>, \"size\" | \"type\"> {\n /**\n * Checkbox label (required for accessibility)\n */\n label: string;\n\n /**\n * Checkbox size\n * @default \"medium\"\n */\n size?: \"small\" | \"medium\" | \"large\";\n\n /**\n * Error message (when present, checkbox is marked as invalid)\n */\n error?: string;\n\n /**\n * Helper text (additional description)\n */\n helperText?: string;\n}\n\n/**\n * Accessible Checkbox component following WCAG 2.1 AA standards\n *\n * Features:\n * - Native <input type=\"checkbox\"> element for semantic HTML\n * - Proper label association via htmlFor\n * - Space key toggles checked state (native behavior)\n * - Error states with aria-invalid and aria-describedby\n * - Helper text support\n * - Visible focus indicator\n * - Required indicator\n *\n * @example\n * ```tsx\n * <Checkbox label=\"I agree to terms\" required />\n *\n * <Checkbox\n * label=\"Subscribe to newsletter\"\n * checked={isChecked}\n * onChange={(e) => setIsChecked(e.target.checked)}\n * error=\"This field is required\"\n * />\n * ```\n */\nexport const Checkbox = React.forwardRef<HTMLInputElement, CheckboxProps>(\n (\n {\n label,\n size = \"medium\",\n error,\n helperText,\n disabled = false,\n required = false,\n className,\n id: providedId,\n ...props\n },\n ref\n ) => {\n // Generate unique IDs for accessibility\n const generatedId = useId();\n const id = providedId || generatedId;\n const errorId = error ? `${id}-error` : undefined;\n const helperTextId = helperText ? `${id}-helper` : undefined;\n\n // Build aria-describedby\n const describedBy =\n [errorId, helperTextId].filter(Boolean).join(\" \") || undefined;\n\n const checkboxClasses = [\n styles.checkbox,\n styles[size],\n error && styles.error,\n disabled && styles.disabled,\n className,\n ]\n .filter(Boolean)\n .join(\" \");\n\n const labelClasses = [\n styles.label,\n disabled && styles.disabled,\n required && styles.required,\n ]\n .filter(Boolean)\n .join(\" \");\n\n return (\n <div className={styles.checkboxWrapper}>\n <div className={styles.inputGroup}>\n <input\n ref={ref}\n id={id}\n type=\"checkbox\"\n className={checkboxClasses}\n disabled={disabled}\n required={required}\n aria-invalid={error ? true : undefined}\n aria-describedby={describedBy}\n aria-required={required || undefined}\n {...props}\n />\n\n <label htmlFor={id} className={labelClasses}>\n {label}\n {required && (\n <span className={styles.requiredIndicator} aria-label=\"required\">\n {\" \"}\n *\n </span>\n )}\n </label>\n </div>\n\n {helperText && !error && (\n <span id={helperTextId} className={styles.helperText}>\n {helperText}\n </span>\n )}\n\n {error && (\n <span id={errorId} className={styles.errorText} role=\"alert\">\n {error}\n </span>\n )}\n </div>\n );\n }\n);\n\nCheckbox.displayName = \"Checkbox\";\n"],"names":["Button","React","variant","size","children","disabled","loading","fullWidth","className","type","onClick","props","ref","isDisabled","handleClick","event","handleKeyDown","classNames","styles","jsxs","jsx","Input","label","error","helperText","hideLabel","required","providedId","generatedId","useId","id","errorId","helperTextId","describedBy","inputClasses","labelClasses","Checkbox","checkboxClasses"],"mappings":";;;;;;;;;;;;;;;;;GAkCaA,IAASC,EAAM;AAAA,EAC1B,CACE;AAAA,IACE,SAAAC,IAAU;AAAA,IACV,MAAAC,IAAO;AAAA,IACP,UAAAC;AAAA,IACA,UAAAC,IAAW;AAAA,IACX,SAAAC,IAAU;AAAA,IACV,WAAAC,IAAY;AAAA,IACZ,WAAAC;AAAA,IACA,MAAAC,IAAO;AAAA,IACP,SAAAC;AAAA,IACA,GAAGC;AAAA,EAAA,GAELC,MACG;AACH,UAAMC,IAAaR,KAAYC,GAGzBQ,IAAc,CAACC,MAA+C;AAClE,UAAIF,GAAY;AACd,QAAAE,EAAM,eAAA;AACN;AAAA,MACF;AACA,MAAAL,IAAUK,CAAK;AAAA,IACjB,GAGMC,IAAgB,CAACD,MAAkD;AACvE,MAAIF,MAAeE,EAAM,QAAQ,WAAWA,EAAM,QAAQ,QACxDA,EAAM,eAAA;AAAA,IAEV,GAEME,IAAa;AAAA,MACjBC,EAAO;AAAA,MACPA,EAAOhB,CAAO;AAAA,MACdgB,EAAOf,CAAI;AAAA,MACXG,KAAWY,EAAO;AAAA,MAClBX,KAAaW,EAAO;AAAA,MACpBL,KAAcK,EAAO;AAAA,MAC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WAAWK,GAC5B,UAAA;AAAA,UAAAb;AAAA,UACAI,KACC,gBAAAP,EAAC,QAAA,EAAK,WAAWD,EAAO,mBAAmB,cAAW,YACnD,UAAA;AAAA,YAAA;AAAA,YAAI;AAAA,UAAA,EAAA,CAEP;AAAA,QAAA,EAAA,CAEJ;AAAA,MAAA,GACF;AAAA,MAECM,KAAc,CAACD,KACd,gBAAAH,EAAC,QAAA,EAAK,IAAIY,GAAc,WAAWd,EAAO,YACvC,UAAAM,EAAA,CACH;AAAA,MAGDD,KACC,gBAAAH,EAAC,QAAA,EAAK,IAAIW,GAAS,WAAWb,EAAO,WAAW,MAAK,SAClD,UAAAK,EAAA,CACH;AAAA,IAAA,GAEJ;AAAA,EAEJ;AACF;AAEAa,GAAS,cAAc;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/atoms/Button/Button.tsx","../src/atoms/Input/Input.tsx","../src/atoms/Checkbox/Checkbox.tsx"],"sourcesContent":["// src/atoms/Button/Button.tsx\nimport React from 'react';\nimport styles from './Button.module.css';\n\nexport interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {\n variant?: 'primary' | 'secondary' | 'danger';\n size?: 'small' | 'medium' | 'large';\n children: React.ReactNode;\n loading?: boolean;\n fullWidth?: boolean;\n}\n\n/**\n * Accessible button component following WCAG 2.1 AA standards\n *\n * Features:\n * - Native <button> element for semantic HTML\n * - Full keyboard support (Tab, Enter, Space)\n * - Screen reader announcements for loading state\n * - Visible focus indicator\n * - Color contrast compliant\n *\n * @example\n * ```tsx\n * <Button variant=\"primary\" onClick={handleClick}>\n * Click me\n * </Button>\n *\n * <Button loading disabled>\n * Submitting...\n * </Button>\n * ```\n */\nexport const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(\n (\n {\n variant = 'primary',\n size = 'medium',\n children,\n disabled = false,\n loading = false,\n fullWidth = false,\n className,\n type = 'button',\n onClick,\n ...props\n },\n ref\n ) => {\n const isDisabled = disabled || loading;\n\n // Handle click with disabled check (prevents action but keeps focusable)\n const handleClick = (event: React.MouseEvent<HTMLButtonElement>) => {\n if (isDisabled) {\n event.preventDefault();\n return;\n }\n onClick?.(event);\n };\n\n // Handle keyboard events to prevent action when disabled\n const handleKeyDown = (event: React.KeyboardEvent<HTMLButtonElement>) => {\n if (isDisabled && (event.key === 'Enter' || event.key === ' ')) {\n event.preventDefault();\n }\n };\n\n const classNames = [\n styles.button,\n styles[variant],\n styles[size],\n loading && styles.loading,\n fullWidth && styles.fullWidth,\n isDisabled && styles.disabled,\n className,\n ]\n .filter(Boolean)\n .join(' ');\n\n return (\n <button\n ref={ref}\n type={type}\n className={classNames}\n aria-disabled={isDisabled}\n aria-busy={loading || undefined}\n onClick={handleClick}\n onKeyDown={handleKeyDown}\n {...props}\n >\n {loading && (\n <span role=\"status\" aria-live=\"polite\" className={styles.loadingContainer}>\n <span className={styles.spinner} aria-hidden=\"true\" />\n <span className={styles.srOnly}>Loading...</span>\n </span>\n )}\n <span aria-hidden={loading || undefined}>{children}</span>\n </button>\n );\n }\n);\n\nButton.displayName = 'Button';\n","import React, { useId } from 'react';\nimport styles from './Input.module.css';\n\nexport interface InputProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'size'> {\n /**\n * Input label (required for accessibility)\n */\n label: string;\n\n /**\n * Input type\n * @default \"text\"\n */\n type?: 'text' | 'email' | 'password' | 'tel' | 'url' | 'search' | 'number';\n\n /**\n * Input size\n * @default \"medium\"\n */\n size?: 'small' | 'medium' | 'large';\n\n /**\n * Error message (when present, input is marked as invalid)\n */\n error?: string;\n\n /**\n * Helper text (additional description)\n */\n helperText?: string;\n\n /**\n * Full width input\n * @default false\n */\n fullWidth?: boolean;\n\n /**\n * Hide label visually but keep it for screen readers\n * @default false\n */\n hideLabel?: boolean;\n}\n\n/**\n * Accessible Input component following WCAG 2.1 AA standards\n *\n * Features:\n * - Native <input> element for semantic HTML\n * - Proper label association via htmlFor\n * - Error states with aria-invalid and aria-describedby\n * - Helper text support\n * - Visible focus indicator\n * - Required indicator\n *\n * @example\n * ```tsx\n * <Input\n * label=\"Email\"\n * type=\"email\"\n * required\n * error=\"Invalid email address\"\n * helperText=\"We'll never share your email\"\n * />\n * ```\n */\nexport const Input = React.forwardRef<HTMLInputElement, InputProps>(\n (\n {\n label,\n type = 'text',\n size = 'medium',\n error,\n helperText,\n fullWidth = false,\n hideLabel = false,\n required = false,\n disabled = false,\n className,\n id: providedId,\n ...props\n },\n ref\n ) => {\n // Generate unique IDs for accessibility\n const generatedId = useId();\n const id = providedId || generatedId;\n const errorId = error ? `${id}-error` : undefined;\n const helperTextId = helperText ? `${id}-helper` : undefined;\n\n // Build aria-describedby\n const describedBy = [errorId, helperTextId].filter(Boolean).join(' ') || undefined;\n\n const inputClasses = [\n styles.input,\n styles[size],\n error && styles.error,\n disabled && styles.disabled,\n fullWidth && styles.fullWidth,\n className,\n ]\n .filter(Boolean)\n .join(' ');\n\n const labelClasses = [\n styles.label,\n hideLabel && styles.visuallyHidden,\n required && styles.required,\n ]\n .filter(Boolean)\n .join(' ');\n\n return (\n <div className={`${styles.inputWrapper} ${fullWidth ? styles.fullWidth : ''}`}>\n <label htmlFor={id} className={labelClasses}>\n {label}\n {required && (\n <span className={styles.requiredIndicator} aria-label=\"required\">\n {' '}\n *\n </span>\n )}\n </label>\n\n <input\n ref={ref}\n id={id}\n type={type}\n className={inputClasses}\n required={required}\n disabled={disabled}\n aria-invalid={error ? true : undefined}\n aria-describedby={describedBy}\n aria-required={required || undefined}\n {...props}\n />\n\n {helperText && !error && (\n <span id={helperTextId} className={styles.helperText}>\n {helperText}\n </span>\n )}\n\n {error && (\n <span id={errorId} className={styles.errorText} role=\"alert\">\n {error}\n </span>\n )}\n </div>\n );\n }\n);\n\nInput.displayName = 'Input';\n","import React, { useId, useEffect, useRef } from 'react';\nimport styles from './Checkbox.module.css';\n\nexport interface CheckboxProps extends Omit<\n React.InputHTMLAttributes<HTMLInputElement>,\n 'size' | 'type'\n> {\n label: string;\n size?: 'small' | 'medium' | 'large';\n error?: string;\n helperText?: string;\n indeterminate?: boolean;\n}\n\nexport const Checkbox = React.forwardRef<HTMLInputElement, CheckboxProps>(\n (\n {\n label,\n size = 'medium',\n error,\n helperText,\n disabled = false,\n required = false,\n indeterminate = false,\n className,\n id: providedId,\n ...props\n },\n ref\n ) => {\n const internalRef = useRef<HTMLInputElement>(null);\n const checkboxRef = (ref as React.RefObject<HTMLInputElement>) || internalRef;\n\n const generatedId = useId();\n const id = providedId || generatedId;\n const errorId = error ? `${id}-error` : undefined;\n const helperTextId = helperText ? `${id}-helper` : undefined;\n\n const describedBy = [errorId, helperTextId].filter(Boolean).join(' ') || undefined;\n\n useEffect(() => {\n if (checkboxRef.current) {\n checkboxRef.current.indeterminate = indeterminate;\n }\n }, [indeterminate, checkboxRef]);\n\n const checkboxClasses = [\n styles.checkbox,\n styles[size],\n error && styles.error,\n disabled && styles.disabled,\n indeterminate && styles.indeterminate,\n className,\n ]\n .filter(Boolean)\n .join(' ');\n\n const labelClasses = [styles.label, disabled && styles.disabled, required && styles.required]\n .filter(Boolean)\n .join(' ');\n\n return (\n <div className={styles.checkboxWrapper}>\n <div className={styles.inputGroup}>\n <input\n ref={checkboxRef}\n id={id}\n type=\"checkbox\"\n className={checkboxClasses}\n disabled={disabled}\n required={required}\n aria-invalid={error ? true : undefined}\n aria-describedby={describedBy}\n aria-required={required || undefined}\n aria-checked={indeterminate ? 'mixed' : undefined}\n {...props}\n />\n\n <label htmlFor={id} className={labelClasses}>\n {label}\n {required && (\n <span className={styles.requiredIndicator} aria-label=\"required\">\n {' '}\n *\n </span>\n )}\n </label>\n </div>\n\n {helperText && !error && (\n <span id={helperTextId} className={styles.helperText}>\n {helperText}\n </span>\n )}\n\n {error && (\n <span id={errorId} className={styles.errorText} role=\"alert\">\n {error}\n </span>\n )}\n </div>\n );\n }\n);\n\nCheckbox.displayName = 'Checkbox';\n"],"names":["Button","React","variant","size","children","disabled","loading","fullWidth","className","type","onClick","props","ref","isDisabled","handleClick","event","handleKeyDown","classNames","styles","jsxs","jsx","Input","label","error","helperText","hideLabel","required","providedId","generatedId","useId","id","errorId","helperTextId","describedBy","inputClasses","labelClasses","Checkbox","indeterminate","internalRef","useRef","checkboxRef","useEffect","checkboxClasses"],"mappings":";;;;;;;;;;;;;;;;;GAiCaA,IAASC,EAAM;AAAA,EAC1B,CACE;AAAA,IACE,SAAAC,IAAU;AAAA,IACV,MAAAC,IAAO;AAAA,IACP,UAAAC;AAAA,IACA,UAAAC,IAAW;AAAA,IACX,SAAAC,IAAU;AAAA,IACV,WAAAC,IAAY;AAAA,IACZ,WAAAC;AAAA,IACA,MAAAC,IAAO;AAAA,IACP,SAAAC;AAAA,IACA,GAAGC;AAAA,EAAA,GAELC,MACG;AACH,UAAMC,IAAaR,KAAYC,GAGzBQ,IAAc,CAACC,MAA+C;AAClE,UAAIF,GAAY;AACd,QAAAE,EAAM,eAAA;AACN;AAAA,MACF;AACA,MAAAL,IAAUK,CAAK;AAAA,IACjB,GAGMC,IAAgB,CAACD,MAAkD;AACvE,MAAIF,MAAeE,EAAM,QAAQ,WAAWA,EAAM,QAAQ,QACxDA,EAAM,eAAA;AAAA,IAEV,GAEME,IAAa;AAAA,MACjBC,EAAO;AAAA,MACPA,EAAOhB,CAAO;AAAA,MACdgB,EAAOf,CAAI;AAAA,MACXG,KAAWY,EAAO;AAAA,MAClBX,KAAaW,EAAO;AAAA,MACpBL,KAAcK,EAAO;AAAA,MACrBV;AAAA,IAAA,EAEC,OAAO,OAAO,EACd,KAAK,GAAG;AAEX,WACE,gBAAAW;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,KAAAP;AAAA,QACA,MAAAH;AAAA,QACA,WAAWQ;AAAA,QACX,iBAAeJ;AAAA,QACf,aAAWP,KAAW;AAAA,QACtB,SAASQ;AAAA,QACT,WAAWE;AAAA,QACV,GAAGL;AAAA,QAEH,UAAA;AAAA,UAAAL,KACC,gBAAAa,EAAC,UAAK,MAAK,UAAS,aAAU,UAAS,WAAW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AAW,YACnD,UAAA;AAAA,YAAA;AAAA,YAAI;AAAA,UAAA,EAAA,CAEP;AAAA,QAAA,EAAA,CAEJ;AAAA,MAAA,GACF;AAAA,MAECM,KAAc,CAACD,KACd,gBAAAH,EAAC,QAAA,EAAK,IAAIY,GAAc,WAAWd,EAAO,YACvC,UAAAM,EAAA,CACH;AAAA,MAGDD,KACC,gBAAAH,EAAC,QAAA,EAAK,IAAIW,GAAS,WAAWb,EAAO,WAAW,MAAK,SAClD,UAAAK,EAAA,CACH;AAAA,IAAA,GAEJ;AAAA,EAEJ;AACF;AAEAa,GAAS,cAAc;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flavia-dev/a11y-ui-kit-react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Enterprise-grade accessible React components library following WCAG 2.1 AA/AAA standards. Production-ready, type-safe, and fully customizable UI components with built-in accessibility.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -22,10 +22,9 @@
|
|
|
22
22
|
"build": "tsc && vite build",
|
|
23
23
|
"test": "vitest run",
|
|
24
24
|
"test:watch": "vitest",
|
|
25
|
-
"test:unit": "vitest run --reporter=verbose
|
|
26
|
-
"test:
|
|
27
|
-
"test:
|
|
28
|
-
"test:contrast": "vitest run --reporter=verbose --run src/test/color-contrast.test.ts",
|
|
25
|
+
"test:unit": "vitest run --reporter=verbose src --exclude=\"src/**/*.a11y.test.tsx\"",
|
|
26
|
+
"test:a11y": "vitest run --reporter=verbose src/atoms/Button/Button.a11y.test.tsx src/atoms/Input/Input.a11y.test.tsx src/atoms/Checkbox/Checkbox.a11y.test.tsx src/atoms/Radio/Radio.a11y.test.tsx src/atoms/Icon/Icon.a11y.test.tsx",
|
|
27
|
+
"test:e2e": "playwright test tests/e2e",
|
|
29
28
|
"test:coverage": "vitest run --coverage",
|
|
30
29
|
"test:ui": "vitest --ui",
|
|
31
30
|
"test:visual": "playwright test tests/visual",
|
|
@@ -35,14 +34,22 @@
|
|
|
35
34
|
"test:visual:input": "playwright test tests/visual/Input.visual.test.ts",
|
|
36
35
|
"test:visual:button:update": "playwright test tests/visual/Button.visual.test.ts --update-snapshots",
|
|
37
36
|
"test:visual:input:update": "playwright test tests/visual/Input.visual.test.ts --update-snapshots",
|
|
38
|
-
"test:e2e": "playwright test tests/e2e",
|
|
39
37
|
"test:e2e:button": "playwright test tests/e2e/Button.e2e.test.ts",
|
|
40
38
|
"test:e2e:input": "playwright test tests/e2e/Input.e2e.test.ts",
|
|
39
|
+
"test:e2e:radio": "playwright test tests/e2e/Radio.e2e.test.ts",
|
|
40
|
+
"test:e2e:checkbox": "playwright test tests/e2e/Checkbox.e2e.test.ts",
|
|
41
|
+
"test:e2e:icon": "playwright test tests/e2e/Icon.e2e.test.ts",
|
|
41
42
|
"test:e2e:ui": "playwright test tests/e2e --ui",
|
|
42
43
|
"test:playwright": "playwright test",
|
|
43
44
|
"storybook": "storybook dev -p 6006",
|
|
44
45
|
"build-storybook": "storybook build",
|
|
45
|
-
"typecheck": "tsc --noEmit"
|
|
46
|
+
"typecheck": "tsc --noEmit",
|
|
47
|
+
"lint": "eslint src --ext .ts,.tsx",
|
|
48
|
+
"lint:fix": "eslint src --ext .ts,.tsx --fix",
|
|
49
|
+
"format": "prettier --write \"src/**/*.{ts,tsx,css}\"",
|
|
50
|
+
"format:check": "prettier --check \"src/**/*.{ts,tsx,css}\"",
|
|
51
|
+
"prepublishOnly": "npm run typecheck && npm run build",
|
|
52
|
+
"prepare": "husky"
|
|
46
53
|
},
|
|
47
54
|
"keywords": [
|
|
48
55
|
"react",
|
|
@@ -54,7 +61,7 @@
|
|
|
54
61
|
"button",
|
|
55
62
|
"typescript"
|
|
56
63
|
],
|
|
57
|
-
"author": "
|
|
64
|
+
"author": "Flavia",
|
|
58
65
|
"license": "MIT",
|
|
59
66
|
"repository": {
|
|
60
67
|
"type": "git",
|
|
@@ -70,6 +77,8 @@
|
|
|
70
77
|
},
|
|
71
78
|
"devDependencies": {
|
|
72
79
|
"@axe-core/react": "^4.11.0",
|
|
80
|
+
"@eslint/eslintrc": "^3.3.3",
|
|
81
|
+
"@eslint/js": "^9.39.2",
|
|
73
82
|
"@playwright/test": "^1.57.0",
|
|
74
83
|
"@storybook/addon-a11y": "^8.6.14",
|
|
75
84
|
"@storybook/addon-essentials": "^8.6.14",
|
|
@@ -84,17 +93,41 @@
|
|
|
84
93
|
"@types/node": "^25.0.2",
|
|
85
94
|
"@types/react": "^19.2.7",
|
|
86
95
|
"@types/react-dom": "^19.2.3",
|
|
96
|
+
"@typescript-eslint/eslint-plugin": "^8.53.1",
|
|
97
|
+
"@typescript-eslint/parser": "^8.53.1",
|
|
87
98
|
"@vitejs/plugin-react": "^5.1.2",
|
|
88
99
|
"@vitest/ui": "^4.0.15",
|
|
89
100
|
"axe-core": "^4.11.0",
|
|
101
|
+
"eslint": "^9.39.2",
|
|
102
|
+
"eslint-config-prettier": "^10.1.8",
|
|
103
|
+
"eslint-plugin-jsx-a11y": "^6.10.2",
|
|
104
|
+
"eslint-plugin-react": "^7.37.5",
|
|
105
|
+
"eslint-plugin-react-hooks": "^7.0.1",
|
|
106
|
+
"eslint-plugin-react-refresh": "^0.4.26",
|
|
107
|
+
"husky": "^9.1.7",
|
|
90
108
|
"jest-axe": "^10.0.0",
|
|
91
109
|
"jsdom": "^27.3.0",
|
|
110
|
+
"lint-staged": "^16.2.7",
|
|
111
|
+
"prettier": "^3.8.0",
|
|
92
112
|
"react": "^19.2.3",
|
|
93
113
|
"react-dom": "^19.2.3",
|
|
94
114
|
"storybook": "^8.6.14",
|
|
95
115
|
"typescript": "^5.9.3",
|
|
116
|
+
"typescript-eslint": "^8.53.1",
|
|
96
117
|
"vite": "^7.3.0",
|
|
97
118
|
"vite-plugin-dts": "^4.5.4",
|
|
98
119
|
"vitest": "^4.0.15"
|
|
120
|
+
},
|
|
121
|
+
"lint-staged": {
|
|
122
|
+
"src/**/*.{ts,tsx}": [
|
|
123
|
+
"prettier --write",
|
|
124
|
+
"eslint --fix"
|
|
125
|
+
],
|
|
126
|
+
"src/**/*.css": [
|
|
127
|
+
"prettier --write"
|
|
128
|
+
]
|
|
129
|
+
},
|
|
130
|
+
"dependencies": {
|
|
131
|
+
"lucide-react": "^0.562.0"
|
|
99
132
|
}
|
|
100
133
|
}
|