@tonyarbor/components 0.1.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (126) hide show
  1. package/dist/Banner.d.mts +59 -0
  2. package/dist/Banner.d.ts +59 -0
  3. package/dist/Banner.js +222 -0
  4. package/dist/Banner.js.map +1 -0
  5. package/dist/Banner.mjs +7 -0
  6. package/dist/Banner.mjs.map +1 -0
  7. package/dist/Checkbox.d.mts +52 -0
  8. package/dist/Checkbox.d.ts +52 -0
  9. package/dist/Checkbox.js +194 -0
  10. package/dist/Checkbox.js.map +1 -0
  11. package/dist/Checkbox.mjs +7 -0
  12. package/dist/Checkbox.mjs.map +1 -0
  13. package/dist/Combobox.d.mts +67 -0
  14. package/dist/Combobox.d.ts +67 -0
  15. package/dist/Combobox.js +329 -0
  16. package/dist/Combobox.js.map +1 -0
  17. package/dist/Combobox.mjs +7 -0
  18. package/dist/Combobox.mjs.map +1 -0
  19. package/dist/DatePicker.d.mts +68 -0
  20. package/dist/DatePicker.d.ts +68 -0
  21. package/dist/DatePicker.js +490 -0
  22. package/dist/DatePicker.js.map +1 -0
  23. package/dist/DatePicker.mjs +7 -0
  24. package/dist/DatePicker.mjs.map +1 -0
  25. package/dist/NumericInput.d.mts +68 -0
  26. package/dist/NumericInput.d.ts +68 -0
  27. package/dist/NumericInput.js +319 -0
  28. package/dist/NumericInput.js.map +1 -0
  29. package/dist/NumericInput.mjs +7 -0
  30. package/dist/NumericInput.mjs.map +1 -0
  31. package/dist/Pagination.d.mts +36 -0
  32. package/dist/Pagination.d.ts +36 -0
  33. package/dist/Pagination.js +301 -0
  34. package/dist/Pagination.js.map +1 -0
  35. package/dist/Pagination.mjs +7 -0
  36. package/dist/Pagination.mjs.map +1 -0
  37. package/dist/Radio.d.mts +48 -0
  38. package/dist/Radio.d.ts +48 -0
  39. package/dist/Radio.js +194 -0
  40. package/dist/Radio.js.map +1 -0
  41. package/dist/Radio.mjs +7 -0
  42. package/dist/Radio.mjs.map +1 -0
  43. package/dist/Table.d.mts +80 -0
  44. package/dist/Table.d.ts +80 -0
  45. package/dist/Table.js +347 -0
  46. package/dist/Table.js.map +1 -0
  47. package/dist/Table.mjs +8 -0
  48. package/dist/Table.mjs.map +1 -0
  49. package/dist/TableControls.d.mts +76 -0
  50. package/dist/TableControls.d.ts +76 -0
  51. package/dist/TableControls.js +461 -0
  52. package/dist/TableControls.js.map +1 -0
  53. package/dist/TableControls.mjs +7 -0
  54. package/dist/TableControls.mjs.map +1 -0
  55. package/dist/TableFooterPagination.d.mts +56 -0
  56. package/dist/TableFooterPagination.d.ts +56 -0
  57. package/dist/TableFooterPagination.js +499 -0
  58. package/dist/TableFooterPagination.js.map +1 -0
  59. package/dist/TableFooterPagination.mjs +7 -0
  60. package/dist/TableFooterPagination.mjs.map +1 -0
  61. package/dist/Tabs.d.mts +50 -0
  62. package/dist/Tabs.d.ts +50 -0
  63. package/dist/Tabs.js +187 -0
  64. package/dist/Tabs.js.map +1 -0
  65. package/dist/Tabs.mjs +7 -0
  66. package/dist/Tabs.mjs.map +1 -0
  67. package/dist/TextArea.d.mts +64 -0
  68. package/dist/TextArea.d.ts +64 -0
  69. package/dist/TextArea.js +171 -0
  70. package/dist/TextArea.js.map +1 -0
  71. package/dist/TextArea.mjs +7 -0
  72. package/dist/TextArea.mjs.map +1 -0
  73. package/dist/Toast.d.mts +48 -0
  74. package/dist/Toast.d.ts +48 -0
  75. package/dist/Toast.js +169 -0
  76. package/dist/Toast.js.map +1 -0
  77. package/dist/Toast.mjs +7 -0
  78. package/dist/Toast.mjs.map +1 -0
  79. package/dist/Toggle.d.mts +48 -0
  80. package/dist/Toggle.d.ts +48 -0
  81. package/dist/Toggle.js +291 -0
  82. package/dist/Toggle.js.map +1 -0
  83. package/dist/Toggle.mjs +7 -0
  84. package/dist/Toggle.mjs.map +1 -0
  85. package/dist/Tooltip.d.mts +32 -0
  86. package/dist/Tooltip.d.ts +32 -0
  87. package/dist/Tooltip.js +109 -0
  88. package/dist/Tooltip.js.map +1 -0
  89. package/dist/Tooltip.mjs +7 -0
  90. package/dist/Tooltip.mjs.map +1 -0
  91. package/dist/chunk-52TG3BFX.mjs +463 -0
  92. package/dist/chunk-52TG3BFX.mjs.map +1 -0
  93. package/dist/chunk-5BUXFTPW.mjs +283 -0
  94. package/dist/chunk-5BUXFTPW.mjs.map +1 -0
  95. package/dist/chunk-7OWLBYNM.mjs +293 -0
  96. package/dist/chunk-7OWLBYNM.mjs.map +1 -0
  97. package/dist/chunk-AI2U34CF.mjs +159 -0
  98. package/dist/chunk-AI2U34CF.mjs.map +1 -0
  99. package/dist/chunk-C25FFMRQ.mjs +255 -0
  100. package/dist/chunk-C25FFMRQ.mjs.map +1 -0
  101. package/dist/chunk-CUTYEIFE.mjs +158 -0
  102. package/dist/chunk-CUTYEIFE.mjs.map +1 -0
  103. package/dist/chunk-DULH2KRW.mjs +133 -0
  104. package/dist/chunk-DULH2KRW.mjs.map +1 -0
  105. package/dist/chunk-G5NVKF2G.mjs +434 -0
  106. package/dist/chunk-G5NVKF2G.mjs.map +1 -0
  107. package/dist/chunk-M6DVBEEL.mjs +158 -0
  108. package/dist/chunk-M6DVBEEL.mjs.map +1 -0
  109. package/dist/chunk-MBUMR2XJ.mjs +135 -0
  110. package/dist/chunk-MBUMR2XJ.mjs.map +1 -0
  111. package/dist/chunk-MNH2TGUX.mjs +73 -0
  112. package/dist/chunk-MNH2TGUX.mjs.map +1 -0
  113. package/dist/chunk-RRMG2SSZ.mjs +265 -0
  114. package/dist/chunk-RRMG2SSZ.mjs.map +1 -0
  115. package/dist/chunk-U4JXKZZG.mjs +186 -0
  116. package/dist/chunk-U4JXKZZG.mjs.map +1 -0
  117. package/dist/chunk-W55QJIAN.mjs +467 -0
  118. package/dist/chunk-W55QJIAN.mjs.map +1 -0
  119. package/dist/chunk-YV4OXFIM.mjs +151 -0
  120. package/dist/chunk-YV4OXFIM.mjs.map +1 -0
  121. package/dist/index.d.mts +22 -1
  122. package/dist/index.d.ts +22 -1
  123. package/dist/index.js +3559 -2
  124. package/dist/index.js.map +1 -1
  125. package/dist/index.mjs +61 -1
  126. package/package.json +81 -3
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/TableFooterPagination/TableFooterPagination.tsx"],"sourcesContent":["import * as React from 'react';\nimport { clsx } from 'clsx';\nimport { ChevronDown } from 'lucide-react';\n\nexport interface TableFooterPaginationProps {\n /**\n * Current page number (1-indexed)\n */\n currentPage: number;\n /**\n * Total number of pages\n */\n totalPages: number;\n /**\n * Callback when page changes\n */\n onPageChange: (page: number) => void;\n /**\n * Total number of results\n */\n totalResults: number;\n /**\n * Number of results currently showing\n */\n currentResults: number;\n /**\n * Items per page\n */\n itemsPerPage: number;\n /**\n * Callback when items per page changes\n */\n onItemsPerPageChange?: (itemsPerPage: number) => void;\n /**\n * Callback when expand table is clicked\n */\n onExpandTable?: () => void;\n /**\n * Custom className\n */\n className?: string;\n /**\n * Custom style\n */\n style?: React.CSSProperties;\n /**\n * Test ID for testing\n */\n 'data-testid'?: string;\n}\n\nconst containerStyles: React.CSSProperties = {\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'space-between',\n backgroundColor: 'white',\n paddingTop: '4px',\n paddingBottom: 0,\n paddingLeft: 0,\n paddingRight: 0,\n fontFamily: \"'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif\",\n};\n\nconst textStyles: React.CSSProperties = {\n fontSize: '13px',\n fontWeight: 400,\n lineHeight: '1.5',\n color: '#2f2f2f',\n minWidth: '165px',\n};\n\nconst paginationWrapperStyles: React.CSSProperties = {\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n gap: '8px',\n minWidth: '165px',\n flexWrap: 'wrap',\n};\n\nconst paginationButtonStyles: React.CSSProperties = {\n width: '32px',\n height: '32px',\n minWidth: '32px',\n minHeight: '32px',\n maxWidth: '32px',\n maxHeight: '32px',\n borderRadius: '99px',\n border: 'none',\n background: 'white',\n cursor: 'pointer',\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n padding: 0,\n transition: 'background-color 0.2s ease-in-out, box-shadow 0.2s ease-in-out',\n flexShrink: 0,\n WebkitTapHighlightColor: 'transparent',\n outline: 'none',\n};\n\nconst paginationButtonDisabledStyles: React.CSSProperties = {\n cursor: 'not-allowed',\n opacity: 0.5,\n};\n\nconst paginationLabelStyles: React.CSSProperties = {\n fontSize: '13px',\n fontWeight: 400,\n lineHeight: '1.5',\n color: '#2f2f2f',\n};\n\nconst paginationInputWrapperStyles: React.CSSProperties = {\n display: 'flex',\n alignItems: 'center',\n gap: '8px',\n};\n\nconst paginationInputStyles: React.CSSProperties = {\n width: '60px',\n paddingTop: '12px',\n paddingBottom: '12px',\n paddingLeft: '16px',\n paddingRight: '16px',\n fontSize: '13px',\n fontWeight: 400,\n lineHeight: '1.5',\n color: '#2f2f2f',\n backgroundColor: 'white',\n border: '1px solid #dfdfdf',\n borderRadius: '8px',\n fontFamily: 'inherit',\n textAlign: 'center',\n outline: 'none',\n};\n\nconst paginationInputFocusStyles: React.CSSProperties = {\n boxShadow: '0px 0px 0px 3px #3cad51',\n};\n\nconst rightAlignedStyles: React.CSSProperties = {\n display: 'flex',\n gap: '16px',\n alignItems: 'center',\n justifyContent: 'flex-end',\n minWidth: '165px',\n};\n\nconst perPageButtonStyles: React.CSSProperties = {\n height: '32px',\n backgroundColor: 'white',\n border: '1px solid #d1d1d1',\n borderRadius: '8px',\n display: 'flex',\n alignItems: 'center',\n gap: '8px',\n paddingLeft: '12px',\n paddingRight: '8px',\n paddingTop: '8px',\n paddingBottom: '8px',\n cursor: 'pointer',\n transition: 'background-color 0.2s ease-in-out',\n outline: 'none',\n};\n\nconst perPageTextStyles: React.CSSProperties = {\n fontSize: '13px',\n fontWeight: 600,\n lineHeight: '1.5',\n color: '#2f2f2f',\n textAlign: 'center',\n};\n\nconst expandButtonStyles: React.CSSProperties = {\n height: '32px',\n minHeight: '32px',\n backgroundColor: '#efefef',\n border: 'none',\n borderRadius: '99px',\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n paddingLeft: '16px',\n paddingRight: '16px',\n paddingTop: 0,\n paddingBottom: 0,\n gap: 0,\n cursor: 'pointer',\n transition: 'background-color 0.2s ease-in-out',\n outline: 'none',\n};\n\nconst expandButtonTextStyles: React.CSSProperties = {\n fontSize: '13px',\n fontWeight: 600,\n lineHeight: '1.5',\n color: '#2f2f2f',\n textAlign: 'center',\n};\n\n/**\n * TableFooterPagination component - Arbor Design System\n *\n * A table footer component with result count, pagination, and table controls.\n */\nexport const TableFooterPagination = React.forwardRef<\n HTMLDivElement,\n TableFooterPaginationProps\n>(\n (\n {\n currentPage,\n totalPages,\n onPageChange,\n totalResults,\n currentResults,\n itemsPerPage,\n onItemsPerPageChange,\n onExpandTable,\n className,\n style,\n 'data-testid': dataTestId,\n },\n ref\n ) => {\n const [inputValue, setInputValue] = React.useState(currentPage.toString());\n const [focusedButton, setFocusedButton] = React.useState<string | null>(null);\n const [hoveredButton, setHoveredButton] = React.useState<string | null>(null);\n const [activeButton, setActiveButton] = React.useState<string | null>(null);\n const [inputFocused, setInputFocused] = React.useState(false);\n const [perPageHovered, setPerPageHovered] = React.useState(false);\n const [expandHovered, setExpandHovered] = React.useState(false);\n\n React.useEffect(() => {\n setInputValue(currentPage.toString());\n }, [currentPage]);\n\n const handleFirstPage = () => {\n if (currentPage !== 1) {\n onPageChange(1);\n }\n };\n\n const handlePreviousPage = () => {\n if (currentPage > 1) {\n onPageChange(currentPage - 1);\n }\n };\n\n const handleNextPage = () => {\n if (currentPage < totalPages) {\n onPageChange(currentPage + 1);\n }\n };\n\n const handleLastPage = () => {\n if (currentPage !== totalPages) {\n onPageChange(totalPages);\n }\n };\n\n const handleInputChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n const value = e.target.value;\n if (value === '' || /^\\d+$/.test(value)) {\n setInputValue(value);\n }\n };\n\n const handleInputBlur = () => {\n setInputFocused(false);\n const pageNumber = parseInt(inputValue, 10);\n if (isNaN(pageNumber) || pageNumber < 1) {\n setInputValue(currentPage.toString());\n } else if (pageNumber > totalPages) {\n setInputValue(totalPages.toString());\n onPageChange(totalPages);\n } else if (pageNumber !== currentPage) {\n onPageChange(pageNumber);\n }\n };\n\n const handleInputKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {\n if (e.key === 'Enter') {\n handleInputBlur();\n (e.target as HTMLInputElement).blur();\n }\n };\n\n const getButtonStyle = (\n buttonName: string,\n disabled: boolean\n ): React.CSSProperties => {\n if (disabled) {\n return { ...paginationButtonStyles, ...paginationButtonDisabledStyles };\n }\n\n const isHovered = hoveredButton === buttonName;\n const isFocused = focusedButton === buttonName;\n const isActive = activeButton === buttonName;\n\n const style: React.CSSProperties = {\n ...paginationButtonStyles,\n };\n\n if (isHovered && !isFocused && !isActive) {\n style.backgroundColor = '#efefef';\n }\n\n if (isActive && !isFocused) {\n style.backgroundColor = 'transparent';\n }\n\n if (isFocused) {\n style.boxShadow = '0px 0px 0px 3px #3cad51';\n style.backgroundColor = 'rgba(255, 255, 255, 0.01)';\n }\n\n return style;\n };\n\n const isFirstDisabled = currentPage === 1;\n const isPreviousDisabled = currentPage === 1;\n const isNextDisabled = currentPage === totalPages;\n const isLastDisabled = currentPage === totalPages;\n\n const resultText =\n currentResults === totalResults\n ? `Showing ${totalResults} results`\n : `Showing ${currentResults} of ${totalResults} results`;\n\n return (\n <div\n ref={ref}\n className={clsx('arbor-table-footer-pagination', className)}\n style={{ ...containerStyles, ...style }}\n data-testid={dataTestId}\n >\n {/* Left section - Results count */}\n <div style={textStyles}>{resultText}</div>\n\n {/* Middle section - Pagination */}\n <div style={paginationWrapperStyles}>\n <button\n type=\"button\"\n onClick={handleFirstPage}\n disabled={isFirstDisabled}\n onMouseEnter={() => setHoveredButton('first')}\n onMouseLeave={() => setHoveredButton(null)}\n onMouseDown={() => setActiveButton('first')}\n onMouseUp={() => setActiveButton(null)}\n onFocus={() => setFocusedButton('first')}\n onBlur={() => setFocusedButton(null)}\n style={getButtonStyle('first', isFirstDisabled)}\n aria-label=\"Go to first page\"\n >\n <svg\n width=\"16\"\n height=\"16\"\n viewBox=\"0 0 16 16\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <path\n d=\"M7 12L3 8L7 4M11 12L7 8L11 4\"\n stroke=\"#2f2f2f\"\n strokeWidth=\"1.5\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n />\n </svg>\n </button>\n\n <button\n type=\"button\"\n onClick={handlePreviousPage}\n disabled={isPreviousDisabled}\n onMouseEnter={() => setHoveredButton('previous')}\n onMouseLeave={() => setHoveredButton(null)}\n onMouseDown={() => setActiveButton('previous')}\n onMouseUp={() => setActiveButton(null)}\n onFocus={() => setFocusedButton('previous')}\n onBlur={() => setFocusedButton(null)}\n style={getButtonStyle('previous', isPreviousDisabled)}\n aria-label=\"Go to previous page\"\n >\n <svg\n width=\"16\"\n height=\"16\"\n viewBox=\"0 0 16 16\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <path\n d=\"M10 12L6 8L10 4\"\n stroke=\"#2f2f2f\"\n strokeWidth=\"1.5\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n />\n </svg>\n </button>\n\n <div style={paginationInputWrapperStyles}>\n <span style={paginationLabelStyles}>Page</span>\n <input\n type=\"text\"\n value={inputValue}\n onChange={handleInputChange}\n onBlur={handleInputBlur}\n onFocus={() => setInputFocused(true)}\n onKeyDown={handleInputKeyDown}\n style={{\n ...paginationInputStyles,\n ...(inputFocused && paginationInputFocusStyles),\n }}\n aria-label={`Page ${currentPage} of ${totalPages}`}\n />\n <span style={paginationLabelStyles}>of {totalPages}</span>\n </div>\n\n <button\n type=\"button\"\n onClick={handleNextPage}\n disabled={isNextDisabled}\n onMouseEnter={() => setHoveredButton('next')}\n onMouseLeave={() => setHoveredButton(null)}\n onMouseDown={() => setActiveButton('next')}\n onMouseUp={() => setActiveButton(null)}\n onFocus={() => setFocusedButton('next')}\n onBlur={() => setFocusedButton(null)}\n style={getButtonStyle('next', isNextDisabled)}\n aria-label=\"Go to next page\"\n >\n <svg\n width=\"16\"\n height=\"16\"\n viewBox=\"0 0 16 16\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <path\n d=\"M6 4L10 8L6 12\"\n stroke=\"#2f2f2f\"\n strokeWidth=\"1.5\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n />\n </svg>\n </button>\n\n <button\n type=\"button\"\n onClick={handleLastPage}\n disabled={isLastDisabled}\n onMouseEnter={() => setHoveredButton('last')}\n onMouseLeave={() => setHoveredButton(null)}\n onMouseDown={() => setActiveButton('last')}\n onMouseUp={() => setActiveButton(null)}\n onFocus={() => setFocusedButton('last')}\n onBlur={() => setFocusedButton(null)}\n style={getButtonStyle('last', isLastDisabled)}\n aria-label=\"Go to last page\"\n >\n <svg\n width=\"16\"\n height=\"16\"\n viewBox=\"0 0 16 16\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <path\n d=\"M9 4L13 8L9 12M5 4L9 8L5 12\"\n stroke=\"#2f2f2f\"\n strokeWidth=\"1.5\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n />\n </svg>\n </button>\n </div>\n\n {/* Right section - Controls */}\n <div style={rightAlignedStyles}>\n {onItemsPerPageChange && (\n <button\n type=\"button\"\n onClick={() => onItemsPerPageChange(itemsPerPage)}\n onMouseEnter={() => setPerPageHovered(true)}\n onMouseLeave={() => setPerPageHovered(false)}\n style={{\n ...perPageButtonStyles,\n backgroundColor: perPageHovered ? '#f5f5f5' : 'white',\n }}\n aria-label=\"Items per page\"\n >\n <span style={perPageTextStyles}>{itemsPerPage} per page</span>\n <ChevronDown size={16} color=\"#2f2f2f\" />\n </button>\n )}\n\n {onExpandTable && (\n <button\n type=\"button\"\n onClick={onExpandTable}\n onMouseEnter={() => setExpandHovered(true)}\n onMouseLeave={() => setExpandHovered(false)}\n style={{\n ...expandButtonStyles,\n backgroundColor: expandHovered ? '#e5e5e5' : '#efefef',\n }}\n aria-label=\"Expand table\"\n >\n <span style={expandButtonTextStyles}>Expand table</span>\n </button>\n )}\n </div>\n </div>\n );\n }\n);\n\nTableFooterPagination.displayName = 'TableFooterPagination';\n"],"mappings":";AAAA,YAAY,WAAW;AACvB,SAAS,YAAY;AACrB,SAAS,mBAAmB;AAiVpB,cA+EI,YA/EJ;AAhSR,IAAM,kBAAuC;AAAA,EAC3C,SAAS;AAAA,EACT,YAAY;AAAA,EACZ,gBAAgB;AAAA,EAChB,iBAAiB;AAAA,EACjB,YAAY;AAAA,EACZ,eAAe;AAAA,EACf,aAAa;AAAA,EACb,cAAc;AAAA,EACd,YAAY;AACd;AAEA,IAAM,aAAkC;AAAA,EACtC,UAAU;AAAA,EACV,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,OAAO;AAAA,EACP,UAAU;AACZ;AAEA,IAAM,0BAA+C;AAAA,EACnD,SAAS;AAAA,EACT,YAAY;AAAA,EACZ,gBAAgB;AAAA,EAChB,KAAK;AAAA,EACL,UAAU;AAAA,EACV,UAAU;AACZ;AAEA,IAAM,yBAA8C;AAAA,EAClD,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,UAAU;AAAA,EACV,WAAW;AAAA,EACX,UAAU;AAAA,EACV,WAAW;AAAA,EACX,cAAc;AAAA,EACd,QAAQ;AAAA,EACR,YAAY;AAAA,EACZ,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,YAAY;AAAA,EACZ,gBAAgB;AAAA,EAChB,SAAS;AAAA,EACT,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,yBAAyB;AAAA,EACzB,SAAS;AACX;AAEA,IAAM,iCAAsD;AAAA,EAC1D,QAAQ;AAAA,EACR,SAAS;AACX;AAEA,IAAM,wBAA6C;AAAA,EACjD,UAAU;AAAA,EACV,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,OAAO;AACT;AAEA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BAAiB,YAAY;AAAA,gBAChD;AAAA,gBACA,cAAW;AAAA,gBAEX;AAAA,uCAAC,UAAK,OAAO,mBAAoB;AAAA;AAAA,oBAAa;AAAA,qBAAS;AAAA,kBACvD,oBAAC,eAAY,MAAM,IAAI,OAAM,WAAU;AAAA;AAAA;AAAA,YACzC;AAAA,YAGD,iBACC;AAAA,cAAC;AAAA;AAAA,gBACC,MAAK;AAAA,gBACL,SAAS;AAAA,gBACT,cAAc,MAAM,iBAAiB,IAAI;AAAA,gBACzC,cAAc,MAAM,iBAAiB,KAAK;AAAA,gBAC1C,OAAO;AAAA,kBACL,GAAG;AAAA,kBACH,iBAAiB,gBAAgB,YAAY;AAAA,gBAC/C;AAAA,gBACA,cAAW;AAAA,gBAEX,8BAAC,UAAK,OAAO,wBAAwB,0BAAY;AAAA;AAAA,YACnD;AAAA,aAEJ;AAAA;AAAA;AAAA,IACF;AAAA,EAEJ;AACF;AAEA,sBAAsB,cAAc;","names":["style"]}
@@ -0,0 +1,283 @@
1
+ // src/NumericInput/NumericInput.tsx
2
+ import * as React from "react";
3
+ import { clsx } from "clsx";
4
+ import { jsx, jsxs } from "react/jsx-runtime";
5
+ var labelStyles = {
6
+ display: "block",
7
+ fontSize: "13px",
8
+ fontWeight: "600",
9
+ color: "#2f2f2f",
10
+ marginBottom: "4px",
11
+ fontFamily: "'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif"
12
+ };
13
+ var helperTextStyles = {
14
+ fontSize: "13px",
15
+ margin: "0",
16
+ marginTop: "2px",
17
+ color: "#595959",
18
+ fontFamily: "'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif",
19
+ lineHeight: "1.4"
20
+ };
21
+ var errorTextStyles = {
22
+ ...helperTextStyles,
23
+ color: "#a62323",
24
+ // destructive-600
25
+ display: "flex",
26
+ alignItems: "center",
27
+ gap: "4px"
28
+ };
29
+ var containerStyles = {
30
+ base: {
31
+ display: "flex",
32
+ alignItems: "center",
33
+ height: "46px",
34
+ fontFamily: "'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif",
35
+ backgroundColor: "#ffffff",
36
+ borderRadius: "8px",
37
+ transition: "all 0.2s ease-in-out",
38
+ overflow: "hidden"
39
+ },
40
+ states: {
41
+ default: {
42
+ border: "1px solid #d1d1d1"
43
+ // grey-300
44
+ },
45
+ defaultFocus: {
46
+ borderColor: "#3cad51",
47
+ // brand-500
48
+ outline: "3px solid rgba(60, 173, 81, 0.2)"
49
+ },
50
+ error: {
51
+ border: "1px solid #c93232"
52
+ // destructive-500
53
+ },
54
+ errorFocus: {
55
+ borderColor: "#c93232",
56
+ outline: "3px solid rgba(201, 50, 50, 0.2)"
57
+ },
58
+ success: {
59
+ border: "1px solid #16a33d"
60
+ // success-500
61
+ },
62
+ successFocus: {
63
+ borderColor: "#16a33d",
64
+ outline: "3px solid rgba(22, 163, 61, 0.2)"
65
+ },
66
+ disabled: {
67
+ backgroundColor: "#f8f8f8",
68
+ // grey-050
69
+ borderColor: "#efefef",
70
+ // grey-100
71
+ cursor: "not-allowed"
72
+ }
73
+ }
74
+ };
75
+ var buttonStyles = {
76
+ width: "46px",
77
+ height: "100%",
78
+ border: "none",
79
+ background: "transparent",
80
+ cursor: "pointer",
81
+ fontSize: "16px",
82
+ color: "#2f2f2f",
83
+ display: "flex",
84
+ alignItems: "center",
85
+ justifyContent: "center",
86
+ transition: "background-color 0.2s",
87
+ fontFamily: "'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif",
88
+ userSelect: "none"
89
+ };
90
+ var inputStyles = {
91
+ flex: 1,
92
+ border: "none",
93
+ outline: "none",
94
+ background: "transparent",
95
+ textAlign: "center",
96
+ fontSize: "13px",
97
+ color: "#2f2f2f",
98
+ fontFamily: "'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif",
99
+ padding: "0 8px",
100
+ appearance: "textfield"
101
+ };
102
+ var NumericInput = React.forwardRef(
103
+ ({
104
+ label,
105
+ value,
106
+ onChange,
107
+ min,
108
+ max,
109
+ step = 1,
110
+ state = "default",
111
+ error,
112
+ helperText,
113
+ disabled = false,
114
+ className,
115
+ style,
116
+ "data-testid": dataTestId
117
+ }, ref) => {
118
+ const [isFocused, setIsFocused] = React.useState(false);
119
+ const inputRef = React.useRef(null);
120
+ const inputId = React.useId();
121
+ const helperTextId = React.useId();
122
+ const errorId = React.useId();
123
+ const clampValue = (val) => {
124
+ let clamped = val;
125
+ if (min !== void 0 && clamped < min) clamped = min;
126
+ if (max !== void 0 && clamped > max) clamped = max;
127
+ return clamped;
128
+ };
129
+ const handleIncrement = () => {
130
+ if (disabled) return;
131
+ const currentValue = value ?? 0;
132
+ const newValue = currentValue + step;
133
+ const clampedValue = clampValue(newValue);
134
+ if (clampedValue !== currentValue) {
135
+ onChange?.(clampedValue);
136
+ }
137
+ };
138
+ const handleDecrement = () => {
139
+ if (disabled) return;
140
+ const currentValue = value ?? 0;
141
+ const newValue = currentValue - step;
142
+ const clampedValue = clampValue(newValue);
143
+ if (clampedValue !== currentValue) {
144
+ onChange?.(clampedValue);
145
+ }
146
+ };
147
+ const handleInputChange = (e) => {
148
+ const inputValue = e.target.value;
149
+ if (inputValue === "" || inputValue === "-") {
150
+ onChange?.(void 0);
151
+ return;
152
+ }
153
+ const numValue = parseFloat(inputValue);
154
+ if (!isNaN(numValue)) {
155
+ const clampedValue = clampValue(numValue);
156
+ onChange?.(clampedValue);
157
+ }
158
+ };
159
+ const handleKeyDown = (e) => {
160
+ const allowedKeys = ["Backspace", "Delete", "Tab", "Escape", "Enter", "ArrowLeft", "ArrowRight", "ArrowUp", "ArrowDown", "-", "."];
161
+ if (allowedKeys.includes(e.key)) {
162
+ if (e.key === "ArrowUp") {
163
+ e.preventDefault();
164
+ handleIncrement();
165
+ } else if (e.key === "ArrowDown") {
166
+ e.preventDefault();
167
+ handleDecrement();
168
+ }
169
+ return;
170
+ }
171
+ if (!/^[0-9]$/.test(e.key)) {
172
+ e.preventDefault();
173
+ }
174
+ };
175
+ const currentState = error ? "error" : state;
176
+ const stateStyles = containerStyles.states[currentState];
177
+ const focusStyles = currentState === "error" ? containerStyles.states.errorFocus : currentState === "success" ? containerStyles.states.successFocus : containerStyles.states.defaultFocus;
178
+ const containerStyle = {
179
+ ...containerStyles.base,
180
+ ...stateStyles,
181
+ ...isFocused && !disabled && focusStyles,
182
+ ...disabled && containerStyles.states.disabled
183
+ };
184
+ const isDecrementDisabled = disabled || min !== void 0 && value !== void 0 && value <= min;
185
+ const isIncrementDisabled = disabled || max !== void 0 && value !== void 0 && value >= max;
186
+ const getButtonStyle = (isDisabled) => {
187
+ const baseStyle = {
188
+ ...buttonStyles,
189
+ cursor: isDisabled ? "not-allowed" : "pointer",
190
+ color: isDisabled ? "#7e7e7e" : "#2f2f2f"
191
+ };
192
+ if (currentState === "success" && !isDisabled) {
193
+ return {
194
+ ...baseStyle,
195
+ color: "#16a33d",
196
+ // success-500
197
+ border: "2px solid #16a33d",
198
+ borderRadius: "50%",
199
+ width: "32px",
200
+ height: "32px"
201
+ };
202
+ }
203
+ return baseStyle;
204
+ };
205
+ return /* @__PURE__ */ jsxs("div", { className: clsx("arbor-numeric-input-wrapper", className), style, ref, "data-testid": dataTestId, children: [
206
+ label && /* @__PURE__ */ jsx("label", { htmlFor: inputId, style: labelStyles, children: label }),
207
+ /* @__PURE__ */ jsxs("div", { style: containerStyle, children: [
208
+ /* @__PURE__ */ jsx(
209
+ "button",
210
+ {
211
+ type: "button",
212
+ onClick: handleDecrement,
213
+ disabled: isDecrementDisabled,
214
+ style: getButtonStyle(isDecrementDisabled),
215
+ onMouseEnter: (e) => {
216
+ if (!isDecrementDisabled) {
217
+ e.currentTarget.style.backgroundColor = "#f8f8f8";
218
+ e.currentTarget.style.borderRadius = "99px";
219
+ }
220
+ },
221
+ onMouseLeave: (e) => {
222
+ e.currentTarget.style.backgroundColor = "transparent";
223
+ e.currentTarget.style.borderRadius = currentState === "success" ? "50%" : "0";
224
+ },
225
+ "aria-label": "Decrement",
226
+ children: "\u2212"
227
+ }
228
+ ),
229
+ /* @__PURE__ */ jsx(
230
+ "input",
231
+ {
232
+ ref: inputRef,
233
+ id: inputId,
234
+ type: "text",
235
+ inputMode: "numeric",
236
+ value: value !== void 0 ? value : "",
237
+ onChange: handleInputChange,
238
+ onKeyDown: handleKeyDown,
239
+ onFocus: () => setIsFocused(true),
240
+ onBlur: () => setIsFocused(false),
241
+ disabled,
242
+ "aria-invalid": error ? "true" : "false",
243
+ "aria-describedby": error ? errorId : helperText ? helperTextId : void 0,
244
+ style: {
245
+ ...inputStyles,
246
+ color: disabled ? "#7e7e7e" : "#2f2f2f",
247
+ cursor: disabled ? "not-allowed" : "text"
248
+ }
249
+ }
250
+ ),
251
+ /* @__PURE__ */ jsx(
252
+ "button",
253
+ {
254
+ type: "button",
255
+ onClick: handleIncrement,
256
+ disabled: isIncrementDisabled,
257
+ style: getButtonStyle(isIncrementDisabled),
258
+ onMouseEnter: (e) => {
259
+ if (!isIncrementDisabled) {
260
+ e.currentTarget.style.backgroundColor = "#f8f8f8";
261
+ e.currentTarget.style.borderRadius = "99px";
262
+ }
263
+ },
264
+ onMouseLeave: (e) => {
265
+ e.currentTarget.style.backgroundColor = "transparent";
266
+ e.currentTarget.style.borderRadius = currentState === "success" ? "50%" : "0";
267
+ },
268
+ "aria-label": "Increment",
269
+ children: "+"
270
+ }
271
+ )
272
+ ] }),
273
+ error && /* @__PURE__ */ jsx("p", { id: errorId, style: errorTextStyles, children: error }),
274
+ helperText && !error && /* @__PURE__ */ jsx("p", { id: helperTextId, style: helperTextStyles, children: helperText })
275
+ ] });
276
+ }
277
+ );
278
+ NumericInput.displayName = "NumericInput";
279
+
280
+ export {
281
+ NumericInput
282
+ };
283
+ //# sourceMappingURL=chunk-5BUXFTPW.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/NumericInput/NumericInput.tsx"],"sourcesContent":["import * as React from 'react';\nimport { clsx } from 'clsx';\n\nexport type NumericInputState = 'default' | 'error' | 'success';\n\nexport interface NumericInputProps {\n /**\n * The label for the numeric input\n */\n label?: string;\n /**\n * The current value\n */\n value?: number;\n /**\n * Callback when value changes\n */\n onChange?: (value: number | undefined) => void;\n /**\n * Minimum allowed value\n */\n min?: number;\n /**\n * Maximum allowed value\n */\n max?: number;\n /**\n * Step increment/decrement value\n * @default 1\n */\n step?: number;\n /**\n * The validation state\n * @default 'default'\n */\n state?: NumericInputState;\n /**\n * Optional error message\n */\n error?: string;\n /**\n * Optional helper text\n */\n helperText?: string;\n /**\n * Whether the input is disabled\n */\n disabled?: boolean;\n /**\n * Custom className\n */\n className?: string;\n /**\n * Custom style\n */\n style?: React.CSSProperties;\n /**\n * Test ID for testing\n */\n 'data-testid'?: string;\n}\n\nconst labelStyles: React.CSSProperties = {\n display: 'block',\n fontSize: '13px',\n fontWeight: '600',\n color: '#2f2f2f',\n marginBottom: '4px',\n fontFamily: \"'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif\",\n};\n\nconst helperTextStyles: React.CSSProperties = {\n fontSize: '13px',\n margin: '0',\n marginTop: '2px',\n color: '#595959',\n fontFamily: \"'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif\",\n lineHeight: '1.4',\n};\n\nconst errorTextStyles: React.CSSProperties = {\n ...helperTextStyles,\n color: '#a62323', // destructive-600\n display: 'flex',\n alignItems: 'center',\n gap: '4px',\n};\n\nconst containerStyles = {\n base: {\n display: 'flex',\n alignItems: 'center',\n height: '46px',\n fontFamily: \"'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif\",\n backgroundColor: '#ffffff',\n borderRadius: '8px',\n transition: 'all 0.2s ease-in-out',\n overflow: 'hidden',\n },\n states: {\n default: {\n border: '1px solid #d1d1d1', // grey-300\n },\n defaultFocus: {\n borderColor: '#3cad51', // brand-500\n outline: '3px solid rgba(60, 173, 81, 0.2)',\n },\n error: {\n border: '1px solid #c93232', // destructive-500\n },\n errorFocus: {\n borderColor: '#c93232',\n outline: '3px solid rgba(201, 50, 50, 0.2)',\n },\n success: {\n border: '1px solid #16a33d', // success-500\n },\n successFocus: {\n borderColor: '#16a33d',\n outline: '3px solid rgba(22, 163, 61, 0.2)',\n },\n disabled: {\n backgroundColor: '#f8f8f8', // grey-050\n borderColor: '#efefef', // grey-100\n cursor: 'not-allowed',\n },\n },\n};\n\nconst buttonStyles: React.CSSProperties = {\n width: '46px',\n height: '100%',\n border: 'none',\n background: 'transparent',\n cursor: 'pointer',\n fontSize: '16px',\n color: '#2f2f2f',\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n transition: 'background-color 0.2s',\n fontFamily: \"'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif\",\n userSelect: 'none' as const,\n};\n\nconst inputStyles: React.CSSProperties = {\n flex: 1,\n border: 'none',\n outline: 'none',\n background: 'transparent',\n textAlign: 'center',\n fontSize: '13px',\n color: '#2f2f2f',\n fontFamily: \"'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif\",\n padding: '0 8px',\n appearance: 'textfield' as any,\n};\n\n/**\n * NumericInput component - Arbor Design System\n *\n * A number input with increment/decrement buttons.\n * Enforces numeric rules (min, max, step) and prevents non-numeric input.\n */\nexport const NumericInput = React.forwardRef<HTMLDivElement, NumericInputProps>(\n (\n {\n label,\n value,\n onChange,\n min,\n max,\n step = 1,\n state = 'default',\n error,\n helperText,\n disabled = false,\n className,\n style,\n 'data-testid': dataTestId,\n },\n ref\n ) => {\n const [isFocused, setIsFocused] = React.useState(false);\n const inputRef = React.useRef<HTMLInputElement>(null);\n\n const inputId = React.useId();\n const helperTextId = React.useId();\n const errorId = React.useId();\n\n const clampValue = (val: number): number => {\n let clamped = val;\n if (min !== undefined && clamped < min) clamped = min;\n if (max !== undefined && clamped > max) clamped = max;\n return clamped;\n };\n\n const handleIncrement = () => {\n if (disabled) return;\n const currentValue = value ?? 0;\n const newValue = currentValue + step;\n const clampedValue = clampValue(newValue);\n if (clampedValue !== currentValue) {\n onChange?.(clampedValue);\n }\n };\n\n const handleDecrement = () => {\n if (disabled) return;\n const currentValue = value ?? 0;\n const newValue = currentValue - step;\n const clampedValue = clampValue(newValue);\n if (clampedValue !== currentValue) {\n onChange?.(clampedValue);\n }\n };\n\n const handleInputChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n const inputValue = e.target.value;\n\n // Allow empty input\n if (inputValue === '' || inputValue === '-') {\n onChange?.(undefined);\n return;\n }\n\n // Parse as number\n const numValue = parseFloat(inputValue);\n\n // Only update if it's a valid number\n if (!isNaN(numValue)) {\n const clampedValue = clampValue(numValue);\n onChange?.(clampedValue);\n }\n };\n\n const handleKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {\n // Allow: backspace, delete, tab, escape, enter, minus sign, decimal point\n const allowedKeys = ['Backspace', 'Delete', 'Tab', 'Escape', 'Enter', 'ArrowLeft', 'ArrowRight', 'ArrowUp', 'ArrowDown', '-', '.'];\n\n if (allowedKeys.includes(e.key)) {\n // Handle arrow keys for increment/decrement\n if (e.key === 'ArrowUp') {\n e.preventDefault();\n handleIncrement();\n } else if (e.key === 'ArrowDown') {\n e.preventDefault();\n handleDecrement();\n }\n return;\n }\n\n // Only allow numbers\n if (!/^[0-9]$/.test(e.key)) {\n e.preventDefault();\n }\n };\n\n const currentState = error ? 'error' : state;\n const stateStyles = containerStyles.states[currentState];\n const focusStyles =\n currentState === 'error'\n ? containerStyles.states.errorFocus\n : currentState === 'success'\n ? containerStyles.states.successFocus\n : containerStyles.states.defaultFocus;\n\n const containerStyle: React.CSSProperties = {\n ...containerStyles.base,\n ...stateStyles,\n ...(isFocused && !disabled && focusStyles),\n ...(disabled && containerStyles.states.disabled),\n };\n\n const isDecrementDisabled = disabled || (min !== undefined && value !== undefined && value <= min);\n const isIncrementDisabled = disabled || (max !== undefined && value !== undefined && value >= max);\n\n // Button styles for success state (green outlined circles)\n const getButtonStyle = (isDisabled: boolean) => {\n const baseStyle: React.CSSProperties = {\n ...buttonStyles,\n cursor: isDisabled ? 'not-allowed' : 'pointer',\n color: isDisabled ? '#7e7e7e' : '#2f2f2f',\n };\n\n // Add green circle border for success state\n if (currentState === 'success' && !isDisabled) {\n return {\n ...baseStyle,\n color: '#16a33d', // success-500\n border: '2px solid #16a33d',\n borderRadius: '50%',\n width: '32px',\n height: '32px',\n };\n }\n\n return baseStyle;\n };\n\n return (\n <div className={clsx('arbor-numeric-input-wrapper', className)} style={style} ref={ref} data-testid={dataTestId}>\n {label && (\n <label htmlFor={inputId} style={labelStyles}>\n {label}\n </label>\n )}\n\n <div style={containerStyle}>\n <button\n type=\"button\"\n onClick={handleDecrement}\n disabled={isDecrementDisabled}\n style={getButtonStyle(isDecrementDisabled)}\n onMouseEnter={(e) => {\n if (!isDecrementDisabled) {\n e.currentTarget.style.backgroundColor = '#f8f8f8';\n e.currentTarget.style.borderRadius = '99px';\n }\n }}\n onMouseLeave={(e) => {\n e.currentTarget.style.backgroundColor = 'transparent';\n e.currentTarget.style.borderRadius = currentState === 'success' ? '50%' : '0';\n }}\n aria-label=\"Decrement\"\n >\n −\n </button>\n\n <input\n ref={inputRef}\n id={inputId}\n type=\"text\"\n inputMode=\"numeric\"\n value={value !== undefined ? value : ''}\n onChange={handleInputChange}\n onKeyDown={handleKeyDown}\n onFocus={() => setIsFocused(true)}\n onBlur={() => setIsFocused(false)}\n disabled={disabled}\n aria-invalid={error ? 'true' : 'false'}\n aria-describedby={error ? errorId : helperText ? helperTextId : undefined}\n style={{\n ...inputStyles,\n color: disabled ? '#7e7e7e' : '#2f2f2f',\n cursor: disabled ? 'not-allowed' : 'text',\n }}\n />\n\n <button\n type=\"button\"\n onClick={handleIncrement}\n disabled={isIncrementDisabled}\n style={getButtonStyle(isIncrementDisabled)}\n onMouseEnter={(e) => {\n if (!isIncrementDisabled) {\n e.currentTarget.style.backgroundColor = '#f8f8f8';\n e.currentTarget.style.borderRadius = '99px';\n }\n }}\n onMouseLeave={(e) => {\n e.currentTarget.style.backgroundColor = 'transparent';\n e.currentTarget.style.borderRadius = currentState === 'success' ? '50%' : '0';\n }}\n aria-label=\"Increment\"\n >\n +\n </button>\n </div>\n\n {error && (\n <p id={errorId} style={errorTextStyles}>\n {error}\n </p>\n )}\n\n {helperText && !error && (\n <p id={helperTextId} style={helperTextStyles}>\n {helperText}\n </p>\n )}\n </div>\n );\n }\n);\n\nNumericInput.displayName = 'NumericInput';\n"],"mappings":";AAAA,YAAY,WAAW;AACvB,SAAS,YAAY;AA8SX,cAKF,YALE;AAjPV,IAAM,cAAmC;AAAA,EACvC,SAAS;AAAA,EACT,UAAU;AAAA,EACV,YAAY;AAAA,EACZ,OAAO;AAAA,EACP,cAAc;AAAA,EACd,YAAY;AACd;AAEA,IAAM,mBAAwC;AAAA,EAC5C,UAAU;AAAA,EACV,QAAQ;AAAA,EACR,WAAW;AAAA,EACX,OAAO;AAAA,EACP,YAAY;AAAA,EACZ,YAAY;AACd;AAEA,IAAM,kBAAuC;AAAA,EAC3C,GAAG;AAAA,EACH,OAAO;AAAA;AAAA,EACP,SAAS;AAAA,EACT,YAAY;AAAA,EACZ,KAAK;AACP;AAEA,IAAM,kBAAkB;AAAA,EACtB,MAAM;AAAA,IACJ,SAAS;AAAA,IACT,YAAY;AAAA,IACZ,QAAQ;AAAA,IACR,YAAY;AAAA,IACZ,iBAAiB;AAAA,IACjB,cAAc;AAAA,IACd,YAAY;AAAA,IACZ,UAAU;AAAA,EACZ;AAAA,EACA,QAAQ;AAAA,IACN,SAAS;AAAA,MACP,QAAQ;AAAA;AAAA,IACV;AAAA,IACA,cAAc;AAAA,MACZ,aAAa;AAAA;AAAA,MACb,SAAS;AAAA,IACX;AAAA,IACA,OAAO;AAAA,MACL,QAAQ;AAAA;AAAA,IACV;AAAA,IACA,YAAY;AAAA,MACV,aAAa;AAAA,MACb,SAAS;AAAA,IACX;AAAA,IACA,SAAS;AAAA,MACP,QAAQ;AAAA;AAAA,IACV;AAAA,IACA,cAAc;AAAA,MACZ,aAA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AK;AAAA,YACL,WAAU;AAAA,YACV,OAAO,UAAU,SAAY,QAAQ;AAAA,YACrC,UAAU;AAAA,YACV,WAAW;AAAA,YACX,SAAS,MAAM,aAAa,IAAI;AAAA,YAChC,QAAQ,MAAM,aAAa,KAAK;AAAA,YAChC;AAAA,YACA,gBAAc,QAAQ,SAAS;AAAA,YAC/B,oBAAkB,QAAQ,UAAU,aAAa,eAAe;AAAA,YAChE,OAAO;AAAA,cACL,GAAG;AAAA,cACH,OAAO,WAAW,YAAY;AAAA,cAC9B,QAAQ,WAAW,gBAAgB;AAAA,YACrC;AAAA;AAAA,QACF;AAAA,QAEA;AAAA,UAAC;AAAA;AAAA,YACC,MAAK;AAAA,YACL,SAAS;AAAA,YACT,UAAU;AAAA,YACV,OAAO,eAAe,mBAAmB;AAAA,YACzC,cAAc,CAAC,MAAM;AACnB,kBAAI,CAAC,qBAAqB;AACxB,kBAAE,cAAc,MAAM,kBAAkB;AACxC,kBAAE,cAAc,MAAM,eAAe;AAAA,cACvC;AAAA,YACF;AAAA,YACA,cAAc,CAAC,MAAM;AACnB,gBAAE,cAAc,MAAM,kBAAkB;AACxC,gBAAE,cAAc,MAAM,eAAe,iBAAiB,YAAY,QAAQ;AAAA,YAC5E;AAAA,YACA,cAAW;AAAA,YACZ;AAAA;AAAA,QAED;AAAA,SACF;AAAA,MAEC,SACC,oBAAC,OAAE,IAAI,SAAS,OAAO,iBACpB,iBACH;AAAA,MAGD,cAAc,CAAC,SACd,oBAAC,OAAE,IAAI,cAAc,OAAO,kBACzB,sBACH;AAAA,OAEJ;AAAA,EAEJ;AACF;AAEA,aAAa,cAAc;","names":[]}
@@ -0,0 +1,293 @@
1
+ // src/Combobox/Combobox.tsx
2
+ import * as React from "react";
3
+ import { clsx } from "clsx";
4
+ import { X, ChevronDown, Check } from "lucide-react";
5
+ import { jsx, jsxs } from "react/jsx-runtime";
6
+ var comboboxStyles = {
7
+ base: {
8
+ width: "100%",
9
+ height: "36px",
10
+ fontFamily: "'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif",
11
+ backgroundColor: "#ffffff",
12
+ borderRadius: "8px",
13
+ transition: "all 0.2s ease-in-out",
14
+ outline: "none",
15
+ fontSize: "13px",
16
+ padding: "8px",
17
+ paddingRight: "32px",
18
+ margin: "0",
19
+ display: "flex",
20
+ alignItems: "center",
21
+ cursor: "pointer",
22
+ position: "relative"
23
+ },
24
+ states: {
25
+ default: {
26
+ border: "1px solid #d1d1d1",
27
+ // grey-300
28
+ color: "#2f2f2f"
29
+ // grey-900
30
+ },
31
+ defaultFocus: {
32
+ borderColor: "#3cad51",
33
+ // brand-500
34
+ outline: "3px solid rgba(60, 173, 81, 0.2)"
35
+ },
36
+ error: {
37
+ border: "1px solid #c93232",
38
+ // destructive-500
39
+ color: "#2f2f2f"
40
+ },
41
+ errorFocus: {
42
+ borderColor: "#c93232",
43
+ outline: "3px solid rgba(201, 50, 50, 0.2)"
44
+ },
45
+ success: {
46
+ border: "1px solid #16a33d",
47
+ // success-500
48
+ color: "#2f2f2f"
49
+ },
50
+ successFocus: {
51
+ borderColor: "#16a33d",
52
+ outline: "3px solid rgba(22, 163, 61, 0.2)"
53
+ },
54
+ disabled: {
55
+ backgroundColor: "#f8f8f8",
56
+ // grey-050
57
+ borderColor: "#efefef",
58
+ // grey-100
59
+ color: "#7e7e7e",
60
+ // grey-500
61
+ cursor: "not-allowed"
62
+ }
63
+ }
64
+ };
65
+ var labelStyles = {
66
+ display: "block",
67
+ fontSize: "13px",
68
+ fontWeight: "600",
69
+ color: "#2f2f2f",
70
+ marginBottom: "4px",
71
+ fontFamily: "'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif"
72
+ };
73
+ var helperTextStyles = {
74
+ fontSize: "13px",
75
+ margin: "0",
76
+ marginTop: "2px",
77
+ color: "#595959",
78
+ fontFamily: "'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif",
79
+ lineHeight: "1.4"
80
+ };
81
+ var errorTextStyles = {
82
+ ...helperTextStyles,
83
+ color: "#a62323",
84
+ // destructive-600
85
+ display: "flex",
86
+ alignItems: "center",
87
+ gap: "4px"
88
+ };
89
+ var dropdownStyles = {
90
+ position: "absolute",
91
+ top: "calc(100% + 4px)",
92
+ left: "0",
93
+ right: "0",
94
+ backgroundColor: "#ffffff",
95
+ border: "1px solid #d1d1d1",
96
+ borderRadius: "8px",
97
+ maxHeight: "200px",
98
+ overflowY: "auto",
99
+ boxShadow: "0 4px 12px rgba(0, 0, 0, 0.1)",
100
+ zIndex: 1e3
101
+ };
102
+ var optionStyles = {
103
+ padding: "8px 12px",
104
+ fontSize: "13px",
105
+ cursor: "pointer",
106
+ display: "flex",
107
+ alignItems: "center",
108
+ justifyContent: "space-between",
109
+ fontFamily: "'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif",
110
+ color: "#2f2f2f"
111
+ // grey-900
112
+ };
113
+ var Combobox = React.forwardRef(
114
+ ({
115
+ label,
116
+ placeholder = "default-text",
117
+ options,
118
+ value,
119
+ onChange,
120
+ state = "default",
121
+ error,
122
+ helperText,
123
+ disabled = false,
124
+ className,
125
+ style,
126
+ "data-testid": dataTestId
127
+ }, ref) => {
128
+ const [isOpen, setIsOpen] = React.useState(false);
129
+ const [searchQuery, setSearchQuery] = React.useState("");
130
+ const [isFocused, setIsFocused] = React.useState(false);
131
+ const inputRef = React.useRef(null);
132
+ const dropdownRef = React.useRef(null);
133
+ const wrapperRef = React.useRef(null);
134
+ const comboboxId = React.useId();
135
+ const helperTextId = React.useId();
136
+ const errorId = React.useId();
137
+ const selectedOption = options.find((opt) => opt.value === value);
138
+ const filteredOptions = React.useMemo(() => {
139
+ if (!searchQuery) return options;
140
+ return options.filter(
141
+ (option) => option.label.toLowerCase().includes(searchQuery.toLowerCase())
142
+ );
143
+ }, [options, searchQuery]);
144
+ React.useEffect(() => {
145
+ const handleClickOutside = (event) => {
146
+ if (wrapperRef.current && !wrapperRef.current.contains(event.target)) {
147
+ setIsOpen(false);
148
+ setSearchQuery("");
149
+ }
150
+ };
151
+ document.addEventListener("mousedown", handleClickOutside);
152
+ return () => document.removeEventListener("mousedown", handleClickOutside);
153
+ }, []);
154
+ const handleInputChange = (e) => {
155
+ setSearchQuery(e.target.value);
156
+ if (!isOpen) setIsOpen(true);
157
+ };
158
+ const handleSelectOption = (optionValue) => {
159
+ onChange?.(optionValue);
160
+ setIsOpen(false);
161
+ setSearchQuery("");
162
+ inputRef.current?.blur();
163
+ };
164
+ const handleClear = (e) => {
165
+ e.stopPropagation();
166
+ onChange?.(void 0);
167
+ setSearchQuery("");
168
+ inputRef.current?.focus();
169
+ };
170
+ const handleInputFocus = () => {
171
+ setIsFocused(true);
172
+ if (!disabled) setIsOpen(true);
173
+ };
174
+ const handleInputBlur = () => {
175
+ setIsFocused(false);
176
+ setTimeout(() => {
177
+ if (!wrapperRef.current?.contains(document.activeElement)) {
178
+ setSearchQuery("");
179
+ }
180
+ }, 200);
181
+ };
182
+ const currentState = error ? "error" : state;
183
+ const stateStyles = comboboxStyles.states[currentState];
184
+ const focusStyles = currentState === "error" ? comboboxStyles.states.errorFocus : currentState === "success" ? comboboxStyles.states.successFocus : comboboxStyles.states.defaultFocus;
185
+ const inputWrapperStyle = {
186
+ ...comboboxStyles.base,
187
+ ...stateStyles,
188
+ ...isFocused && !disabled && focusStyles,
189
+ ...disabled && comboboxStyles.states.disabled
190
+ };
191
+ const displayValue = selectedOption ? selectedOption.label : "";
192
+ const showPlaceholder = !selectedOption && !searchQuery && !isFocused;
193
+ return /* @__PURE__ */ jsxs("div", { className: clsx("arbor-combobox-wrapper", className), style, ref: wrapperRef, "data-testid": dataTestId, children: [
194
+ label && /* @__PURE__ */ jsx("label", { htmlFor: comboboxId, style: labelStyles, children: label }),
195
+ /* @__PURE__ */ jsxs("div", { style: { position: "relative" }, ref, children: [
196
+ /* @__PURE__ */ jsxs("div", { style: inputWrapperStyle, children: [
197
+ /* @__PURE__ */ jsx(
198
+ "input",
199
+ {
200
+ ref: inputRef,
201
+ id: comboboxId,
202
+ type: "text",
203
+ value: searchQuery || displayValue,
204
+ onChange: handleInputChange,
205
+ onFocus: handleInputFocus,
206
+ onBlur: handleInputBlur,
207
+ placeholder: showPlaceholder ? placeholder : "",
208
+ disabled,
209
+ "aria-invalid": error ? "true" : "false",
210
+ "aria-describedby": error ? errorId : helperText ? helperTextId : void 0,
211
+ "aria-expanded": isOpen,
212
+ "aria-autocomplete": "list",
213
+ role: "combobox",
214
+ style: {
215
+ border: "none",
216
+ outline: "none",
217
+ background: "transparent",
218
+ flex: 1,
219
+ fontSize: "13px",
220
+ padding: 0,
221
+ margin: 0,
222
+ color: showPlaceholder ? "#7e7e7e" : "#2f2f2f",
223
+ fontFamily: "'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif"
224
+ }
225
+ }
226
+ ),
227
+ /* @__PURE__ */ jsxs("div", { style: { display: "flex", alignItems: "center", gap: "4px", position: "absolute", right: "8px" }, children: [
228
+ selectedOption && !disabled && /* @__PURE__ */ jsx(
229
+ "button",
230
+ {
231
+ type: "button",
232
+ onClick: handleClear,
233
+ style: {
234
+ border: "none",
235
+ background: "transparent",
236
+ padding: "2px",
237
+ cursor: "pointer",
238
+ display: "flex",
239
+ alignItems: "center",
240
+ color: "#7e7e7e"
241
+ },
242
+ "aria-label": "Clear selection",
243
+ children: /* @__PURE__ */ jsx(X, { size: 16 })
244
+ }
245
+ ),
246
+ currentState === "success" && !isOpen && /* @__PURE__ */ jsx(Check, { size: 16, color: "#16a33d" }),
247
+ /* @__PURE__ */ jsx(
248
+ ChevronDown,
249
+ {
250
+ size: 16,
251
+ color: "#7e7e7e",
252
+ style: {
253
+ transform: isOpen ? "rotate(180deg)" : "rotate(0deg)",
254
+ transition: "transform 0.2s"
255
+ }
256
+ }
257
+ )
258
+ ] })
259
+ ] }),
260
+ isOpen && !disabled && /* @__PURE__ */ jsx("div", { ref: dropdownRef, style: dropdownStyles, children: filteredOptions.length === 0 ? /* @__PURE__ */ jsx("div", { style: { ...optionStyles, color: "#7e7e7e", cursor: "default" }, children: "No options found" }) : filteredOptions.map((option) => /* @__PURE__ */ jsxs(
261
+ "div",
262
+ {
263
+ onClick: () => handleSelectOption(option.value),
264
+ onMouseDown: (e) => e.preventDefault(),
265
+ style: {
266
+ ...optionStyles,
267
+ backgroundColor: option.value === value ? "#f8f8f8" : "transparent"
268
+ },
269
+ onMouseEnter: (e) => {
270
+ e.currentTarget.style.backgroundColor = "#f8f8f8";
271
+ },
272
+ onMouseLeave: (e) => {
273
+ e.currentTarget.style.backgroundColor = option.value === value ? "#f8f8f8" : "transparent";
274
+ },
275
+ children: [
276
+ /* @__PURE__ */ jsx("span", { children: option.label }),
277
+ option.value === value && /* @__PURE__ */ jsx(Check, { size: 16, color: "#16a33d" })
278
+ ]
279
+ },
280
+ option.value
281
+ )) })
282
+ ] }),
283
+ error && /* @__PURE__ */ jsx("p", { id: errorId, style: errorTextStyles, role: "alert", children: error }),
284
+ !error && helperText && /* @__PURE__ */ jsx("p", { id: helperTextId, style: helperTextStyles, children: helperText })
285
+ ] });
286
+ }
287
+ );
288
+ Combobox.displayName = "Combobox";
289
+
290
+ export {
291
+ Combobox
292
+ };
293
+ //# sourceMappingURL=chunk-7OWLBYNM.mjs.map