tekivex-ui 2.5.15 → 2.6.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/charts.cjs +1 -1
- package/dist/charts.js +22 -553
- package/dist/chunk-B3ph66Zb.js +1 -0
- package/dist/chunk-Bc16rJT-.js +1 -0
- package/dist/chunk-Dike2DLU.js +3 -0
- package/dist/chunk-DjxOP8W4.js +1 -0
- package/dist/chunk-DkoFTL1O.js +1 -0
- package/dist/chunk-DmRB1Blb.js +1 -0
- package/dist/chunk-DnCXUUx5.js +1 -0
- package/dist/chunk-LWkKqC8d.js +1 -0
- package/dist/chunk-PJ50l0JC.js +1 -0
- package/dist/headless.cjs +1 -1
- package/dist/headless.js +1 -442
- package/dist/i18n.cjs +1 -1
- package/dist/i18n.js +1 -733
- package/dist/index.cjs +1 -152
- package/dist/index.d.ts +4 -2
- package/dist/index.js +429 -16786
- package/dist/quantum.cjs +1 -89
- package/dist/quantum.js +74 -2551
- package/dist/realtime.cjs +1 -23
- package/dist/realtime.js +1 -804
- package/dist/src/a11y/index.d.ts +0 -1
- package/dist/src/charts/TkxAreaChart.d.ts +0 -5
- package/dist/src/charts/TkxBarChart.d.ts +0 -3
- package/dist/src/charts/TkxDonutChart.d.ts +0 -5
- package/dist/src/charts/TkxLineChart.d.ts +0 -1
- package/dist/src/charts/TkxPieChart.d.ts +0 -3
- package/dist/src/charts/TkxRadarChart.d.ts +0 -3
- package/dist/src/charts/TkxScatterChart.d.ts +0 -2
- package/dist/src/charts/index.d.ts +0 -1
- package/dist/src/charts/shared.d.ts +0 -3
- package/dist/src/components/TkxAIChatBubble.d.ts +0 -9
- package/dist/src/components/TkxAIConfidenceBar.d.ts +0 -6
- package/dist/src/components/TkxAIThinking.d.ts +0 -6
- package/dist/src/components/TkxAccordion.d.ts +0 -1
- package/dist/src/components/TkxAffix.d.ts +0 -1
- package/dist/src/components/TkxAlert.d.ts +0 -1
- package/dist/src/components/TkxAnchor.d.ts +0 -1
- package/dist/src/components/TkxAppBar.d.ts +0 -1
- package/dist/src/components/TkxAutocomplete.d.ts +0 -1
- package/dist/src/components/TkxAvatar.d.ts +0 -1
- package/dist/src/components/TkxBadge.d.ts +0 -1
- package/dist/src/components/TkxBottomNav.d.ts +0 -1
- package/dist/src/components/TkxBreadcrumb.d.ts +0 -1
- package/dist/src/components/TkxButton.d.ts +0 -1
- package/dist/src/components/TkxCard.d.ts +0 -1
- package/dist/src/components/TkxCarousel.d.ts +0 -1
- package/dist/src/components/TkxCascader.d.ts +0 -1
- package/dist/src/components/TkxChat.d.ts +0 -1
- package/dist/src/components/TkxCheckbox.d.ts +0 -1
- package/dist/src/components/TkxClock.d.ts +0 -1
- package/dist/src/components/TkxColorPicker.d.ts +0 -1
- package/dist/src/components/TkxCommand.d.ts +0 -1
- package/dist/src/components/TkxConfigProvider.d.ts +0 -30
- package/dist/src/components/TkxDataGrid.d.ts +0 -15
- package/dist/src/components/TkxDatePicker.d.ts +0 -1
- package/dist/src/components/TkxDivider.d.ts +0 -1
- package/dist/src/components/TkxDrawer.d.ts +0 -1
- package/dist/src/components/TkxDropdown.d.ts +0 -1
- package/dist/src/components/TkxEmpty.d.ts +0 -1
- package/dist/src/components/TkxFileUpload.d.ts +0 -1
- package/dist/src/components/TkxForm.d.ts +0 -35
- package/dist/src/components/TkxIcon.d.ts +0 -1
- package/dist/src/components/TkxImage.d.ts +0 -1
- package/dist/src/components/TkxInput.d.ts +1 -1
- package/dist/src/components/TkxLayout.d.ts +0 -22
- package/dist/src/components/TkxList.d.ts +0 -1
- package/dist/src/components/TkxLiveFeed.d.ts +0 -1
- package/dist/src/components/TkxLiveLog.d.ts +0 -1
- package/dist/src/components/TkxLiveMetrics.d.ts +0 -1
- package/dist/src/components/TkxLogo.d.ts +0 -1
- package/dist/src/components/TkxMarkdown.d.ts +0 -10
- package/dist/src/components/TkxMasonry.d.ts +0 -1
- package/dist/src/components/TkxMentions.d.ts +0 -1
- package/dist/src/components/TkxMenu.d.ts +0 -1
- package/dist/src/components/TkxModal.d.ts +0 -1
- package/dist/src/components/TkxNumberInput.d.ts +0 -1
- package/dist/src/components/TkxOTP.d.ts +0 -1
- package/dist/src/components/TkxOrgChart.d.ts +32 -0
- package/dist/src/components/TkxPagination.d.ts +0 -1
- package/dist/src/components/TkxPlayground.d.ts +0 -13
- package/dist/src/components/TkxPopover.d.ts +0 -1
- package/dist/src/components/TkxProgress.d.ts +0 -1
- package/dist/src/components/TkxQRCode.d.ts +0 -1
- package/dist/src/components/TkxQuantumForm.d.ts +0 -1
- package/dist/src/components/TkxRadio.d.ts +0 -1
- package/dist/src/components/TkxRating.d.ts +0 -1
- package/dist/src/components/TkxRealTimeChart.d.ts +0 -1
- package/dist/src/components/TkxResult.d.ts +0 -1
- package/dist/src/components/TkxRichTextDisplay.d.ts +0 -1
- package/dist/src/components/TkxSegmented.d.ts +0 -1
- package/dist/src/components/TkxSelect.d.ts +0 -3
- package/dist/src/components/TkxSkeleton.d.ts +0 -1
- package/dist/src/components/TkxSlider.d.ts +0 -1
- package/dist/src/components/TkxSnackbar.d.ts +0 -1
- package/dist/src/components/TkxSpeedDial.d.ts +0 -1
- package/dist/src/components/TkxSpin.d.ts +0 -1
- package/dist/src/components/TkxStatistic.d.ts +0 -1
- package/dist/src/components/TkxStepper.d.ts +0 -1
- package/dist/src/components/TkxTable.d.ts +0 -1
- package/dist/src/components/TkxTabs.d.ts +0 -1
- package/dist/src/components/TkxTag.d.ts +0 -1
- package/dist/src/components/TkxThemeBuilder.d.ts +0 -1
- package/dist/src/components/TkxTimeline.d.ts +0 -1
- package/dist/src/components/TkxToast.d.ts +0 -1
- package/dist/src/components/TkxToggle.d.ts +0 -1
- package/dist/src/components/TkxToolbar.d.ts +0 -1
- package/dist/src/components/TkxTooltip.d.ts +0 -1
- package/dist/src/components/TkxTour.d.ts +0 -1
- package/dist/src/components/TkxTransferList.d.ts +0 -1
- package/dist/src/components/TkxTreeView.d.ts +0 -1
- package/dist/src/components/TkxTypography.d.ts +0 -1
- package/dist/src/components/TkxVideoPlayer.d.ts +0 -1
- package/dist/src/components/TkxWatermark.d.ts +0 -1
- package/dist/src/components/index.d.ts +1 -1
- package/dist/src/engine/css.d.ts +0 -1
- package/dist/src/engine/index.d.ts +0 -1
- package/dist/src/engine/quantum-ai.d.ts +0 -73
- package/dist/src/engine/quantum.d.ts +0 -1
- package/dist/src/engine/security.d.ts +45 -9
- package/dist/src/engine/tkx.d.ts +0 -53
- package/dist/src/engine/wcag.d.ts +0 -1
- package/dist/src/headless/index.d.ts +0 -1
- package/dist/src/headless/useControllable.d.ts +0 -15
- package/dist/src/headless/useDebounce.d.ts +0 -12
- package/dist/src/headless/useDisclosure.d.ts +0 -13
- package/dist/src/headless/useFormState.d.ts +0 -13
- package/dist/src/headless/useInfiniteQuery.d.ts +0 -11
- package/dist/src/headless/useIntersectionObserver.d.ts +0 -10
- package/dist/src/headless/useListSelection.d.ts +0 -9
- package/dist/src/headless/useLocalStorage.d.ts +0 -8
- package/dist/src/headless/useMediaQuery.d.ts +0 -10
- package/dist/src/headless/useRovingTabIndex.d.ts +0 -15
- package/dist/src/headless/useSSE.d.ts +0 -9
- package/dist/src/headless/useThrottle.d.ts +0 -7
- package/dist/src/headless/useWebSocket.d.ts +0 -9
- package/dist/src/hooks/index.d.ts +0 -1
- package/dist/src/i18n/I18nProvider.d.ts +0 -1
- package/dist/src/i18n/index.d.ts +0 -1
- package/dist/src/quantum/index.d.ts +0 -1
- package/dist/src/realtime/index.d.ts +0 -1
- package/dist/src/themes/index.d.ts +0 -1
- package/package.json +5 -3
- package/dist/TkxForm-BaO4wvXt.js +0 -320
- package/dist/TkxForm-M6ttomry.cjs +0 -12
- package/dist/chunk-Bmb41Sf3.cjs +0 -1
- package/dist/hooks-6pRsPOyG.js +0 -58
- package/dist/hooks-mivgRljH.cjs +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/src/a11y/index.d.ts.map +0 -1
- package/dist/src/charts/TkxAreaChart.d.ts.map +0 -1
- package/dist/src/charts/TkxBarChart.d.ts.map +0 -1
- package/dist/src/charts/TkxDonutChart.d.ts.map +0 -1
- package/dist/src/charts/TkxLineChart.d.ts.map +0 -1
- package/dist/src/charts/TkxPieChart.d.ts.map +0 -1
- package/dist/src/charts/TkxRadarChart.d.ts.map +0 -1
- package/dist/src/charts/TkxScatterChart.d.ts.map +0 -1
- package/dist/src/charts/index.d.ts.map +0 -1
- package/dist/src/charts/shared.d.ts.map +0 -1
- package/dist/src/components/TkxAIChatBubble.d.ts.map +0 -1
- package/dist/src/components/TkxAIConfidenceBar.d.ts.map +0 -1
- package/dist/src/components/TkxAIThinking.d.ts.map +0 -1
- package/dist/src/components/TkxAccordion.d.ts.map +0 -1
- package/dist/src/components/TkxAffix.d.ts.map +0 -1
- package/dist/src/components/TkxAlert.d.ts.map +0 -1
- package/dist/src/components/TkxAnchor.d.ts.map +0 -1
- package/dist/src/components/TkxAppBar.d.ts.map +0 -1
- package/dist/src/components/TkxAutocomplete.d.ts.map +0 -1
- package/dist/src/components/TkxAvatar.d.ts.map +0 -1
- package/dist/src/components/TkxBadge.d.ts.map +0 -1
- package/dist/src/components/TkxBottomNav.d.ts.map +0 -1
- package/dist/src/components/TkxBreadcrumb.d.ts.map +0 -1
- package/dist/src/components/TkxButton.d.ts.map +0 -1
- package/dist/src/components/TkxCard.d.ts.map +0 -1
- package/dist/src/components/TkxCarousel.d.ts.map +0 -1
- package/dist/src/components/TkxCascader.d.ts.map +0 -1
- package/dist/src/components/TkxChat.d.ts.map +0 -1
- package/dist/src/components/TkxCheckbox.d.ts.map +0 -1
- package/dist/src/components/TkxClock.d.ts.map +0 -1
- package/dist/src/components/TkxColorPicker.d.ts.map +0 -1
- package/dist/src/components/TkxCommand.d.ts.map +0 -1
- package/dist/src/components/TkxConfigProvider.d.ts.map +0 -1
- package/dist/src/components/TkxDataGrid.d.ts.map +0 -1
- package/dist/src/components/TkxDatePicker.d.ts.map +0 -1
- package/dist/src/components/TkxDivider.d.ts.map +0 -1
- package/dist/src/components/TkxDrawer.d.ts.map +0 -1
- package/dist/src/components/TkxDropdown.d.ts.map +0 -1
- package/dist/src/components/TkxEmpty.d.ts.map +0 -1
- package/dist/src/components/TkxFileUpload.d.ts.map +0 -1
- package/dist/src/components/TkxForm.d.ts.map +0 -1
- package/dist/src/components/TkxIcon.d.ts.map +0 -1
- package/dist/src/components/TkxImage.d.ts.map +0 -1
- package/dist/src/components/TkxInput.d.ts.map +0 -1
- package/dist/src/components/TkxLayout.d.ts.map +0 -1
- package/dist/src/components/TkxList.d.ts.map +0 -1
- package/dist/src/components/TkxLiveFeed.d.ts.map +0 -1
- package/dist/src/components/TkxLiveLog.d.ts.map +0 -1
- package/dist/src/components/TkxLiveMetrics.d.ts.map +0 -1
- package/dist/src/components/TkxLogo.d.ts.map +0 -1
- package/dist/src/components/TkxMarkdown.d.ts.map +0 -1
- package/dist/src/components/TkxMasonry.d.ts.map +0 -1
- package/dist/src/components/TkxMentions.d.ts.map +0 -1
- package/dist/src/components/TkxMenu.d.ts.map +0 -1
- package/dist/src/components/TkxModal.d.ts.map +0 -1
- package/dist/src/components/TkxNumberInput.d.ts.map +0 -1
- package/dist/src/components/TkxOTP.d.ts.map +0 -1
- package/dist/src/components/TkxPagination.d.ts.map +0 -1
- package/dist/src/components/TkxPlayground.d.ts.map +0 -1
- package/dist/src/components/TkxPopover.d.ts.map +0 -1
- package/dist/src/components/TkxProgress.d.ts.map +0 -1
- package/dist/src/components/TkxQRCode.d.ts.map +0 -1
- package/dist/src/components/TkxQuantumForm.d.ts.map +0 -1
- package/dist/src/components/TkxRadio.d.ts.map +0 -1
- package/dist/src/components/TkxRating.d.ts.map +0 -1
- package/dist/src/components/TkxRealTimeChart.d.ts.map +0 -1
- package/dist/src/components/TkxResult.d.ts.map +0 -1
- package/dist/src/components/TkxRichTextDisplay.d.ts.map +0 -1
- package/dist/src/components/TkxSegmented.d.ts.map +0 -1
- package/dist/src/components/TkxSelect.d.ts.map +0 -1
- package/dist/src/components/TkxSkeleton.d.ts.map +0 -1
- package/dist/src/components/TkxSlider.d.ts.map +0 -1
- package/dist/src/components/TkxSnackbar.d.ts.map +0 -1
- package/dist/src/components/TkxSpeedDial.d.ts.map +0 -1
- package/dist/src/components/TkxSpin.d.ts.map +0 -1
- package/dist/src/components/TkxStatistic.d.ts.map +0 -1
- package/dist/src/components/TkxStepper.d.ts.map +0 -1
- package/dist/src/components/TkxTable.d.ts.map +0 -1
- package/dist/src/components/TkxTabs.d.ts.map +0 -1
- package/dist/src/components/TkxTag.d.ts.map +0 -1
- package/dist/src/components/TkxThemeBuilder.d.ts.map +0 -1
- package/dist/src/components/TkxTimeline.d.ts.map +0 -1
- package/dist/src/components/TkxToast.d.ts.map +0 -1
- package/dist/src/components/TkxToggle.d.ts.map +0 -1
- package/dist/src/components/TkxToolbar.d.ts.map +0 -1
- package/dist/src/components/TkxTooltip.d.ts.map +0 -1
- package/dist/src/components/TkxTour.d.ts.map +0 -1
- package/dist/src/components/TkxTransferList.d.ts.map +0 -1
- package/dist/src/components/TkxTreeView.d.ts.map +0 -1
- package/dist/src/components/TkxTypography.d.ts.map +0 -1
- package/dist/src/components/TkxVideoPlayer.d.ts.map +0 -1
- package/dist/src/components/TkxWatermark.d.ts.map +0 -1
- package/dist/src/components/index.d.ts.map +0 -1
- package/dist/src/engine/css.d.ts.map +0 -1
- package/dist/src/engine/index.d.ts.map +0 -1
- package/dist/src/engine/quantum-ai.d.ts.map +0 -1
- package/dist/src/engine/quantum.d.ts.map +0 -1
- package/dist/src/engine/security.d.ts.map +0 -1
- package/dist/src/engine/tkx.d.ts.map +0 -1
- package/dist/src/engine/wcag.d.ts.map +0 -1
- package/dist/src/headless/index.d.ts.map +0 -1
- package/dist/src/headless/useControllable.d.ts.map +0 -1
- package/dist/src/headless/useDebounce.d.ts.map +0 -1
- package/dist/src/headless/useDisclosure.d.ts.map +0 -1
- package/dist/src/headless/useFormState.d.ts.map +0 -1
- package/dist/src/headless/useInfiniteQuery.d.ts.map +0 -1
- package/dist/src/headless/useIntersectionObserver.d.ts.map +0 -1
- package/dist/src/headless/useListSelection.d.ts.map +0 -1
- package/dist/src/headless/useLocalStorage.d.ts.map +0 -1
- package/dist/src/headless/useMediaQuery.d.ts.map +0 -1
- package/dist/src/headless/useRovingTabIndex.d.ts.map +0 -1
- package/dist/src/headless/useSSE.d.ts.map +0 -1
- package/dist/src/headless/useThrottle.d.ts.map +0 -1
- package/dist/src/headless/useWebSocket.d.ts.map +0 -1
- package/dist/src/hooks/index.d.ts.map +0 -1
- package/dist/src/i18n/I18nProvider.d.ts.map +0 -1
- package/dist/src/i18n/index.d.ts.map +0 -1
- package/dist/src/quantum/index.d.ts.map +0 -1
- package/dist/src/realtime/index.d.ts.map +0 -1
- package/dist/src/themes/index.d.ts.map +0 -1
- package/dist/themes-BbJanqiC.js +0 -498
- package/dist/themes-CMq2vWXj.cjs +0 -2
- package/dist/tkx-BoP5V5zy.cjs +0 -4
- package/dist/tkx-mOKMzvUK.js +0 -1174
- package/src/a11y/index.tsx +0 -87
- package/src/charts/TkxAreaChart.tsx +0 -121
- package/src/charts/TkxBarChart.tsx +0 -117
- package/src/charts/TkxDonutChart.tsx +0 -164
- package/src/charts/TkxLineChart.tsx +0 -137
- package/src/charts/TkxPieChart.tsx +0 -103
- package/src/charts/TkxRadarChart.tsx +0 -92
- package/src/charts/TkxScatterChart.tsx +0 -104
- package/src/charts/index.ts +0 -22
- package/src/charts/shared.ts +0 -47
- package/src/components/TkxAIChatBubble.tsx +0 -256
- package/src/components/TkxAIConfidenceBar.tsx +0 -133
- package/src/components/TkxAIThinking.tsx +0 -193
- package/src/components/TkxAccordion.tsx +0 -590
- package/src/components/TkxAffix.tsx +0 -140
- package/src/components/TkxAlert.tsx +0 -94
- package/src/components/TkxAnchor.tsx +0 -195
- package/src/components/TkxAppBar.tsx +0 -262
- package/src/components/TkxAutocomplete.tsx +0 -455
- package/src/components/TkxAvatar.tsx +0 -103
- package/src/components/TkxBadge.tsx +0 -75
- package/src/components/TkxBottomNav.tsx +0 -241
- package/src/components/TkxBreadcrumb.tsx +0 -324
- package/src/components/TkxButton.tsx +0 -155
- package/src/components/TkxCard.tsx +0 -96
- package/src/components/TkxCarousel.tsx +0 -554
- package/src/components/TkxCascader.tsx +0 -278
- package/src/components/TkxChat.tsx +0 -356
- package/src/components/TkxCheckbox.tsx +0 -220
- package/src/components/TkxClock.tsx +0 -603
- package/src/components/TkxColorPicker.tsx +0 -635
- package/src/components/TkxCommand.tsx +0 -646
- package/src/components/TkxConfigProvider.tsx +0 -460
- package/src/components/TkxDataGrid.tsx +0 -941
- package/src/components/TkxDatePicker.tsx +0 -1625
- package/src/components/TkxDivider.tsx +0 -51
- package/src/components/TkxDrawer.tsx +0 -236
- package/src/components/TkxDropdown.tsx +0 -804
- package/src/components/TkxEmpty.tsx +0 -221
- package/src/components/TkxFileUpload.tsx +0 -373
- package/src/components/TkxForm.tsx +0 -683
- package/src/components/TkxIcon.tsx +0 -685
- package/src/components/TkxImage.tsx +0 -279
- package/src/components/TkxInput.tsx +0 -103
- package/src/components/TkxLayout.tsx +0 -649
- package/src/components/TkxList.tsx +0 -244
- package/src/components/TkxLiveFeed.tsx +0 -331
- package/src/components/TkxLiveLog.tsx +0 -472
- package/src/components/TkxLiveMetrics.tsx +0 -315
- package/src/components/TkxLogo.tsx +0 -299
- package/src/components/TkxMarkdown.tsx +0 -855
- package/src/components/TkxMasonry.tsx +0 -178
- package/src/components/TkxMentions.tsx +0 -212
- package/src/components/TkxMenu.tsx +0 -1044
- package/src/components/TkxModal.tsx +0 -122
- package/src/components/TkxNumberInput.tsx +0 -410
- package/src/components/TkxOTP.tsx +0 -297
- package/src/components/TkxPagination.tsx +0 -390
- package/src/components/TkxPlayground.tsx +0 -845
- package/src/components/TkxPopover.tsx +0 -297
- package/src/components/TkxProgress.tsx +0 -114
- package/src/components/TkxQRCode.tsx +0 -176
- package/src/components/TkxQuantumForm.tsx +0 -594
- package/src/components/TkxRadio.tsx +0 -286
- package/src/components/TkxRating.tsx +0 -288
- package/src/components/TkxRealTimeChart.tsx +0 -383
- package/src/components/TkxResult.tsx +0 -130
- package/src/components/TkxRichTextDisplay.tsx +0 -396
- package/src/components/TkxSegmented.tsx +0 -171
- package/src/components/TkxSelect.tsx +0 -1130
- package/src/components/TkxSkeleton.tsx +0 -107
- package/src/components/TkxSlider.tsx +0 -495
- package/src/components/TkxSnackbar.tsx +0 -316
- package/src/components/TkxSpeedDial.tsx +0 -397
- package/src/components/TkxSpin.tsx +0 -263
- package/src/components/TkxStatistic.tsx +0 -263
- package/src/components/TkxStepper.tsx +0 -487
- package/src/components/TkxTable.tsx +0 -424
- package/src/components/TkxTabs.tsx +0 -126
- package/src/components/TkxTag.tsx +0 -321
- package/src/components/TkxThemeBuilder.tsx +0 -687
- package/src/components/TkxTimeline.tsx +0 -305
- package/src/components/TkxToast.tsx +0 -287
- package/src/components/TkxToggle.tsx +0 -95
- package/src/components/TkxToolbar.tsx +0 -262
- package/src/components/TkxTooltip.tsx +0 -85
- package/src/components/TkxTour.tsx +0 -241
- package/src/components/TkxTransferList.tsx +0 -489
- package/src/components/TkxTreeView.tsx +0 -423
- package/src/components/TkxTypography.tsx +0 -267
- package/src/components/TkxVideoPlayer.tsx +0 -1015
- package/src/components/TkxWatermark.tsx +0 -145
- package/src/components/index.ts +0 -80
- package/src/engine/css.ts +0 -126
- package/src/engine/index.ts +0 -12
- package/src/engine/quantum-ai.ts +0 -1045
- package/src/engine/quantum.ts +0 -207
- package/src/engine/security.ts +0 -232
- package/src/engine/tkx.ts +0 -1084
- package/src/engine/wcag.ts +0 -276
- package/src/headless/index.ts +0 -52
- package/src/headless/useControllable.ts +0 -42
- package/src/headless/useDebounce.ts +0 -37
- package/src/headless/useDisclosure.ts +0 -30
- package/src/headless/useFormState.ts +0 -113
- package/src/headless/useInfiniteQuery.ts +0 -155
- package/src/headless/useIntersectionObserver.ts +0 -53
- package/src/headless/useListSelection.ts +0 -103
- package/src/headless/useLocalStorage.ts +0 -48
- package/src/headless/useMediaQuery.ts +0 -39
- package/src/headless/useRovingTabIndex.ts +0 -86
- package/src/headless/useSSE.ts +0 -167
- package/src/headless/useThrottle.ts +0 -48
- package/src/headless/useWebSocket.ts +0 -231
- package/src/hooks/index.ts +0 -122
- package/src/i18n/I18nProvider.tsx +0 -36
- package/src/i18n/index.ts +0 -877
- package/src/quantum/index.ts +0 -39
- package/src/realtime/index.ts +0 -21
- package/src/styles/global.css +0 -167
- package/src/themes/index.ts +0 -294
|
@@ -1,455 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
useState,
|
|
5
|
-
useRef,
|
|
6
|
-
useEffect,
|
|
7
|
-
useCallback,
|
|
8
|
-
useId,
|
|
9
|
-
useMemo,
|
|
10
|
-
type ReactNode,
|
|
11
|
-
type CSSProperties,
|
|
12
|
-
type KeyboardEvent,
|
|
13
|
-
} from 'react';
|
|
14
|
-
import { createPortal } from 'react-dom';
|
|
15
|
-
import { useTheme } from '../themes';
|
|
16
|
-
import { sanitizeString } from '../engine/security';
|
|
17
|
-
import { useReducedMotion, useEscapeKey } from '../hooks';
|
|
18
|
-
import { tkx } from '../engine/tkx';
|
|
19
|
-
|
|
20
|
-
// ── Types ─────────────────────────────────────────────────────────────────────
|
|
21
|
-
|
|
22
|
-
export interface AutocompleteOption {
|
|
23
|
-
value: string;
|
|
24
|
-
label: string;
|
|
25
|
-
description?: string;
|
|
26
|
-
icon?: ReactNode;
|
|
27
|
-
disabled?: boolean;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export interface TkxAutocompleteProps {
|
|
31
|
-
options: AutocompleteOption[];
|
|
32
|
-
value?: string;
|
|
33
|
-
onChange?: (value: string) => void;
|
|
34
|
-
onInputChange?: (input: string) => void;
|
|
35
|
-
placeholder?: string;
|
|
36
|
-
label: string;
|
|
37
|
-
isLoading?: boolean;
|
|
38
|
-
emptyMessage?: string;
|
|
39
|
-
filterFn?: (option: AutocompleteOption, input: string) => boolean;
|
|
40
|
-
freeSolo?: boolean;
|
|
41
|
-
className?: string;
|
|
42
|
-
style?: CSSProperties;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
// ── Default fuzzy filter ────────────────────────────────────────────────────
|
|
46
|
-
|
|
47
|
-
function defaultFilter(option: AutocompleteOption, input: string): boolean {
|
|
48
|
-
if (!input) return true;
|
|
49
|
-
const query = input.toLowerCase();
|
|
50
|
-
const label = option.label.toLowerCase();
|
|
51
|
-
// Fuzzy: check if all chars of query appear in order in label
|
|
52
|
-
let qi = 0;
|
|
53
|
-
for (let li = 0; li < label.length && qi < query.length; li++) {
|
|
54
|
-
if (label[li] === query[qi]) qi++;
|
|
55
|
-
}
|
|
56
|
-
return qi === query.length;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
// ── Dropdown positioning ────────────────────────────────────────────────────
|
|
60
|
-
|
|
61
|
-
interface DropdownPos {
|
|
62
|
-
top: number;
|
|
63
|
-
left: number;
|
|
64
|
-
width: number;
|
|
65
|
-
placement: 'below' | 'above';
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
function calcDropdown(triggerEl: HTMLElement, maxHeight: number): DropdownPos {
|
|
69
|
-
const rect = triggerEl.getBoundingClientRect();
|
|
70
|
-
const gap = 4;
|
|
71
|
-
const spaceBelow = window.innerHeight - rect.bottom;
|
|
72
|
-
const spaceAbove = rect.top;
|
|
73
|
-
|
|
74
|
-
const placement = spaceBelow >= maxHeight + gap || spaceBelow >= spaceAbove ? 'below' : 'above';
|
|
75
|
-
|
|
76
|
-
return {
|
|
77
|
-
top:
|
|
78
|
-
placement === 'below'
|
|
79
|
-
? rect.bottom + window.scrollY + gap
|
|
80
|
-
: rect.top + window.scrollY - maxHeight - gap,
|
|
81
|
-
left: rect.left + window.scrollX,
|
|
82
|
-
width: rect.width,
|
|
83
|
-
placement,
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
// ── Spinner ─────────────────────────────────────────────────────────────────
|
|
88
|
-
|
|
89
|
-
function Spinner({ color }: { color: string }) {
|
|
90
|
-
return (
|
|
91
|
-
<svg
|
|
92
|
-
width="16"
|
|
93
|
-
height="16"
|
|
94
|
-
viewBox="0 0 16 16"
|
|
95
|
-
fill="none"
|
|
96
|
-
aria-hidden="true"
|
|
97
|
-
style={{ animation: 'spin 0.8s linear infinite', flexShrink: 0 }}
|
|
98
|
-
>
|
|
99
|
-
<circle cx="8" cy="8" r="6" stroke={color} strokeWidth="2" opacity="0.3" />
|
|
100
|
-
<path
|
|
101
|
-
d="M14 8a6 6 0 00-6-6"
|
|
102
|
-
stroke={color}
|
|
103
|
-
strokeWidth="2"
|
|
104
|
-
strokeLinecap="round"
|
|
105
|
-
/>
|
|
106
|
-
</svg>
|
|
107
|
-
);
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
// ── Component ───────────────────────────────────────────────────────────────
|
|
111
|
-
|
|
112
|
-
const MAX_DROPDOWN_HEIGHT = 280;
|
|
113
|
-
|
|
114
|
-
export function TkxAutocomplete({
|
|
115
|
-
options,
|
|
116
|
-
value,
|
|
117
|
-
onChange,
|
|
118
|
-
onInputChange,
|
|
119
|
-
placeholder = '',
|
|
120
|
-
label,
|
|
121
|
-
isLoading = false,
|
|
122
|
-
emptyMessage = 'No results found',
|
|
123
|
-
filterFn,
|
|
124
|
-
freeSolo = false,
|
|
125
|
-
className,
|
|
126
|
-
style,
|
|
127
|
-
}: TkxAutocompleteProps) {
|
|
128
|
-
const theme = useTheme();
|
|
129
|
-
const reducedMotion = useReducedMotion();
|
|
130
|
-
const inputId = useId();
|
|
131
|
-
const listboxId = useId();
|
|
132
|
-
|
|
133
|
-
const inputRef = useRef<HTMLInputElement>(null);
|
|
134
|
-
const wrapperRef = useRef<HTMLDivElement>(null);
|
|
135
|
-
|
|
136
|
-
const [inputValue, setInputValue] = useState('');
|
|
137
|
-
const [isOpen, setIsOpen] = useState(false);
|
|
138
|
-
const [activeIndex, setActiveIndex] = useState(-1);
|
|
139
|
-
const [dropdownPos, setDropdownPos] = useState<DropdownPos | null>(null);
|
|
140
|
-
|
|
141
|
-
// Sync input value from controlled value
|
|
142
|
-
useEffect(() => {
|
|
143
|
-
if (value !== undefined) {
|
|
144
|
-
const selectedOption = options.find((o) => o.value === value);
|
|
145
|
-
setInputValue(selectedOption ? selectedOption.label : value);
|
|
146
|
-
}
|
|
147
|
-
}, [value, options]);
|
|
148
|
-
|
|
149
|
-
const filter = filterFn ?? defaultFilter;
|
|
150
|
-
|
|
151
|
-
const filtered = useMemo(() => {
|
|
152
|
-
if (!isOpen) return [];
|
|
153
|
-
return options.filter((o) => filter(o, inputValue));
|
|
154
|
-
}, [options, inputValue, isOpen, filter]);
|
|
155
|
-
|
|
156
|
-
const safeLabel = sanitizeString(label);
|
|
157
|
-
const safeEmptyMessage = sanitizeString(emptyMessage);
|
|
158
|
-
|
|
159
|
-
// Position the dropdown
|
|
160
|
-
useEffect(() => {
|
|
161
|
-
if (!isOpen || !wrapperRef.current) return;
|
|
162
|
-
const update = () => {
|
|
163
|
-
if (!wrapperRef.current) return;
|
|
164
|
-
setDropdownPos(calcDropdown(wrapperRef.current, MAX_DROPDOWN_HEIGHT));
|
|
165
|
-
};
|
|
166
|
-
update();
|
|
167
|
-
window.addEventListener('scroll', update, true);
|
|
168
|
-
window.addEventListener('resize', update);
|
|
169
|
-
return () => {
|
|
170
|
-
window.removeEventListener('scroll', update, true);
|
|
171
|
-
window.removeEventListener('resize', update);
|
|
172
|
-
};
|
|
173
|
-
}, [isOpen]);
|
|
174
|
-
|
|
175
|
-
// Close on click outside
|
|
176
|
-
useEffect(() => {
|
|
177
|
-
if (!isOpen) return;
|
|
178
|
-
const handler = (e: PointerEvent) => {
|
|
179
|
-
const target = e.target as Node;
|
|
180
|
-
if (wrapperRef.current?.contains(target)) return;
|
|
181
|
-
// check portal dropdown
|
|
182
|
-
const dropdown = document.getElementById(listboxId);
|
|
183
|
-
if (dropdown?.contains(target)) return;
|
|
184
|
-
setIsOpen(false);
|
|
185
|
-
};
|
|
186
|
-
document.addEventListener('pointerdown', handler);
|
|
187
|
-
return () => document.removeEventListener('pointerdown', handler);
|
|
188
|
-
}, [isOpen, listboxId]);
|
|
189
|
-
|
|
190
|
-
useEscapeKey(() => setIsOpen(false), isOpen);
|
|
191
|
-
|
|
192
|
-
const selectOption = useCallback(
|
|
193
|
-
(option: AutocompleteOption) => {
|
|
194
|
-
if (option.disabled) return;
|
|
195
|
-
setInputValue(option.label);
|
|
196
|
-
onChange?.(option.value);
|
|
197
|
-
setIsOpen(false);
|
|
198
|
-
setActiveIndex(-1);
|
|
199
|
-
inputRef.current?.focus();
|
|
200
|
-
},
|
|
201
|
-
[onChange],
|
|
202
|
-
);
|
|
203
|
-
|
|
204
|
-
const handleInputChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
|
205
|
-
const val = e.target.value;
|
|
206
|
-
setInputValue(val);
|
|
207
|
-
onInputChange?.(val);
|
|
208
|
-
if (!isOpen) setIsOpen(true);
|
|
209
|
-
setActiveIndex(-1);
|
|
210
|
-
if (freeSolo) {
|
|
211
|
-
onChange?.(val);
|
|
212
|
-
}
|
|
213
|
-
};
|
|
214
|
-
|
|
215
|
-
const handleKeyDown = (e: KeyboardEvent<HTMLInputElement>) => {
|
|
216
|
-
if (!isOpen && (e.key === 'ArrowDown' || e.key === 'ArrowUp')) {
|
|
217
|
-
setIsOpen(true);
|
|
218
|
-
return;
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
switch (e.key) {
|
|
222
|
-
case 'ArrowDown': {
|
|
223
|
-
e.preventDefault();
|
|
224
|
-
setActiveIndex((prev) => {
|
|
225
|
-
let next = prev + 1;
|
|
226
|
-
while (next < filtered.length && filtered[next].disabled) next++;
|
|
227
|
-
return next < filtered.length ? next : prev;
|
|
228
|
-
});
|
|
229
|
-
break;
|
|
230
|
-
}
|
|
231
|
-
case 'ArrowUp': {
|
|
232
|
-
e.preventDefault();
|
|
233
|
-
setActiveIndex((prev) => {
|
|
234
|
-
let next = prev - 1;
|
|
235
|
-
while (next >= 0 && filtered[next].disabled) next--;
|
|
236
|
-
return next >= 0 ? next : prev;
|
|
237
|
-
});
|
|
238
|
-
break;
|
|
239
|
-
}
|
|
240
|
-
case 'Enter': {
|
|
241
|
-
e.preventDefault();
|
|
242
|
-
if (activeIndex >= 0 && activeIndex < filtered.length) {
|
|
243
|
-
selectOption(filtered[activeIndex]);
|
|
244
|
-
} else if (freeSolo && inputValue) {
|
|
245
|
-
onChange?.(inputValue);
|
|
246
|
-
setIsOpen(false);
|
|
247
|
-
}
|
|
248
|
-
break;
|
|
249
|
-
}
|
|
250
|
-
case 'Escape': {
|
|
251
|
-
setIsOpen(false);
|
|
252
|
-
setActiveIndex(-1);
|
|
253
|
-
break;
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
};
|
|
257
|
-
|
|
258
|
-
// Scroll active option into view
|
|
259
|
-
useEffect(() => {
|
|
260
|
-
if (activeIndex < 0) return;
|
|
261
|
-
const optionId = `${listboxId}-opt-${activeIndex}`;
|
|
262
|
-
document.getElementById(optionId)?.scrollIntoView({ block: 'nearest' });
|
|
263
|
-
}, [activeIndex, listboxId]);
|
|
264
|
-
|
|
265
|
-
const activeDescendant =
|
|
266
|
-
activeIndex >= 0 ? `${listboxId}-opt-${activeIndex}` : undefined;
|
|
267
|
-
|
|
268
|
-
const animStyle: CSSProperties = reducedMotion
|
|
269
|
-
? {}
|
|
270
|
-
: { animation: 'tkxAutoFadeIn 120ms ease forwards' };
|
|
271
|
-
|
|
272
|
-
const dropdown =
|
|
273
|
-
isOpen && typeof document !== 'undefined' && dropdownPos
|
|
274
|
-
? createPortal(
|
|
275
|
-
<ul
|
|
276
|
-
id={listboxId}
|
|
277
|
-
role="listbox"
|
|
278
|
-
aria-label={safeLabel}
|
|
279
|
-
className={tkx('absolute z-[9200] list-none m-0 p-1 rounded-lg overflow-y-auto font-sans')}
|
|
280
|
-
style={{
|
|
281
|
-
top: dropdownPos.top,
|
|
282
|
-
left: dropdownPos.left,
|
|
283
|
-
width: dropdownPos.width,
|
|
284
|
-
maxHeight: MAX_DROPDOWN_HEIGHT,
|
|
285
|
-
backgroundColor: theme.surface,
|
|
286
|
-
border: `1px solid ${theme.border}`,
|
|
287
|
-
boxShadow: `0 8px 24px rgba(0,0,0,0.15)`,
|
|
288
|
-
...animStyle,
|
|
289
|
-
}}
|
|
290
|
-
>
|
|
291
|
-
{isLoading ? (
|
|
292
|
-
<li
|
|
293
|
-
role="option"
|
|
294
|
-
aria-selected={false}
|
|
295
|
-
aria-disabled="true"
|
|
296
|
-
className={tkx('flex items-center gap-2 px-3 py-2 text-sm')}
|
|
297
|
-
style={{ color: theme.textMuted }}
|
|
298
|
-
>
|
|
299
|
-
<Spinner color={theme.primary} />
|
|
300
|
-
Loading...
|
|
301
|
-
</li>
|
|
302
|
-
) : filtered.length === 0 ? (
|
|
303
|
-
<li
|
|
304
|
-
role="option"
|
|
305
|
-
aria-selected={false}
|
|
306
|
-
aria-disabled="true"
|
|
307
|
-
className={tkx('px-3 py-2 text-sm text-center')}
|
|
308
|
-
style={{ color: theme.textMuted }}
|
|
309
|
-
>
|
|
310
|
-
{safeEmptyMessage}
|
|
311
|
-
</li>
|
|
312
|
-
) : (
|
|
313
|
-
filtered.map((option, idx) => {
|
|
314
|
-
const isActive = idx === activeIndex;
|
|
315
|
-
const safeOptionLabel = sanitizeString(option.label);
|
|
316
|
-
const safeDesc = option.description
|
|
317
|
-
? sanitizeString(option.description)
|
|
318
|
-
: null;
|
|
319
|
-
|
|
320
|
-
return (
|
|
321
|
-
<li
|
|
322
|
-
key={option.value}
|
|
323
|
-
id={`${listboxId}-opt-${idx}`}
|
|
324
|
-
role="option"
|
|
325
|
-
aria-selected={option.value === value}
|
|
326
|
-
aria-disabled={option.disabled || undefined}
|
|
327
|
-
className={tkx(
|
|
328
|
-
'flex items-center gap-2 px-3 py-2 text-sm rounded-md cursor-pointer',
|
|
329
|
-
option.disabled ? 'opacity-50 cursor-not-allowed' : '',
|
|
330
|
-
)}
|
|
331
|
-
style={{
|
|
332
|
-
backgroundColor: isActive ? theme.surfaceAlt : 'transparent',
|
|
333
|
-
color: option.disabled ? theme.textMuted : theme.text,
|
|
334
|
-
transition: reducedMotion ? 'none' : 'background-color 100ms ease',
|
|
335
|
-
}}
|
|
336
|
-
onMouseEnter={() => !option.disabled && setActiveIndex(idx)}
|
|
337
|
-
onMouseDown={(e) => {
|
|
338
|
-
e.preventDefault(); // keep focus on input
|
|
339
|
-
selectOption(option);
|
|
340
|
-
}}
|
|
341
|
-
>
|
|
342
|
-
{option.icon && (
|
|
343
|
-
<span aria-hidden="true" className={tkx('flex-shrink-0')}>
|
|
344
|
-
{option.icon}
|
|
345
|
-
</span>
|
|
346
|
-
)}
|
|
347
|
-
<span className={tkx('flex flex-col min-w-0')}>
|
|
348
|
-
<span className={tkx('truncate')}>{safeOptionLabel}</span>
|
|
349
|
-
{safeDesc && (
|
|
350
|
-
<span
|
|
351
|
-
className={tkx('text-xs truncate')}
|
|
352
|
-
style={{ color: theme.textMuted }}
|
|
353
|
-
>
|
|
354
|
-
{safeDesc}
|
|
355
|
-
</span>
|
|
356
|
-
)}
|
|
357
|
-
</span>
|
|
358
|
-
{option.value === value && (
|
|
359
|
-
<svg
|
|
360
|
-
width="16"
|
|
361
|
-
height="16"
|
|
362
|
-
viewBox="0 0 16 16"
|
|
363
|
-
fill="none"
|
|
364
|
-
aria-hidden="true"
|
|
365
|
-
className={tkx('ml-auto flex-shrink-0')}
|
|
366
|
-
>
|
|
367
|
-
<path
|
|
368
|
-
d="M3 8l3.5 3.5L13 5"
|
|
369
|
-
stroke={theme.primary}
|
|
370
|
-
strokeWidth="2"
|
|
371
|
-
strokeLinecap="round"
|
|
372
|
-
strokeLinejoin="round"
|
|
373
|
-
/>
|
|
374
|
-
</svg>
|
|
375
|
-
)}
|
|
376
|
-
</li>
|
|
377
|
-
);
|
|
378
|
-
})
|
|
379
|
-
)}
|
|
380
|
-
</ul>,
|
|
381
|
-
document.body,
|
|
382
|
-
)
|
|
383
|
-
: null;
|
|
384
|
-
|
|
385
|
-
return (
|
|
386
|
-
<div
|
|
387
|
-
ref={wrapperRef}
|
|
388
|
-
className={tkx('relative font-sans', className ?? '')}
|
|
389
|
-
style={style}
|
|
390
|
-
>
|
|
391
|
-
{/* Label */}
|
|
392
|
-
<label
|
|
393
|
-
htmlFor={inputId}
|
|
394
|
-
className={tkx('block text-sm font-medium mb-1.5')}
|
|
395
|
-
style={{ color: theme.text }}
|
|
396
|
-
>
|
|
397
|
-
{safeLabel}
|
|
398
|
-
</label>
|
|
399
|
-
|
|
400
|
-
{/* Input */}
|
|
401
|
-
<div
|
|
402
|
-
className={tkx('relative flex items-center')}
|
|
403
|
-
style={{
|
|
404
|
-
backgroundColor: theme.surface,
|
|
405
|
-
border: `1px solid ${isOpen ? theme.primary : theme.border}`,
|
|
406
|
-
borderRadius: 8,
|
|
407
|
-
transition: reducedMotion ? 'none' : 'border-color 150ms ease',
|
|
408
|
-
}}
|
|
409
|
-
>
|
|
410
|
-
<input
|
|
411
|
-
ref={inputRef}
|
|
412
|
-
id={inputId}
|
|
413
|
-
type="text"
|
|
414
|
-
role="combobox"
|
|
415
|
-
aria-expanded={isOpen}
|
|
416
|
-
aria-controls={listboxId}
|
|
417
|
-
aria-activedescendant={activeDescendant}
|
|
418
|
-
aria-autocomplete="list"
|
|
419
|
-
aria-label={safeLabel}
|
|
420
|
-
value={inputValue}
|
|
421
|
-
placeholder={placeholder}
|
|
422
|
-
onChange={handleInputChange}
|
|
423
|
-
onFocus={() => setIsOpen(true)}
|
|
424
|
-
onKeyDown={handleKeyDown}
|
|
425
|
-
className={tkx(
|
|
426
|
-
'w-full bg-transparent border-none outline-none text-sm py-2.5 px-3',
|
|
427
|
-
'placeholder:opacity-50',
|
|
428
|
-
)}
|
|
429
|
-
style={{
|
|
430
|
-
color: theme.text,
|
|
431
|
-
}}
|
|
432
|
-
/>
|
|
433
|
-
{isLoading && (
|
|
434
|
-
<span className={tkx('pr-3')}>
|
|
435
|
-
<Spinner color={theme.primary} />
|
|
436
|
-
</span>
|
|
437
|
-
)}
|
|
438
|
-
</div>
|
|
439
|
-
|
|
440
|
-
{dropdown}
|
|
441
|
-
|
|
442
|
-
{/* Keyframes */}
|
|
443
|
-
{isOpen && !reducedMotion && (
|
|
444
|
-
<style>{`
|
|
445
|
-
@keyframes tkxAutoFadeIn {
|
|
446
|
-
from { opacity: 0; transform: translateY(4px); }
|
|
447
|
-
to { opacity: 1; transform: translateY(0); }
|
|
448
|
-
}
|
|
449
|
-
`}</style>
|
|
450
|
-
)}
|
|
451
|
-
</div>
|
|
452
|
-
);
|
|
453
|
-
}
|
|
454
|
-
|
|
455
|
-
export default TkxAutocomplete;
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import { forwardRef, useState, type ImgHTMLAttributes } from 'react';
|
|
4
|
-
import { useTheme } from '../themes';
|
|
5
|
-
import { getAccessibleForeground } from '../engine/wcag';
|
|
6
|
-
import { sanitizeString } from '../engine/security';
|
|
7
|
-
import { tkx, cx } from '../engine/tkx';
|
|
8
|
-
|
|
9
|
-
export type AvatarSize = 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
10
|
-
export type AvatarShape = 'circle' | 'square';
|
|
11
|
-
export type AvatarStatus = 'online' | 'offline' | 'away' | 'busy';
|
|
12
|
-
|
|
13
|
-
export interface TkxAvatarProps extends Omit<ImgHTMLAttributes<HTMLImageElement>, 'src' | 'alt'> {
|
|
14
|
-
src?: string;
|
|
15
|
-
alt: string;
|
|
16
|
-
initials?: string;
|
|
17
|
-
size?: AvatarSize;
|
|
18
|
-
shape?: AvatarShape;
|
|
19
|
-
status?: AvatarStatus;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
const SIZE_PX: Record<AvatarSize, number> = { xs: 24, sm: 32, md: 40, lg: 56, xl: 72 };
|
|
23
|
-
const STATUS_COLORS: Record<AvatarStatus, string> = {
|
|
24
|
-
online: '#06d6a0', offline: '#8888aa', away: '#ffbe0b', busy: '#f72585',
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
export const TkxAvatar = forwardRef<HTMLDivElement, TkxAvatarProps>(
|
|
28
|
-
({ src, alt, initials, size = 'md', shape = 'circle', status, className, style, ...rest }, ref) => {
|
|
29
|
-
const theme = useTheme();
|
|
30
|
-
const [imageError, setImageError] = useState(false);
|
|
31
|
-
const px = SIZE_PX[size];
|
|
32
|
-
const isCircle = shape === 'circle';
|
|
33
|
-
const bgColor = theme.surfaceAlt;
|
|
34
|
-
const textColor = getAccessibleForeground(bgColor, [theme.text, theme.textMuted]);
|
|
35
|
-
const showImage = src && !imageError;
|
|
36
|
-
const showInitials = !showImage && initials;
|
|
37
|
-
const statusDotSize = Math.max(8, px * 0.22);
|
|
38
|
-
|
|
39
|
-
const containerClass = tkx(
|
|
40
|
-
'relative inline-flex shrink-0',
|
|
41
|
-
isCircle ? 'rounded-full' : 'rounded-lg',
|
|
42
|
-
);
|
|
43
|
-
|
|
44
|
-
const mediaClass = tkx(
|
|
45
|
-
'block object-cover',
|
|
46
|
-
isCircle ? 'rounded-full' : 'rounded-lg',
|
|
47
|
-
);
|
|
48
|
-
|
|
49
|
-
const fallbackClass = tkx(
|
|
50
|
-
'flex items-center justify-center font-semibold font-sans select-none',
|
|
51
|
-
isCircle ? 'rounded-full' : 'rounded-lg',
|
|
52
|
-
);
|
|
53
|
-
|
|
54
|
-
return (
|
|
55
|
-
<div
|
|
56
|
-
ref={ref}
|
|
57
|
-
className={cx(containerClass, className)}
|
|
58
|
-
style={{ width: px, height: px, ...style }}
|
|
59
|
-
{...(rest as React.HTMLAttributes<HTMLDivElement>)}
|
|
60
|
-
>
|
|
61
|
-
{showImage ? (
|
|
62
|
-
<img
|
|
63
|
-
src={sanitizeString(src!)}
|
|
64
|
-
alt={sanitizeString(alt)}
|
|
65
|
-
onError={() => setImageError(true)}
|
|
66
|
-
className={mediaClass}
|
|
67
|
-
style={{ width: px, height: px }}
|
|
68
|
-
/>
|
|
69
|
-
) : (
|
|
70
|
-
<div
|
|
71
|
-
role="img"
|
|
72
|
-
aria-label={sanitizeString(alt)}
|
|
73
|
-
className={fallbackClass}
|
|
74
|
-
style={{ width: px, height: px, backgroundColor: bgColor, color: textColor, fontSize: px * 0.38 }}
|
|
75
|
-
>
|
|
76
|
-
{showInitials ? (
|
|
77
|
-
sanitizeString(initials!).slice(0, 2).toUpperCase()
|
|
78
|
-
) : (
|
|
79
|
-
<svg width={px * 0.5} height={px * 0.5} viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth={2} aria-hidden="true">
|
|
80
|
-
<path d="M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2" />
|
|
81
|
-
<circle cx="12" cy="7" r="4" />
|
|
82
|
-
</svg>
|
|
83
|
-
)}
|
|
84
|
-
</div>
|
|
85
|
-
)}
|
|
86
|
-
|
|
87
|
-
{status && (
|
|
88
|
-
<span
|
|
89
|
-
aria-label={`Status: ${status}`}
|
|
90
|
-
className={tkx('absolute bottom-0 right-0 rounded-full')}
|
|
91
|
-
style={{
|
|
92
|
-
width: statusDotSize, height: statusDotSize,
|
|
93
|
-
backgroundColor: STATUS_COLORS[status],
|
|
94
|
-
border: `2px solid ${theme.bg}`,
|
|
95
|
-
}}
|
|
96
|
-
/>
|
|
97
|
-
)}
|
|
98
|
-
</div>
|
|
99
|
-
);
|
|
100
|
-
},
|
|
101
|
-
);
|
|
102
|
-
|
|
103
|
-
TkxAvatar.displayName = 'TkxAvatar';
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import { forwardRef, type HTMLAttributes } from 'react';
|
|
4
|
-
import { useTheme } from '../themes';
|
|
5
|
-
import { getAccessibleForeground } from '../engine/wcag';
|
|
6
|
-
import { sanitizeString } from '../engine/security';
|
|
7
|
-
import { tkx, cx } from '../engine/tkx';
|
|
8
|
-
|
|
9
|
-
export type BadgeVariant = 'default' | 'primary' | 'secondary' | 'danger' | 'warning' | 'success' | 'info';
|
|
10
|
-
export type BadgeSize = 'sm' | 'md' | 'lg';
|
|
11
|
-
|
|
12
|
-
export interface TkxBadgeProps extends HTMLAttributes<HTMLSpanElement> {
|
|
13
|
-
variant?: BadgeVariant;
|
|
14
|
-
size?: BadgeSize;
|
|
15
|
-
dot?: boolean;
|
|
16
|
-
pulse?: boolean;
|
|
17
|
-
outlined?: boolean;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
const SIZE_CLASS: Record<BadgeSize, string> = {
|
|
21
|
-
sm: 'text-xs px-1.5 py-[2px] min-h-[16px]',
|
|
22
|
-
md: 'text-xs px-2 py-[3px] min-h-[20px]',
|
|
23
|
-
lg: 'text-sm px-3 py-1 min-h-[24px]',
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
const DOT_SIZE: Record<BadgeSize, string> = { sm: 'size-[6px]', md: 'size-2', lg: 'size-2.5' };
|
|
27
|
-
|
|
28
|
-
export const TkxBadge = forwardRef<HTMLSpanElement, TkxBadgeProps>(
|
|
29
|
-
({ variant = 'default', size = 'md', dot = false, pulse = false, outlined = false, children, className, style, ...rest }, ref) => {
|
|
30
|
-
const theme = useTheme();
|
|
31
|
-
|
|
32
|
-
const colorMap: Record<BadgeVariant, string> = {
|
|
33
|
-
default: theme.border, primary: theme.primary, secondary: theme.secondary,
|
|
34
|
-
danger: theme.danger, warning: theme.warning, success: theme.success, info: theme.info,
|
|
35
|
-
};
|
|
36
|
-
const bgColor = colorMap[variant] || '#666666';
|
|
37
|
-
const textColor = getAccessibleForeground(bgColor, ['#ffffff', '#000000', theme.bg || '#000000']);
|
|
38
|
-
|
|
39
|
-
const safeChildren = typeof children === 'string' ? sanitizeString(children) : children;
|
|
40
|
-
|
|
41
|
-
if (dot) {
|
|
42
|
-
return (
|
|
43
|
-
<span
|
|
44
|
-
ref={ref}
|
|
45
|
-
aria-label={typeof children === 'string' ? sanitizeString(children) : undefined}
|
|
46
|
-
className={cx(tkx('inline-block rounded-full', DOT_SIZE[size], pulse && 'animate-pulse'), className)}
|
|
47
|
-
style={{ backgroundColor: bgColor, ...style }}
|
|
48
|
-
{...rest}
|
|
49
|
-
/>
|
|
50
|
-
);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
return (
|
|
54
|
-
<span
|
|
55
|
-
ref={ref}
|
|
56
|
-
className={cx(tkx(
|
|
57
|
-
'inline-flex items-center justify-center rounded-full font-semibold font-sans tracking-wide',
|
|
58
|
-
SIZE_CLASS[size],
|
|
59
|
-
pulse && 'animate-pulse',
|
|
60
|
-
), className)}
|
|
61
|
-
style={{
|
|
62
|
-
backgroundColor: outlined ? 'transparent' : bgColor,
|
|
63
|
-
color: outlined ? bgColor : textColor,
|
|
64
|
-
border: outlined ? `1px solid ${bgColor}` : 'none',
|
|
65
|
-
...style,
|
|
66
|
-
}}
|
|
67
|
-
{...rest}
|
|
68
|
-
>
|
|
69
|
-
{safeChildren}
|
|
70
|
-
</span>
|
|
71
|
-
);
|
|
72
|
-
},
|
|
73
|
-
);
|
|
74
|
-
|
|
75
|
-
TkxBadge.displayName = 'TkxBadge';
|