@langchain/macaw-components 1.0.0-beta.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/LICENSE +21 -0
- package/README.md +27 -0
- package/dist/_chunks/ErrorState-CmPX01HV.js +13361 -0
- package/dist/_chunks/ErrorState-CmPX01HV.js.map +1 -0
- package/dist/_chunks/LoadingIndicator-DgtU9aqD.js +80 -0
- package/dist/_chunks/LoadingIndicator-DgtU9aqD.js.map +1 -0
- package/dist/base.css +305 -0
- package/dist/catalog.json +1675 -0
- package/dist/components/Avatar/Avatar.d.ts +28 -0
- package/dist/components/Avatar/Avatar.js +47 -0
- package/dist/components/Avatar/Avatar.js.map +1 -0
- package/dist/components/Avatar/index.d.ts +2 -0
- package/dist/components/Avatar/index.js +2 -0
- package/dist/components/Badge/Badge.d.ts +25 -0
- package/dist/components/Badge/Badge.js +82 -0
- package/dist/components/Badge/Badge.js.map +1 -0
- package/dist/components/Badge/index.d.ts +2 -0
- package/dist/components/Badge/index.js +2 -0
- package/dist/components/Banner/Banner.d.ts +15 -0
- package/dist/components/Banner/Banner.js +102 -0
- package/dist/components/Banner/Banner.js.map +1 -0
- package/dist/components/Banner/index.d.ts +2 -0
- package/dist/components/Banner/index.js +2 -0
- package/dist/components/BarChart/AnimatedBar.d.ts +20 -0
- package/dist/components/BarChart/AnimatedBar.js +65 -0
- package/dist/components/BarChart/AnimatedBar.js.map +1 -0
- package/dist/components/BarChart/BarChart.d.ts +25 -0
- package/dist/components/BarChart/BarChart.js +248 -0
- package/dist/components/BarChart/BarChart.js.map +1 -0
- package/dist/components/BarChart/BarChart.types.d.ts +239 -0
- package/dist/components/BarChart/BarChart.types.js +0 -0
- package/dist/components/BarChart/BarChart.utils.d.ts +51 -0
- package/dist/components/BarChart/BarChart.utils.js +215 -0
- package/dist/components/BarChart/BarChart.utils.js.map +1 -0
- package/dist/components/BarChart/BarChartAxes.d.ts +22 -0
- package/dist/components/BarChart/BarChartAxes.js +144 -0
- package/dist/components/BarChart/BarChartAxes.js.map +1 -0
- package/dist/components/BarChart/BarChartGuides.d.ts +22 -0
- package/dist/components/BarChart/BarChartGuides.js +83 -0
- package/dist/components/BarChart/BarChartGuides.js.map +1 -0
- package/dist/components/BarChart/BarChartPlot.d.ts +40 -0
- package/dist/components/BarChart/BarChartPlot.js +262 -0
- package/dist/components/BarChart/BarChartPlot.js.map +1 -0
- package/dist/components/BarChart/constants.d.ts +21 -0
- package/dist/components/BarChart/constants.js +26 -0
- package/dist/components/BarChart/constants.js.map +1 -0
- package/dist/components/BarChart/index.d.ts +3 -0
- package/dist/components/BarChart/index.js +3 -0
- package/dist/components/Button/Button.d.ts +36 -0
- package/dist/components/Button/Button.js +99 -0
- package/dist/components/Button/Button.js.map +1 -0
- package/dist/components/Button/constants.d.ts +26 -0
- package/dist/components/Button/constants.js +31 -0
- package/dist/components/Button/constants.js.map +1 -0
- package/dist/components/Button/index.d.ts +2 -0
- package/dist/components/Button/index.js +2 -0
- package/dist/components/ButtonGroup/ButtonGroup.d.ts +30 -0
- package/dist/components/ButtonGroup/ButtonGroup.js +26 -0
- package/dist/components/ButtonGroup/ButtonGroup.js.map +1 -0
- package/dist/components/ButtonGroup/index.d.ts +2 -0
- package/dist/components/ButtonGroup/index.js +2 -0
- package/dist/components/Card/Card.d.ts +10 -0
- package/dist/components/Card/Card.js +23 -0
- package/dist/components/Card/Card.js.map +1 -0
- package/dist/components/Card/index.d.ts +2 -0
- package/dist/components/Card/index.js +2 -0
- package/dist/components/ChartCard/ChartCard.d.ts +53 -0
- package/dist/components/ChartCard/ChartCard.js +172 -0
- package/dist/components/ChartCard/ChartCard.js.map +1 -0
- package/dist/components/ChartCard/ChartCardSkeleton.d.ts +7 -0
- package/dist/components/ChartCard/ChartCardSkeleton.js +61 -0
- package/dist/components/ChartCard/ChartCardSkeleton.js.map +1 -0
- package/dist/components/ChartCard/index.d.ts +4 -0
- package/dist/components/ChartCard/index.js +3 -0
- package/dist/components/ChartLegend/ChartLegend.d.ts +19 -0
- package/dist/components/ChartLegend/ChartLegend.js +195 -0
- package/dist/components/ChartLegend/ChartLegend.js.map +1 -0
- package/dist/components/ChartLegend/ChartLegendItemRenderer.d.ts +14 -0
- package/dist/components/ChartLegend/ChartLegendItemRenderer.js +90 -0
- package/dist/components/ChartLegend/ChartLegendItemRenderer.js.map +1 -0
- package/dist/components/ChartLegend/index.d.ts +3 -0
- package/dist/components/ChartLegend/index.js +3 -0
- package/dist/components/ChartLegend/useChartLegendActiveItem.d.ts +7 -0
- package/dist/components/ChartLegend/useChartLegendActiveItem.js +35 -0
- package/dist/components/ChartLegend/useChartLegendActiveItem.js.map +1 -0
- package/dist/components/ChartLegend/utils.d.ts +20 -0
- package/dist/components/ChartLegend/utils.js +33 -0
- package/dist/components/ChartLegend/utils.js.map +1 -0
- package/dist/components/ChartTooltip/ChartTooltip.d.ts +23 -0
- package/dist/components/ChartTooltip/ChartTooltip.js +83 -0
- package/dist/components/ChartTooltip/ChartTooltip.js.map +1 -0
- package/dist/components/ChartTooltip/index.d.ts +2 -0
- package/dist/components/ChartTooltip/index.js +2 -0
- package/dist/components/Checkbox/Checkbox.d.ts +58 -0
- package/dist/components/Checkbox/Checkbox.js +50 -0
- package/dist/components/Checkbox/Checkbox.js.map +1 -0
- package/dist/components/Checkbox/constants.d.ts +28 -0
- package/dist/components/Checkbox/constants.js +57 -0
- package/dist/components/Checkbox/constants.js.map +1 -0
- package/dist/components/Checkbox/getCheckedState.d.ts +6 -0
- package/dist/components/Checkbox/getCheckedState.js +14 -0
- package/dist/components/Checkbox/getCheckedState.js.map +1 -0
- package/dist/components/Checkbox/index.d.ts +3 -0
- package/dist/components/Checkbox/index.js +3 -0
- package/dist/components/CircularProgress/CircularProgress.d.ts +54 -0
- package/dist/components/CircularProgress/CircularProgress.js +85 -0
- package/dist/components/CircularProgress/CircularProgress.js.map +1 -0
- package/dist/components/CircularProgress/index.d.ts +2 -0
- package/dist/components/CircularProgress/index.js +2 -0
- package/dist/components/Code/Code.utils.d.ts +24 -0
- package/dist/components/Code/Code.utils.js +160 -0
- package/dist/components/Code/Code.utils.js.map +1 -0
- package/dist/components/Code/CodeLite.d.ts +19 -0
- package/dist/components/Code/CodeLite.js +146 -0
- package/dist/components/Code/CodeLite.js.map +1 -0
- package/dist/components/Code/CodeLite.utils.d.ts +24 -0
- package/dist/components/Code/CodeLite.utils.js +273 -0
- package/dist/components/Code/CodeLite.utils.js.map +1 -0
- package/dist/components/Code/ImageReplacerExtension.d.ts +9 -0
- package/dist/components/Code/ImageReplacerExtension.js +227 -0
- package/dist/components/Code/ImageReplacerExtension.js.map +1 -0
- package/dist/components/Code/JsonHighlighterExtension.d.ts +4 -0
- package/dist/components/Code/JsonHighlighterExtension.js +172 -0
- package/dist/components/Code/JsonHighlighterExtension.js.map +1 -0
- package/dist/components/Code/constants.d.ts +6 -0
- package/dist/components/Code/constants.js +11 -0
- package/dist/components/Code/constants.js.map +1 -0
- package/dist/components/Code/index.d.ts +30 -0
- package/dist/components/Code/index.js +140 -0
- package/dist/components/Code/index.js.map +1 -0
- package/dist/components/Code/languages/json.d.ts +1 -0
- package/dist/components/Code/languages/json.js +7 -0
- package/dist/components/Code/languages/json.js.map +1 -0
- package/dist/components/Code/languages/languages.d.ts +7 -0
- package/dist/components/Code/languages/languages.js +12 -0
- package/dist/components/Code/languages/languages.js.map +1 -0
- package/dist/components/Code/languages/python.d.ts +1 -0
- package/dist/components/Code/languages/python.js +7 -0
- package/dist/components/Code/languages/python.js.map +1 -0
- package/dist/components/Code/languages/shell.d.ts +7 -0
- package/dist/components/Code/languages/shell.js +241 -0
- package/dist/components/Code/languages/shell.js.map +1 -0
- package/dist/components/Code/languages/typescript.d.ts +1 -0
- package/dist/components/Code/languages/typescript.js +7 -0
- package/dist/components/Code/languages/typescript.js.map +1 -0
- package/dist/components/Code/languages/yaml.d.ts +2 -0
- package/dist/components/Code/languages/yaml.js +44 -0
- package/dist/components/Code/languages/yaml.js.map +1 -0
- package/dist/components/Code/types.d.ts +8 -0
- package/dist/components/Code/types.js +0 -0
- package/dist/components/Code/utils.d.ts +4 -0
- package/dist/components/Code/utils.js +27 -0
- package/dist/components/Code/utils.js.map +1 -0
- package/dist/components/Command/Command.d.ts +78 -0
- package/dist/components/Command/Command.js +78 -0
- package/dist/components/Command/Command.js.map +1 -0
- package/dist/components/Command/CommandMenu.d.ts +65 -0
- package/dist/components/Command/CommandMenu.js +101 -0
- package/dist/components/Command/CommandMenu.js.map +1 -0
- package/dist/components/Command/index.d.ts +4 -0
- package/dist/components/Command/index.js +3 -0
- package/dist/components/ContextMenu/ContextMenu.d.ts +9 -0
- package/dist/components/ContextMenu/ContextMenu.js +43 -0
- package/dist/components/ContextMenu/ContextMenu.js.map +1 -0
- package/dist/components/ContextMenu/index.d.ts +1 -0
- package/dist/components/ContextMenu/index.js +2 -0
- package/dist/components/CopyButton/CopyButton.d.ts +24 -0
- package/dist/components/CopyButton/CopyButton.js +121 -0
- package/dist/components/CopyButton/CopyButton.js.map +1 -0
- package/dist/components/CopyButton/copyToClipboard.d.ts +1 -0
- package/dist/components/CopyButton/copyToClipboard.js +29 -0
- package/dist/components/CopyButton/copyToClipboard.js.map +1 -0
- package/dist/components/CopyButton/index.d.ts +4 -0
- package/dist/components/CopyButton/index.js +4 -0
- package/dist/components/CopyButton/useCopy.d.ts +10 -0
- package/dist/components/CopyButton/useCopy.js +46 -0
- package/dist/components/CopyButton/useCopy.js.map +1 -0
- package/dist/components/Dialog/index.d.ts +49 -0
- package/dist/components/Dialog/index.js +130 -0
- package/dist/components/Dialog/index.js.map +1 -0
- package/dist/components/Divider/Divider.d.ts +9 -0
- package/dist/components/Divider/Divider.js +27 -0
- package/dist/components/Divider/Divider.js.map +1 -0
- package/dist/components/Divider/index.d.ts +2 -0
- package/dist/components/Divider/index.js +2 -0
- package/dist/components/DonutChart/DonutChart.d.ts +101 -0
- package/dist/components/DonutChart/DonutChart.js +197 -0
- package/dist/components/DonutChart/DonutChart.js.map +1 -0
- package/dist/components/DonutChart/DonutChart.utils.d.ts +38 -0
- package/dist/components/DonutChart/DonutChart.utils.js +93 -0
- package/dist/components/DonutChart/DonutChart.utils.js.map +1 -0
- package/dist/components/DonutChart/constants.d.ts +7 -0
- package/dist/components/DonutChart/constants.js +12 -0
- package/dist/components/DonutChart/constants.js.map +1 -0
- package/dist/components/DonutChart/index.d.ts +4 -0
- package/dist/components/DonutChart/index.js +4 -0
- package/dist/components/DropdownMenu/DropdownMenu.d.ts +24 -0
- package/dist/components/DropdownMenu/DropdownMenu.js +149 -0
- package/dist/components/DropdownMenu/DropdownMenu.js.map +1 -0
- package/dist/components/DropdownMenu/index.d.ts +1 -0
- package/dist/components/DropdownMenu/index.js +2 -0
- package/dist/components/EmptyState/EmptyState.d.ts +26 -0
- package/dist/components/EmptyState/EmptyState.js +85 -0
- package/dist/components/EmptyState/EmptyState.js.map +1 -0
- package/dist/components/EmptyState/index.d.ts +2 -0
- package/dist/components/EmptyState/index.js +2 -0
- package/dist/components/ErrorBoundary.d.ts +35 -0
- package/dist/components/ErrorBoundary.js +41 -0
- package/dist/components/ErrorBoundary.js.map +1 -0
- package/dist/components/ErrorMessage/ErrorMessage.d.ts +17 -0
- package/dist/components/ErrorMessage/ErrorMessage.js +146 -0
- package/dist/components/ErrorMessage/ErrorMessage.js.map +1 -0
- package/dist/components/ErrorMessage/index.d.ts +2 -0
- package/dist/components/ErrorMessage/index.js +2 -0
- package/dist/components/ErrorState/ErrorState.d.ts +23 -0
- package/dist/components/ErrorState/ErrorState.js +2 -0
- package/dist/components/ErrorState/index.d.ts +2 -0
- package/dist/components/ErrorState/index.js +2 -0
- package/dist/components/GroupedTabs/GroupedTabs.d.ts +31 -0
- package/dist/components/GroupedTabs/GroupedTabs.js +92 -0
- package/dist/components/GroupedTabs/GroupedTabs.js.map +1 -0
- package/dist/components/GroupedTabs/index.d.ts +2 -0
- package/dist/components/GroupedTabs/index.js +2 -0
- package/dist/components/HoverCard.d.ts +4 -0
- package/dist/components/HoverCard.js +34 -0
- package/dist/components/HoverCard.js.map +1 -0
- package/dist/components/Icon/Icon.d.ts +25 -0
- package/dist/components/Icon/Icon.js +57 -0
- package/dist/components/Icon/Icon.js.map +1 -0
- package/dist/components/Icon/index.d.ts +2 -0
- package/dist/components/Icon/index.js +2 -0
- package/dist/components/IconButton/IconButton.d.ts +35 -0
- package/dist/components/IconButton/IconButton.js +73 -0
- package/dist/components/IconButton/IconButton.js.map +1 -0
- package/dist/components/IconButton/index.d.ts +2 -0
- package/dist/components/IconButton/index.js +2 -0
- package/dist/components/Input/Input.d.ts +72 -0
- package/dist/components/Input/Input.js +221 -0
- package/dist/components/Input/Input.js.map +1 -0
- package/dist/components/Input/index.d.ts +2 -0
- package/dist/components/Input/index.js +2 -0
- package/dist/components/Input/inputStyles.d.ts +28 -0
- package/dist/components/Input/inputStyles.js +45 -0
- package/dist/components/Input/inputStyles.js.map +1 -0
- package/dist/components/Kbd/Kbd.d.ts +15 -0
- package/dist/components/Kbd/Kbd.js +30 -0
- package/dist/components/Kbd/Kbd.js.map +1 -0
- package/dist/components/Kbd/index.d.ts +2 -0
- package/dist/components/Kbd/index.js +2 -0
- package/dist/components/LineChart/LineChart.d.ts +8 -0
- package/dist/components/LineChart/LineChart.js +194 -0
- package/dist/components/LineChart/LineChart.js.map +1 -0
- package/dist/components/LineChart/LineChart.types.d.ts +138 -0
- package/dist/components/LineChart/LineChart.types.js +0 -0
- package/dist/components/LineChart/LineChart.utils.d.ts +29 -0
- package/dist/components/LineChart/LineChart.utils.js +123 -0
- package/dist/components/LineChart/LineChart.utils.js.map +1 -0
- package/dist/components/LineChart/LineChartPlot.d.ts +43 -0
- package/dist/components/LineChart/LineChartPlot.js +306 -0
- package/dist/components/LineChart/LineChartPlot.js.map +1 -0
- package/dist/components/LineChart/constants.d.ts +3 -0
- package/dist/components/LineChart/constants.js +8 -0
- package/dist/components/LineChart/constants.js.map +1 -0
- package/dist/components/LineChart/index.d.ts +2 -0
- package/dist/components/LineChart/index.js +2 -0
- package/dist/components/LinearProgress/LinearProgress.d.ts +16 -0
- package/dist/components/LinearProgress/LinearProgress.js +42 -0
- package/dist/components/LinearProgress/LinearProgress.js.map +1 -0
- package/dist/components/LinearProgress/index.d.ts +2 -0
- package/dist/components/LinearProgress/index.js +2 -0
- package/dist/components/Link/Link.d.ts +30 -0
- package/dist/components/Link/Link.js +51 -0
- package/dist/components/Link/Link.js.map +1 -0
- package/dist/components/Link/index.d.ts +2 -0
- package/dist/components/Link/index.js +2 -0
- package/dist/components/Logo/index.d.ts +17 -0
- package/dist/components/Logo/index.js +705 -0
- package/dist/components/Logo/index.js.map +1 -0
- package/dist/components/MetricChart/MetricChart.d.ts +9 -0
- package/dist/components/MetricChart/MetricChart.js +42 -0
- package/dist/components/MetricChart/MetricChart.js.map +1 -0
- package/dist/components/MetricChart/formatters.d.ts +18 -0
- package/dist/components/MetricChart/formatters.js +34 -0
- package/dist/components/MetricChart/formatters.js.map +1 -0
- package/dist/components/MetricChart/index.d.ts +4 -0
- package/dist/components/MetricChart/index.js +3 -0
- package/dist/components/Pane/Pane.d.ts +29 -0
- package/dist/components/Pane/Pane.js +171 -0
- package/dist/components/Pane/Pane.js.map +1 -0
- package/dist/components/Pane/Pane.utils.d.ts +10 -0
- package/dist/components/Pane/Pane.utils.js +7 -0
- package/dist/components/Pane/Pane.utils.js.map +1 -0
- package/dist/components/Pane/index.d.ts +3 -0
- package/dist/components/Pane/index.js +3 -0
- package/dist/components/PlainTextEditor/hooks/useResizeTextEditor.d.ts +9 -0
- package/dist/components/PlainTextEditor/hooks/useResizeTextEditor.js +76 -0
- package/dist/components/PlainTextEditor/hooks/useResizeTextEditor.js.map +1 -0
- package/dist/components/PlainTextEditor/index.d.ts +18 -0
- package/dist/components/PlainTextEditor/index.js +71 -0
- package/dist/components/PlainTextEditor/index.js.map +1 -0
- package/dist/components/Popover/Popover.d.ts +13 -0
- package/dist/components/Popover/Popover.js +48 -0
- package/dist/components/Popover/Popover.js.map +1 -0
- package/dist/components/Popover/constants.d.ts +1 -0
- package/dist/components/Popover/constants.js +6 -0
- package/dist/components/Popover/constants.js.map +1 -0
- package/dist/components/Popover/index.d.ts +1 -0
- package/dist/components/Popover/index.js +2 -0
- package/dist/components/PortalSlot.d.ts +11 -0
- package/dist/components/PortalSlot.js +41 -0
- package/dist/components/PortalSlot.js.map +1 -0
- package/dist/components/ProgressBar/ProgressBar.d.ts +38 -0
- package/dist/components/ProgressBar/ProgressBar.js +82 -0
- package/dist/components/ProgressBar/ProgressBar.js.map +1 -0
- package/dist/components/ProgressBar/index.d.ts +2 -0
- package/dist/components/ProgressBar/index.js +2 -0
- package/dist/components/RadioButton/RadioButton.d.ts +62 -0
- package/dist/components/RadioButton/RadioButton.js +38 -0
- package/dist/components/RadioButton/RadioButton.js.map +1 -0
- package/dist/components/RadioButton/constants.d.ts +30 -0
- package/dist/components/RadioButton/constants.js +55 -0
- package/dist/components/RadioButton/constants.js.map +1 -0
- package/dist/components/RadioButton/index.d.ts +2 -0
- package/dist/components/RadioButton/index.js +2 -0
- package/dist/components/RadioCard/RadioCard.d.ts +26 -0
- package/dist/components/RadioCard/RadioCard.js +43 -0
- package/dist/components/RadioCard/RadioCard.js.map +1 -0
- package/dist/components/RadioCard/index.d.ts +2 -0
- package/dist/components/RadioCard/index.js +2 -0
- package/dist/components/RadioGroup/RadioGroup.d.ts +5 -0
- package/dist/components/RadioGroup/RadioGroup.js +17 -0
- package/dist/components/RadioGroup/RadioGroup.js.map +1 -0
- package/dist/components/RadioGroup/RadioGroupItem.d.ts +5 -0
- package/dist/components/RadioGroup/RadioGroupItem.js +22 -0
- package/dist/components/RadioGroup/RadioGroupItem.js.map +1 -0
- package/dist/components/RadioGroup/index.d.ts +4 -0
- package/dist/components/RadioGroup/index.js +3 -0
- package/dist/components/Select/Select.d.ts +84 -0
- package/dist/components/Select/Select.js +120 -0
- package/dist/components/Select/Select.js.map +1 -0
- package/dist/components/Select/SelectPrimitive.d.ts +17 -0
- package/dist/components/Select/SelectPrimitive.js +126 -0
- package/dist/components/Select/SelectPrimitive.js.map +1 -0
- package/dist/components/Select/index.d.ts +4 -0
- package/dist/components/Select/index.js +3 -0
- package/dist/components/Skeleton/Skeleton.d.ts +13 -0
- package/dist/components/Skeleton/Skeleton.js +25 -0
- package/dist/components/Skeleton/Skeleton.js.map +1 -0
- package/dist/components/Skeleton/index.d.ts +1 -0
- package/dist/components/Skeleton/index.js +2 -0
- package/dist/components/Slider/Slider.d.ts +33 -0
- package/dist/components/Slider/Slider.js +64 -0
- package/dist/components/Slider/Slider.js.map +1 -0
- package/dist/components/Slider/index.d.ts +2 -0
- package/dist/components/Slider/index.js +2 -0
- package/dist/components/SparkLineChart/SparkLineChart.d.ts +14 -0
- package/dist/components/SparkLineChart/SparkLineChart.js +112 -0
- package/dist/components/SparkLineChart/SparkLineChart.js.map +1 -0
- package/dist/components/SparkLineChart/index.d.ts +2 -0
- package/dist/components/SparkLineChart/index.js +2 -0
- package/dist/components/Spinner/Spinner.d.ts +12 -0
- package/dist/components/Spinner/Spinner.js +33 -0
- package/dist/components/Spinner/Spinner.js.map +1 -0
- package/dist/components/Spinner/index.d.ts +1 -0
- package/dist/components/Spinner/index.js +2 -0
- package/dist/components/SplitViewPane/SplitViewPane.d.ts +41 -0
- package/dist/components/SplitViewPane/SplitViewPane.js +314 -0
- package/dist/components/SplitViewPane/SplitViewPane.js.map +1 -0
- package/dist/components/SplitViewPane/SplitViewPaneHeader.d.ts +22 -0
- package/dist/components/SplitViewPane/SplitViewPaneHeader.js +105 -0
- package/dist/components/SplitViewPane/SplitViewPaneHeader.js.map +1 -0
- package/dist/components/SplitViewPane/index.d.ts +2 -0
- package/dist/components/SplitViewPane/index.js +3 -0
- package/dist/components/SplitViewPane/openPaneRegistry.d.ts +2 -0
- package/dist/components/SplitViewPane/openPaneRegistry.js +49 -0
- package/dist/components/SplitViewPane/openPaneRegistry.js.map +1 -0
- package/dist/components/Switch/Switch.d.ts +35 -0
- package/dist/components/Switch/Switch.js +65 -0
- package/dist/components/Switch/Switch.js.map +1 -0
- package/dist/components/Switch/index.d.ts +2 -0
- package/dist/components/Switch/index.js +2 -0
- package/dist/components/Tabs/index.d.ts +27 -0
- package/dist/components/Tabs/index.js +45 -0
- package/dist/components/Tabs/index.js.map +1 -0
- package/dist/components/Text/Text.d.ts +13 -0
- package/dist/components/Text/Text.js +58 -0
- package/dist/components/Text/Text.js.map +1 -0
- package/dist/components/Text/index.d.ts +2 -0
- package/dist/components/Text/index.js +2 -0
- package/dist/components/TextVirtualizer.d.ts +8 -0
- package/dist/components/TextVirtualizer.js +53 -0
- package/dist/components/TextVirtualizer.js.map +1 -0
- package/dist/components/TextWithLinks.d.ts +6 -0
- package/dist/components/TextWithLinks.js +61 -0
- package/dist/components/TextWithLinks.js.map +1 -0
- package/dist/components/Textarea/Textarea.d.ts +47 -0
- package/dist/components/Textarea/Textarea.js +150 -0
- package/dist/components/Textarea/Textarea.js.map +1 -0
- package/dist/components/Textarea/index.d.ts +2 -0
- package/dist/components/Textarea/index.js +2 -0
- package/dist/components/ThinkingState/LoadingIndicator.d.ts +19 -0
- package/dist/components/ThinkingState/LoadingIndicator.js +2 -0
- package/dist/components/ThinkingState/NOTICE +25 -0
- package/dist/components/ThinkingState/ThinkingState.d.ts +21 -0
- package/dist/components/ThinkingState/ThinkingState.js +42 -0
- package/dist/components/ThinkingState/ThinkingState.js.map +1 -0
- package/dist/components/ThinkingState/ThinkingStateTimer.d.ts +9 -0
- package/dist/components/ThinkingState/ThinkingStateTimer.js +43 -0
- package/dist/components/ThinkingState/ThinkingStateTimer.js.map +1 -0
- package/dist/components/ThinkingState/index.d.ts +4 -0
- package/dist/components/ThinkingState/index.js +3 -0
- package/dist/components/Toast/ToastContext.d.ts +5 -0
- package/dist/components/Toast/ToastContext.js +9 -0
- package/dist/components/Toast/ToastContext.js.map +1 -0
- package/dist/components/Toast/index.d.ts +13 -0
- package/dist/components/Toast/index.js +166 -0
- package/dist/components/Toast/index.js.map +1 -0
- package/dist/components/Toast/useToast.d.ts +3 -0
- package/dist/components/Toast/useToast.js +11 -0
- package/dist/components/Toast/useToast.js.map +1 -0
- package/dist/components/Tooltip/Tooltip.d.ts +19 -0
- package/dist/components/Tooltip/Tooltip.js +57 -0
- package/dist/components/Tooltip/Tooltip.js.map +1 -0
- package/dist/components/Tooltip/index.d.ts +3 -0
- package/dist/components/Tooltip/index.js +3 -0
- package/dist/components/TopList/TopList.d.ts +3 -0
- package/dist/components/TopList/TopList.js +186 -0
- package/dist/components/TopList/TopList.js.map +1 -0
- package/dist/components/TopList/TopList.types.d.ts +34 -0
- package/dist/components/TopList/TopList.types.js +0 -0
- package/dist/components/TopList/TopList.utils.d.ts +3 -0
- package/dist/components/TopList/TopList.utils.js +16 -0
- package/dist/components/TopList/TopList.utils.js.map +1 -0
- package/dist/components/TopList/index.d.ts +2 -0
- package/dist/components/TopList/index.js +2 -0
- package/dist/components/Typeahead/Typeahead.d.ts +5 -0
- package/dist/components/Typeahead/Typeahead.js +305 -0
- package/dist/components/Typeahead/Typeahead.js.map +1 -0
- package/dist/components/Typeahead/Typeahead.types.d.ts +99 -0
- package/dist/components/Typeahead/Typeahead.types.js +0 -0
- package/dist/components/Typeahead/Typeahead.utils.d.ts +25 -0
- package/dist/components/Typeahead/Typeahead.utils.js +73 -0
- package/dist/components/Typeahead/Typeahead.utils.js.map +1 -0
- package/dist/components/Typeahead/TypeaheadParts.d.ts +25 -0
- package/dist/components/Typeahead/TypeaheadParts.js +109 -0
- package/dist/components/Typeahead/TypeaheadParts.js.map +1 -0
- package/dist/components/Typeahead/TypeaheadView.d.ts +81 -0
- package/dist/components/Typeahead/TypeaheadView.js +228 -0
- package/dist/components/Typeahead/TypeaheadView.js.map +1 -0
- package/dist/components/Typeahead/index.d.ts +2 -0
- package/dist/components/Typeahead/index.js +2 -0
- package/dist/components/Typeahead/useTypeaheadDomSync.d.ts +15 -0
- package/dist/components/Typeahead/useTypeaheadDomSync.js +43 -0
- package/dist/components/Typeahead/useTypeaheadDomSync.js.map +1 -0
- package/dist/components/Typeahead/useTypeaheadUncontrolledInput.d.ts +11 -0
- package/dist/components/Typeahead/useTypeaheadUncontrolledInput.js +32 -0
- package/dist/components/Typeahead/useTypeaheadUncontrolledInput.js.map +1 -0
- package/dist/components/UnsavedChangesDialog.d.ts +14 -0
- package/dist/components/UnsavedChangesDialog.js +67 -0
- package/dist/components/UnsavedChangesDialog.js.map +1 -0
- package/dist/components/index.d.ts +58 -0
- package/dist/components/index.js +35 -0
- package/dist/components.css +102 -0
- package/dist/contexts/ErrorReporterContext.d.ts +6 -0
- package/dist/contexts/ErrorReporterContext.js +7 -0
- package/dist/contexts/ErrorReporterContext.js.map +1 -0
- package/dist/hooks/AppThemeProvider.d.ts +8 -0
- package/dist/hooks/AppThemeProvider.js +52 -0
- package/dist/hooks/AppThemeProvider.js.map +1 -0
- package/dist/hooks/useColorScheme.d.ts +20 -0
- package/dist/hooks/useColorScheme.js +50 -0
- package/dist/hooks/useColorScheme.js.map +1 -0
- package/dist/icons/LongTailPhosphorIcons.d.ts +51 -0
- package/dist/icons/LongTailPhosphorIcons.js +102 -0
- package/dist/icons/LongTailPhosphorIcons.js.map +1 -0
- package/dist/icons/PaddedPhosphorIcons.d.ts +17 -0
- package/dist/icons/PaddedPhosphorIcons.js +55 -0
- package/dist/icons/PaddedPhosphorIcons.js.map +1 -0
- package/dist/icons/WeightedPhosphorIcons.d.ts +45 -0
- package/dist/icons/WeightedPhosphorIcons.js +96 -0
- package/dist/icons/WeightedPhosphorIcons.js.map +1 -0
- package/dist/icons/index.d.ts +2 -0
- package/dist/icons/index.js +4 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +36 -0
- package/dist/styles.css +10 -0
- package/dist/utilities.css +2 -0
- package/dist/utils/VirtuosoCustomScrollParentContext/index.d.ts +7 -0
- package/dist/utils/VirtuosoCustomScrollParentContext/index.js +15 -0
- package/dist/utils/VirtuosoCustomScrollParentContext/index.js.map +1 -0
- package/dist/utils/VirtuosoCustomScrollParentContext/useScrollParent.d.ts +4 -0
- package/dist/utils/VirtuosoCustomScrollParentContext/useScrollParent.js +10 -0
- package/dist/utils/VirtuosoCustomScrollParentContext/useScrollParent.js.map +1 -0
- package/dist/utils/ZIndexContext.d.ts +5 -0
- package/dist/utils/ZIndexContext.js +13 -0
- package/dist/utils/ZIndexContext.js.map +1 -0
- package/dist/utils/animation.d.ts +37 -0
- package/dist/utils/animation.js +42 -0
- package/dist/utils/animation.js.map +1 -0
- package/dist/utils/chartAxisLayout.d.ts +6 -0
- package/dist/utils/chartAxisLayout.js +8 -0
- package/dist/utils/chartAxisLayout.js.map +1 -0
- package/dist/utils/chartColors.d.ts +38 -0
- package/dist/utils/chartColors.js +78 -0
- package/dist/utils/chartColors.js.map +1 -0
- package/dist/utils/chartConstants.d.ts +10 -0
- package/dist/utils/chartConstants.js +15 -0
- package/dist/utils/chartConstants.js.map +1 -0
- package/dist/utils/chartValues.d.ts +2 -0
- package/dist/utils/chartValues.js +36 -0
- package/dist/utils/chartValues.js.map +1 -0
- package/dist/utils/clamp.d.ts +2 -0
- package/dist/utils/clamp.js +7 -0
- package/dist/utils/clamp.js.map +1 -0
- package/dist/utils/cn.d.ts +2 -0
- package/dist/utils/cn.js +191 -0
- package/dist/utils/cn.js.map +1 -0
- package/dist/utils/componentSizes.d.ts +104 -0
- package/dist/utils/componentSizes.js +104 -0
- package/dist/utils/componentSizes.js.map +1 -0
- package/dist/utils/controlIconSizes.d.ts +10 -0
- package/dist/utils/controlIconSizes.js +32 -0
- package/dist/utils/controlIconSizes.js.map +1 -0
- package/dist/utils/csp-nonce.d.ts +11 -0
- package/dist/utils/csp-nonce.js +17 -0
- package/dist/utils/csp-nonce.js.map +1 -0
- package/dist/utils/get-closest-scroll-parent.d.ts +1 -0
- package/dist/utils/get-closest-scroll-parent.js +16 -0
- package/dist/utils/get-closest-scroll-parent.js.map +1 -0
- package/dist/utils/get-color-by-string.d.ts +1 -0
- package/dist/utils/get-color-by-string.js +10 -0
- package/dist/utils/get-color-by-string.js.map +1 -0
- package/dist/utils/getYAxisLeftMargin.d.ts +10 -0
- package/dist/utils/getYAxisLeftMargin.js +20 -0
- package/dist/utils/getYAxisLeftMargin.js.map +1 -0
- package/dist/utils/icon-types.d.ts +8 -0
- package/dist/utils/icon-types.js +0 -0
- package/dist/utils/lazy-codemirror-loader.d.ts +70 -0
- package/dist/utils/lazy-codemirror-loader.js +79 -0
- package/dist/utils/lazy-codemirror-loader.js.map +1 -0
- package/dist/utils/merge-refs.d.ts +2 -0
- package/dist/utils/merge-refs.js +13 -0
- package/dist/utils/merge-refs.js.map +1 -0
- package/dist/utils/parseTextLinks.d.ts +7 -0
- package/dist/utils/parseTextLinks.js +46 -0
- package/dist/utils/parseTextLinks.js.map +1 -0
- package/dist/utils/prettify-error-payload.d.ts +7 -0
- package/dist/utils/prettify-error-payload.js +188 -0
- package/dist/utils/prettify-error-payload.js.map +1 -0
- package/dist/utils/spacing.d.ts +30 -0
- package/dist/utils/spacing.js +34 -0
- package/dist/utils/spacing.js.map +1 -0
- package/dist/utils/useCodeMirror.d.ts +7 -0
- package/dist/utils/useCodeMirror.js +28 -0
- package/dist/utils/useCodeMirror.js.map +1 -0
- package/dist/utils/useZIndex.d.ts +52 -0
- package/dist/utils/useZIndex.js +62 -0
- package/dist/utils/useZIndex.js.map +1 -0
- package/dist/utils/zIndices.d.ts +42 -0
- package/dist/utils/zIndices.js +46 -0
- package/dist/utils/zIndices.js.map +1 -0
- package/docs/DESIGN.md +134 -0
- package/docs/STYLES.md +568 -0
- package/package.json +619 -0
- package/tailwind.preset.cjs +738 -0
- package/tailwind.preset.d.cts +5 -0
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import type { HTMLAttributes, KeyboardEvent, ReactNode } from 'react';
|
|
2
|
+
import type { ControlSize } from '../../utils/componentSizes.js';
|
|
3
|
+
export interface TypeaheadOption<TValue extends string = string> {
|
|
4
|
+
value: TValue;
|
|
5
|
+
label?: string;
|
|
6
|
+
description?: string;
|
|
7
|
+
disabled?: boolean;
|
|
8
|
+
rightDecorator?: ReactNode;
|
|
9
|
+
keywords?: string[];
|
|
10
|
+
}
|
|
11
|
+
export type FreeSoloValue = string & Record<never, never>;
|
|
12
|
+
export type TypeaheadSize = ControlSize;
|
|
13
|
+
export type TypeaheadSelectedValue<TOption> = TOption | FreeSoloValue;
|
|
14
|
+
export type TypeaheadSingleValue<TOption> = TypeaheadSelectedValue<TOption> | null | undefined;
|
|
15
|
+
export type TypeaheadMultipleValue<TOption> = Array<TypeaheadSelectedValue<TOption>>;
|
|
16
|
+
export interface TypeaheadTagProps {
|
|
17
|
+
key: string;
|
|
18
|
+
tabIndex: number;
|
|
19
|
+
'data-tag-index': number;
|
|
20
|
+
onDelete: () => void;
|
|
21
|
+
}
|
|
22
|
+
export interface TypeaheadRenderOptionState {
|
|
23
|
+
selected: boolean;
|
|
24
|
+
disabled: boolean;
|
|
25
|
+
inputValue: string;
|
|
26
|
+
}
|
|
27
|
+
export interface TypeaheadFilterOptionsState<TOption> {
|
|
28
|
+
inputValue: string;
|
|
29
|
+
getOptionLabel: (option: TypeaheadSelectedValue<TOption>) => string;
|
|
30
|
+
}
|
|
31
|
+
export interface TypeaheadListItem<TOption> {
|
|
32
|
+
option: TypeaheadSelectedValue<TOption>;
|
|
33
|
+
source: 'option' | 'selected';
|
|
34
|
+
}
|
|
35
|
+
interface TypeaheadBaseProps<TOption> extends Omit<HTMLAttributes<HTMLDivElement>, 'defaultValue' | 'onChange' | 'onKeyDown'> {
|
|
36
|
+
options: TOption[];
|
|
37
|
+
placeholder?: string;
|
|
38
|
+
/** Static content rendered before the editable input. */
|
|
39
|
+
leftDecorator?: ReactNode;
|
|
40
|
+
/** Keeps the placeholder visible after values have been selected in multiple mode. */
|
|
41
|
+
showPlaceholderWithValues?: boolean;
|
|
42
|
+
emptyText?: string;
|
|
43
|
+
/** Control height: xs=20px, sm=24px, md=32px, lg=40px. */
|
|
44
|
+
size?: TypeaheadSize;
|
|
45
|
+
disabled?: boolean;
|
|
46
|
+
isError?: boolean;
|
|
47
|
+
freeSolo?: boolean;
|
|
48
|
+
disableClearable?: boolean;
|
|
49
|
+
disableCloseOnSelect?: boolean;
|
|
50
|
+
/** Override the default client-side option filtering. */
|
|
51
|
+
filterOptions?: (options: TOption[], state: TypeaheadFilterOptionsState<TOption>) => TOption[];
|
|
52
|
+
forcePopupIcon?: boolean;
|
|
53
|
+
clearOnBlur?: boolean;
|
|
54
|
+
clearValueOnInputClear?: boolean;
|
|
55
|
+
displaySelectedValueWhenInputEmpty?: boolean;
|
|
56
|
+
maxVisibleOptions?: number;
|
|
57
|
+
hideEmptyList?: boolean;
|
|
58
|
+
emptyState?: ReactNode;
|
|
59
|
+
listFooter?: ReactNode;
|
|
60
|
+
onCreateNew?: (inputValue: string) => void;
|
|
61
|
+
createNewLabel?: (inputValue: string) => ReactNode;
|
|
62
|
+
inputValue?: string;
|
|
63
|
+
onInputChange?: (value: string) => void;
|
|
64
|
+
getOptionLabel?: (option: TypeaheadSelectedValue<TOption>) => string;
|
|
65
|
+
getOptionValue?: (option: TypeaheadSelectedValue<TOption>) => string;
|
|
66
|
+
getOptionDisabled?: (option: TOption) => boolean;
|
|
67
|
+
renderOption?: (option: TOption, state: TypeaheadRenderOptionState) => ReactNode;
|
|
68
|
+
inputId?: string;
|
|
69
|
+
autoFocus?: boolean;
|
|
70
|
+
autoComplete?: string;
|
|
71
|
+
onKeyDown?: (event: KeyboardEvent<HTMLInputElement>) => void;
|
|
72
|
+
'aria-label'?: string;
|
|
73
|
+
'data-testid'?: string;
|
|
74
|
+
}
|
|
75
|
+
interface TypeaheadSingleProps<TOption> extends TypeaheadBaseProps<TOption> {
|
|
76
|
+
/** Searchable single-select mode. */
|
|
77
|
+
multiple?: false;
|
|
78
|
+
value?: TypeaheadSingleValue<NoInfer<TOption>>;
|
|
79
|
+
onChange: (value: TypeaheadSingleValue<NoInfer<TOption>>) => void;
|
|
80
|
+
renderTags?: never;
|
|
81
|
+
}
|
|
82
|
+
interface TypeaheadMultipleProps<TOption> extends TypeaheadBaseProps<TOption> {
|
|
83
|
+
/**
|
|
84
|
+
* Enables the canonical searchable multi-select pattern. Selected values are
|
|
85
|
+
* rendered as removable tags and the option list stays searchable.
|
|
86
|
+
*/
|
|
87
|
+
multiple: true;
|
|
88
|
+
value?: TypeaheadMultipleValue<NoInfer<TOption>>;
|
|
89
|
+
onChange: (value: TypeaheadMultipleValue<NoInfer<TOption>>) => void;
|
|
90
|
+
renderTags?: (value: TypeaheadMultipleValue<TOption>, getTagProps: (params: {
|
|
91
|
+
index: number;
|
|
92
|
+
}) => TypeaheadTagProps) => ReactNode;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Searchable selection input. Use `multiple` for searchable multi-selects and
|
|
96
|
+
* add `freeSolo` only when values outside the provided options are valid.
|
|
97
|
+
*/
|
|
98
|
+
export type TypeaheadProps<TOption = string> = TypeaheadSingleProps<TOption> | TypeaheadMultipleProps<TOption>;
|
|
99
|
+
export {};
|
|
File without changes
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { TypeaheadFilterOptionsState, TypeaheadListItem, TypeaheadMultipleValue, TypeaheadOption, TypeaheadSelectedValue } from './Typeahead.types.js';
|
|
2
|
+
export declare function isTypeaheadOption(option: unknown): option is TypeaheadOption;
|
|
3
|
+
export declare function defaultOptionLabel<TOption>(option: TypeaheadSelectedValue<TOption>): string;
|
|
4
|
+
export declare function defaultOptionValue<TOption>(option: TypeaheadSelectedValue<TOption>): string;
|
|
5
|
+
export declare const normalize: (value: string) => string;
|
|
6
|
+
export declare function filterTypeaheadOptions<TOption>(options: TOption[], inputValue: string, getLabel: (option: TOption) => string): TOption[];
|
|
7
|
+
export declare function getTypeaheadListItems<TOption>({ options, selectedValues, inputValue, getLabel, getValue, filterOptions, maxVisibleOptions, includeSelectedValues, }: {
|
|
8
|
+
options: TOption[];
|
|
9
|
+
selectedValues: TypeaheadMultipleValue<TOption>;
|
|
10
|
+
inputValue: string;
|
|
11
|
+
getLabel: (option: TypeaheadSelectedValue<TOption>) => string;
|
|
12
|
+
getValue: (option: TypeaheadSelectedValue<TOption>) => string;
|
|
13
|
+
filterOptions?: (options: TOption[], state: TypeaheadFilterOptionsState<TOption>) => TOption[];
|
|
14
|
+
maxVisibleOptions?: number;
|
|
15
|
+
includeSelectedValues?: boolean;
|
|
16
|
+
}): TypeaheadListItem<TOption>[];
|
|
17
|
+
export declare function isActiveOptionSelected<TOption>(listNode: HTMLElement | null, selectedValues: TypeaheadMultipleValue<TOption>, getValue: (option: TypeaheadSelectedValue<TOption>) => string): boolean;
|
|
18
|
+
export declare function getTypeaheadDisplayInputValue<TOption>(inputValue: string, selectedValues: TypeaheadMultipleValue<TOption>, getLabel: (option: TypeaheadSelectedValue<TOption>) => string, multiple?: boolean, displaySelectedValueWhenInputEmpty?: boolean): string;
|
|
19
|
+
export declare function getTypeaheadSelectedSummary<TOption>(selectedValues: TypeaheadMultipleValue<TOption>, getLabel: (option: TypeaheadSelectedValue<TOption>) => string, multiple?: boolean): string | undefined;
|
|
20
|
+
export declare function getTypeaheadCreateState<TOption>(inputValue: string, options: TOption[], selectedValues: TypeaheadMultipleValue<TOption>, getLabel: (option: TypeaheadSelectedValue<TOption>) => string, freeSolo: boolean, hasCustomCreate: boolean): {
|
|
21
|
+
customCreateInputValue: string;
|
|
22
|
+
showCreateOption: boolean;
|
|
23
|
+
showFreeSoloCreateOption: boolean;
|
|
24
|
+
trimmedInputValue: string;
|
|
25
|
+
};
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
//#region packages/components/src/components/Typeahead/Typeahead.utils.ts
|
|
2
|
+
function isTypeaheadOption(option) {
|
|
3
|
+
return typeof option === "object" && option != null && "value" in option && typeof option.value === "string";
|
|
4
|
+
}
|
|
5
|
+
function defaultOptionLabel(option) {
|
|
6
|
+
if (isTypeaheadOption(option)) return option.label ?? option.value;
|
|
7
|
+
return String(option ?? "");
|
|
8
|
+
}
|
|
9
|
+
function defaultOptionValue(option) {
|
|
10
|
+
if (isTypeaheadOption(option)) return option.value;
|
|
11
|
+
return defaultOptionLabel(option);
|
|
12
|
+
}
|
|
13
|
+
var normalize = (value) => value.trim().toLowerCase();
|
|
14
|
+
function filterTypeaheadOptions(options, inputValue, getLabel) {
|
|
15
|
+
const query = normalize(inputValue);
|
|
16
|
+
return query ? options.filter((option) => {
|
|
17
|
+
if (normalize(getLabel(option)).includes(query)) return true;
|
|
18
|
+
if (isTypeaheadOption(option)) return option.keywords?.some((keyword) => normalize(keyword).includes(query));
|
|
19
|
+
return false;
|
|
20
|
+
}) : options;
|
|
21
|
+
}
|
|
22
|
+
function getTypeaheadListItems({ options, selectedValues, inputValue, getLabel, getValue, filterOptions, maxVisibleOptions, includeSelectedValues }) {
|
|
23
|
+
const filteredOptions = filterOptions ? filterOptions(options, {
|
|
24
|
+
inputValue,
|
|
25
|
+
getOptionLabel: getLabel
|
|
26
|
+
}) : filterTypeaheadOptions(options, inputValue, getLabel);
|
|
27
|
+
const filteredItems = (maxVisibleOptions == null ? filteredOptions : filteredOptions.slice(0, maxVisibleOptions)).map((option) => ({
|
|
28
|
+
option,
|
|
29
|
+
source: "option"
|
|
30
|
+
}));
|
|
31
|
+
const query = normalize(inputValue);
|
|
32
|
+
if (!includeSelectedValues || query.length === 0) return filteredItems;
|
|
33
|
+
const optionKeys = new Set(options.map((option) => getValue(option)));
|
|
34
|
+
const itemKeys = new Set(filteredItems.map((item) => getValue(item.option)));
|
|
35
|
+
const selectedItems = selectedValues.filter((selected) => {
|
|
36
|
+
const selectedKey = getValue(selected);
|
|
37
|
+
return !optionKeys.has(selectedKey) && !itemKeys.has(selectedKey) && normalize(getLabel(selected)).includes(query);
|
|
38
|
+
}).map((option) => ({
|
|
39
|
+
option,
|
|
40
|
+
source: "selected"
|
|
41
|
+
}));
|
|
42
|
+
return [...filteredItems, ...selectedItems];
|
|
43
|
+
}
|
|
44
|
+
function isActiveOptionSelected(listNode, selectedValues, getValue) {
|
|
45
|
+
const activeValue = listNode?.querySelector("[cmdk-item][aria-selected=\"true\"]")?.getAttribute("data-value");
|
|
46
|
+
if (activeValue == null) return false;
|
|
47
|
+
return selectedValues.some((selected) => getValue(selected).trim() === activeValue);
|
|
48
|
+
}
|
|
49
|
+
function getTypeaheadDisplayInputValue(inputValue, selectedValues, getLabel, multiple, displaySelectedValueWhenInputEmpty) {
|
|
50
|
+
return displaySelectedValueWhenInputEmpty && !multiple && inputValue.length === 0 && selectedValues.length > 0 ? getLabel(selectedValues[0]) : inputValue;
|
|
51
|
+
}
|
|
52
|
+
function getTypeaheadSelectedSummary(selectedValues, getLabel, multiple) {
|
|
53
|
+
if (!multiple) return void 0;
|
|
54
|
+
if (selectedValues.length === 0) return "No selected values.";
|
|
55
|
+
return `Selected values: ${selectedValues.map((selected) => getLabel(selected)).join(", ")}.`;
|
|
56
|
+
}
|
|
57
|
+
function getTypeaheadCreateState(inputValue, options, selectedValues, getLabel, freeSolo, hasCustomCreate) {
|
|
58
|
+
const trimmedInputValue = inputValue.trim();
|
|
59
|
+
const normalizedInputValue = normalize(inputValue);
|
|
60
|
+
const createMatchesOption = normalizedInputValue.length > 0 && options.some((option) => normalize(getLabel(option)) === normalizedInputValue);
|
|
61
|
+
const createMatchesSelection = normalizedInputValue.length > 0 && selectedValues.some((selected) => normalize(getLabel(selected)) === normalizedInputValue);
|
|
62
|
+
const showFreeSoloCreateOption = freeSolo && !hasCustomCreate && trimmedInputValue.length > 0 && !createMatchesOption && !createMatchesSelection;
|
|
63
|
+
return {
|
|
64
|
+
customCreateInputValue: createMatchesOption || createMatchesSelection ? "" : trimmedInputValue,
|
|
65
|
+
showCreateOption: showFreeSoloCreateOption || hasCustomCreate,
|
|
66
|
+
showFreeSoloCreateOption,
|
|
67
|
+
trimmedInputValue
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
//#endregion
|
|
71
|
+
export { defaultOptionLabel, defaultOptionValue, filterTypeaheadOptions, getTypeaheadCreateState, getTypeaheadDisplayInputValue, getTypeaheadListItems, getTypeaheadSelectedSummary, isActiveOptionSelected, isTypeaheadOption, normalize };
|
|
72
|
+
|
|
73
|
+
//# sourceMappingURL=Typeahead.utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Typeahead.utils.js","names":[],"sources":["../../../src/components/Typeahead/Typeahead.utils.ts"],"sourcesContent":["import type {\n TypeaheadFilterOptionsState,\n TypeaheadListItem,\n TypeaheadMultipleValue,\n TypeaheadOption,\n TypeaheadSelectedValue,\n} from './Typeahead.types';\n\nexport function isTypeaheadOption(option: unknown): option is TypeaheadOption {\n return (\n typeof option === 'object' &&\n option != null &&\n 'value' in option &&\n typeof (option as TypeaheadOption).value === 'string'\n );\n}\n\nexport function defaultOptionLabel<TOption>(\n option: TypeaheadSelectedValue<TOption>\n) {\n if (isTypeaheadOption(option)) {\n return option.label ?? option.value;\n }\n return String(option ?? '');\n}\n\nexport function defaultOptionValue<TOption>(\n option: TypeaheadSelectedValue<TOption>\n) {\n if (isTypeaheadOption(option)) {\n return option.value;\n }\n return defaultOptionLabel(option);\n}\n\nexport const normalize = (value: string) => value.trim().toLowerCase();\n\nexport function filterTypeaheadOptions<TOption>(\n options: TOption[],\n inputValue: string,\n getLabel: (option: TOption) => string\n) {\n const query = normalize(inputValue);\n const filteredOptions = query\n ? options.filter((option) => {\n const labelMatch = normalize(getLabel(option)).includes(query);\n if (labelMatch) {\n return true;\n }\n if (isTypeaheadOption(option)) {\n return option.keywords?.some((keyword) =>\n normalize(keyword).includes(query)\n );\n }\n return false;\n })\n : options;\n\n return filteredOptions;\n}\n\nexport function getTypeaheadListItems<TOption>({\n options,\n selectedValues,\n inputValue,\n getLabel,\n getValue,\n filterOptions,\n maxVisibleOptions,\n includeSelectedValues,\n}: {\n options: TOption[];\n selectedValues: TypeaheadMultipleValue<TOption>;\n inputValue: string;\n getLabel: (option: TypeaheadSelectedValue<TOption>) => string;\n getValue: (option: TypeaheadSelectedValue<TOption>) => string;\n filterOptions?: (\n options: TOption[],\n state: TypeaheadFilterOptionsState<TOption>\n ) => TOption[];\n maxVisibleOptions?: number;\n includeSelectedValues?: boolean;\n}): TypeaheadListItem<TOption>[] {\n const filteredOptions = filterOptions\n ? filterOptions(options, { inputValue, getOptionLabel: getLabel })\n : filterTypeaheadOptions(options, inputValue, getLabel);\n const visibleOptions =\n maxVisibleOptions == null\n ? filteredOptions\n : filteredOptions.slice(0, maxVisibleOptions);\n const filteredItems = visibleOptions.map<TypeaheadListItem<TOption>>(\n (option) => ({\n option,\n source: 'option',\n })\n );\n\n const query = normalize(inputValue);\n if (!includeSelectedValues || query.length === 0) return filteredItems;\n\n const optionKeys = new Set(options.map((option) => getValue(option)));\n const itemKeys = new Set(filteredItems.map((item) => getValue(item.option)));\n const selectedItems = selectedValues\n .filter((selected) => {\n const selectedKey = getValue(selected);\n return (\n !optionKeys.has(selectedKey) &&\n !itemKeys.has(selectedKey) &&\n normalize(getLabel(selected)).includes(query)\n );\n })\n .map<TypeaheadListItem<TOption>>((option) => ({\n option,\n source: 'selected',\n }));\n\n return [...filteredItems, ...selectedItems];\n}\n\nexport function isActiveOptionSelected<TOption>(\n listNode: HTMLElement | null,\n selectedValues: TypeaheadMultipleValue<TOption>,\n getValue: (option: TypeaheadSelectedValue<TOption>) => string\n) {\n const activeValue = listNode\n ?.querySelector('[cmdk-item][aria-selected=\"true\"]')\n ?.getAttribute('data-value');\n if (activeValue == null) return false;\n return selectedValues.some(\n (selected) => getValue(selected).trim() === activeValue\n );\n}\n\nexport function getTypeaheadDisplayInputValue<TOption>(\n inputValue: string,\n selectedValues: TypeaheadMultipleValue<TOption>,\n getLabel: (option: TypeaheadSelectedValue<TOption>) => string,\n multiple?: boolean,\n displaySelectedValueWhenInputEmpty?: boolean\n) {\n return displaySelectedValueWhenInputEmpty &&\n !multiple &&\n inputValue.length === 0 &&\n selectedValues.length > 0\n ? getLabel(selectedValues[0])\n : inputValue;\n}\n\nexport function getTypeaheadSelectedSummary<TOption>(\n selectedValues: TypeaheadMultipleValue<TOption>,\n getLabel: (option: TypeaheadSelectedValue<TOption>) => string,\n multiple?: boolean\n) {\n if (!multiple) return undefined;\n if (selectedValues.length === 0) return 'No selected values.';\n return `Selected values: ${selectedValues.map((selected) => getLabel(selected)).join(', ')}.`;\n}\n\nexport function getTypeaheadCreateState<TOption>(\n inputValue: string,\n options: TOption[],\n selectedValues: TypeaheadMultipleValue<TOption>,\n getLabel: (option: TypeaheadSelectedValue<TOption>) => string,\n freeSolo: boolean,\n hasCustomCreate: boolean\n) {\n const trimmedInputValue = inputValue.trim();\n const normalizedInputValue = normalize(inputValue);\n const createMatchesOption =\n normalizedInputValue.length > 0 &&\n options.some(\n (option) => normalize(getLabel(option)) === normalizedInputValue\n );\n const createMatchesSelection =\n normalizedInputValue.length > 0 &&\n selectedValues.some(\n (selected) => normalize(getLabel(selected)) === normalizedInputValue\n );\n const showFreeSoloCreateOption =\n freeSolo &&\n !hasCustomCreate &&\n trimmedInputValue.length > 0 &&\n !createMatchesOption &&\n !createMatchesSelection;\n\n return {\n customCreateInputValue:\n createMatchesOption || createMatchesSelection ? '' : trimmedInputValue,\n showCreateOption: showFreeSoloCreateOption || hasCustomCreate,\n showFreeSoloCreateOption,\n trimmedInputValue,\n };\n}\n"],"mappings":";AAQA,SAAgB,kBAAkB,QAA4C;CAC5E,OACE,OAAO,WAAW,YAClB,UAAU,QACV,WAAW,UACX,OAAQ,OAA2B,UAAU;AAEjD;AAEA,SAAgB,mBACd,QACA;CACA,IAAI,kBAAkB,MAAM,GAC1B,OAAO,OAAO,SAAS,OAAO;CAEhC,OAAO,OAAO,UAAU,EAAE;AAC5B;AAEA,SAAgB,mBACd,QACA;CACA,IAAI,kBAAkB,MAAM,GAC1B,OAAO,OAAO;CAEhB,OAAO,mBAAmB,MAAM;AAClC;AAEA,IAAa,aAAa,UAAkB,MAAM,KAAK,CAAC,CAAC,YAAY;AAErE,SAAgB,uBACd,SACA,YACA,UACA;CACA,MAAM,QAAQ,UAAU,UAAU;CAgBlC,OAfwB,QACpB,QAAQ,QAAQ,WAAW;EAEzB,IADmB,UAAU,SAAS,MAAM,CAAC,CAAC,CAAC,SAAS,KACpD,GACF,OAAO;EAET,IAAI,kBAAkB,MAAM,GAC1B,OAAO,OAAO,UAAU,MAAM,YAC5B,UAAU,OAAO,CAAC,CAAC,SAAS,KAAK,CACnC;EAEF,OAAO;CACT,CAAC,IACD;AAGN;AAEA,SAAgB,sBAA+B,EAC7C,SACA,gBACA,YACA,UACA,UACA,eACA,mBACA,yBAa+B;CAC/B,MAAM,kBAAkB,gBACpB,cAAc,SAAS;EAAE;EAAY,gBAAgB;CAAS,CAAC,IAC/D,uBAAuB,SAAS,YAAY,QAAQ;CAKxD,MAAM,iBAHJ,qBAAqB,OACjB,kBACA,gBAAgB,MAAM,GAAG,iBAAiB,EAAA,CACX,KAClC,YAAY;EACX;EACA,QAAQ;CACV,EACF;CAEA,MAAM,QAAQ,UAAU,UAAU;CAClC,IAAI,CAAC,yBAAyB,MAAM,WAAW,GAAG,OAAO;CAEzD,MAAM,aAAa,IAAI,IAAI,QAAQ,KAAK,WAAW,SAAS,MAAM,CAAC,CAAC;CACpE,MAAM,WAAW,IAAI,IAAI,cAAc,KAAK,SAAS,SAAS,KAAK,MAAM,CAAC,CAAC;CAC3E,MAAM,gBAAgB,eACnB,QAAQ,aAAa;EACpB,MAAM,cAAc,SAAS,QAAQ;EACrC,OACE,CAAC,WAAW,IAAI,WAAW,KAC3B,CAAC,SAAS,IAAI,WAAW,KACzB,UAAU,SAAS,QAAQ,CAAC,CAAC,CAAC,SAAS,KAAK;CAEhD,CAAC,CAAC,CACD,KAAiC,YAAY;EAC5C;EACA,QAAQ;CACV,EAAE;CAEJ,OAAO,CAAC,GAAG,eAAe,GAAG,aAAa;AAC5C;AAEA,SAAgB,uBACd,UACA,gBACA,UACA;CACA,MAAM,cAAc,UAChB,cAAc,qCAAmC,CAAC,EAClD,aAAa,YAAY;CAC7B,IAAI,eAAe,MAAM,OAAO;CAChC,OAAO,eAAe,MACnB,aAAa,SAAS,QAAQ,CAAC,CAAC,KAAK,MAAM,WAC9C;AACF;AAEA,SAAgB,8BACd,YACA,gBACA,UACA,UACA,oCACA;CACA,OAAO,sCACL,CAAC,YACD,WAAW,WAAW,KACtB,eAAe,SAAS,IACtB,SAAS,eAAe,EAAE,IAC1B;AACN;AAEA,SAAgB,4BACd,gBACA,UACA,UACA;CACA,IAAI,CAAC,UAAU,OAAO,KAAA;CACtB,IAAI,eAAe,WAAW,GAAG,OAAO;CACxC,OAAO,oBAAoB,eAAe,KAAK,aAAa,SAAS,QAAQ,CAAC,CAAC,CAAC,KAAK,IAAI,EAAE;AAC7F;AAEA,SAAgB,wBACd,YACA,SACA,gBACA,UACA,UACA,iBACA;CACA,MAAM,oBAAoB,WAAW,KAAK;CAC1C,MAAM,uBAAuB,UAAU,UAAU;CACjD,MAAM,sBACJ,qBAAqB,SAAS,KAC9B,QAAQ,MACL,WAAW,UAAU,SAAS,MAAM,CAAC,MAAM,oBAC9C;CACF,MAAM,yBACJ,qBAAqB,SAAS,KAC9B,eAAe,MACZ,aAAa,UAAU,SAAS,QAAQ,CAAC,MAAM,oBAClD;CACF,MAAM,2BACJ,YACA,CAAC,mBACD,kBAAkB,SAAS,KAC3B,CAAC,uBACD,CAAC;CAEH,OAAO;EACL,wBACE,uBAAuB,yBAAyB,KAAK;EACvD,kBAAkB,4BAA4B;EAC9C;EACA;CACF;AACF"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import type { TypeaheadRenderOptionState, TypeaheadSelectedValue, TypeaheadSize } from './Typeahead.types.js';
|
|
3
|
+
export declare function TypeaheadClearButton({ label, onClick, size, }: {
|
|
4
|
+
label: string;
|
|
5
|
+
onClick: (event: React.MouseEvent<HTMLButtonElement>) => void;
|
|
6
|
+
size: TypeaheadSize;
|
|
7
|
+
}): import("react").JSX.Element;
|
|
8
|
+
export declare function TypeaheadDefaultTag<TOption>({ selected, index, disabled, size, getLabel, getValue, onRemove, }: {
|
|
9
|
+
selected: TypeaheadSelectedValue<TOption>;
|
|
10
|
+
index: number;
|
|
11
|
+
disabled: boolean;
|
|
12
|
+
size: TypeaheadSize;
|
|
13
|
+
getLabel: (option: TypeaheadSelectedValue<TOption>) => string;
|
|
14
|
+
getValue: (option: TypeaheadSelectedValue<TOption>) => string;
|
|
15
|
+
onRemove: () => void;
|
|
16
|
+
}): import("react").JSX.Element;
|
|
17
|
+
export declare function TypeaheadDefaultOption<TOption>({ option, state, getLabel, }: {
|
|
18
|
+
option: TypeaheadSelectedValue<TOption>;
|
|
19
|
+
state: TypeaheadRenderOptionState;
|
|
20
|
+
getLabel: (option: TypeaheadSelectedValue<TOption>) => string;
|
|
21
|
+
}): import("react").JSX.Element;
|
|
22
|
+
export declare function TypeaheadCreateOption({ inputValue, label, }: {
|
|
23
|
+
inputValue: string;
|
|
24
|
+
label?: ReactNode;
|
|
25
|
+
}): string | number | bigint | boolean | Iterable<ReactNode> | Promise<string | number | bigint | boolean | import("react").ReactPortal | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | Iterable<ReactNode> | null | undefined> | import("react").JSX.Element;
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { cn } from "../../utils/cn.js";
|
|
2
|
+
import { Text } from "../Text/Text.js";
|
|
3
|
+
import { Badge } from "../Badge/Badge.js";
|
|
4
|
+
import { CheckIcon, PlusIcon, XIcon } from "../../icons/PaddedPhosphorIcons.js";
|
|
5
|
+
import { Icon } from "../Icon/Icon.js";
|
|
6
|
+
import { IconButton } from "../IconButton/IconButton.js";
|
|
7
|
+
import { CONTROL_ICON_SIZES } from "../../utils/controlIconSizes.js";
|
|
8
|
+
import { isTypeaheadOption } from "./Typeahead.utils.js";
|
|
9
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
10
|
+
//#region packages/components/src/components/Typeahead/TypeaheadParts.tsx
|
|
11
|
+
function TypeaheadClearButton({ label, onClick, size }) {
|
|
12
|
+
return /* @__PURE__ */ jsx(IconButton, {
|
|
13
|
+
type: "button",
|
|
14
|
+
icon: XIcon,
|
|
15
|
+
iconWeight: "regular",
|
|
16
|
+
label,
|
|
17
|
+
variant: "plain",
|
|
18
|
+
color: "secondary",
|
|
19
|
+
size: CONTROL_ICON_SIZES[size].buttonSize,
|
|
20
|
+
tooltipProps: { title: null },
|
|
21
|
+
className: "bg-transparent text-icon-tertiary shadow-none hover:bg-elevated-hover hover:text-icon-primary",
|
|
22
|
+
style: { marginBlock: CONTROL_ICON_SIZES[size].actionOffset },
|
|
23
|
+
onMouseDown: (event) => event.preventDefault(),
|
|
24
|
+
onClick
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
function TypeaheadDefaultTag({ selected, index, disabled, size, getLabel, getValue, onRemove }) {
|
|
28
|
+
const label = getLabel(selected);
|
|
29
|
+
return /* @__PURE__ */ jsx(Badge, {
|
|
30
|
+
color: "plain",
|
|
31
|
+
rounded: "xs",
|
|
32
|
+
size: size === "xs" || size === "sm" ? "xs" : "sm",
|
|
33
|
+
textWeight: "normal",
|
|
34
|
+
rightDecorator: !disabled ? XIcon : void 0,
|
|
35
|
+
iconWeight: "regular",
|
|
36
|
+
"aria-label": !disabled ? `Remove ${label}` : void 0,
|
|
37
|
+
role: !disabled ? "button" : void 0,
|
|
38
|
+
tabIndex: !disabled ? 0 : void 0,
|
|
39
|
+
onMouseDown: (event) => event.preventDefault(),
|
|
40
|
+
onKeyDown: (event) => {
|
|
41
|
+
if (!disabled && (event.key === "Enter" || event.key === " ")) {
|
|
42
|
+
event.preventDefault();
|
|
43
|
+
event.stopPropagation();
|
|
44
|
+
onRemove();
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
onClick: !disabled ? (event) => {
|
|
48
|
+
event.stopPropagation();
|
|
49
|
+
onRemove();
|
|
50
|
+
} : void 0,
|
|
51
|
+
className: cn("min-w-0 max-w-full justify-start border-default bg-surface-level-2 px-space-1 text-primary [&>span]:min-w-0 [&>span]:truncate [&>span]:text-xxs", size === "xs" && "border-0 py-0", !disabled && "cursor-pointer focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[var(--border-focus)]", disabled && "cursor-not-allowed"),
|
|
52
|
+
children: label
|
|
53
|
+
}, `${getValue(selected)}-${index}`);
|
|
54
|
+
}
|
|
55
|
+
function TypeaheadDefaultOption({ option, state, getLabel }) {
|
|
56
|
+
const label = getLabel(option);
|
|
57
|
+
const description = isTypeaheadOption(option) ? option.description : void 0;
|
|
58
|
+
const rightDecorator = isTypeaheadOption(option) ? option.rightDecorator : void 0;
|
|
59
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
60
|
+
/* @__PURE__ */ jsx(Icon, {
|
|
61
|
+
"aria-hidden": "true",
|
|
62
|
+
icon: CheckIcon,
|
|
63
|
+
size: "md",
|
|
64
|
+
className: cn("shrink-0 text-icon-primary", state.selected ? "opacity-100" : "opacity-0")
|
|
65
|
+
}),
|
|
66
|
+
/* @__PURE__ */ jsx(OptionText, {
|
|
67
|
+
label,
|
|
68
|
+
description
|
|
69
|
+
}),
|
|
70
|
+
rightDecorator && /* @__PURE__ */ jsx("div", {
|
|
71
|
+
className: "ml-auto shrink-0",
|
|
72
|
+
children: rightDecorator
|
|
73
|
+
})
|
|
74
|
+
] });
|
|
75
|
+
}
|
|
76
|
+
function OptionText({ label, description }) {
|
|
77
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
78
|
+
className: "flex min-w-0 flex-1 flex-col",
|
|
79
|
+
children: [/* @__PURE__ */ jsx(Text, {
|
|
80
|
+
as: "span",
|
|
81
|
+
variant: "sm",
|
|
82
|
+
className: "truncate text-primary",
|
|
83
|
+
children: label
|
|
84
|
+
}), description && /* @__PURE__ */ jsx(Text, {
|
|
85
|
+
as: "span",
|
|
86
|
+
variant: "xs",
|
|
87
|
+
className: "truncate text-tertiary",
|
|
88
|
+
children: description
|
|
89
|
+
})]
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
function TypeaheadCreateOption({ inputValue, label }) {
|
|
93
|
+
if (label != null) return label;
|
|
94
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("span", {
|
|
95
|
+
"aria-hidden": true,
|
|
96
|
+
className: "inline-flex size-4 shrink-0 text-icon-secondary",
|
|
97
|
+
children: /* @__PURE__ */ jsx(PlusIcon, {
|
|
98
|
+
size: "100%",
|
|
99
|
+
weight: "regular"
|
|
100
|
+
})
|
|
101
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
102
|
+
className: "min-w-0 truncate",
|
|
103
|
+
children: inputValue || "Add new"
|
|
104
|
+
})] });
|
|
105
|
+
}
|
|
106
|
+
//#endregion
|
|
107
|
+
export { TypeaheadClearButton, TypeaheadCreateOption, TypeaheadDefaultOption, TypeaheadDefaultTag };
|
|
108
|
+
|
|
109
|
+
//# sourceMappingURL=TypeaheadParts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TypeaheadParts.js","names":[],"sources":["../../../src/components/Typeahead/TypeaheadParts.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\n\nimport { CheckIcon, PlusIcon, XIcon } from '../../icons/PaddedPhosphorIcons';\nimport { cn } from '../../utils/cn';\nimport { CONTROL_ICON_SIZES } from '../../utils/controlIconSizes';\nimport { Badge } from '../Badge';\nimport { Icon } from '../Icon';\nimport { IconButton } from '../IconButton';\nimport { Text } from '../Text';\nimport type {\n TypeaheadRenderOptionState,\n TypeaheadSelectedValue,\n TypeaheadSize,\n} from './Typeahead.types';\nimport { isTypeaheadOption } from './Typeahead.utils';\n\nexport function TypeaheadClearButton({\n label,\n onClick,\n size,\n}: {\n label: string;\n onClick: (event: React.MouseEvent<HTMLButtonElement>) => void;\n size: TypeaheadSize;\n}) {\n // Let the click target extend vertically without making tag rows taller.\n return (\n <IconButton\n type=\"button\"\n icon={XIcon}\n iconWeight=\"regular\"\n label={label}\n variant=\"plain\"\n color=\"secondary\"\n size={CONTROL_ICON_SIZES[size].buttonSize}\n tooltipProps={{ title: null }}\n className=\"bg-transparent text-icon-tertiary shadow-none hover:bg-elevated-hover hover:text-icon-primary\"\n style={{ marginBlock: CONTROL_ICON_SIZES[size].actionOffset }}\n onMouseDown={(event) => event.preventDefault()}\n onClick={onClick}\n />\n );\n}\n\nexport function TypeaheadDefaultTag<TOption>({\n selected,\n index,\n disabled,\n size,\n getLabel,\n getValue,\n onRemove,\n}: {\n selected: TypeaheadSelectedValue<TOption>;\n index: number;\n disabled: boolean;\n size: TypeaheadSize;\n getLabel: (option: TypeaheadSelectedValue<TOption>) => string;\n getValue: (option: TypeaheadSelectedValue<TOption>) => string;\n onRemove: () => void;\n}) {\n const label = getLabel(selected);\n\n return (\n <Badge\n key={`${getValue(selected)}-${index}`}\n color=\"plain\"\n rounded=\"xs\"\n size={size === 'xs' || size === 'sm' ? 'xs' : 'sm'}\n textWeight=\"normal\"\n rightDecorator={!disabled ? XIcon : undefined}\n iconWeight=\"regular\"\n aria-label={!disabled ? `Remove ${label}` : undefined}\n role={!disabled ? 'button' : undefined}\n tabIndex={!disabled ? 0 : undefined}\n onMouseDown={(event) => event.preventDefault()}\n onKeyDown={(event) => {\n if (!disabled && (event.key === 'Enter' || event.key === ' ')) {\n event.preventDefault();\n event.stopPropagation();\n onRemove();\n }\n }}\n onClick={\n !disabled\n ? (event) => {\n event.stopPropagation();\n onRemove();\n }\n : undefined\n }\n className={cn(\n 'min-w-0 max-w-full justify-start border-default bg-surface-level-2 px-space-1 text-primary [&>span]:min-w-0 [&>span]:truncate [&>span]:text-xxs',\n size === 'xs' && 'border-0 py-0',\n !disabled &&\n 'cursor-pointer focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[var(--border-focus)]',\n disabled && 'cursor-not-allowed'\n )}\n >\n {label}\n </Badge>\n );\n}\n\nexport function TypeaheadDefaultOption<TOption>({\n option,\n state,\n getLabel,\n}: {\n option: TypeaheadSelectedValue<TOption>;\n state: TypeaheadRenderOptionState;\n getLabel: (option: TypeaheadSelectedValue<TOption>) => string;\n}) {\n const label = getLabel(option);\n const description = isTypeaheadOption(option)\n ? option.description\n : undefined;\n const rightDecorator = isTypeaheadOption(option)\n ? option.rightDecorator\n : undefined;\n\n return (\n <>\n <Icon\n aria-hidden=\"true\"\n icon={CheckIcon}\n size=\"md\"\n className={cn(\n 'shrink-0 text-icon-primary',\n state.selected ? 'opacity-100' : 'opacity-0'\n )}\n />\n <OptionText label={label} description={description} />\n {rightDecorator && (\n <div className=\"ml-auto shrink-0\">{rightDecorator}</div>\n )}\n </>\n );\n}\n\nfunction OptionText({\n label,\n description,\n}: {\n label: string;\n description: ReactNode;\n}) {\n return (\n <div className=\"flex min-w-0 flex-1 flex-col\">\n <Text as=\"span\" variant=\"sm\" className=\"truncate text-primary\">\n {label}\n </Text>\n {description && (\n <Text as=\"span\" variant=\"xs\" className=\"truncate text-tertiary\">\n {description}\n </Text>\n )}\n </div>\n );\n}\n\nexport function TypeaheadCreateOption({\n inputValue,\n label,\n}: {\n inputValue: string;\n label?: ReactNode;\n}) {\n if (label != null) {\n return label;\n }\n\n return (\n <>\n <span\n aria-hidden\n className=\"inline-flex size-4 shrink-0 text-icon-secondary\"\n >\n <PlusIcon size=\"100%\" weight=\"regular\" />\n </span>\n <span className=\"min-w-0 truncate\">{inputValue || 'Add new'}</span>\n </>\n );\n}\n"],"mappings":";;;;;;;;;;AAgBA,SAAgB,qBAAqB,EACnC,OACA,SACA,QAKC;CAED,OACE,oBAAC,YAAD;EACE,MAAK;EACL,MAAM;EACN,YAAW;EACJ;EACP,SAAQ;EACR,OAAM;EACN,MAAM,mBAAmB,KAAK,CAAC;EAC/B,cAAc,EAAE,OAAO,KAAK;EAC5B,WAAU;EACV,OAAO,EAAE,aAAa,mBAAmB,KAAK,CAAC,aAAa;EAC5D,cAAc,UAAU,MAAM,eAAe;EACpC;CACV,CAAA;AAEL;AAEA,SAAgB,oBAA6B,EAC3C,UACA,OACA,UACA,MACA,UACA,UACA,YASC;CACD,MAAM,QAAQ,SAAS,QAAQ;CAE/B,OACE,oBAAC,OAAD;EAEE,OAAM;EACN,SAAQ;EACR,MAAM,SAAS,QAAQ,SAAS,OAAO,OAAO;EAC9C,YAAW;EACX,gBAAgB,CAAC,WAAW,QAAQ,KAAA;EACpC,YAAW;EACX,cAAY,CAAC,WAAW,UAAU,UAAU,KAAA;EAC5C,MAAM,CAAC,WAAW,WAAW,KAAA;EAC7B,UAAU,CAAC,WAAW,IAAI,KAAA;EAC1B,cAAc,UAAU,MAAM,eAAe;EAC7C,YAAY,UAAU;GACpB,IAAI,CAAC,aAAa,MAAM,QAAQ,WAAW,MAAM,QAAQ,MAAM;IAC7D,MAAM,eAAe;IACrB,MAAM,gBAAgB;IACtB,SAAS;GACX;EACF;EACA,SACE,CAAC,YACI,UAAU;GACT,MAAM,gBAAgB;GACtB,SAAS;EACX,IACA,KAAA;EAEN,WAAW,GACT,mJACA,SAAS,QAAQ,iBACjB,CAAC,YACC,2IACF,YAAY,oBACd;EAEC,UAAA;CACI,GAnCA,GAAG,SAAS,QAAQ,EAAE,GAAG,OAmCzB;AAEX;AAEA,SAAgB,uBAAgC,EAC9C,QACA,OACA,YAKC;CACD,MAAM,QAAQ,SAAS,MAAM;CAC7B,MAAM,cAAc,kBAAkB,MAAM,IACxC,OAAO,cACP,KAAA;CACJ,MAAM,iBAAiB,kBAAkB,MAAM,IAC3C,OAAO,iBACP,KAAA;CAEJ,OACE,qBAAA,UAAA,EAAA,UAAA;EACE,oBAAC,MAAD;GACE,eAAY;GACZ,MAAM;GACN,MAAK;GACL,WAAW,GACT,8BACA,MAAM,WAAW,gBAAgB,WACnC;EACD,CAAA;EACD,oBAAC,YAAD;GAAmB;GAAoB;EAAc,CAAA;EACpD,kBACC,oBAAC,OAAD;GAAK,WAAU;GAAoB,UAAA;EAAoB,CAAA;CAEzD,EAAA,CAAA;AAEN;AAEA,SAAS,WAAW,EAClB,OACA,eAIC;CACD,OACE,qBAAC,OAAD;EAAK,WAAU;EAAf,UAAA,CACE,oBAAC,MAAD;GAAM,IAAG;GAAO,SAAQ;GAAK,WAAU;GACpC,UAAA;EACG,CAAA,GACL,eACC,oBAAC,MAAD;GAAM,IAAG;GAAO,SAAQ;GAAK,WAAU;GACpC,UAAA;EACG,CAAA,CAEL;;AAET;AAEA,SAAgB,sBAAsB,EACpC,YACA,SAIC;CACD,IAAI,SAAS,MACX,OAAO;CAGT,OACE,qBAAA,UAAA,EAAA,UAAA,CACE,oBAAC,QAAD;EACE,eAAA;EACA,WAAU;EAEV,UAAA,oBAAC,UAAD;GAAU,MAAK;GAAO,QAAO;EAAW,CAAA;CACpC,CAAA,GACN,oBAAC,QAAD;EAAM,WAAU;EAAoB,UAAA,cAAc;CAAgB,CAAA,CAClE,EAAA,CAAA;AAEN"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import type { FocusEvent, HTMLAttributes, KeyboardEvent, ReactNode, Ref } from 'react';
|
|
2
|
+
import type { TypeaheadListItem, TypeaheadMultipleValue, TypeaheadRenderOptionState, TypeaheadSelectedValue, TypeaheadSize, TypeaheadTagProps } from './Typeahead.types.js';
|
|
3
|
+
interface TypeaheadViewRootProps {
|
|
4
|
+
ref: Ref<HTMLDivElement>;
|
|
5
|
+
props: HTMLAttributes<HTMLDivElement>;
|
|
6
|
+
handleBlur: (event: FocusEvent<HTMLDivElement>) => void;
|
|
7
|
+
dataTestId?: string;
|
|
8
|
+
className?: string;
|
|
9
|
+
}
|
|
10
|
+
interface TypeaheadViewState {
|
|
11
|
+
size: TypeaheadSize;
|
|
12
|
+
disabled: boolean;
|
|
13
|
+
isError: boolean;
|
|
14
|
+
multiple?: boolean;
|
|
15
|
+
open: boolean;
|
|
16
|
+
setOpen: (open: boolean) => void;
|
|
17
|
+
}
|
|
18
|
+
interface TypeaheadViewIds {
|
|
19
|
+
commandLabel: string;
|
|
20
|
+
resolvedInputId: string;
|
|
21
|
+
listId: string;
|
|
22
|
+
selectedSummaryId: string;
|
|
23
|
+
inputAriaLabel?: string;
|
|
24
|
+
}
|
|
25
|
+
interface TypeaheadViewInputProps {
|
|
26
|
+
value: string;
|
|
27
|
+
onValueChange: (value: string) => void;
|
|
28
|
+
onKeyDown: (event: KeyboardEvent<HTMLInputElement>) => void;
|
|
29
|
+
placeholder: string;
|
|
30
|
+
leftDecorator?: ReactNode;
|
|
31
|
+
showPlaceholderWithValues: boolean;
|
|
32
|
+
autoFocus?: boolean;
|
|
33
|
+
autoComplete?: string;
|
|
34
|
+
setNode: (node: HTMLInputElement | null) => void;
|
|
35
|
+
focus: () => void;
|
|
36
|
+
}
|
|
37
|
+
interface TypeaheadViewSelectionProps<TOption> {
|
|
38
|
+
selectedValues: TypeaheadMultipleValue<TOption>;
|
|
39
|
+
selectedKeys: Set<string>;
|
|
40
|
+
getTagProps: (params: {
|
|
41
|
+
index: number;
|
|
42
|
+
}) => TypeaheadTagProps;
|
|
43
|
+
renderTags?: (value: TypeaheadMultipleValue<TOption>, getTagProps: (params: {
|
|
44
|
+
index: number;
|
|
45
|
+
}) => TypeaheadTagProps) => ReactNode;
|
|
46
|
+
getLabel: (option: TypeaheadSelectedValue<TOption>) => string;
|
|
47
|
+
getValue: (option: TypeaheadSelectedValue<TOption>) => string;
|
|
48
|
+
showClearButton: boolean;
|
|
49
|
+
clearValue: () => void;
|
|
50
|
+
forcePopupIcon: boolean;
|
|
51
|
+
selectedSummary?: string;
|
|
52
|
+
}
|
|
53
|
+
interface TypeaheadViewListProps<TOption> {
|
|
54
|
+
ref: Ref<HTMLDivElement>;
|
|
55
|
+
items: TypeaheadListItem<TOption>[];
|
|
56
|
+
emptyText: string;
|
|
57
|
+
emptyState?: ReactNode;
|
|
58
|
+
listFooter?: ReactNode;
|
|
59
|
+
hideEmptyList: boolean;
|
|
60
|
+
optionIsDisabled: (item: TypeaheadListItem<TOption>) => boolean;
|
|
61
|
+
selectValue: (selected: TypeaheadSelectedValue<TOption>) => void;
|
|
62
|
+
renderOption?: (option: TOption, state: TypeaheadRenderOptionState) => ReactNode;
|
|
63
|
+
}
|
|
64
|
+
interface TypeaheadViewCreateOptionProps {
|
|
65
|
+
show: boolean;
|
|
66
|
+
inputValue: string;
|
|
67
|
+
label?: ReactNode;
|
|
68
|
+
onCreate: () => void;
|
|
69
|
+
}
|
|
70
|
+
interface TypeaheadViewProps<TOption> {
|
|
71
|
+
root: TypeaheadViewRootProps;
|
|
72
|
+
state: TypeaheadViewState;
|
|
73
|
+
ids: TypeaheadViewIds;
|
|
74
|
+
input: TypeaheadViewInputProps;
|
|
75
|
+
selection: TypeaheadViewSelectionProps<TOption>;
|
|
76
|
+
list: TypeaheadViewListProps<TOption>;
|
|
77
|
+
createOption: TypeaheadViewCreateOptionProps;
|
|
78
|
+
popoverContentRef: Ref<HTMLDivElement>;
|
|
79
|
+
}
|
|
80
|
+
export declare function TypeaheadView<TOption>({ root, state, ids, input, selection, list, createOption, popoverContentRef, }: TypeaheadViewProps<TOption>): import("react").JSX.Element;
|
|
81
|
+
export {};
|