@keboola/design 11.3.0 → 11.5.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/AGENTS.md +208 -1
- package/CHANGELOG.md +528 -0
- package/COMPONENT-API.md +68 -46
- package/dist/{AIKit-DaFT7p92.js → AIKit-CNX6aiKm.js} +338 -113
- package/dist/AIKit-CNX6aiKm.js.map +1 -0
- package/dist/{Alert-CseY3yAj.js → Alert-Ba5b2YPq.js} +3 -3
- package/dist/{Alert-CseY3yAj.js.map → Alert-Ba5b2YPq.js.map} +1 -1
- package/dist/{AlertModal-DQAGpsEy.js → AlertModal-BGJdaRRj.js} +3 -3
- package/dist/{AlertModal-DQAGpsEy.js.map → AlertModal-BGJdaRRj.js.map} +1 -1
- package/dist/{AppShell-BUoxM3fv.js → AppShell-DRgJxpXW.js} +2 -2
- package/dist/{AppShell-BUoxM3fv.js.map → AppShell-DRgJxpXW.js.map} +1 -1
- package/dist/{Badge-Ch26CXoP.js → Badge-D0pXdekt.js} +2 -2
- package/dist/Badge-D0pXdekt.js.map +1 -0
- package/dist/{BrandEditor-BnTLMRMp.js → BrandEditor-CSANsxUz.js} +8 -8
- package/dist/{BrandEditor-BnTLMRMp.js.map → BrandEditor-CSANsxUz.js.map} +1 -1
- package/dist/{BrandLogo-V2pRUAeO.js → BrandLogo-CoKBk4MI.js} +5 -5
- package/dist/BrandLogo-CoKBk4MI.js.map +1 -0
- package/dist/{Breadcrumb-CQTPn_KB.js → Breadcrumb-g_xn_-Nf.js} +3 -3
- package/dist/{Breadcrumb-CQTPn_KB.js.map → Breadcrumb-g_xn_-Nf.js.map} +1 -1
- package/dist/{Button-CPsEQuTN.js → Button-DsRrU5F1.js} +6 -5
- package/dist/Button-DsRrU5F1.js.map +1 -0
- package/dist/{Card-Cd5HSBmv.js → Card-Dyo7055Q.js} +2 -2
- package/dist/{Card-Cd5HSBmv.js.map → Card-Dyo7055Q.js.map} +1 -1
- package/dist/{Checkbox-5VNCcV7E.js → Checkbox-CUIn2jap.js} +3 -3
- package/dist/{Checkbox-5VNCcV7E.js.map → Checkbox-CUIn2jap.js.map} +1 -1
- package/dist/{Clipboard-B7rckqV_.js → Clipboard-BTW6C-b_.js} +2 -2
- package/dist/{Clipboard-B7rckqV_.js.map → Clipboard-BTW6C-b_.js.map} +1 -1
- package/dist/{ClipboardButton-CQ6Aewpg.js → ClipboardButton-CwZJdRaz.js} +3 -3
- package/dist/{ClipboardButton-CQ6Aewpg.js.map → ClipboardButton-CwZJdRaz.js.map} +1 -1
- package/dist/{CodeEditor-CUse8znx.js → CodeEditor-C9zy7PxK.js} +16 -27
- package/dist/CodeEditor-C9zy7PxK.js.map +1 -0
- package/dist/{ColorInput-Q1D9Vcc_.js → ColorInput-BZV-u_94.js} +3 -3
- package/dist/{ColorInput-Q1D9Vcc_.js.map → ColorInput-BZV-u_94.js.map} +1 -1
- package/dist/{ColorModeSwitch-B5PXCVqB.js → ColorModeSwitch-CsWLiTBX.js} +3 -3
- package/dist/{ColorModeSwitch-B5PXCVqB.js.map → ColorModeSwitch-CsWLiTBX.js.map} +1 -1
- package/dist/{Combobox-CyoRA7oY.js → Combobox-BfIfaVMA.js} +285 -109
- package/dist/Combobox-BfIfaVMA.js.map +1 -0
- package/dist/{Command-Ds68v2rX.js → Command-Bfa1kpbt.js} +6 -6
- package/dist/{Command-Ds68v2rX.js.map → Command-Bfa1kpbt.js.map} +1 -1
- package/dist/{CopyField-DI66uY_g.js → CopyField-DpT0Ngz1.js} +2 -2
- package/dist/{CopyField-DI66uY_g.js.map → CopyField-DpT0Ngz1.js.map} +1 -1
- package/dist/{DateInput-BPj2pzsn.js → DateInput-DiEd5uCL.js} +4 -4
- package/dist/{DateInput-BPj2pzsn.js.map → DateInput-DiEd5uCL.js.map} +1 -1
- package/dist/{DatePicker-DyEGuW9m.js → DatePicker-nA8YdE84.js} +2 -2
- package/dist/{DatePicker-DyEGuW9m.js.map → DatePicker-nA8YdE84.js.map} +1 -1
- package/dist/{DateRangeInput-u9DxNbHW.js → DateRangeInput-DPfVYchl.js} +4 -4
- package/dist/{DateRangeInput-u9DxNbHW.js.map → DateRangeInput-DPfVYchl.js.map} +1 -1
- package/dist/{DateRangePicker-CYYhX6S7.js → DateRangePicker-DjSUFjh4.js} +5 -5
- package/dist/{DateRangePicker-CYYhX6S7.js.map → DateRangePicker-DjSUFjh4.js.map} +1 -1
- package/dist/{DropdownMenu-DpMEcyCq.js → DropdownMenu-CASr-jgl.js} +2 -2
- package/dist/{DropdownMenu-DpMEcyCq.js.map → DropdownMenu-CASr-jgl.js.map} +1 -1
- package/dist/{FieldItem-qQKGU9lF.js → FieldItem-B7XMmZSz.js} +3 -3
- package/dist/{FieldItem-qQKGU9lF.js.map → FieldItem-B7XMmZSz.js.map} +1 -1
- package/dist/{FileUpload-C336MVnU.js → FileUpload-ABThVZyg.js} +2 -2
- package/dist/{FileUpload-C336MVnU.js.map → FileUpload-ABThVZyg.js.map} +1 -1
- package/dist/{Form-CTygENDc.js → Form-CsttTHn4.js} +8 -8
- package/dist/Form-CsttTHn4.js.map +1 -0
- package/dist/{FormGroup-BnwP0jNu.js → FormGroup-DHvTFdno.js} +3 -3
- package/dist/{FormGroup-BnwP0jNu.js.map → FormGroup-DHvTFdno.js.map} +1 -1
- package/dist/{FullScreenModal-j-M4aPFd.js → FullScreenModal-BvPuYibe.js} +3 -3
- package/dist/{FullScreenModal-j-M4aPFd.js.map → FullScreenModal-BvPuYibe.js.map} +1 -1
- package/dist/{HoverCard-yQq-O49c.js → HoverCard-B9ZMJxjn.js} +2 -2
- package/dist/{HoverCard-yQq-O49c.js.map → HoverCard-B9ZMJxjn.js.map} +1 -1
- package/dist/{InputGroup-D7zlmqPB.js → InputGroup-DcZRlVnN.js} +24 -16
- package/dist/InputGroup-DcZRlVnN.js.map +1 -0
- package/dist/{Kbd-D6LpR7G2.js → Kbd-Cvvt91Q8.js} +14 -4
- package/dist/Kbd-Cvvt91Q8.js.map +1 -0
- package/dist/MarkedText-DNGEUVWc.js +67 -0
- package/dist/MarkedText-DNGEUVWc.js.map +1 -0
- package/dist/{MermaidDiagram-JlvuGcY-.js → MermaidDiagram-CXG5tC6J.js} +19 -18
- package/dist/MermaidDiagram-CXG5tC6J.js.map +1 -0
- package/dist/{Modal-o4ATIexE.js → Modal-Coj-H02o.js} +16 -4
- package/dist/Modal-Coj-H02o.js.map +1 -0
- package/dist/{MultiActionButtonGroup-GTeFk-L8.js → MultiActionButtonGroup-DokHbPgM.js} +3 -3
- package/dist/{MultiActionButtonGroup-GTeFk-L8.js.map → MultiActionButtonGroup-DokHbPgM.js.map} +1 -1
- package/dist/{Navbar-CAQs4BZz.js → Navbar-Liy1TPI7.js} +7 -7
- package/dist/{Navbar-CAQs4BZz.js.map → Navbar-Liy1TPI7.js.map} +1 -1
- package/dist/PageHeader-Q3IpCnQd.js.map +1 -1
- package/dist/{PageToolbar-bG2YtSa3.js → PageToolbar-DExqEYGl.js} +4 -4
- package/dist/{PageToolbar-bG2YtSa3.js.map → PageToolbar-DExqEYGl.js.map} +1 -1
- package/dist/{Pagination-BB3X7ooY.js → Pagination-C_b7Xhey.js} +2 -2
- package/dist/{Pagination-BB3X7ooY.js.map → Pagination-C_b7Xhey.js.map} +1 -1
- package/dist/{Popconfirm-C2Ky5hJO.js → Popconfirm-5pBzT_HQ.js} +12 -13
- package/dist/{Popconfirm-C2Ky5hJO.js.map → Popconfirm-5pBzT_HQ.js.map} +1 -1
- package/dist/{Popover-DsbI2HKu.js → Popover-BEbQrC_P.js} +22 -19
- package/dist/Popover-BEbQrC_P.js.map +1 -0
- package/dist/{RadioGroup-BMxuZEbT.js → RadioGroup-DXPbSj8P.js} +3 -3
- package/dist/{RadioGroup-BMxuZEbT.js.map → RadioGroup-DXPbSj8P.js.map} +1 -1
- package/dist/{Search-DFeECt5D.js → Search-5uQAiNIP.js} +2 -2
- package/dist/{Search-DFeECt5D.js.map → Search-5uQAiNIP.js.map} +1 -1
- package/dist/{SearchInput-CCpdUego.js → SearchInput-D4UgAXJK.js} +3 -3
- package/dist/{SearchInput-CCpdUego.js.map → SearchInput-D4UgAXJK.js.map} +1 -1
- package/dist/{SectionNav-Bw_MVL0_.js → SectionNav-OkKCjSA-.js} +5 -5
- package/dist/{SectionNav-Bw_MVL0_.js.map → SectionNav-OkKCjSA-.js.map} +1 -1
- package/dist/{Select-D6IZVvwL.js → Select-DV3Hak_l.js} +31 -21
- package/dist/Select-DV3Hak_l.js.map +1 -0
- package/dist/{Sheet-BIzs2K2H.js → Sheet-Chf0kX1E.js} +3 -3
- package/dist/{Sheet-BIzs2K2H.js.map → Sheet-Chf0kX1E.js.map} +1 -1
- package/dist/{Sidebar-r1TW4g_b.js → Sidebar-D3cY1kha.js} +48 -22
- package/dist/Sidebar-D3cY1kha.js.map +1 -0
- package/dist/{Slider-CjxyfEty.js → Slider-CRf-bB4y.js} +3 -3
- package/dist/{Slider-CjxyfEty.js.map → Slider-CRf-bB4y.js.map} +1 -1
- package/dist/{Switch-BueTV03C.js → Switch-B0WdGSjz.js} +8 -8
- package/dist/{Switch-BueTV03C.js.map → Switch-B0WdGSjz.js.map} +1 -1
- package/dist/{Tabs-l72-WuhK.js → Tabs-eB974xJf.js} +2 -2
- package/dist/{Tabs-l72-WuhK.js.map → Tabs-eB974xJf.js.map} +1 -1
- package/dist/{TextInput-DhdRk8qm.js → TextInput-DH5SkbsE.js} +3 -3
- package/dist/{TextInput-DhdRk8qm.js.map → TextInput-DH5SkbsE.js.map} +1 -1
- package/dist/{ThemeProvider-DZfGdf1v.js → ThemeProvider-2RMdVGxO.js} +95 -15
- package/dist/ThemeProvider-2RMdVGxO.js.map +1 -0
- package/dist/{TimePicker-B6d2rAbX.js → TimePicker-BGeqc-Ed.js} +2 -2
- package/dist/{TimePicker-B6d2rAbX.js.map → TimePicker-BGeqc-Ed.js.map} +1 -1
- package/dist/{Timeline-6btyJl4D.js → Timeline-BG5Xogxh.js} +11 -11
- package/dist/{Timeline-6btyJl4D.js.map → Timeline-BG5Xogxh.js.map} +1 -1
- package/dist/{Toast-CxXUulYN.js → Toast-Dr6Uw7ao.js} +2 -2
- package/dist/{Toast-CxXUulYN.js.map → Toast-Dr6Uw7ao.js.map} +1 -1
- package/dist/{Workbench-BzE-Vvd9.js → Workbench-UR2FBC7I.js} +3 -1
- package/dist/Workbench-UR2FBC7I.js.map +1 -0
- package/dist/{ZoomableSvg-CNIzRHKH.js → ZoomableSvg-pooPb1Cu.js} +4 -4
- package/dist/{ZoomableSvg-CNIzRHKH.js.map → ZoomableSvg-pooPb1Cu.js.map} +1 -1
- package/dist/{context-BrNtMc1H.js → context-D7X470dy.js} +4 -3
- package/dist/context-D7X470dy.js.map +1 -0
- package/dist/{defaults-CTfvj2KB.js → defaults-i_xG2F_1.js} +2 -4
- package/dist/defaults-i_xG2F_1.js.map +1 -0
- package/dist/editors.js +5 -5
- package/dist/findLiteralMatches-BGBw8Vbl.js +62 -0
- package/dist/findLiteralMatches-BGBw8Vbl.js.map +1 -0
- package/dist/flint.js +134 -8
- package/dist/flint.js.map +1 -1
- package/dist/index.d.ts +1118 -566
- package/dist/index.js +64 -62
- package/dist/internal/blocks/AIKit.js +2 -2
- package/dist/internal/blocks/AppShell.js +1 -1
- package/dist/internal/blocks/AuthLayout.js +118 -0
- package/dist/internal/blocks/AuthLayout.js.map +1 -0
- package/dist/internal/blocks/BrandEditor.js +1 -1
- package/dist/internal/blocks/ChartPanel.js +1 -1
- package/dist/internal/blocks/ClipboardButton.js +1 -1
- package/dist/internal/blocks/ColorInput.js +1 -1
- package/dist/internal/blocks/ColorModeSwitch.js +1 -1
- package/dist/internal/blocks/Command.js +1 -1
- package/dist/internal/blocks/CopyField.js +1 -1
- package/dist/internal/blocks/DateInput.js +1 -1
- package/dist/internal/blocks/DateRangeInput.js +1 -1
- package/dist/internal/blocks/EmptyConfigurationActionCard.js +1 -1
- package/dist/internal/blocks/ErrorState.js +1 -1
- package/dist/internal/blocks/ExportMenu.js +5 -5
- package/dist/internal/blocks/ExportMenu.js.map +1 -1
- package/dist/internal/blocks/Form/connectors/MultiComboboxField.js +1 -1
- package/dist/internal/blocks/Form.js +1 -1
- package/dist/internal/blocks/FormGroup.js +1 -1
- package/dist/internal/blocks/MultiActionButtonGroup.js +1 -1
- package/dist/internal/blocks/MultiCombobox.js +116 -54
- package/dist/internal/blocks/MultiCombobox.js.map +1 -1
- package/dist/internal/blocks/NumberInput.js +1 -1
- package/dist/internal/blocks/PageToolbar.js +1 -1
- package/dist/internal/blocks/PasswordInput.js +2 -2
- package/dist/internal/blocks/SearchInput.js +1 -1
- package/dist/internal/blocks/SearchInputWithNavigation.js +3 -3
- package/dist/internal/blocks/SectionNav.js +1 -1
- package/dist/internal/blocks/SplitButton.js +2 -2
- package/dist/internal/blocks/StatCard.js +1 -1
- package/dist/internal/blocks/TextInput.js +1 -1
- package/dist/internal/blocks/Textarea.js +1 -1
- package/dist/internal/blocks/TimeInput.js +3 -3
- package/dist/internal/components/Alert.js +1 -1
- package/dist/internal/components/AlertModal.js +1 -1
- package/dist/internal/components/Avatar.js +1 -1
- package/dist/internal/components/Badge.js +1 -1
- package/dist/internal/components/BrandLogo.js +1 -1
- package/dist/internal/components/Breadcrumb.js +1 -1
- package/dist/internal/components/Button.js +1 -1
- package/dist/internal/components/Card.js +1 -1
- package/dist/internal/components/Checkbox.js +1 -1
- package/dist/internal/components/Clipboard.js +1 -1
- package/dist/internal/components/CollapsiblePanel.js +1 -1
- package/dist/internal/components/Combobox.js +2 -2
- package/dist/internal/components/DatePicker.js +1 -1
- package/dist/internal/components/DateRangePicker.js +1 -1
- package/dist/internal/components/DropdownMenu.js +1 -1
- package/dist/internal/components/FileUpload.js +1 -1
- package/dist/internal/components/FullScreenModal.js +1 -1
- package/dist/internal/components/HoverCard.js +1 -1
- package/dist/internal/components/InputGroup.js +1 -1
- package/dist/internal/components/Kbd.js +1 -1
- package/dist/internal/components/MarkedText.js +1 -1
- package/dist/internal/components/Modal.js +1 -1
- package/dist/internal/components/Navbar.js +1 -1
- package/dist/internal/components/Pagination.js +1 -1
- package/dist/internal/components/Popconfirm.js +1 -1
- package/dist/internal/components/Popover.js +1 -1
- package/dist/internal/components/RadioGroup.js +1 -1
- package/dist/internal/components/Search.js +1 -1
- package/dist/internal/components/Select.js +1 -1
- package/dist/internal/components/Sheet.js +1 -1
- package/dist/internal/components/Sidebar.js +1 -1
- package/dist/internal/components/Slider.js +1 -1
- package/dist/internal/components/Switch.js +1 -1
- package/dist/internal/components/Tabs.js +1 -1
- package/dist/internal/components/ThemeProvider.js +4 -4
- package/dist/internal/components/TimePicker.js +1 -1
- package/dist/internal/components/Timeline.js +1 -1
- package/dist/internal/components/Toast.js +2 -2
- package/dist/internal/components/Toggle.js +3 -3
- package/dist/internal/components/Toggle.js.map +1 -1
- package/dist/internal/components/Tooltip.js +1 -1
- package/dist/internal/components/Truncated.js +1 -1
- package/dist/internal/components/Workbench.js +1 -1
- package/dist/internal/components/ZoomableSvg.js +1 -1
- package/dist/internal/utils.js +3 -3
- package/dist/markdown-editor.js +32 -26
- package/dist/markdown-editor.js.map +1 -1
- package/dist/mermaid.js +1 -1
- package/dist/rjsf.js +24 -25
- package/dist/rjsf.js.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/testing.js +4 -4
- package/dist/testing.js.map +1 -1
- package/dist/{useColorSchemeState-BJEk6esG.js → themeScopeContext-D7fSyb06.js} +17 -4
- package/dist/themeScopeContext-D7fSyb06.js.map +1 -0
- package/dist/{themeTokens-7T1AFLhq.js → themeTokens-qP1-55O7.js} +38 -11
- package/dist/themeTokens-qP1-55O7.js.map +1 -0
- package/dist/{toast-BweSoKn3.js → toast-DIC0iNRf.js} +2 -2
- package/dist/{toast-BweSoKn3.js.map → toast-DIC0iNRf.js.map} +1 -1
- package/dist/{utils-B-g7d_Jb.js → utils-DSvrhU8E.js} +7 -3
- package/dist/{utils-B-g7d_Jb.js.map → utils-DSvrhU8E.js.map} +1 -1
- package/dist/vega.d.ts +1 -1
- package/dist/vega.js +3 -3
- package/dist/vega.js.map +1 -1
- package/dist/{vegaTheme-FBXgAdHK.js → vegaTheme-CSvFEMBl.js} +6 -6
- package/dist/vegaTheme-CSvFEMBl.js.map +1 -0
- package/package.json +12 -10
- package/src/styles.css +3 -0
- package/dist/AIKit-DaFT7p92.js.map +0 -1
- package/dist/Badge-Ch26CXoP.js.map +0 -1
- package/dist/BrandLogo-V2pRUAeO.js.map +0 -1
- package/dist/Button-CPsEQuTN.js.map +0 -1
- package/dist/CodeEditor-CUse8znx.js.map +0 -1
- package/dist/Combobox-CyoRA7oY.js.map +0 -1
- package/dist/Form-CTygENDc.js.map +0 -1
- package/dist/InputGroup-D7zlmqPB.js.map +0 -1
- package/dist/Kbd-D6LpR7G2.js.map +0 -1
- package/dist/MarkedText-Ckbft5mw.js +0 -44
- package/dist/MarkedText-Ckbft5mw.js.map +0 -1
- package/dist/MermaidDiagram-JlvuGcY-.js.map +0 -1
- package/dist/Modal-o4ATIexE.js.map +0 -1
- package/dist/Popover-DsbI2HKu.js.map +0 -1
- package/dist/Select-D6IZVvwL.js.map +0 -1
- package/dist/Sidebar-r1TW4g_b.js.map +0 -1
- package/dist/ThemeProvider-DZfGdf1v.js.map +0 -1
- package/dist/Workbench-BzE-Vvd9.js.map +0 -1
- package/dist/context-BrNtMc1H.js.map +0 -1
- package/dist/defaults-CTfvj2KB.js.map +0 -1
- package/dist/escapeStringRegexp-8MxP2knR.js +0 -6
- package/dist/escapeStringRegexp-8MxP2knR.js.map +0 -1
- package/dist/themeTokens-7T1AFLhq.js.map +0 -1
- package/dist/useColorSchemeState-BJEk6esG.js.map +0 -1
- package/dist/vegaTheme-FBXgAdHK.js.map +0 -1
|
@@ -1,18 +1,97 @@
|
|
|
1
1
|
import { cn } from "./classNames-BzrkDnOD.js";
|
|
2
|
-
import {
|
|
2
|
+
import { noop } from "./utils-DSvrhU8E.js";
|
|
3
|
+
import { useArgoDesign } from "./context-D7X470dy.js";
|
|
3
4
|
import { Check, ChevronDown, Plus, X } from "./icons-Cek151jC.js";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
5
|
+
import { useStableCallback } from "./internal/hooks/useStableCallback.js";
|
|
6
|
+
import { InputGroup } from "./InputGroup-DcZRlVnN.js";
|
|
7
|
+
import { Badge } from "./Badge-D0pXdekt.js";
|
|
8
|
+
import { useEffect, useMemo, useState } from "react";
|
|
7
9
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
8
10
|
import { Combobox } from "@base-ui/react/combobox";
|
|
9
11
|
import { useVirtualizer } from "@tanstack/react-virtual";
|
|
12
|
+
import { DismissableLayer } from "@radix-ui/react-dismissable-layer";
|
|
13
|
+
//#region src/components/Combobox/blankValues.ts
|
|
14
|
+
/**
|
|
15
|
+
* The two blank strings a Storage filter predicates on, in list order.
|
|
16
|
+
*
|
|
17
|
+
* - Reach for {@link withBlankValues} to offer them; this is the pair itself.
|
|
18
|
+
*/
|
|
19
|
+
const BLANK_VALUES = ["", " "];
|
|
20
|
+
const BLANK_LABELS = {
|
|
21
|
+
"": "[empty string]",
|
|
22
|
+
" ": "[space character]"
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* A string as a row or a chip shows it — named when its text is blank, itself otherwise.
|
|
26
|
+
*
|
|
27
|
+
* - Exported so an `itemToLabel` / `itemToChipLabel` / `itemToSelectedLabel` / `renderChips`
|
|
28
|
+
* override can keep the default naming instead of retyping the labels.
|
|
29
|
+
* - The two blank values get their own labels; any other whitespace-only string (a tab, a run of
|
|
30
|
+
* spaces) falls back to a generic one, so two different ones read alike.
|
|
31
|
+
* - Identity is unaffected — `toLabel` keys items off the raw string.
|
|
32
|
+
*/
|
|
33
|
+
const namedLabel = (text) => text.trim() === "" ? BLANK_LABELS[text] ?? "[whitespace]" : text;
|
|
34
|
+
/**
|
|
35
|
+
* `values` with both blank values offered ahead of them, and duplicates collapsed.
|
|
36
|
+
*
|
|
37
|
+
* - The dedupe matters where the list is the distinct values of a Storage column: it can already
|
|
38
|
+
* hold a blank, and two `Object.is`-equal rows both report `aria-selected` and toggle each other.
|
|
39
|
+
* - First occurrence wins, so the order of the values is otherwise preserved.
|
|
40
|
+
* - String items only — the seven Storage filters this serves are all string-valued.
|
|
41
|
+
*/
|
|
42
|
+
const withBlankValues = (values) => [.../* @__PURE__ */ new Set([...BLANK_VALUES, ...values])];
|
|
43
|
+
//#endregion
|
|
44
|
+
//#region src/components/Combobox/ComboboxChip.tsx
|
|
45
|
+
/**
|
|
46
|
+
* Keeps a chip's own keyboard handling off its content's.
|
|
47
|
+
*
|
|
48
|
+
* - Base UI's chip calls `preventDefault` on Enter and Space, which would cancel the activation of
|
|
49
|
+
* a link or button rendered inside the chip.
|
|
50
|
+
* - Capture phase, because React dispatches capture and bubble in one pass over the event path:
|
|
51
|
+
* stopping here means the chip's own bubble handler never runs.
|
|
52
|
+
* - Guarded on the target, so keys the chip itself receives while focused — Backspace, Delete, the
|
|
53
|
+
* arrows — still reach that handler.
|
|
54
|
+
*/
|
|
55
|
+
const stopNestedKeyDown = (event) => {
|
|
56
|
+
if (event.target !== event.currentTarget) event.stopPropagation();
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* One chip in a `MultiCombobox`'s chip area — Badge chrome plus the remove button.
|
|
60
|
+
*
|
|
61
|
+
* - Position is the identity: Base UI removes the chip at an index, so render one per entry of
|
|
62
|
+
* `value`, in that order. There is no value prop to pass.
|
|
63
|
+
* - `children` is the chip's content, so it can hold a link or an action of its own.
|
|
64
|
+
* - Renders inside a `MultiCombobox`'s `renderChips` slot, or `Combobox.Chips`.
|
|
65
|
+
* - A chip the user cannot remove is a plain `Badge`, not a chip — a chip would take a position
|
|
66
|
+
* that a removal counts against.
|
|
67
|
+
*/
|
|
68
|
+
const ComboboxChip = ({ children, color, variant }) => {
|
|
69
|
+
const renderArgo = useArgoDesign();
|
|
70
|
+
return /* @__PURE__ */ jsxs(Combobox.Chip, {
|
|
71
|
+
render: /* @__PURE__ */ jsx(Badge.Root, {
|
|
72
|
+
color,
|
|
73
|
+
variant: variant ?? (renderArgo ? "pill" : "default"),
|
|
74
|
+
className: "tw:max-w-40"
|
|
75
|
+
}),
|
|
76
|
+
onKeyDownCapture: stopNestedKeyDown,
|
|
77
|
+
children: [/* @__PURE__ */ jsx(Badge.Label, { children }), /* @__PURE__ */ jsx(Badge.Addon, {
|
|
78
|
+
variant: "inline",
|
|
79
|
+
align: "inline-end",
|
|
80
|
+
children: /* @__PURE__ */ jsx(Combobox.ChipRemove, { render: /* @__PURE__ */ jsx(Badge.Button, {
|
|
81
|
+
"aria-label": "Remove value",
|
|
82
|
+
children: /* @__PURE__ */ jsx(X, { className: "tw:size-3" })
|
|
83
|
+
}) })
|
|
84
|
+
})]
|
|
85
|
+
});
|
|
86
|
+
};
|
|
87
|
+
//#endregion
|
|
10
88
|
//#region src/components/Combobox/utils.ts
|
|
11
89
|
const isPlainObject = (item) => item !== null && typeof item === "object";
|
|
12
90
|
const isNumber = (item) => typeof item === "number";
|
|
13
91
|
const isString = (item) => typeof item === "string";
|
|
14
92
|
const isLabeledItem = (item) => isPlainObject(item) && Reflect.has(item, "label") && Reflect.has(item, "value");
|
|
15
93
|
const isInternalItem = (item) => isLabeledItem(item) && "__marker" in item;
|
|
94
|
+
const isSelectAllItem = (item) => isInternalItem(item) && item.__marker === "selectAll";
|
|
16
95
|
const isCreatableItem = (item) => {
|
|
17
96
|
return isInternalItem(item) && item.__marker === "creatable";
|
|
18
97
|
};
|
|
@@ -22,12 +101,29 @@ const isGroupItems = (items) => {
|
|
|
22
101
|
if (items.length === 0) return false;
|
|
23
102
|
return isGroupItem(items[0]);
|
|
24
103
|
};
|
|
104
|
+
/**
|
|
105
|
+
* Node a list row and a chip show for an item.
|
|
106
|
+
*
|
|
107
|
+
* - Names a blank string, because a row or a chip rendering as nothing is indistinguishable from
|
|
108
|
+
* an empty control. {@link toLabel} deliberately does not, so the input keeps the raw value.
|
|
109
|
+
* - A non-string `label` (a JSX node) passes through untouched.
|
|
110
|
+
*/
|
|
25
111
|
const defaultItemToLabel = (item) => {
|
|
26
|
-
if (isNumber(item)
|
|
112
|
+
if (isNumber(item)) return item;
|
|
113
|
+
if (isString(item)) return namedLabel(item);
|
|
27
114
|
if (!isLabeledItem(item)) throw new Error("Combobox: Item does not have a `label` field. Pass `itemToLabel` for custom item shapes.");
|
|
28
|
-
return item.label;
|
|
115
|
+
return isString(item.label) ? namedLabel(item.label) : item.label;
|
|
29
116
|
};
|
|
30
|
-
/**
|
|
117
|
+
/**
|
|
118
|
+
* Display string for an item — mirrors base-ui's own default logic.
|
|
119
|
+
*
|
|
120
|
+
* - Also the default search text and the closed `Combobox`'s input value, so it is the item's
|
|
121
|
+
* string identity rather than its decoration.
|
|
122
|
+
* - Blank strings are deliberately **not** named here: a `''` reaching this is as likely to be an
|
|
123
|
+
* owner's "nothing selected" as a real value.
|
|
124
|
+
* - Naming one would paint text into an empty input and suppress the placeholder.
|
|
125
|
+
* - Naming lives in {@link defaultItemToLabel}, which only rows and chips read.
|
|
126
|
+
*/
|
|
31
127
|
const toLabel = (item) => {
|
|
32
128
|
if (isString(item)) return item;
|
|
33
129
|
if (isLabeledItem(item)) {
|
|
@@ -48,11 +144,28 @@ const toValueKey = (item) => {
|
|
|
48
144
|
const defaultItemToIcon = (item) => isLabeledItem(item) ? item.icon : void 0;
|
|
49
145
|
const defaultItemToDisabled = (item) => isLabeledItem(item) ? item.disabled ?? false : false;
|
|
50
146
|
const defaultGroupToLabel = () => void 0;
|
|
147
|
+
const selectAllItem = {
|
|
148
|
+
__marker: "selectAll",
|
|
149
|
+
value: "__select_all__",
|
|
150
|
+
label: "Select All"
|
|
151
|
+
};
|
|
51
152
|
const createCreatableItem = (query) => ({
|
|
52
153
|
__marker: "creatable",
|
|
53
154
|
value: query,
|
|
54
155
|
label: query
|
|
55
156
|
});
|
|
157
|
+
/**
|
|
158
|
+
* Item-equality predicate for a Base UI combobox root.
|
|
159
|
+
*
|
|
160
|
+
* - An injected sentinel row equals only a sentinel of the same marker with the same value key —
|
|
161
|
+
* the create row is rebuilt on every keystroke, so reference equality would never match it.
|
|
162
|
+
* - A sentinel never equals a real item, however the two keys read: that is what the marker is for.
|
|
163
|
+
* - Real items fall through to the caller's predicate, then to Base UI's own `Object.is`.
|
|
164
|
+
*/
|
|
165
|
+
const toItemEquality = (isItemEqualToValue) => (a, b) => {
|
|
166
|
+
if (isInternalItem(a) || isInternalItem(b)) return isInternalItem(a) && isInternalItem(b) && a.__marker === b.__marker && toValueKey(a) === toValueKey(b);
|
|
167
|
+
return isItemEqualToValue?.(a, b) ?? Object.is(a, b);
|
|
168
|
+
};
|
|
56
169
|
const defaultToCreateValue = (query, value, queryToCreateValue) => {
|
|
57
170
|
if (queryToCreateValue) return queryToCreateValue(query);
|
|
58
171
|
if (value === void 0) return query;
|
|
@@ -66,28 +179,27 @@ const defaultToCreateValue = (query, value, queryToCreateValue) => {
|
|
|
66
179
|
const defaultQueryToCreateLabel = (query) => `Create "${query}"`;
|
|
67
180
|
//#endregion
|
|
68
181
|
//#region src/components/Combobox/ComboboxChips.tsx
|
|
69
|
-
const ComboboxChips = ({ maxVisible = 3, itemToChipLabel = defaultItemToLabel, itemToChipColor, variant = "pill" }) => /* @__PURE__ */ jsx(Combobox.Value, { children: (
|
|
70
|
-
|
|
182
|
+
const ComboboxChips = ({ maxVisible = 3, itemToChipLabel = defaultItemToLabel, itemToChipColor, pinnedChipLabels, variant = "pill", children }) => /* @__PURE__ */ jsx(Combobox.Value, { children: (rawValues) => {
|
|
183
|
+
const values = rawValues.filter((value) => !isInternalItem(value));
|
|
184
|
+
if (children) return children(values);
|
|
71
185
|
const visible = values.slice(0, maxVisible);
|
|
72
186
|
const overflow = values.slice(maxVisible);
|
|
73
|
-
return /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
74
|
-
|
|
75
|
-
color: itemToChipColor?.(value),
|
|
187
|
+
return /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
188
|
+
pinnedChipLabels?.map((label, index) => /* @__PURE__ */ jsx(Badge, {
|
|
76
189
|
className: "tw:max-w-40",
|
|
77
|
-
variant
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
})] });
|
|
190
|
+
variant,
|
|
191
|
+
children: label
|
|
192
|
+
}, index)),
|
|
193
|
+
visible.map((value, index) => /* @__PURE__ */ jsx(ComboboxChip, {
|
|
194
|
+
color: itemToChipColor?.(value),
|
|
195
|
+
variant,
|
|
196
|
+
children: itemToChipLabel(value)
|
|
197
|
+
}, index)),
|
|
198
|
+
overflow.length > 0 && /* @__PURE__ */ jsx(Badge.Root, {
|
|
199
|
+
variant: "pill",
|
|
200
|
+
children: /* @__PURE__ */ jsxs(Badge.Label, { children: ["+", overflow.length] })
|
|
201
|
+
})
|
|
202
|
+
] });
|
|
91
203
|
} });
|
|
92
204
|
//#endregion
|
|
93
205
|
//#region src/components/Combobox/ComboboxContent.tsx
|
|
@@ -95,20 +207,23 @@ const ComboboxContent = ({ ref, align = "start", side = "bottom", sideOffset = 4
|
|
|
95
207
|
const effectiveVariant = useArgoDesign() ? "argo" : "default";
|
|
96
208
|
return /* @__PURE__ */ jsx(Combobox.Portal, {
|
|
97
209
|
container,
|
|
98
|
-
children: /* @__PURE__ */ jsx(
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
210
|
+
children: /* @__PURE__ */ jsx(DismissableLayer, {
|
|
211
|
+
asChild: true,
|
|
212
|
+
children: /* @__PURE__ */ jsx(Combobox.Positioner, {
|
|
213
|
+
align,
|
|
214
|
+
side,
|
|
215
|
+
sideOffset,
|
|
216
|
+
alignOffset,
|
|
217
|
+
anchor,
|
|
218
|
+
className: "tw:isolate tw:z-[1055] tailwindcss-preflight",
|
|
219
|
+
children: /* @__PURE__ */ jsx(Combobox.Popup, {
|
|
220
|
+
ref,
|
|
221
|
+
"data-chips": !!anchor,
|
|
222
|
+
"data-variant": effectiveVariant,
|
|
223
|
+
className: cn("tw:!pointer-events-auto", "tw:group/combobox-content", "tw:relative", "tw:flex tw:flex-col tw:overflow-hidden", "tw:max-h-[var(--available-height)]", "tw:w-[var(--anchor-width)]", "tw:max-w-[var(--available-width)]", "tw:origin-[var(--transform-origin)]", "tw:data-[chips=true]:min-w-[var(--anchor-width)]", "tw:rounded-lg", "tw:data-[variant=default]:rounded", "tw:bg-popover", "tw:text-popover-foreground", "tw:shadow-md", "tw:ring-1", "tw:ring-foreground/10", "tw:duration-100", "data-open:animate-in", "data-open:fade-in-0", "data-open:zoom-in-95", "data-closed:animate-out", "data-closed:fade-out-0", "data-closed:zoom-out-95", "tw:data-[side=bottom]:slide-in-from-top-2", "tw:data-[side=top]:slide-in-from-bottom-2", "tw:data-[side=left]:slide-in-from-right-2", "tw:data-[side=right]:slide-in-from-left-2", "tw:data-[side=inline-start]:slide-in-from-right-2", "tw:data-[side=inline-end]:slide-in-from-left-2", className),
|
|
224
|
+
...popupProps,
|
|
225
|
+
children
|
|
226
|
+
})
|
|
112
227
|
})
|
|
113
228
|
})
|
|
114
229
|
});
|
|
@@ -212,27 +327,50 @@ const ComboboxCollection = ({ ...props }) => /* @__PURE__ */ jsx(Combobox.Collec
|
|
|
212
327
|
...props
|
|
213
328
|
});
|
|
214
329
|
//#endregion
|
|
330
|
+
//#region src/components/Combobox/query.ts
|
|
331
|
+
/**
|
|
332
|
+
* The text a combobox's input takes, with `inputValueSanitizer` applied to what the user typed.
|
|
333
|
+
*
|
|
334
|
+
* - `input-change` is the only reason carrying typed text. Every other one carries text the
|
|
335
|
+
* control itself put there — an item's label, or the empty string a clear leaves — which a
|
|
336
|
+
* sanitizer aimed at typed characters would mangle.
|
|
337
|
+
* - A sanitizer sees the whole text on every keystroke, so it has to rewrite rather than drop:
|
|
338
|
+
* one calling `trim()` swallows the space before the next word.
|
|
339
|
+
*/
|
|
340
|
+
const sanitizeTypedInput = (next, reason, sanitizer) => reason === "input-change" ? sanitizer?.(next) ?? next : next;
|
|
341
|
+
/**
|
|
342
|
+
* Reports the query the list filters by to the control's owner.
|
|
343
|
+
*
|
|
344
|
+
* - Fires from an effect rather than the input handler because `query` is derived: in `Combobox`
|
|
345
|
+
* a selection showing its own label empties it without a keystroke, so the handler never sees
|
|
346
|
+
* every value it takes.
|
|
347
|
+
* - The mount render reports too, so an owner fetching on the query needs no first fetch of its
|
|
348
|
+
* own.
|
|
349
|
+
*/
|
|
350
|
+
const useQueryReporter = (query, onQueryChange) => {
|
|
351
|
+
const report = useStableCallback(onQueryChange ?? noop);
|
|
352
|
+
useEffect(() => {
|
|
353
|
+
report(query);
|
|
354
|
+
}, [query, report]);
|
|
355
|
+
};
|
|
356
|
+
//#endregion
|
|
215
357
|
//#region src/components/Combobox/Combobox.tsx
|
|
216
358
|
const VIRTUALIZE_THRESHOLD = 30;
|
|
217
359
|
const ESTIMATED_ROW_HEIGHT = 40;
|
|
218
360
|
const ESTIMATED_LIST_HEIGHT = 320;
|
|
219
|
-
const Combobox$1 = ({ items: _itemsProp, value, defaultValue, onValueChange, itemToStringLabel: itemToStringLabelProp, itemToStringValue, disabled, filter, inputRef, onOpenChangeComplete, isItemEqualToValue: isItemEqualToValueProp, variant, sizing, focusVariant, state, placeholder, allowClear, id, className, empty = "No items", indicator, prefix, virtualized = false, allowCreate, queryToCreateValue, queryToCreateLabel = defaultQueryToCreateLabel, canCreate, itemToDisabled = defaultItemToDisabled, itemToLabel = defaultItemToLabel, itemToIcon = defaultItemToIcon, groupToLabel = defaultGroupToLabel }) => {
|
|
220
|
-
|
|
221
|
-
const
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
const
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
setInputValue((prev) => prev === label ? prev : label);
|
|
231
|
-
}, [value, selections]);
|
|
232
|
-
const selectedLabel = value == null ? void 0 : itemToStringLabelProp?.(value) ?? toLabel(value);
|
|
233
|
-
const isShowingSelection = selectedLabel !== void 0 && inputValue === selectedLabel;
|
|
234
|
-
const query = (isShowingSelection ? "" : inputValue).trim();
|
|
361
|
+
const Combobox$1 = ({ items: _itemsProp, value, defaultValue, onValueChange, itemToStringLabel: itemToStringLabelProp, itemToStringValue, disabled, filter, inputRef, onOpenChangeComplete, isItemEqualToValue: isItemEqualToValueProp, variant, sizing, focusVariant, state, placeholder, allowClear = true, id, className, empty = "No items", indicator, prefix, virtualized = false, inputValueSanitizer, onQueryChange, allowCreate, queryToCreateValue, queryToCreateLabel = defaultQueryToCreateLabel, canCreate, itemToDisabled = defaultItemToDisabled, itemToLabel = defaultItemToLabel, itemToIcon = defaultItemToIcon, itemToSelectedLabel, groupToLabel = defaultGroupToLabel }) => {
|
|
362
|
+
/** An item's string identity: the input's text, the default search subject, and the accessible value. */
|
|
363
|
+
const labelOf = (item) => itemToStringLabelProp?.(item) ?? toLabel(item);
|
|
364
|
+
const [typedText, setTypedText] = useState(null);
|
|
365
|
+
const [uncontrolledValue, setUncontrolledValue] = useState(defaultValue ?? null);
|
|
366
|
+
const selectedItem = value !== void 0 ? value : uncontrolledValue;
|
|
367
|
+
const selectedLabel = selectedItem == null ? null : labelOf(selectedItem);
|
|
368
|
+
const isShowingSelection = selectedLabel !== null && (typedText === null || typedText === selectedLabel);
|
|
369
|
+
const inputValue = typedText ?? selectedLabel ?? "";
|
|
370
|
+
const selectedNode = itemToSelectedLabel && selectedItem != null && isShowingSelection ? itemToSelectedLabel(selectedItem) : null;
|
|
371
|
+
const query = (isShowingSelection ? "" : typedText ?? "").trim();
|
|
235
372
|
const queryLower = query.toLowerCase();
|
|
373
|
+
useQueryReporter(query, onQueryChange);
|
|
236
374
|
const itemsProp = _itemsProp ?? [];
|
|
237
375
|
const sampleItem = itemsProp.flatMap((item) => isGroupItem(item) ? item.items : [item])[0];
|
|
238
376
|
const [createdItems, setCreatedItems] = useState([]);
|
|
@@ -244,49 +382,35 @@ const Combobox$1 = ({ items: _itemsProp, value, defaultValue, onValueChange, ite
|
|
|
244
382
|
const items = (() => {
|
|
245
383
|
if (!allowCreate || disabled) return allItems;
|
|
246
384
|
if (!query) return allItems;
|
|
247
|
-
if (allItems.flatMap((item) => isGroupItem(item) ? item.items : [item]).some((item) => (
|
|
385
|
+
if (allItems.flatMap((item) => isGroupItem(item) ? item.items : [item]).some((item) => labelOf(item).toLowerCase() === queryLower)) return allItems;
|
|
248
386
|
if (canCreate && !canCreate(query)) return allItems;
|
|
249
387
|
const creatable = isGroupItems(itemsProp) ? [{ items: [createCreatableItem(query)] }] : [createCreatableItem(query)];
|
|
250
388
|
return [...allItems, ...creatable];
|
|
251
389
|
})();
|
|
252
|
-
const itemToStringLabel = (value) =>
|
|
253
|
-
if (isCreatableItem(value)) return value.value;
|
|
254
|
-
return itemToStringLabelProp?.(value) ?? toLabel(value);
|
|
255
|
-
};
|
|
390
|
+
const itemToStringLabel = (value) => isCreatableItem(value) ? value.value : labelOf(value);
|
|
256
391
|
const wrappedFilter = isShowingSelection ? () => true : !allowCreate || !filter ? filter : (item, ...args) => isCreatableItem(item) || filter(item, ...args);
|
|
257
392
|
const wrappedItemToStringValue = !allowCreate || !itemToStringValue ? itemToStringValue : (item) => isCreatableItem(item) ? item.value : itemToStringValue(item);
|
|
258
|
-
const isItemEqualToValue = (
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
const handleInputValueChange = (value, { reason }) => {
|
|
263
|
-
if (["input-clear", "none"].includes(reason) && ["item-press", "creatable-item-press"].includes(closeReasonRef.current)) {
|
|
264
|
-
closeReasonRef.current = "none";
|
|
265
|
-
return;
|
|
266
|
-
}
|
|
267
|
-
if (reason === "none" && closeReasonRef.current == "outside-click") {
|
|
268
|
-
closeReasonRef.current = "none";
|
|
269
|
-
setInputValue(value);
|
|
393
|
+
const isItemEqualToValue = useMemo(() => toItemEquality(isItemEqualToValueProp), [isItemEqualToValueProp]);
|
|
394
|
+
const handleInputValueChange = (next, { reason }) => {
|
|
395
|
+
if (reason !== "input-change") {
|
|
396
|
+
setTypedText(null);
|
|
270
397
|
return;
|
|
271
398
|
}
|
|
272
|
-
|
|
399
|
+
const typed = inputValueSanitizer?.(next) ?? next;
|
|
400
|
+
setTypedText(typed === "" || typed.trim() !== "" ? typed : null);
|
|
273
401
|
};
|
|
274
|
-
const
|
|
275
|
-
|
|
276
|
-
if (open) return;
|
|
277
|
-
if (closeReasonRef.current !== "none") return;
|
|
278
|
-
closeReasonRef.current = "outside-click";
|
|
402
|
+
const handleOpenChange = (open) => {
|
|
403
|
+
if (!open) setTypedText(null);
|
|
279
404
|
};
|
|
280
405
|
const handleOnValueChange = (next, event) => {
|
|
281
|
-
setSelections((count) => count + 1);
|
|
282
406
|
if (isCreatableItem(next)) {
|
|
283
407
|
const newValue = defaultToCreateValue(next.value, sampleItem, queryToCreateValue);
|
|
284
|
-
closeReasonRef.current = "creatable-item-press";
|
|
285
408
|
setCreatedItems((prev) => [...prev, newValue]);
|
|
409
|
+
setUncontrolledValue(newValue);
|
|
286
410
|
onValueChange?.(newValue, event);
|
|
287
411
|
return;
|
|
288
412
|
}
|
|
289
|
-
|
|
413
|
+
setUncontrolledValue(next);
|
|
290
414
|
onValueChange?.(next, event);
|
|
291
415
|
};
|
|
292
416
|
const [listElement, setListElement] = useState(null);
|
|
@@ -332,6 +456,12 @@ const Combobox$1 = ({ items: _itemsProp, value, defaultValue, onValueChange, ite
|
|
|
332
456
|
width: "100%",
|
|
333
457
|
transform: `translateY(${offset}px)`
|
|
334
458
|
});
|
|
459
|
+
const comboboxInput = /* @__PURE__ */ jsx(ComboboxInput, {
|
|
460
|
+
id,
|
|
461
|
+
placeholder,
|
|
462
|
+
disabled,
|
|
463
|
+
className: cn(selectedNode != null && "tw:text-transparent tw:caret-foreground tw:selection:bg-transparent")
|
|
464
|
+
});
|
|
335
465
|
return /* @__PURE__ */ jsxs(Combobox.Root, {
|
|
336
466
|
items: shouldVirtualize ? virtualItems : items,
|
|
337
467
|
autoHighlight: true,
|
|
@@ -342,7 +472,8 @@ const Combobox$1 = ({ items: _itemsProp, value, defaultValue, onValueChange, ite
|
|
|
342
472
|
itemToStringLabel,
|
|
343
473
|
isItemEqualToValue,
|
|
344
474
|
itemToStringValue: wrappedItemToStringValue,
|
|
345
|
-
|
|
475
|
+
onOpenChange: handleOpenChange,
|
|
476
|
+
onOpenChangeComplete,
|
|
346
477
|
disabled,
|
|
347
478
|
inputRef,
|
|
348
479
|
inputValue,
|
|
@@ -357,31 +488,30 @@ const Combobox$1 = ({ items: _itemsProp, value, defaultValue, onValueChange, ite
|
|
|
357
488
|
state,
|
|
358
489
|
focusVariant,
|
|
359
490
|
className,
|
|
360
|
-
children: [
|
|
361
|
-
|
|
491
|
+
children: [itemToSelectedLabel != null ? /* @__PURE__ */ jsxs("div", {
|
|
492
|
+
className: "tw:relative tw:flex tw:min-w-0 tw:flex-1",
|
|
493
|
+
children: [(prefix != null || selectedNode != null) && /* @__PURE__ */ jsxs(InputGroup.Addon, {
|
|
362
494
|
align: "inline-start",
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
})
|
|
384
|
-
]
|
|
495
|
+
className: cn(selectedNode != null && "tw:pointer-events-none tw:absolute tw:inset-y-0 tw:left-0 tw:max-w-full tw:overflow-hidden"),
|
|
496
|
+
children: [prefix, selectedNode]
|
|
497
|
+
}), comboboxInput]
|
|
498
|
+
}) : /* @__PURE__ */ jsxs(Fragment$1, { children: [prefix != null && /* @__PURE__ */ jsx(InputGroup.Addon, {
|
|
499
|
+
align: "inline-start",
|
|
500
|
+
children: prefix
|
|
501
|
+
}), comboboxInput] }), /* @__PURE__ */ jsxs(InputGroup.Addon, {
|
|
502
|
+
align: "inline-end",
|
|
503
|
+
children: [allowClear && /* @__PURE__ */ jsx(InputGroup.Button, {
|
|
504
|
+
asChild: true,
|
|
505
|
+
"aria-label": "Clear",
|
|
506
|
+
disabled,
|
|
507
|
+
children: /* @__PURE__ */ jsx(Combobox.Clear, { children: /* @__PURE__ */ jsx(X, { className: "tw:size-4" }) })
|
|
508
|
+
}), /* @__PURE__ */ jsx(InputGroup.Button, {
|
|
509
|
+
disabled,
|
|
510
|
+
asChild: true,
|
|
511
|
+
"aria-label": "Open combobox",
|
|
512
|
+
children: /* @__PURE__ */ jsx(Combobox.Trigger, { children: /* @__PURE__ */ jsx(ChevronDown, { className: "tw:size-4" }) })
|
|
513
|
+
})]
|
|
514
|
+
})]
|
|
385
515
|
}), /* @__PURE__ */ jsxs(ComboboxContent, { children: [/* @__PURE__ */ jsx(ComboboxEmpty, { children: empty }), shouldVirtualize ? /* @__PURE__ */ jsx(ComboboxList, {
|
|
386
516
|
ref: setListElement,
|
|
387
517
|
children: /* @__PURE__ */ jsx("div", {
|
|
@@ -437,7 +567,53 @@ Combobox$1.Group = ComboboxGroup;
|
|
|
437
567
|
Combobox$1.GroupLabel = ComboboxGroupLabel;
|
|
438
568
|
Combobox$1.GroupList = ComboboxCollection;
|
|
439
569
|
Combobox$1.Chips = ComboboxChips;
|
|
570
|
+
Combobox$1.Chip = ComboboxChip;
|
|
571
|
+
//#endregion
|
|
572
|
+
//#region src/components/Combobox/matchByWords.ts
|
|
573
|
+
const toWords = (query) => query.toLowerCase().split(/\s+/).filter(Boolean);
|
|
574
|
+
const isFilled = (text) => text !== null && text !== void 0 && text !== "";
|
|
575
|
+
const isTextList = (texts) => Array.isArray(texts);
|
|
576
|
+
/**
|
|
577
|
+
* Whether every word of `query` occurs in at least one of `texts`, ignoring case.
|
|
578
|
+
*
|
|
579
|
+
* - Words may match different texts and in any order: `prod eu` matches `['eu-central', 'production']`.
|
|
580
|
+
* - A word matches by containment, not as a whole word: `prod` matches `production`.
|
|
581
|
+
* - An empty or whitespace-only query matches every item.
|
|
582
|
+
* - Empty and absent texts are skipped, so a missing field never matches.
|
|
583
|
+
* - Comparison is a plain lowercased `includes`, not Base UI's `Intl.Collator` `contains`, so
|
|
584
|
+
* `Muller` does not find `Müller`. The wrapper this replaces matched the same way.
|
|
585
|
+
* - `apps/kbc-ui` has its own `matchByWords` of the same name over 68 mostly non-combobox call
|
|
586
|
+
* sites. It splits on a single space and keeps empty texts, so the two are not interchangeable
|
|
587
|
+
* until that one re-exports this.
|
|
588
|
+
*
|
|
589
|
+
* Reach for it as a `Combobox` / `MultiCombobox` `filter` when the searchable text is **not** the
|
|
590
|
+
* label — a user's email behind their name, a table id behind its display name:
|
|
591
|
+
*
|
|
592
|
+
* ```tsx
|
|
593
|
+
* <Combobox filter={(user, query) => matchByWords([user.name, user.email], query)} … />
|
|
594
|
+
* ```
|
|
595
|
+
*
|
|
596
|
+
* When only the label is searchable, pass {@link filterByWords} instead of closing over this.
|
|
597
|
+
*/
|
|
598
|
+
const matchByWords = (texts, query) => {
|
|
599
|
+
const words = toWords(query);
|
|
600
|
+
if (words.length === 0) return true;
|
|
601
|
+
const haystacks = (isTextList(texts) ? texts : [texts]).filter(isFilled).map((text) => String(text).toLowerCase());
|
|
602
|
+
return words.every((word) => haystacks.some((haystack) => haystack.includes(word)));
|
|
603
|
+
};
|
|
604
|
+
/**
|
|
605
|
+
* `filter` that matches the item's displayed label word by word.
|
|
606
|
+
*
|
|
607
|
+
* - Drop-in for the built-in match, which takes the query as one substring: `filter={filterByWords}`.
|
|
608
|
+
* - Generic, so passing it leaves the combobox's own item type inference untouched.
|
|
609
|
+
* - The label is what the combobox itself displays — `itemToStringLabel` where the call site passes
|
|
610
|
+
* one, otherwise the item's own `label`, `value`, or string form.
|
|
611
|
+
* - **Only the label is searched.** Nothing walks the rest of the item, so a field the label omits
|
|
612
|
+
* stays unsearchable by design — a filter that quietly matched an id the user cannot see is
|
|
613
|
+
* worse than one that does not match. Close over {@link matchByWords} to name those fields.
|
|
614
|
+
*/
|
|
615
|
+
const filterByWords = (item, query, itemToString) => matchByWords(itemToString?.(item) ?? toLabel(item), query);
|
|
440
616
|
//#endregion
|
|
441
|
-
export { Combobox$1 as Combobox, createCreatableItem, defaultGroupToLabel, defaultItemToDisabled, defaultItemToIcon, defaultItemToLabel, defaultQueryToCreateLabel, defaultToCreateValue, isCreatableItem, isGroupItem, isGroupItems,
|
|
617
|
+
export { Combobox$1 as Combobox, createCreatableItem, defaultGroupToLabel, defaultItemToDisabled, defaultItemToIcon, defaultItemToLabel, defaultQueryToCreateLabel, defaultToCreateValue, filterByWords, isCreatableItem, isGroupItem, isGroupItems, isSelectAllItem, matchByWords, namedLabel, sanitizeTypedInput, selectAllItem, toItemEquality, toLabel, useQueryReporter, withBlankValues };
|
|
442
618
|
|
|
443
|
-
//# sourceMappingURL=Combobox-
|
|
619
|
+
//# sourceMappingURL=Combobox-BfIfaVMA.js.map
|