@fragments-sdk/ui 0.13.0 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/ui.css +1642 -1679
- package/dist/chart.cjs.map +1 -1
- package/dist/chart.js.map +1 -1
- package/dist/codeblock.cjs +26 -18
- package/dist/codeblock.cjs.map +1 -1
- package/dist/codeblock.js +26 -18
- package/dist/codeblock.js.map +1 -1
- package/dist/components/Accordion/Accordion.module.scss.cjs +8 -8
- package/dist/components/Accordion/Accordion.module.scss.js +8 -8
- package/dist/components/Accordion/index.cjs +7 -3
- package/dist/components/Accordion/index.cjs.map +1 -1
- package/dist/components/Accordion/index.d.ts +24 -11
- package/dist/components/Accordion/index.d.ts.map +1 -1
- package/dist/components/Accordion/index.js +7 -3
- package/dist/components/Accordion/index.js.map +1 -1
- package/dist/components/Alert/Alert.module.scss.cjs +12 -12
- package/dist/components/Alert/Alert.module.scss.js +12 -12
- package/dist/components/Alert/index.cjs +37 -15
- package/dist/components/Alert/index.cjs.map +1 -1
- package/dist/components/Alert/index.d.ts +15 -22
- package/dist/components/Alert/index.d.ts.map +1 -1
- package/dist/components/Alert/index.js +37 -15
- package/dist/components/Alert/index.js.map +1 -1
- package/dist/components/AppShell/AppShell.module.scss.cjs +14 -14
- package/dist/components/AppShell/AppShell.module.scss.js +14 -14
- package/dist/components/AppShell/index.cjs +3 -1
- package/dist/components/AppShell/index.cjs.map +1 -1
- package/dist/components/AppShell/index.d.ts.map +1 -1
- package/dist/components/AppShell/index.js +3 -1
- package/dist/components/AppShell/index.js.map +1 -1
- package/dist/components/Avatar/index.cjs +9 -1
- package/dist/components/Avatar/index.cjs.map +1 -1
- package/dist/components/Avatar/index.d.ts +2 -0
- package/dist/components/Avatar/index.d.ts.map +1 -1
- package/dist/components/Avatar/index.js +9 -1
- package/dist/components/Avatar/index.js.map +1 -1
- package/dist/components/Badge/index.cjs +4 -2
- package/dist/components/Badge/index.cjs.map +1 -1
- package/dist/components/Badge/index.d.ts +3 -0
- package/dist/components/Badge/index.d.ts.map +1 -1
- package/dist/components/Badge/index.js +4 -2
- package/dist/components/Badge/index.js.map +1 -1
- package/dist/components/BentoGrid/BentoGrid.module.scss.cjs +11 -11
- package/dist/components/BentoGrid/BentoGrid.module.scss.js +11 -11
- package/dist/components/BentoGrid/index.cjs +8 -5
- package/dist/components/BentoGrid/index.cjs.map +1 -1
- package/dist/components/BentoGrid/index.d.ts +2 -8
- package/dist/components/BentoGrid/index.d.ts.map +1 -1
- package/dist/components/BentoGrid/index.js +8 -5
- package/dist/components/BentoGrid/index.js.map +1 -1
- package/dist/components/Box/index.cjs +12 -2
- package/dist/components/Box/index.cjs.map +1 -1
- package/dist/components/Box/index.d.ts +1 -1
- package/dist/components/Box/index.d.ts.map +1 -1
- package/dist/components/Box/index.js +12 -2
- package/dist/components/Box/index.js.map +1 -1
- package/dist/components/Breadcrumbs/index.cjs +3 -1
- package/dist/components/Breadcrumbs/index.cjs.map +1 -1
- package/dist/components/Breadcrumbs/index.d.ts +3 -1
- package/dist/components/Breadcrumbs/index.d.ts.map +1 -1
- package/dist/components/Breadcrumbs/index.js +3 -1
- package/dist/components/Breadcrumbs/index.js.map +1 -1
- package/dist/components/Button/Button.module.scss.cjs +11 -11
- package/dist/components/Button/Button.module.scss.js +11 -11
- package/dist/components/Button/index.cjs +5 -2
- package/dist/components/Button/index.cjs.map +1 -1
- package/dist/components/Button/index.d.ts +3 -3
- package/dist/components/Button/index.d.ts.map +1 -1
- package/dist/components/Button/index.js +5 -2
- package/dist/components/Button/index.js.map +1 -1
- package/dist/components/ButtonGroup/index.cjs +3 -2
- package/dist/components/ButtonGroup/index.cjs.map +1 -1
- package/dist/components/ButtonGroup/index.d.ts +1 -2
- package/dist/components/ButtonGroup/index.d.ts.map +1 -1
- package/dist/components/ButtonGroup/index.js +3 -2
- package/dist/components/ButtonGroup/index.js.map +1 -1
- package/dist/components/Card/Card.module.scss.cjs +14 -14
- package/dist/components/Card/Card.module.scss.js +14 -14
- package/dist/components/Card/index.cjs +3 -22
- package/dist/components/Card/index.cjs.map +1 -1
- package/dist/components/Card/index.d.ts +6 -11
- package/dist/components/Card/index.d.ts.map +1 -1
- package/dist/components/Card/index.js +3 -22
- package/dist/components/Card/index.js.map +1 -1
- package/dist/components/Chart/Chart.module.scss.cjs +15 -15
- package/dist/components/Chart/Chart.module.scss.js +15 -15
- package/dist/components/Chart/index.d.ts +3 -3
- package/dist/components/Chart/index.d.ts.map +1 -1
- package/dist/components/Checkbox/Checkbox.module.scss.cjs +10 -10
- package/dist/components/Checkbox/Checkbox.module.scss.js +10 -10
- package/dist/components/Checkbox/index.cjs +11 -4
- package/dist/components/Checkbox/index.cjs.map +1 -1
- package/dist/components/Checkbox/index.d.ts +6 -0
- package/dist/components/Checkbox/index.d.ts.map +1 -1
- package/dist/components/Checkbox/index.js +11 -4
- package/dist/components/Checkbox/index.js.map +1 -1
- package/dist/components/Chip/index.cjs +11 -3
- package/dist/components/Chip/index.cjs.map +1 -1
- package/dist/components/Chip/index.d.ts +1 -2
- package/dist/components/Chip/index.d.ts.map +1 -1
- package/dist/components/Chip/index.js +11 -3
- package/dist/components/Chip/index.js.map +1 -1
- package/dist/components/CodeBlock/CodeBlock.module.scss.cjs +20 -20
- package/dist/components/CodeBlock/CodeBlock.module.scss.js +20 -20
- package/dist/components/CodeBlock/index.d.ts +8 -2
- package/dist/components/CodeBlock/index.d.ts.map +1 -1
- package/dist/components/Collapsible/Collapsible.module.scss.cjs +10 -10
- package/dist/components/Collapsible/Collapsible.module.scss.js +10 -10
- package/dist/components/Combobox/Combobox.module.scss.cjs +15 -15
- package/dist/components/Combobox/Combobox.module.scss.js +15 -15
- package/dist/components/Combobox/index.cjs +68 -18
- package/dist/components/Combobox/index.cjs.map +1 -1
- package/dist/components/Combobox/index.d.ts +32 -11
- package/dist/components/Combobox/index.d.ts.map +1 -1
- package/dist/components/Combobox/index.js +68 -18
- package/dist/components/Combobox/index.js.map +1 -1
- package/dist/components/Command/Command.module.scss.cjs +11 -11
- package/dist/components/Command/Command.module.scss.js +11 -11
- package/dist/components/Command/index.cjs +4 -4
- package/dist/components/Command/index.cjs.map +1 -1
- package/dist/components/Command/index.d.ts +1 -1
- package/dist/components/Command/index.d.ts.map +1 -1
- package/dist/components/Command/index.js +4 -4
- package/dist/components/Command/index.js.map +1 -1
- package/dist/components/ConversationList/ConversationList.module.scss.cjs +10 -10
- package/dist/components/ConversationList/ConversationList.module.scss.js +10 -10
- package/dist/components/ConversationList/index.cjs +6 -3
- package/dist/components/ConversationList/index.cjs.map +1 -1
- package/dist/components/ConversationList/index.d.ts +1 -1
- package/dist/components/ConversationList/index.d.ts.map +1 -1
- package/dist/components/ConversationList/index.js +6 -3
- package/dist/components/ConversationList/index.js.map +1 -1
- package/dist/components/DataTable/DataTable.module.scss.cjs +26 -26
- package/dist/components/DataTable/DataTable.module.scss.js +26 -26
- package/dist/components/DataTable/index.cjs +13 -4
- package/dist/components/DataTable/index.cjs.map +1 -1
- package/dist/components/DataTable/index.d.ts +7 -2
- package/dist/components/DataTable/index.d.ts.map +1 -1
- package/dist/components/DataTable/index.js +13 -4
- package/dist/components/DataTable/index.js.map +1 -1
- package/dist/components/DatePicker/DatePicker.module.scss.cjs +26 -26
- package/dist/components/DatePicker/DatePicker.module.scss.js +26 -26
- package/dist/components/DatePicker/index.d.ts +2 -2
- package/dist/components/DatePicker/index.d.ts.map +1 -1
- package/dist/components/Dialog/Dialog.module.scss.cjs +14 -14
- package/dist/components/Dialog/Dialog.module.scss.js +14 -14
- package/dist/components/Dialog/index.cjs +2 -1
- package/dist/components/Dialog/index.cjs.map +1 -1
- package/dist/components/Dialog/index.d.ts +20 -7
- package/dist/components/Dialog/index.d.ts.map +1 -1
- package/dist/components/Dialog/index.js +2 -1
- package/dist/components/Dialog/index.js.map +1 -1
- package/dist/components/Drawer/Drawer.module.scss.cjs +26 -26
- package/dist/components/Drawer/Drawer.module.scss.js +26 -26
- package/dist/components/Drawer/index.cjs +30 -3
- package/dist/components/Drawer/index.cjs.map +1 -1
- package/dist/components/Drawer/index.d.ts +3 -1
- package/dist/components/Drawer/index.d.ts.map +1 -1
- package/dist/components/Drawer/index.js +13 -3
- package/dist/components/Drawer/index.js.map +1 -1
- package/dist/components/Editor/Editor.module.scss.cjs +17 -17
- package/dist/components/Editor/Editor.module.scss.js +17 -17
- package/dist/components/Editor/index.cjs +32 -7
- package/dist/components/Editor/index.cjs.map +1 -1
- package/dist/components/Editor/index.d.ts +16 -3
- package/dist/components/Editor/index.d.ts.map +1 -1
- package/dist/components/Editor/index.js +32 -7
- package/dist/components/Editor/index.js.map +1 -1
- package/dist/components/EmptyState/EmptyState.module.scss.cjs +8 -8
- package/dist/components/EmptyState/EmptyState.module.scss.js +8 -8
- package/dist/components/EmptyState/index.cjs +12 -8
- package/dist/components/EmptyState/index.cjs.map +1 -1
- package/dist/components/EmptyState/index.d.ts +8 -12
- package/dist/components/EmptyState/index.d.ts.map +1 -1
- package/dist/components/EmptyState/index.js +12 -8
- package/dist/components/EmptyState/index.js.map +1 -1
- package/dist/components/Fieldset/index.cjs +2 -2
- package/dist/components/Fieldset/index.cjs.map +1 -1
- package/dist/components/Fieldset/index.d.ts +2 -3
- package/dist/components/Fieldset/index.d.ts.map +1 -1
- package/dist/components/Fieldset/index.js +2 -2
- package/dist/components/Fieldset/index.js.map +1 -1
- package/dist/components/Form/index.cjs +13 -13
- package/dist/components/Form/index.cjs.map +1 -1
- package/dist/components/Form/index.d.ts +5 -2
- package/dist/components/Form/index.d.ts.map +1 -1
- package/dist/components/Form/index.js +13 -13
- package/dist/components/Form/index.js.map +1 -1
- package/dist/components/Grid/Grid.module.scss.cjs +57 -57
- package/dist/components/Grid/Grid.module.scss.js +57 -57
- package/dist/components/Grid/index.cjs +7 -4
- package/dist/components/Grid/index.cjs.map +1 -1
- package/dist/components/Grid/index.d.ts +5 -3
- package/dist/components/Grid/index.d.ts.map +1 -1
- package/dist/components/Grid/index.js +7 -4
- package/dist/components/Grid/index.js.map +1 -1
- package/dist/components/Header/Header.module.scss.cjs +21 -21
- package/dist/components/Header/Header.module.scss.js +21 -21
- package/dist/components/Header/index.cjs +61 -23
- package/dist/components/Header/index.cjs.map +1 -1
- package/dist/components/Header/index.d.ts +27 -34
- package/dist/components/Header/index.d.ts.map +1 -1
- package/dist/components/Header/index.js +61 -23
- package/dist/components/Header/index.js.map +1 -1
- package/dist/components/Icon/index.cjs +11 -1
- package/dist/components/Icon/index.cjs.map +1 -1
- package/dist/components/Icon/index.d.ts +28 -9
- package/dist/components/Icon/index.d.ts.map +1 -1
- package/dist/components/Icon/index.js +11 -1
- package/dist/components/Icon/index.js.map +1 -1
- package/dist/components/Image/index.cjs +15 -4
- package/dist/components/Image/index.cjs.map +1 -1
- package/dist/components/Image/index.d.ts +7 -1
- package/dist/components/Image/index.d.ts.map +1 -1
- package/dist/components/Image/index.js +15 -4
- package/dist/components/Image/index.js.map +1 -1
- package/dist/components/Input/Input.module.scss.cjs +13 -13
- package/dist/components/Input/Input.module.scss.js +13 -13
- package/dist/components/Input/index.cjs +79 -31
- package/dist/components/Input/index.cjs.map +1 -1
- package/dist/components/Input/index.d.ts +17 -3
- package/dist/components/Input/index.d.ts.map +1 -1
- package/dist/components/Input/index.js +79 -31
- package/dist/components/Input/index.js.map +1 -1
- package/dist/components/Link/index.cjs +17 -0
- package/dist/components/Link/index.cjs.map +1 -1
- package/dist/components/Link/index.d.ts.map +1 -1
- package/dist/components/Link/index.js +17 -0
- package/dist/components/Link/index.js.map +1 -1
- package/dist/components/Listbox/Listbox.module.scss.cjs +8 -8
- package/dist/components/Listbox/Listbox.module.scss.js +8 -8
- package/dist/components/Listbox/index.cjs +10 -6
- package/dist/components/Listbox/index.cjs.map +1 -1
- package/dist/components/Listbox/index.d.ts +2 -2
- package/dist/components/Listbox/index.d.ts.map +1 -1
- package/dist/components/Listbox/index.js +10 -6
- package/dist/components/Listbox/index.js.map +1 -1
- package/dist/components/Markdown/Markdown.module.scss.cjs +1 -1
- package/dist/components/Markdown/Markdown.module.scss.js +1 -1
- package/dist/components/Markdown/index.d.ts +4 -2
- package/dist/components/Markdown/index.d.ts.map +1 -1
- package/dist/components/Menu/Menu.module.scss.cjs +13 -13
- package/dist/components/Menu/Menu.module.scss.js +13 -13
- package/dist/components/Menu/index.cjs +12 -1
- package/dist/components/Menu/index.cjs.map +1 -1
- package/dist/components/Menu/index.d.ts +9 -4
- package/dist/components/Menu/index.d.ts.map +1 -1
- package/dist/components/Menu/index.js +12 -1
- package/dist/components/Menu/index.js.map +1 -1
- package/dist/components/Message/Message.module.scss.cjs +18 -18
- package/dist/components/Message/Message.module.scss.js +18 -18
- package/dist/components/NavigationMenu/NavigationMenu.module.scss.cjs +28 -28
- package/dist/components/NavigationMenu/NavigationMenu.module.scss.js +28 -28
- package/dist/components/NavigationMenu/NavigationMenuContext.cjs.map +1 -1
- package/dist/components/NavigationMenu/NavigationMenuContext.d.ts +8 -0
- package/dist/components/NavigationMenu/NavigationMenuContext.d.ts.map +1 -1
- package/dist/components/NavigationMenu/NavigationMenuContext.js.map +1 -1
- package/dist/components/NavigationMenu/index.cjs +49 -10
- package/dist/components/NavigationMenu/index.cjs.map +1 -1
- package/dist/components/NavigationMenu/index.d.ts +5 -1
- package/dist/components/NavigationMenu/index.d.ts.map +1 -1
- package/dist/components/NavigationMenu/index.js +49 -10
- package/dist/components/NavigationMenu/index.js.map +1 -1
- package/dist/components/Pagination/index.cjs +37 -9
- package/dist/components/Pagination/index.cjs.map +1 -1
- package/dist/components/Pagination/index.d.ts +2 -3
- package/dist/components/Pagination/index.d.ts.map +1 -1
- package/dist/components/Pagination/index.js +37 -9
- package/dist/components/Pagination/index.js.map +1 -1
- package/dist/components/Popover/Popover.module.scss.cjs +10 -10
- package/dist/components/Popover/Popover.module.scss.js +10 -10
- package/dist/components/Popover/index.cjs +43 -2
- package/dist/components/Popover/index.cjs.map +1 -1
- package/dist/components/Popover/index.d.ts +16 -6
- package/dist/components/Popover/index.d.ts.map +1 -1
- package/dist/components/Popover/index.js +26 -2
- package/dist/components/Popover/index.js.map +1 -1
- package/dist/components/Progress/index.cjs +3 -1
- package/dist/components/Progress/index.cjs.map +1 -1
- package/dist/components/Progress/index.d.ts.map +1 -1
- package/dist/components/Progress/index.js +3 -1
- package/dist/components/Progress/index.js.map +1 -1
- package/dist/components/Prompt/Prompt.module.scss.cjs +14 -14
- package/dist/components/Prompt/Prompt.module.scss.js +14 -14
- package/dist/components/Prompt/index.cjs +14 -2
- package/dist/components/Prompt/index.cjs.map +1 -1
- package/dist/components/Prompt/index.d.ts +8 -5
- package/dist/components/Prompt/index.d.ts.map +1 -1
- package/dist/components/Prompt/index.js +14 -2
- package/dist/components/Prompt/index.js.map +1 -1
- package/dist/components/RadioGroup/index.cjs +14 -6
- package/dist/components/RadioGroup/index.cjs.map +1 -1
- package/dist/components/RadioGroup/index.d.ts +12 -2
- package/dist/components/RadioGroup/index.d.ts.map +1 -1
- package/dist/components/RadioGroup/index.js +14 -6
- package/dist/components/RadioGroup/index.js.map +1 -1
- package/dist/components/Select/Select.module.scss.cjs +10 -10
- package/dist/components/Select/Select.module.scss.js +10 -10
- package/dist/components/Select/index.cjs +37 -24
- package/dist/components/Select/index.cjs.map +1 -1
- package/dist/components/Select/index.d.ts +6 -2
- package/dist/components/Select/index.d.ts.map +1 -1
- package/dist/components/Select/index.js +37 -24
- package/dist/components/Select/index.js.map +1 -1
- package/dist/components/Sidebar/Sidebar.module.scss.cjs +42 -42
- package/dist/components/Sidebar/Sidebar.module.scss.js +42 -42
- package/dist/components/Sidebar/index.cjs +2 -2
- package/dist/components/Sidebar/index.cjs.map +1 -1
- package/dist/components/Sidebar/index.d.ts +3 -3
- package/dist/components/Sidebar/index.d.ts.map +1 -1
- package/dist/components/Sidebar/index.js +2 -2
- package/dist/components/Sidebar/index.js.map +1 -1
- package/dist/components/Skeleton/index.cjs +6 -3
- package/dist/components/Skeleton/index.cjs.map +1 -1
- package/dist/components/Skeleton/index.d.ts +3 -7
- package/dist/components/Skeleton/index.d.ts.map +1 -1
- package/dist/components/Skeleton/index.js +6 -3
- package/dist/components/Skeleton/index.js.map +1 -1
- package/dist/components/Slider/Slider.module.scss.cjs +13 -10
- package/dist/components/Slider/Slider.module.scss.cjs.map +1 -1
- package/dist/components/Slider/Slider.module.scss.js +13 -10
- package/dist/components/Slider/Slider.module.scss.js.map +1 -1
- package/dist/components/Slider/index.cjs +33 -1
- package/dist/components/Slider/index.cjs.map +1 -1
- package/dist/components/Slider/index.d.ts +2 -0
- package/dist/components/Slider/index.d.ts.map +1 -1
- package/dist/components/Slider/index.js +33 -1
- package/dist/components/Slider/index.js.map +1 -1
- package/dist/components/Stack/index.cjs +12 -2
- package/dist/components/Stack/index.cjs.map +1 -1
- package/dist/components/Stack/index.d.ts +3 -2
- package/dist/components/Stack/index.d.ts.map +1 -1
- package/dist/components/Stack/index.js +12 -2
- package/dist/components/Stack/index.js.map +1 -1
- package/dist/components/Table/Table.module.scss.cjs +16 -16
- package/dist/components/Table/Table.module.scss.js +16 -16
- package/dist/components/Table/index.d.ts +10 -4
- package/dist/components/Table/index.d.ts.map +1 -1
- package/dist/components/TableOfContents/index.cjs +8 -5
- package/dist/components/TableOfContents/index.cjs.map +1 -1
- package/dist/components/TableOfContents/index.d.ts +2 -2
- package/dist/components/TableOfContents/index.d.ts.map +1 -1
- package/dist/components/TableOfContents/index.js +8 -5
- package/dist/components/TableOfContents/index.js.map +1 -1
- package/dist/components/Tabs/Tabs.module.scss.cjs +9 -9
- package/dist/components/Tabs/Tabs.module.scss.js +9 -9
- package/dist/components/Tabs/index.cjs +9 -6
- package/dist/components/Tabs/index.cjs.map +1 -1
- package/dist/components/Tabs/index.d.ts +4 -1
- package/dist/components/Tabs/index.d.ts.map +1 -1
- package/dist/components/Tabs/index.js +9 -6
- package/dist/components/Tabs/index.js.map +1 -1
- package/dist/components/Textarea/index.cjs +61 -43
- package/dist/components/Textarea/index.cjs.map +1 -1
- package/dist/components/Textarea/index.d.ts +9 -1
- package/dist/components/Textarea/index.d.ts.map +1 -1
- package/dist/components/Textarea/index.js +61 -43
- package/dist/components/Textarea/index.js.map +1 -1
- package/dist/components/Theme/index.cjs +3 -1
- package/dist/components/Theme/index.cjs.map +1 -1
- package/dist/components/Theme/index.d.ts +2 -4
- package/dist/components/Theme/index.d.ts.map +1 -1
- package/dist/components/Theme/index.js +3 -1
- package/dist/components/Theme/index.js.map +1 -1
- package/dist/components/ThinkingIndicator/ThinkingIndicator.module.scss.cjs +22 -22
- package/dist/components/ThinkingIndicator/ThinkingIndicator.module.scss.js +22 -22
- package/dist/components/Toast/Toast.module.scss.cjs +20 -20
- package/dist/components/Toast/Toast.module.scss.js +20 -20
- package/dist/components/Toast/index.cjs +15 -14
- package/dist/components/Toast/index.cjs.map +1 -1
- package/dist/components/Toast/index.d.ts +9 -5
- package/dist/components/Toast/index.d.ts.map +1 -1
- package/dist/components/Toast/index.js +15 -14
- package/dist/components/Toast/index.js.map +1 -1
- package/dist/components/Toggle/Toggle.module.scss.cjs +11 -11
- package/dist/components/Toggle/Toggle.module.scss.js +11 -11
- package/dist/components/Toggle/index.cjs +1 -1
- package/dist/components/Toggle/index.cjs.map +1 -1
- package/dist/components/Toggle/index.js +1 -1
- package/dist/components/Toggle/index.js.map +1 -1
- package/dist/components/ToggleGroup/ToggleGroup.module.scss.cjs +17 -17
- package/dist/components/ToggleGroup/ToggleGroup.module.scss.js +17 -17
- package/dist/components/ToggleGroup/index.cjs +27 -8
- package/dist/components/ToggleGroup/index.cjs.map +1 -1
- package/dist/components/ToggleGroup/index.d.ts +8 -3
- package/dist/components/ToggleGroup/index.d.ts.map +1 -1
- package/dist/components/ToggleGroup/index.js +27 -8
- package/dist/components/ToggleGroup/index.js.map +1 -1
- package/dist/components/Tooltip/Tooltip.module.scss.cjs +3 -3
- package/dist/components/Tooltip/Tooltip.module.scss.js +3 -3
- package/dist/components/Tooltip/index.cjs +20 -4
- package/dist/components/Tooltip/index.cjs.map +1 -1
- package/dist/components/Tooltip/index.d.ts +3 -1
- package/dist/components/Tooltip/index.d.ts.map +1 -1
- package/dist/components/Tooltip/index.js +20 -4
- package/dist/components/Tooltip/index.js.map +1 -1
- package/dist/components/VisuallyHidden/index.cjs +10 -2
- package/dist/components/VisuallyHidden/index.cjs.map +1 -1
- package/dist/components/VisuallyHidden/index.d.ts +1 -1
- package/dist/components/VisuallyHidden/index.d.ts.map +1 -1
- package/dist/components/VisuallyHidden/index.js +10 -2
- package/dist/components/VisuallyHidden/index.js.map +1 -1
- package/dist/datepicker.cjs +8 -1
- package/dist/datepicker.cjs.map +1 -1
- package/dist/datepicker.js +8 -1
- package/dist/datepicker.js.map +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/markdown.cjs +5 -5
- package/dist/markdown.cjs.map +1 -1
- package/dist/markdown.js +5 -5
- package/dist/markdown.js.map +1 -1
- package/dist/table.cjs +19 -3
- package/dist/table.cjs.map +1 -1
- package/dist/table.js +19 -3
- package/dist/table.js.map +1 -1
- package/fragments.json +1 -1
- package/package.json +2 -2
- package/src/blocks/AccountSettings.block.ts +1 -1
- package/src/blocks/ActivityFeed.block.ts +1 -1
- package/src/blocks/ActivityFeedSkeleton.block.ts +1 -1
- package/src/blocks/BlogEditor.block.ts +1 -1
- package/src/blocks/ChatInterface.block.ts +1 -1
- package/src/blocks/ChatMessages.block.ts +1 -1
- package/src/blocks/CheckoutForm.block.ts +1 -1
- package/src/blocks/CommandPalette.block.ts +1 -1
- package/src/blocks/ContactForm.block.ts +1 -1
- package/src/blocks/DashboardLayout.block.ts +1 -1
- package/src/blocks/DashboardPage.block.ts +1 -1
- package/src/blocks/DashboardSkeleton.block.ts +1 -1
- package/src/blocks/DataTable.block.ts +1 -1
- package/src/blocks/EmptyState.block.ts +1 -1
- package/src/blocks/FAQSection.block.ts +1 -1
- package/src/blocks/FeatureGrid.block.ts +1 -1
- package/src/blocks/HeroSection.block.ts +1 -1
- package/src/blocks/LoginForm.block.ts +1 -1
- package/src/blocks/NavigationHeader.block.ts +1 -1
- package/src/blocks/PaginatedTable.block.ts +1 -1
- package/src/blocks/PricingComparison.block.ts +1 -1
- package/src/blocks/ProductCard.block.ts +1 -1
- package/src/blocks/RegistrationForm.block.ts +1 -1
- package/src/blocks/SettingsDrawer.block.ts +1 -1
- package/src/blocks/SettingsPanel.block.ts +1 -1
- package/src/blocks/ShoppingCart.block.ts +1 -1
- package/src/blocks/StatsCard.block.ts +1 -1
- package/src/blocks/StatsCardSkeleton.block.ts +1 -1
- package/src/blocks/TableSkeleton.block.ts +1 -1
- package/src/blocks/ThinkingStates.block.ts +1 -1
- package/src/components/Accordion/Accordion.fragment.tsx +7 -7
- package/src/components/Accordion/Accordion.module.scss +2 -2
- package/src/components/Accordion/Accordion.test.tsx +8 -5
- package/src/components/Accordion/index.tsx +33 -13
- package/src/components/Alert/Alert.fragment.tsx +5 -1
- package/src/components/Alert/Alert.module.scss +1 -1
- package/src/components/Alert/Alert.test.tsx +25 -0
- package/src/components/Alert/index.tsx +49 -30
- package/src/components/AppShell/AppShell.fragment.tsx +1 -1
- package/src/components/AppShell/AppShell.module.scss +5 -5
- package/src/components/AppShell/AppShell.test.tsx +12 -0
- package/src/components/AppShell/index.tsx +2 -0
- package/src/components/Avatar/Avatar.fragment.tsx +7 -1
- package/src/components/Avatar/Avatar.test.tsx +24 -2
- package/src/components/Avatar/index.tsx +13 -1
- package/src/components/Badge/Badge.fragment.tsx +16 -1
- package/src/components/Badge/Badge.test.tsx +8 -1
- package/src/components/Badge/index.tsx +7 -2
- package/src/components/BentoGrid/BentoGrid.fragment.tsx +3 -1
- package/src/components/BentoGrid/BentoGrid.module.scss +52 -16
- package/src/components/BentoGrid/BentoGrid.test.tsx +20 -0
- package/src/components/BentoGrid/index.tsx +9 -12
- package/src/components/Box/Box.fragment.tsx +3 -1
- package/src/components/Box/Box.test.tsx +14 -0
- package/src/components/Box/index.tsx +8 -2
- package/src/components/Breadcrumbs/Breadcrumbs.fragment.tsx +19 -1
- package/src/components/Breadcrumbs/Breadcrumbs.test.tsx +13 -0
- package/src/components/Breadcrumbs/index.tsx +5 -1
- package/src/components/Button/Button.fragment.tsx +28 -6
- package/src/components/Button/Button.module.scss +3 -3
- package/src/components/Button/Button.test.tsx +11 -0
- package/src/components/Button/index.tsx +16 -6
- package/src/components/ButtonGroup/ButtonGroup.fragment.tsx +4 -2
- package/src/components/ButtonGroup/ButtonGroup.test.tsx +10 -0
- package/src/components/ButtonGroup/index.tsx +3 -3
- package/src/components/Card/Card.fragment.tsx +24 -9
- package/src/components/Card/Card.module.scss +8 -8
- package/src/components/Card/Card.test.tsx +4 -5
- package/src/components/Card/index.tsx +8 -38
- package/src/components/Chart/Chart.fragment.tsx +5 -3
- package/src/components/Chart/Chart.module.scss +1 -1
- package/src/components/Chart/index.tsx +12 -10
- package/src/components/Checkbox/Checkbox.fragment.tsx +27 -1
- package/src/components/Checkbox/Checkbox.module.scss +3 -3
- package/src/components/Checkbox/index.tsx +16 -3
- package/src/components/Chip/Chip.fragment.tsx +20 -3
- package/src/components/Chip/Chip.test.tsx +28 -0
- package/src/components/Chip/index.tsx +14 -6
- package/src/components/CodeBlock/CodeBlock.fragment.tsx +3 -1
- package/src/components/CodeBlock/CodeBlock.module.scss +9 -9
- package/src/components/CodeBlock/CodeBlock.test.tsx +21 -0
- package/src/components/CodeBlock/index.tsx +23 -9
- package/src/components/Collapsible/Collapsible.fragment.tsx +1 -1
- package/src/components/Collapsible/Collapsible.module.scss +1 -1
- package/src/components/ColorPicker/ColorPicker.fragment.tsx +1 -1
- package/src/components/Combobox/Combobox.fragment.tsx +63 -9
- package/src/components/Combobox/Combobox.module.scss +4 -7
- package/src/components/Combobox/Combobox.test.tsx +24 -3
- package/src/components/Combobox/index.tsx +117 -34
- package/src/components/Command/Command.fragment.tsx +3 -3
- package/src/components/Command/Command.module.scss +5 -5
- package/src/components/Command/Command.test.tsx +17 -0
- package/src/components/Command/index.tsx +8 -5
- package/src/components/ConversationList/ConversationList.fragment.tsx +4 -3
- package/src/components/ConversationList/ConversationList.module.scss +5 -5
- package/src/components/ConversationList/ConversationList.test.tsx +21 -0
- package/src/components/ConversationList/index.tsx +8 -4
- package/src/components/DataTable/DataTable.fragment.tsx +12 -2
- package/src/components/DataTable/DataTable.module.scss +3 -3
- package/src/components/DataTable/DataTable.test.tsx +23 -2
- package/src/components/DataTable/index.tsx +23 -5
- package/src/components/DatePicker/DatePicker.fragment.tsx +3 -1
- package/src/components/DatePicker/DatePicker.module.scss +1 -1
- package/src/components/DatePicker/DatePicker.test.tsx +17 -0
- package/src/components/DatePicker/index.tsx +9 -2
- package/src/components/Dialog/Dialog.fragment.tsx +28 -1
- package/src/components/Dialog/Dialog.module.scss +6 -6
- package/src/components/Dialog/index.tsx +25 -7
- package/src/components/Drawer/Drawer.fragment.tsx +4 -1
- package/src/components/Drawer/Drawer.module.scss +3 -3
- package/src/components/Drawer/Drawer.test.tsx +8 -0
- package/src/components/Drawer/index.tsx +15 -3
- package/src/components/Editor/Editor.fragment.tsx +10 -3
- package/src/components/Editor/Editor.module.scss +4 -4
- package/src/components/Editor/Editor.test.tsx +68 -1
- package/src/components/Editor/index.tsx +60 -9
- package/src/components/EmptyState/EmptyState.fragment.tsx +3 -1
- package/src/components/EmptyState/EmptyState.module.scss +3 -3
- package/src/components/EmptyState/EmptyState.test.tsx +18 -0
- package/src/components/EmptyState/index.tsx +16 -16
- package/src/components/Field/Field.fragment.tsx +1 -1
- package/src/components/Fieldset/Fieldset.fragment.tsx +3 -1
- package/src/components/Fieldset/Fieldset.test.tsx +14 -0
- package/src/components/Fieldset/index.tsx +3 -4
- package/src/components/Form/Form.fragment.tsx +12 -7
- package/src/components/Form/index.tsx +13 -17
- package/src/components/Grid/Grid.fragment.tsx +4 -3
- package/src/components/Grid/Grid.module.scss +3 -3
- package/src/components/Grid/index.tsx +11 -6
- package/src/components/Header/Header.fragment.tsx +31 -1
- package/src/components/Header/Header.module.scss +6 -6
- package/src/components/Header/Header.test.tsx +95 -1
- package/src/components/Header/index.tsx +95 -46
- package/src/components/Icon/Icon.fragment.tsx +21 -8
- package/src/components/Icon/Icon.test.tsx +27 -3
- package/src/components/Icon/index.tsx +39 -15
- package/src/components/Image/Image.fragment.tsx +15 -1
- package/src/components/Image/Image.test.tsx +32 -1
- package/src/components/Image/index.tsx +24 -4
- package/src/components/Input/Input.fragment.tsx +49 -1
- package/src/components/Input/Input.module.scss +4 -2
- package/src/components/Input/Input.test.tsx +3 -3
- package/src/components/Input/index.tsx +103 -37
- package/src/components/Link/Link.fragment.tsx +7 -6
- package/src/components/Link/Link.test.tsx +17 -1
- package/src/components/Link/index.tsx +22 -0
- package/src/components/List/List.fragment.tsx +1 -1
- package/src/components/Listbox/Listbox.fragment.tsx +3 -3
- package/src/components/Listbox/Listbox.module.scss +4 -4
- package/src/components/Listbox/Listbox.test.tsx +14 -0
- package/src/components/Listbox/index.tsx +12 -2
- package/src/components/Loading/Loading.fragment.tsx +1 -1
- package/src/components/Markdown/Markdown.fragment.tsx +5 -3
- package/src/components/Markdown/Markdown.module.scss +5 -5
- package/src/components/Markdown/Markdown.test.tsx +6 -0
- package/src/components/Markdown/index.tsx +12 -9
- package/src/components/Menu/Menu.fragment.tsx +19 -1
- package/src/components/Menu/Menu.module.scss +11 -11
- package/src/components/Menu/index.tsx +19 -7
- package/src/components/Message/Message.fragment.tsx +1 -1
- package/src/components/Message/Message.module.scss +3 -3
- package/src/components/NavigationMenu/NavigationMenu.fragment.tsx +9 -1
- package/src/components/NavigationMenu/NavigationMenu.module.scss +7 -7
- package/src/components/NavigationMenu/NavigationMenu.test.tsx +48 -0
- package/src/components/NavigationMenu/NavigationMenuContext.ts +14 -0
- package/src/components/NavigationMenu/index.tsx +70 -7
- package/src/components/Pagination/Pagination.fragment.tsx +4 -1
- package/src/components/Pagination/Pagination.test.tsx +39 -0
- package/src/components/Pagination/index.tsx +36 -10
- package/src/components/Popover/Popover.fragment.tsx +18 -1
- package/src/components/Popover/Popover.module.scss +13 -13
- package/src/components/Popover/index.tsx +33 -8
- package/src/components/Progress/Progress.fragment.tsx +3 -1
- package/src/components/Progress/Progress.test.tsx +8 -0
- package/src/components/Progress/index.tsx +9 -1
- package/src/components/Prompt/Prompt.fragment.tsx +4 -1
- package/src/components/Prompt/Prompt.module.scss +3 -3
- package/src/components/Prompt/Prompt.test.tsx +19 -0
- package/src/components/Prompt/index.tsx +24 -6
- package/src/components/RadioGroup/RadioGroup.fragment.tsx +31 -1
- package/src/components/RadioGroup/index.tsx +22 -3
- package/src/components/ScrollArea/ScrollArea.fragment.tsx +1 -1
- package/src/components/Select/Select.fragment.tsx +30 -3
- package/src/components/Select/Select.module.scss +3 -3
- package/src/components/Select/index.tsx +46 -33
- package/src/components/Separator/Separator.fragment.tsx +1 -1
- package/src/components/Sidebar/Sidebar.fragment.tsx +3 -1
- package/src/components/Sidebar/Sidebar.module.scss +20 -20
- package/src/components/Sidebar/Sidebar.test.tsx +25 -0
- package/src/components/Sidebar/index.tsx +7 -7
- package/src/components/Skeleton/Skeleton.fragment.tsx +3 -1
- package/src/components/Skeleton/Skeleton.test.tsx +12 -0
- package/src/components/Skeleton/index.tsx +6 -7
- package/src/components/Slider/Slider.fragment.tsx +21 -1
- package/src/components/Slider/Slider.module.scss +31 -0
- package/src/components/Slider/Slider.test.tsx +16 -0
- package/src/components/Slider/index.tsx +40 -1
- package/src/components/Stack/Stack.fragment.tsx +3 -1
- package/src/components/Stack/index.tsx +13 -6
- package/src/components/Table/Table.fragment.tsx +43 -2
- package/src/components/Table/Table.module.scss +2 -2
- package/src/components/Table/index.tsx +23 -5
- package/src/components/TableOfContents/TableOfContents.fragment.tsx +4 -2
- package/src/components/TableOfContents/TableOfContents.test.tsx +34 -9
- package/src/components/TableOfContents/index.tsx +9 -5
- package/src/components/Tabs/Tabs.fragment.tsx +33 -8
- package/src/components/Tabs/Tabs.module.scss +8 -8
- package/src/components/Tabs/index.tsx +22 -14
- package/src/components/Text/Text.fragment.tsx +1 -1
- package/src/components/Textarea/Textarea.fragment.tsx +27 -1
- package/src/components/Textarea/index.tsx +39 -14
- package/src/components/Theme/Theme.fragment.tsx +3 -1
- package/src/components/Theme/Theme.test.tsx +11 -0
- package/src/components/Theme/index.tsx +3 -3
- package/src/components/ThinkingIndicator/ThinkingIndicator.fragment.tsx +1 -1
- package/src/components/ThinkingIndicator/ThinkingIndicator.module.scss +1 -1
- package/src/components/Toast/Toast.fragment.tsx +6 -3
- package/src/components/Toast/Toast.module.scss +8 -6
- package/src/components/Toast/index.tsx +24 -20
- package/src/components/Toggle/Toggle.fragment.tsx +1 -1
- package/src/components/Toggle/Toggle.module.scss +61 -21
- package/src/components/Toggle/index.tsx +3 -3
- package/src/components/ToggleGroup/ToggleGroup.fragment.tsx +33 -8
- package/src/components/ToggleGroup/ToggleGroup.module.scss +3 -3
- package/src/components/ToggleGroup/index.tsx +29 -9
- package/src/components/Tooltip/Tooltip.fragment.tsx +16 -1
- package/src/components/Tooltip/Tooltip.module.scss +1 -1
- package/src/components/Tooltip/index.tsx +16 -1
- package/src/components/VisuallyHidden/VisuallyHidden.fragment.tsx +3 -1
- package/src/components/VisuallyHidden/VisuallyHidden.test.tsx +12 -0
- package/src/components/VisuallyHidden/index.tsx +7 -3
- package/src/index.ts +3 -2
- package/src/tokens/_computed.scss +1 -19
- package/src/tokens/_density.scss +0 -42
- package/src/tokens/_mixins.scss +4 -0
- package/src/tokens/_variables.scss +12 -114
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
3
|
-
const wrapper = "
|
|
4
|
-
const label = "
|
|
5
|
-
const input = "
|
|
6
|
-
const sm = "
|
|
7
|
-
const md = "
|
|
8
|
-
const lg = "
|
|
9
|
-
const labelSm = "
|
|
10
|
-
const error = "
|
|
11
|
-
const helper = "
|
|
12
|
-
const helperError = "
|
|
13
|
-
const inputContainer = "
|
|
14
|
-
const hasShortcut = "
|
|
15
|
-
const shortcut = "
|
|
3
|
+
const wrapper = "_wrapper_15wvb_1";
|
|
4
|
+
const label = "_label_15wvb_6";
|
|
5
|
+
const input = "_input_15wvb_14";
|
|
6
|
+
const sm = "_sm_15wvb_54";
|
|
7
|
+
const md = "_md_15wvb_60";
|
|
8
|
+
const lg = "_lg_15wvb_66";
|
|
9
|
+
const labelSm = "_labelSm_15wvb_72";
|
|
10
|
+
const error = "_error_15wvb_76";
|
|
11
|
+
const helper = "_helper_15wvb_84";
|
|
12
|
+
const helperError = "_helperError_15wvb_91";
|
|
13
|
+
const inputContainer = "_inputContainer_15wvb_95";
|
|
14
|
+
const hasShortcut = "_hasShortcut_15wvb_101";
|
|
15
|
+
const shortcut = "_shortcut_15wvb_105";
|
|
16
16
|
const styles = {
|
|
17
17
|
wrapper,
|
|
18
18
|
label,
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
const wrapper = "
|
|
2
|
-
const label = "
|
|
3
|
-
const input = "
|
|
4
|
-
const sm = "
|
|
5
|
-
const md = "
|
|
6
|
-
const lg = "
|
|
7
|
-
const labelSm = "
|
|
8
|
-
const error = "
|
|
9
|
-
const helper = "
|
|
10
|
-
const helperError = "
|
|
11
|
-
const inputContainer = "
|
|
12
|
-
const hasShortcut = "
|
|
13
|
-
const shortcut = "
|
|
1
|
+
const wrapper = "_wrapper_15wvb_1";
|
|
2
|
+
const label = "_label_15wvb_6";
|
|
3
|
+
const input = "_input_15wvb_14";
|
|
4
|
+
const sm = "_sm_15wvb_54";
|
|
5
|
+
const md = "_md_15wvb_60";
|
|
6
|
+
const lg = "_lg_15wvb_66";
|
|
7
|
+
const labelSm = "_labelSm_15wvb_72";
|
|
8
|
+
const error = "_error_15wvb_76";
|
|
9
|
+
const helper = "_helper_15wvb_84";
|
|
10
|
+
const helperError = "_helperError_15wvb_91";
|
|
11
|
+
const inputContainer = "_inputContainer_15wvb_95";
|
|
12
|
+
const hasShortcut = "_hasShortcut_15wvb_101";
|
|
13
|
+
const shortcut = "_shortcut_15wvb_105";
|
|
14
14
|
const styles = {
|
|
15
15
|
wrapper,
|
|
16
16
|
label,
|
|
@@ -56,23 +56,30 @@ const InputRoot = React__namespace.forwardRef(
|
|
|
56
56
|
label,
|
|
57
57
|
helperText,
|
|
58
58
|
shortcut,
|
|
59
|
+
shortcutBehavior = "display-only",
|
|
59
60
|
onChange,
|
|
61
|
+
onValueChange,
|
|
60
62
|
onBlur,
|
|
61
63
|
onFocus,
|
|
62
64
|
onKeyDown,
|
|
65
|
+
rootProps,
|
|
63
66
|
className,
|
|
64
67
|
style,
|
|
65
68
|
inputStyle,
|
|
66
69
|
inputClassName,
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
"aria-label": ariaLabel,
|
|
70
|
-
"aria-labelledby": ariaLabelledBy,
|
|
71
|
-
"aria-describedby": ariaDescribedBy,
|
|
72
|
-
...htmlProps
|
|
70
|
+
withFieldWrapper = true,
|
|
71
|
+
...inputProps
|
|
73
72
|
}, ref) {
|
|
74
73
|
const generatedId = React__namespace.useId();
|
|
75
74
|
const helperId = helperText ? `input-helper-${generatedId}` : void 0;
|
|
75
|
+
const {
|
|
76
|
+
id,
|
|
77
|
+
"aria-label": ariaLabel,
|
|
78
|
+
"aria-labelledby": ariaLabelledBy,
|
|
79
|
+
"aria-describedby": ariaDescribedBy,
|
|
80
|
+
...nativeInputProps
|
|
81
|
+
} = inputProps;
|
|
82
|
+
const resolvedInputId = id ?? `input-${generatedId}`;
|
|
76
83
|
const internalRef = React__namespace.useRef(null);
|
|
77
84
|
const mergedRef = React__namespace.useCallback(
|
|
78
85
|
(node) => {
|
|
@@ -87,6 +94,7 @@ const InputRoot = React__namespace.forwardRef(
|
|
|
87
94
|
);
|
|
88
95
|
React__namespace.useEffect(() => {
|
|
89
96
|
if (!shortcut) return;
|
|
97
|
+
if (shortcutBehavior !== "focus-input") return;
|
|
90
98
|
const parsed = parseShortcut(shortcut);
|
|
91
99
|
if (!parsed) return;
|
|
92
100
|
const handler = (e) => {
|
|
@@ -100,7 +108,7 @@ const InputRoot = React__namespace.forwardRef(
|
|
|
100
108
|
};
|
|
101
109
|
document.addEventListener("keydown", handler);
|
|
102
110
|
return () => document.removeEventListener("keydown", handler);
|
|
103
|
-
}, [shortcut]);
|
|
111
|
+
}, [shortcut, shortcutBehavior]);
|
|
104
112
|
const inputClasses = [
|
|
105
113
|
Input_module.default.input,
|
|
106
114
|
Input_module.default[size],
|
|
@@ -111,36 +119,76 @@ const InputRoot = React__namespace.forwardRef(
|
|
|
111
119
|
const helperClasses = [Input_module.default.helper, error && Input_module.default.helperError].filter(Boolean).join(" ");
|
|
112
120
|
const wrapperClasses = [Input_module.default.wrapper, className].filter(Boolean).join(" ");
|
|
113
121
|
const labelClasses = [Input_module.default.label, size === "sm" && Input_module.default.labelSm].filter(Boolean).join(" ");
|
|
122
|
+
const sharedInputProps = {
|
|
123
|
+
...nativeInputProps,
|
|
124
|
+
ref: mergedRef,
|
|
125
|
+
id: resolvedInputId,
|
|
126
|
+
type,
|
|
127
|
+
value,
|
|
128
|
+
defaultValue,
|
|
129
|
+
placeholder,
|
|
130
|
+
disabled,
|
|
131
|
+
onChange: (e) => {
|
|
132
|
+
onChange == null ? void 0 : onChange(e.target.value);
|
|
133
|
+
onValueChange == null ? void 0 : onValueChange(e.target.value);
|
|
134
|
+
},
|
|
135
|
+
onBlur: () => onBlur == null ? void 0 : onBlur(),
|
|
136
|
+
onFocus: () => onFocus == null ? void 0 : onFocus(),
|
|
137
|
+
onKeyDown: (e) => onKeyDown == null ? void 0 : onKeyDown(e),
|
|
138
|
+
"aria-label": ariaLabel,
|
|
139
|
+
"aria-labelledby": ariaLabelledBy,
|
|
140
|
+
"aria-describedby": mergeAriaIds(ariaDescribedBy, helperId),
|
|
141
|
+
className: inputClasses,
|
|
142
|
+
style: inputStyle
|
|
143
|
+
};
|
|
114
144
|
const inputElement = /* @__PURE__ */ jsxRuntime.jsx(
|
|
115
145
|
field.Field.Control,
|
|
116
146
|
{
|
|
117
|
-
|
|
118
|
-
type,
|
|
119
|
-
value,
|
|
120
|
-
defaultValue,
|
|
121
|
-
placeholder,
|
|
122
|
-
name,
|
|
123
|
-
id,
|
|
124
|
-
onChange: (e) => onChange == null ? void 0 : onChange(e.target.value),
|
|
125
|
-
onBlur,
|
|
126
|
-
onFocus,
|
|
127
|
-
onKeyDown,
|
|
128
|
-
"aria-label": ariaLabel,
|
|
129
|
-
"aria-labelledby": ariaLabelledBy,
|
|
130
|
-
"aria-describedby": mergeAriaIds(ariaDescribedBy, helperId),
|
|
131
|
-
className: inputClasses,
|
|
132
|
-
style: inputStyle,
|
|
147
|
+
...sharedInputProps,
|
|
133
148
|
render: /* @__PURE__ */ jsxRuntime.jsx("input", {})
|
|
134
149
|
}
|
|
135
150
|
);
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
151
|
+
const fieldlessInputElement = /* @__PURE__ */ jsxRuntime.jsx(
|
|
152
|
+
"input",
|
|
153
|
+
{
|
|
154
|
+
...sharedInputProps,
|
|
155
|
+
"aria-invalid": error || void 0
|
|
156
|
+
}
|
|
157
|
+
);
|
|
158
|
+
const content = shortcut ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: Input_module.default.inputContainer, children: [
|
|
159
|
+
withFieldWrapper ? inputElement : fieldlessInputElement,
|
|
160
|
+
/* @__PURE__ */ jsxRuntime.jsx("kbd", { className: Input_module.default.shortcut, children: shortcut })
|
|
161
|
+
] }) : withFieldWrapper ? inputElement : fieldlessInputElement;
|
|
162
|
+
if (!withFieldWrapper) {
|
|
163
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
164
|
+
"div",
|
|
165
|
+
{
|
|
166
|
+
...rootProps,
|
|
167
|
+
className: [Input_module.default.wrapper, rootProps == null ? void 0 : rootProps.className, className].filter(Boolean).join(" "),
|
|
168
|
+
style: { ...(rootProps == null ? void 0 : rootProps.style) ?? {}, ...style ?? {} },
|
|
169
|
+
children: [
|
|
170
|
+
label && /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: resolvedInputId, className: labelClasses, children: label }),
|
|
171
|
+
content,
|
|
172
|
+
helperText && /* @__PURE__ */ jsxRuntime.jsx("div", { id: helperId, className: helperClasses, children: helperText })
|
|
173
|
+
]
|
|
174
|
+
}
|
|
175
|
+
);
|
|
176
|
+
}
|
|
177
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
178
|
+
field.Field.Root,
|
|
179
|
+
{
|
|
180
|
+
...rootProps,
|
|
181
|
+
disabled,
|
|
182
|
+
invalid: error,
|
|
183
|
+
className: [wrapperClasses, rootProps == null ? void 0 : rootProps.className].filter(Boolean).join(" "),
|
|
184
|
+
style: { ...(rootProps == null ? void 0 : rootProps.style) ?? {}, ...style ?? {} },
|
|
185
|
+
children: [
|
|
186
|
+
label && /* @__PURE__ */ jsxRuntime.jsx(field.Field.Label, { className: labelClasses, children: label }),
|
|
187
|
+
content,
|
|
188
|
+
helperText && /* @__PURE__ */ jsxRuntime.jsx(field.Field.Description, { id: helperId, className: helperClasses, children: helperText })
|
|
189
|
+
]
|
|
190
|
+
}
|
|
191
|
+
);
|
|
144
192
|
}
|
|
145
193
|
);
|
|
146
194
|
const Input = Object.assign(InputRoot, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../../../src/components/Input/index.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { Field } from '@base-ui/react/field';\nimport styles from './Input.module.scss';\n\n/**\n * Text input field with label, helper text, and validation.\n * @see https://usefragments.com/components/input\n */\nexport interface InputProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'onChange' | 'onBlur' | 'onFocus' | 'onKeyDown' | 'defaultValue'> {\n /** Controlled input value */\n value?: string;\n /** Default value for uncontrolled usage */\n defaultValue?: string;\n /** Placeholder text shown when empty */\n placeholder?: string;\n /** HTML input type */\n type?: 'text' | 'email' | 'password' | 'number' | 'tel' | 'url';\n /** Input size.\n * @default \"md\"\n * @see https://usefragments.com/components/input#sizes */\n size?: 'sm' | 'md' | 'lg';\n /** Whether the input is non-interactive */\n disabled?: boolean;\n /** Show error styling */\n error?: boolean;\n /** Visible label text */\n label?: string;\n /** Helper text shown below the input */\n helperText?: string;\n /** Keyboard shortcut hint displayed inside the input (e.g., \"⌘K\"). Also registers a global keydown listener that focuses the input when the shortcut is pressed. */\n shortcut?: string;\n onChange?: (value: string) => void;\n onBlur?: () => void;\n onFocus?: () => void;\n onKeyDown?: (e: React.KeyboardEvent<HTMLInputElement>) => void;\n /** Styles applied directly to the input element */\n inputStyle?: React.CSSProperties;\n /** Class applied directly to the input element */\n inputClassName?: string;\n name?: string;\n}\n\nfunction mergeAriaIds(...ids: Array<string | undefined>): string | undefined {\n const merged = ids.filter(Boolean).join(' ').trim();\n return merged.length > 0 ? merged : undefined;\n}\n\nfunction parseShortcut(shortcut: string): { meta: boolean; shift: boolean; alt: boolean; key: string } | null {\n let meta = false, shift = false, alt = false;\n let remaining = shortcut;\n\n if (remaining.includes('⌘')) { meta = true; remaining = remaining.replace('⌘', ''); }\n if (remaining.includes('⇧')) { shift = true; remaining = remaining.replace('⇧', ''); }\n if (remaining.includes('⌥')) { alt = true; remaining = remaining.replace('⌥', ''); }\n\n remaining = remaining.trim();\n if (!remaining) return null;\n\n return { meta, shift, alt, key: remaining };\n}\n\nconst InputRoot = React.forwardRef<HTMLInputElement, InputProps>(\n function Input(\n {\n value,\n defaultValue,\n placeholder,\n type = 'text',\n size = 'md',\n disabled = false,\n error = false,\n label,\n helperText,\n shortcut,\n onChange,\n onBlur,\n onFocus,\n onKeyDown,\n className,\n style,\n inputStyle,\n inputClassName,\n name,\n id,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n 'aria-describedby': ariaDescribedBy,\n ...htmlProps\n },\n ref\n ) {\n const generatedId = React.useId();\n const helperId = helperText ? `input-helper-${generatedId}` : undefined;\n\n const internalRef = React.useRef<HTMLInputElement>(null);\n const mergedRef = React.useCallback(\n (node: HTMLInputElement | null) => {\n internalRef.current = node;\n if (typeof ref === 'function') {\n ref(node);\n } else if (ref) {\n (ref as React.MutableRefObject<HTMLInputElement | null>).current = node;\n }\n },\n [ref]\n );\n\n // Register global keydown handler when shortcut is provided\n React.useEffect(() => {\n if (!shortcut) return;\n const parsed = parseShortcut(shortcut);\n if (!parsed) return;\n\n const handler = (e: KeyboardEvent) => {\n if (parsed.meta && !(e.metaKey || e.ctrlKey)) return;\n if (parsed.shift && !e.shiftKey) return;\n if (parsed.alt && !e.altKey) return;\n if (e.key.toLowerCase() !== parsed.key.toLowerCase()) return;\n e.preventDefault();\n internalRef.current?.focus();\n };\n document.addEventListener('keydown', handler);\n return () => document.removeEventListener('keydown', handler);\n }, [shortcut]);\n\n const inputClasses = [\n styles.input,\n styles[size],\n error && styles.error,\n shortcut && styles.hasShortcut,\n inputClassName,\n ]\n .filter(Boolean)\n .join(' ');\n\n const helperClasses = [styles.helper, error && styles.helperError]\n .filter(Boolean)\n .join(' ');\n\n const wrapperClasses = [styles.wrapper, className].filter(Boolean).join(' ');\n const labelClasses = [styles.label, size === 'sm' && styles.labelSm].filter(Boolean).join(' ');\n\n const inputElement = (\n <Field.Control\n ref={mergedRef}\n type={type}\n value={value}\n defaultValue={defaultValue}\n placeholder={placeholder}\n name={name}\n id={id}\n onChange={(e: React.ChangeEvent<HTMLInputElement>) =>\n onChange?.(e.target.value)\n }\n onBlur={onBlur}\n onFocus={onFocus}\n onKeyDown={onKeyDown}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy}\n aria-describedby={mergeAriaIds(ariaDescribedBy, helperId)}\n className={inputClasses}\n style={inputStyle}\n render={<input />}\n />\n );\n\n return (\n <Field.Root {...htmlProps} disabled={disabled} invalid={error} className={wrapperClasses} style={style}>\n {label && <Field.Label className={labelClasses}>{label}</Field.Label>}\n {shortcut ? (\n <div className={styles.inputContainer}>\n {inputElement}\n <kbd className={styles.shortcut}>{shortcut}</kbd>\n </div>\n ) : (\n inputElement\n )}\n {helperText && (\n <Field.Description id={helperId} className={helperClasses}>\n {helperText}\n </Field.Description>\n )}\n </Field.Root>\n );\n }\n);\n\nexport const Input = Object.assign(InputRoot, {\n Root: InputRoot,\n});\n"],"names":["React","Input","styles","jsx","Field","jsxs"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AA4CA,SAAS,gBAAgB,KAAoD;AAC3E,QAAM,SAAS,IAAI,OAAO,OAAO,EAAE,KAAK,GAAG,EAAE,KAAA;AAC7C,SAAO,OAAO,SAAS,IAAI,SAAS;AACtC;AAEA,SAAS,cAAc,UAAuF;AAC5G,MAAI,OAAO,OAAO,QAAQ,OAAO,MAAM;AACvC,MAAI,YAAY;AAEhB,MAAI,UAAU,SAAS,GAAG,GAAG;AAAE,WAAO;AAAM,gBAAY,UAAU,QAAQ,KAAK,EAAE;AAAA,EAAG;AACpF,MAAI,UAAU,SAAS,GAAG,GAAG;AAAE,YAAQ;AAAM,gBAAY,UAAU,QAAQ,KAAK,EAAE;AAAA,EAAG;AACrF,MAAI,UAAU,SAAS,GAAG,GAAG;AAAE,UAAM;AAAM,gBAAY,UAAU,QAAQ,KAAK,EAAE;AAAA,EAAG;AAEnF,cAAY,UAAU,KAAA;AACtB,MAAI,CAAC,UAAW,QAAO;AAEvB,SAAO,EAAE,MAAM,OAAO,KAAK,KAAK,UAAA;AAClC;AAEA,MAAM,YAAYA,iBAAM;AAAA,EACtB,SAASC,OACP;AAAA,IACE;AAAA,IACA;AAAA,IACA;AAAA,IACA,OAAO;AAAA,IACP,OAAO;AAAA,IACP,WAAW;AAAA,IACX,QAAQ;AAAA,IACR;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,I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index.cjs","sources":["../../../src/components/Input/index.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { Field } from '@base-ui/react/field';\nimport styles from './Input.module.scss';\n\n/**\n * Text input field with label, helper text, and validation.\n * @see https://usefragments.com/components/input\n */\nexport interface InputProps extends Omit<\n React.InputHTMLAttributes<HTMLInputElement>,\n 'size' | 'onChange' | 'onBlur' | 'onFocus' | 'onKeyDown' | 'className' | 'style'\n> {\n /** Controlled input value */\n value?: string;\n /** Default value for uncontrolled usage */\n defaultValue?: string;\n /** Placeholder text shown when empty */\n placeholder?: string;\n /** HTML input type */\n type?: 'text' | 'email' | 'password' | 'number' | 'tel' | 'url';\n /** Input size.\n * @default \"md\"\n * @see https://usefragments.com/components/input#sizes */\n size?: 'sm' | 'md' | 'lg';\n /** Whether the input is non-interactive */\n disabled?: boolean;\n /** Show error styling */\n error?: boolean;\n /** Visible label text */\n label?: string;\n /** Helper text shown below the input */\n helperText?: string;\n /** Keyboard shortcut hint displayed inside the input (e.g., \"⌘K\"). */\n shortcut?: string;\n /** Whether the shortcut should also register a global focus hotkey.\n * @default \"display-only\" */\n shortcutBehavior?: 'display-only' | 'focus-input';\n /** Called when value changes (string value) */\n onChange?: (value: string) => void;\n /** Alias for onChange (value-first callback) */\n onValueChange?: (value: string) => void;\n onBlur?: () => void;\n onFocus?: () => void;\n onKeyDown?: (e: React.KeyboardEvent<HTMLInputElement>) => void;\n /** Props applied to the wrapper element */\n rootProps?: React.HTMLAttributes<HTMLDivElement>;\n /** Styles applied directly to the input element */\n inputStyle?: React.CSSProperties;\n /** Class applied directly to the input element */\n inputClassName?: string;\n /** Whether to render the Base UI Field wrapper (label/description/invalid wiring)\n * @default true */\n withFieldWrapper?: boolean;\n /** Wrapper class name */\n className?: string;\n /** Wrapper styles */\n style?: React.CSSProperties;\n}\n\nfunction mergeAriaIds(...ids: Array<string | undefined>): string | undefined {\n const merged = ids.filter(Boolean).join(' ').trim();\n return merged.length > 0 ? merged : undefined;\n}\n\nfunction parseShortcut(shortcut: string): { meta: boolean; shift: boolean; alt: boolean; key: string } | null {\n let meta = false, shift = false, alt = false;\n let remaining = shortcut;\n\n if (remaining.includes('⌘')) { meta = true; remaining = remaining.replace('⌘', ''); }\n if (remaining.includes('⇧')) { shift = true; remaining = remaining.replace('⇧', ''); }\n if (remaining.includes('⌥')) { alt = true; remaining = remaining.replace('⌥', ''); }\n\n remaining = remaining.trim();\n if (!remaining) return null;\n\n return { meta, shift, alt, key: remaining };\n}\n\nconst InputRoot = React.forwardRef<HTMLInputElement, InputProps>(\n function Input(\n {\n value,\n defaultValue,\n placeholder,\n type = 'text',\n size = 'md',\n disabled = false,\n error = false,\n label,\n helperText,\n shortcut,\n shortcutBehavior = 'display-only',\n onChange,\n onValueChange,\n onBlur,\n onFocus,\n onKeyDown,\n rootProps,\n className,\n style,\n inputStyle,\n inputClassName,\n withFieldWrapper = true,\n ...inputProps\n },\n ref\n ) {\n const generatedId = React.useId();\n const helperId = helperText ? `input-helper-${generatedId}` : undefined;\n const {\n id,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n 'aria-describedby': ariaDescribedBy,\n ...nativeInputProps\n } = inputProps;\n const resolvedInputId = id ?? `input-${generatedId}`;\n\n const internalRef = React.useRef<HTMLInputElement>(null);\n const mergedRef = React.useCallback(\n (node: HTMLInputElement | null) => {\n internalRef.current = node;\n if (typeof ref === 'function') {\n ref(node);\n } else if (ref) {\n (ref as React.MutableRefObject<HTMLInputElement | null>).current = node;\n }\n },\n [ref]\n );\n\n // Register global keydown handler when shortcut is provided\n React.useEffect(() => {\n if (!shortcut) return;\n if (shortcutBehavior !== 'focus-input') return;\n const parsed = parseShortcut(shortcut);\n if (!parsed) return;\n\n const handler = (e: KeyboardEvent) => {\n if (parsed.meta && !(e.metaKey || e.ctrlKey)) return;\n if (parsed.shift && !e.shiftKey) return;\n if (parsed.alt && !e.altKey) return;\n if (e.key.toLowerCase() !== parsed.key.toLowerCase()) return;\n e.preventDefault();\n internalRef.current?.focus();\n };\n document.addEventListener('keydown', handler);\n return () => document.removeEventListener('keydown', handler);\n }, [shortcut, shortcutBehavior]);\n\n const inputClasses = [\n styles.input,\n styles[size],\n error && styles.error,\n shortcut && styles.hasShortcut,\n inputClassName,\n ]\n .filter(Boolean)\n .join(' ');\n\n const helperClasses = [styles.helper, error && styles.helperError]\n .filter(Boolean)\n .join(' ');\n\n const wrapperClasses = [styles.wrapper, className].filter(Boolean).join(' ');\n const labelClasses = [styles.label, size === 'sm' && styles.labelSm].filter(Boolean).join(' ');\n\n const sharedInputProps = {\n ...nativeInputProps,\n ref: mergedRef,\n id: resolvedInputId,\n type,\n value,\n defaultValue,\n placeholder,\n disabled,\n onChange: (e: React.ChangeEvent<HTMLInputElement>) => {\n onChange?.(e.target.value);\n onValueChange?.(e.target.value);\n },\n onBlur: () => onBlur?.(),\n onFocus: () => onFocus?.(),\n onKeyDown: (e: React.KeyboardEvent<HTMLInputElement>) => onKeyDown?.(e),\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n 'aria-describedby': mergeAriaIds(ariaDescribedBy, helperId),\n className: inputClasses,\n style: inputStyle,\n } satisfies React.InputHTMLAttributes<HTMLInputElement> & {\n ref: React.Ref<HTMLInputElement>;\n };\n\n const inputElement = (\n <Field.Control\n {...sharedInputProps}\n render={<input />}\n />\n );\n\n const fieldlessInputElement = (\n <input\n {...sharedInputProps}\n aria-invalid={error || undefined}\n />\n );\n\n const content = shortcut ? (\n <div className={styles.inputContainer}>\n {withFieldWrapper ? inputElement : fieldlessInputElement}\n <kbd className={styles.shortcut}>{shortcut}</kbd>\n </div>\n ) : (\n withFieldWrapper ? inputElement : fieldlessInputElement\n );\n\n if (!withFieldWrapper) {\n return (\n <div\n {...rootProps}\n className={[styles.wrapper, rootProps?.className, className].filter(Boolean).join(' ')}\n style={{ ...(rootProps?.style ?? {}), ...(style ?? {}) }}\n >\n {label && <label htmlFor={resolvedInputId} className={labelClasses}>{label}</label>}\n {content}\n {helperText && (\n <div id={helperId} className={helperClasses}>\n {helperText}\n </div>\n )}\n </div>\n );\n }\n\n return (\n <Field.Root\n {...rootProps}\n disabled={disabled}\n invalid={error}\n className={[wrapperClasses, rootProps?.className].filter(Boolean).join(' ')}\n style={{ ...(rootProps?.style ?? {}), ...(style ?? {}) }}\n >\n {label && <Field.Label className={labelClasses}>{label}</Field.Label>}\n {content}\n {helperText && (\n <Field.Description id={helperId} className={helperClasses}>\n {helperText}\n </Field.Description>\n )}\n </Field.Root>\n );\n }\n);\n\nexport const Input = Object.assign(InputRoot, {\n Root: InputRoot,\n});\n"],"names":["React","Input","styles","jsx","Field","jsxs"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AA6DA,SAAS,gBAAgB,KAAoD;AAC3E,QAAM,SAAS,IAAI,OAAO,OAAO,EAAE,KAAK,GAAG,EAAE,KAAA;AAC7C,SAAO,OAAO,SAAS,IAAI,SAAS;AACtC;AAEA,SAAS,cAAc,UAAuF;AAC5G,MAAI,OAAO,OAAO,QAAQ,OAAO,MAAM;AACvC,MAAI,YAAY;AAEhB,MAAI,UAAU,SAAS,GAAG,GAAG;AAAE,WAAO;AAAM,gBAAY,UAAU,QAAQ,KAAK,EAAE;AAAA,EAAG;AACpF,MAAI,UAAU,SAAS,GAAG,GAAG;AAAE,YAAQ;AAAM,gBAAY,UAAU,QAAQ,KAAK,EAAE;AAAA,EAAG;AACrF,MAAI,UAAU,SAAS,GAAG,GAAG;AAAE,UAAM;AAAM,gBAAY,UAAU,QAAQ,KAAK,EAAE;AAAA,EAAG;AAEnF,cAAY,UAAU,KAAA;AACtB,MAAI,CAAC,UAAW,QAAO;AAEvB,SAAO,EAAE,MAAM,OAAO,KAAK,KAAK,UAAA;AAClC;AAEA,MAAM,YAAYA,iBAAM;AAAA,EACtB,SAASC,OACP;AAAA,IACE;AAAA,IACA;AAAA,IACA;AAAA,IACA,OAAO;AAAA,IACP,OAAO;AAAA,IACP,WAAW;AAAA,IACX,QAAQ;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AO,WAAW;AAAA,EAC5C,MAAM;AACR,CAAC;;"}
|
|
@@ -3,7 +3,7 @@ import * as React from 'react';
|
|
|
3
3
|
* Text input field with label, helper text, and validation.
|
|
4
4
|
* @see https://usefragments.com/components/input
|
|
5
5
|
*/
|
|
6
|
-
export interface InputProps extends Omit<React.
|
|
6
|
+
export interface InputProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'size' | 'onChange' | 'onBlur' | 'onFocus' | 'onKeyDown' | 'className' | 'style'> {
|
|
7
7
|
/** Controlled input value */
|
|
8
8
|
value?: string;
|
|
9
9
|
/** Default value for uncontrolled usage */
|
|
@@ -24,17 +24,31 @@ export interface InputProps extends Omit<React.HTMLAttributes<HTMLDivElement>, '
|
|
|
24
24
|
label?: string;
|
|
25
25
|
/** Helper text shown below the input */
|
|
26
26
|
helperText?: string;
|
|
27
|
-
/** Keyboard shortcut hint displayed inside the input (e.g., "⌘K").
|
|
27
|
+
/** Keyboard shortcut hint displayed inside the input (e.g., "⌘K"). */
|
|
28
28
|
shortcut?: string;
|
|
29
|
+
/** Whether the shortcut should also register a global focus hotkey.
|
|
30
|
+
* @default "display-only" */
|
|
31
|
+
shortcutBehavior?: 'display-only' | 'focus-input';
|
|
32
|
+
/** Called when value changes (string value) */
|
|
29
33
|
onChange?: (value: string) => void;
|
|
34
|
+
/** Alias for onChange (value-first callback) */
|
|
35
|
+
onValueChange?: (value: string) => void;
|
|
30
36
|
onBlur?: () => void;
|
|
31
37
|
onFocus?: () => void;
|
|
32
38
|
onKeyDown?: (e: React.KeyboardEvent<HTMLInputElement>) => void;
|
|
39
|
+
/** Props applied to the wrapper element */
|
|
40
|
+
rootProps?: React.HTMLAttributes<HTMLDivElement>;
|
|
33
41
|
/** Styles applied directly to the input element */
|
|
34
42
|
inputStyle?: React.CSSProperties;
|
|
35
43
|
/** Class applied directly to the input element */
|
|
36
44
|
inputClassName?: string;
|
|
37
|
-
|
|
45
|
+
/** Whether to render the Base UI Field wrapper (label/description/invalid wiring)
|
|
46
|
+
* @default true */
|
|
47
|
+
withFieldWrapper?: boolean;
|
|
48
|
+
/** Wrapper class name */
|
|
49
|
+
className?: string;
|
|
50
|
+
/** Wrapper styles */
|
|
51
|
+
style?: React.CSSProperties;
|
|
38
52
|
}
|
|
39
53
|
export declare const Input: React.ForwardRefExoticComponent<InputProps & React.RefAttributes<HTMLInputElement>> & {
|
|
40
54
|
Root: React.ForwardRefExoticComponent<InputProps & React.RefAttributes<HTMLInputElement>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Input/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B;;;GAGG;AACH,MAAM,WAAW,UAAW,SAAQ,IAAI,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Input/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B;;;GAGG;AACH,MAAM,WAAW,UAAW,SAAQ,IAAI,CACtC,KAAK,CAAC,mBAAmB,CAAC,gBAAgB,CAAC,EAC3C,MAAM,GAAG,UAAU,GAAG,QAAQ,GAAG,SAAS,GAAG,WAAW,GAAG,WAAW,GAAG,OAAO,CACjF;IACC,6BAA6B;IAC7B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,2CAA2C;IAC3C,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,wCAAwC;IACxC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,sBAAsB;IACtB,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,UAAU,GAAG,QAAQ,GAAG,KAAK,GAAG,KAAK,CAAC;IAChE;;8DAE0D;IAC1D,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;IAC1B,2CAA2C;IAC3C,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,yBAAyB;IACzB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,yBAAyB;IACzB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,wCAAwC;IACxC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,sEAAsE;IACtE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;iCAC6B;IAC7B,gBAAgB,CAAC,EAAE,cAAc,GAAG,aAAa,CAAC;IAClD,+CAA+C;IAC/C,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,gDAAgD;IAChD,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACxC,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,SAAS,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC,gBAAgB,CAAC,KAAK,IAAI,CAAC;IAC/D,2CAA2C;IAC3C,SAAS,CAAC,EAAE,KAAK,CAAC,cAAc,CAAC,cAAc,CAAC,CAAC;IACjD,mDAAmD;IACnD,UAAU,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;IACjC,kDAAkD;IAClD,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;uBACmB;IACnB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,yBAAyB;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,qBAAqB;IACrB,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;CAC7B;AAoMD,eAAO,MAAM,KAAK;;CAEhB,CAAC"}
|
|
@@ -37,23 +37,30 @@ const InputRoot = React.forwardRef(
|
|
|
37
37
|
label,
|
|
38
38
|
helperText,
|
|
39
39
|
shortcut,
|
|
40
|
+
shortcutBehavior = "display-only",
|
|
40
41
|
onChange,
|
|
42
|
+
onValueChange,
|
|
41
43
|
onBlur,
|
|
42
44
|
onFocus,
|
|
43
45
|
onKeyDown,
|
|
46
|
+
rootProps,
|
|
44
47
|
className,
|
|
45
48
|
style,
|
|
46
49
|
inputStyle,
|
|
47
50
|
inputClassName,
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
"aria-label": ariaLabel,
|
|
51
|
-
"aria-labelledby": ariaLabelledBy,
|
|
52
|
-
"aria-describedby": ariaDescribedBy,
|
|
53
|
-
...htmlProps
|
|
51
|
+
withFieldWrapper = true,
|
|
52
|
+
...inputProps
|
|
54
53
|
}, ref) {
|
|
55
54
|
const generatedId = React.useId();
|
|
56
55
|
const helperId = helperText ? `input-helper-${generatedId}` : void 0;
|
|
56
|
+
const {
|
|
57
|
+
id,
|
|
58
|
+
"aria-label": ariaLabel,
|
|
59
|
+
"aria-labelledby": ariaLabelledBy,
|
|
60
|
+
"aria-describedby": ariaDescribedBy,
|
|
61
|
+
...nativeInputProps
|
|
62
|
+
} = inputProps;
|
|
63
|
+
const resolvedInputId = id ?? `input-${generatedId}`;
|
|
57
64
|
const internalRef = React.useRef(null);
|
|
58
65
|
const mergedRef = React.useCallback(
|
|
59
66
|
(node) => {
|
|
@@ -68,6 +75,7 @@ const InputRoot = React.forwardRef(
|
|
|
68
75
|
);
|
|
69
76
|
React.useEffect(() => {
|
|
70
77
|
if (!shortcut) return;
|
|
78
|
+
if (shortcutBehavior !== "focus-input") return;
|
|
71
79
|
const parsed = parseShortcut(shortcut);
|
|
72
80
|
if (!parsed) return;
|
|
73
81
|
const handler = (e) => {
|
|
@@ -81,7 +89,7 @@ const InputRoot = React.forwardRef(
|
|
|
81
89
|
};
|
|
82
90
|
document.addEventListener("keydown", handler);
|
|
83
91
|
return () => document.removeEventListener("keydown", handler);
|
|
84
|
-
}, [shortcut]);
|
|
92
|
+
}, [shortcut, shortcutBehavior]);
|
|
85
93
|
const inputClasses = [
|
|
86
94
|
styles.input,
|
|
87
95
|
styles[size],
|
|
@@ -92,36 +100,76 @@ const InputRoot = React.forwardRef(
|
|
|
92
100
|
const helperClasses = [styles.helper, error && styles.helperError].filter(Boolean).join(" ");
|
|
93
101
|
const wrapperClasses = [styles.wrapper, className].filter(Boolean).join(" ");
|
|
94
102
|
const labelClasses = [styles.label, size === "sm" && styles.labelSm].filter(Boolean).join(" ");
|
|
103
|
+
const sharedInputProps = {
|
|
104
|
+
...nativeInputProps,
|
|
105
|
+
ref: mergedRef,
|
|
106
|
+
id: resolvedInputId,
|
|
107
|
+
type,
|
|
108
|
+
value,
|
|
109
|
+
defaultValue,
|
|
110
|
+
placeholder,
|
|
111
|
+
disabled,
|
|
112
|
+
onChange: (e) => {
|
|
113
|
+
onChange == null ? void 0 : onChange(e.target.value);
|
|
114
|
+
onValueChange == null ? void 0 : onValueChange(e.target.value);
|
|
115
|
+
},
|
|
116
|
+
onBlur: () => onBlur == null ? void 0 : onBlur(),
|
|
117
|
+
onFocus: () => onFocus == null ? void 0 : onFocus(),
|
|
118
|
+
onKeyDown: (e) => onKeyDown == null ? void 0 : onKeyDown(e),
|
|
119
|
+
"aria-label": ariaLabel,
|
|
120
|
+
"aria-labelledby": ariaLabelledBy,
|
|
121
|
+
"aria-describedby": mergeAriaIds(ariaDescribedBy, helperId),
|
|
122
|
+
className: inputClasses,
|
|
123
|
+
style: inputStyle
|
|
124
|
+
};
|
|
95
125
|
const inputElement = /* @__PURE__ */ jsx(
|
|
96
126
|
Field.Control,
|
|
97
127
|
{
|
|
98
|
-
|
|
99
|
-
type,
|
|
100
|
-
value,
|
|
101
|
-
defaultValue,
|
|
102
|
-
placeholder,
|
|
103
|
-
name,
|
|
104
|
-
id,
|
|
105
|
-
onChange: (e) => onChange == null ? void 0 : onChange(e.target.value),
|
|
106
|
-
onBlur,
|
|
107
|
-
onFocus,
|
|
108
|
-
onKeyDown,
|
|
109
|
-
"aria-label": ariaLabel,
|
|
110
|
-
"aria-labelledby": ariaLabelledBy,
|
|
111
|
-
"aria-describedby": mergeAriaIds(ariaDescribedBy, helperId),
|
|
112
|
-
className: inputClasses,
|
|
113
|
-
style: inputStyle,
|
|
128
|
+
...sharedInputProps,
|
|
114
129
|
render: /* @__PURE__ */ jsx("input", {})
|
|
115
130
|
}
|
|
116
131
|
);
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
132
|
+
const fieldlessInputElement = /* @__PURE__ */ jsx(
|
|
133
|
+
"input",
|
|
134
|
+
{
|
|
135
|
+
...sharedInputProps,
|
|
136
|
+
"aria-invalid": error || void 0
|
|
137
|
+
}
|
|
138
|
+
);
|
|
139
|
+
const content = shortcut ? /* @__PURE__ */ jsxs("div", { className: styles.inputContainer, children: [
|
|
140
|
+
withFieldWrapper ? inputElement : fieldlessInputElement,
|
|
141
|
+
/* @__PURE__ */ jsx("kbd", { className: styles.shortcut, children: shortcut })
|
|
142
|
+
] }) : withFieldWrapper ? inputElement : fieldlessInputElement;
|
|
143
|
+
if (!withFieldWrapper) {
|
|
144
|
+
return /* @__PURE__ */ jsxs(
|
|
145
|
+
"div",
|
|
146
|
+
{
|
|
147
|
+
...rootProps,
|
|
148
|
+
className: [styles.wrapper, rootProps == null ? void 0 : rootProps.className, className].filter(Boolean).join(" "),
|
|
149
|
+
style: { ...(rootProps == null ? void 0 : rootProps.style) ?? {}, ...style ?? {} },
|
|
150
|
+
children: [
|
|
151
|
+
label && /* @__PURE__ */ jsx("label", { htmlFor: resolvedInputId, className: labelClasses, children: label }),
|
|
152
|
+
content,
|
|
153
|
+
helperText && /* @__PURE__ */ jsx("div", { id: helperId, className: helperClasses, children: helperText })
|
|
154
|
+
]
|
|
155
|
+
}
|
|
156
|
+
);
|
|
157
|
+
}
|
|
158
|
+
return /* @__PURE__ */ jsxs(
|
|
159
|
+
Field.Root,
|
|
160
|
+
{
|
|
161
|
+
...rootProps,
|
|
162
|
+
disabled,
|
|
163
|
+
invalid: error,
|
|
164
|
+
className: [wrapperClasses, rootProps == null ? void 0 : rootProps.className].filter(Boolean).join(" "),
|
|
165
|
+
style: { ...(rootProps == null ? void 0 : rootProps.style) ?? {}, ...style ?? {} },
|
|
166
|
+
children: [
|
|
167
|
+
label && /* @__PURE__ */ jsx(Field.Label, { className: labelClasses, children: label }),
|
|
168
|
+
content,
|
|
169
|
+
helperText && /* @__PURE__ */ jsx(Field.Description, { id: helperId, className: helperClasses, children: helperText })
|
|
170
|
+
]
|
|
171
|
+
}
|
|
172
|
+
);
|
|
125
173
|
}
|
|
126
174
|
);
|
|
127
175
|
const Input = Object.assign(InputRoot, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/components/Input/index.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { Field } from '@base-ui/react/field';\nimport styles from './Input.module.scss';\n\n/**\n * Text input field with label, helper text, and validation.\n * @see https://usefragments.com/components/input\n */\nexport interface InputProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'onChange' | 'onBlur' | 'onFocus' | 'onKeyDown' | 'defaultValue'> {\n /** Controlled input value */\n value?: string;\n /** Default value for uncontrolled usage */\n defaultValue?: string;\n /** Placeholder text shown when empty */\n placeholder?: string;\n /** HTML input type */\n type?: 'text' | 'email' | 'password' | 'number' | 'tel' | 'url';\n /** Input size.\n * @default \"md\"\n * @see https://usefragments.com/components/input#sizes */\n size?: 'sm' | 'md' | 'lg';\n /** Whether the input is non-interactive */\n disabled?: boolean;\n /** Show error styling */\n error?: boolean;\n /** Visible label text */\n label?: string;\n /** Helper text shown below the input */\n helperText?: string;\n /** Keyboard shortcut hint displayed inside the input (e.g., \"⌘K\"). Also registers a global keydown listener that focuses the input when the shortcut is pressed. */\n shortcut?: string;\n onChange?: (value: string) => void;\n onBlur?: () => void;\n onFocus?: () => void;\n onKeyDown?: (e: React.KeyboardEvent<HTMLInputElement>) => void;\n /** Styles applied directly to the input element */\n inputStyle?: React.CSSProperties;\n /** Class applied directly to the input element */\n inputClassName?: string;\n name?: string;\n}\n\nfunction mergeAriaIds(...ids: Array<string | undefined>): string | undefined {\n const merged = ids.filter(Boolean).join(' ').trim();\n return merged.length > 0 ? merged : undefined;\n}\n\nfunction parseShortcut(shortcut: string): { meta: boolean; shift: boolean; alt: boolean; key: string } | null {\n let meta = false, shift = false, alt = false;\n let remaining = shortcut;\n\n if (remaining.includes('⌘')) { meta = true; remaining = remaining.replace('⌘', ''); }\n if (remaining.includes('⇧')) { shift = true; remaining = remaining.replace('⇧', ''); }\n if (remaining.includes('⌥')) { alt = true; remaining = remaining.replace('⌥', ''); }\n\n remaining = remaining.trim();\n if (!remaining) return null;\n\n return { meta, shift, alt, key: remaining };\n}\n\nconst InputRoot = React.forwardRef<HTMLInputElement, InputProps>(\n function Input(\n {\n value,\n defaultValue,\n placeholder,\n type = 'text',\n size = 'md',\n disabled = false,\n error = false,\n label,\n helperText,\n shortcut,\n onChange,\n onBlur,\n onFocus,\n onKeyDown,\n className,\n style,\n inputStyle,\n inputClassName,\n name,\n id,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n 'aria-describedby': ariaDescribedBy,\n ...htmlProps\n },\n ref\n ) {\n const generatedId = React.useId();\n const helperId = helperText ? `input-helper-${generatedId}` : undefined;\n\n const internalRef = React.useRef<HTMLInputElement>(null);\n const mergedRef = React.useCallback(\n (node: HTMLInputElement | null) => {\n internalRef.current = node;\n if (typeof ref === 'function') {\n ref(node);\n } else if (ref) {\n (ref as React.MutableRefObject<HTMLInputElement | null>).current = node;\n }\n },\n [ref]\n );\n\n // Register global keydown handler when shortcut is provided\n React.useEffect(() => {\n if (!shortcut) return;\n const parsed = parseShortcut(shortcut);\n if (!parsed) return;\n\n const handler = (e: KeyboardEvent) => {\n if (parsed.meta && !(e.metaKey || e.ctrlKey)) return;\n if (parsed.shift && !e.shiftKey) return;\n if (parsed.alt && !e.altKey) return;\n if (e.key.toLowerCase() !== parsed.key.toLowerCase()) return;\n e.preventDefault();\n internalRef.current?.focus();\n };\n document.addEventListener('keydown', handler);\n return () => document.removeEventListener('keydown', handler);\n }, [shortcut]);\n\n const inputClasses = [\n styles.input,\n styles[size],\n error && styles.error,\n shortcut && styles.hasShortcut,\n inputClassName,\n ]\n .filter(Boolean)\n .join(' ');\n\n const helperClasses = [styles.helper, error && styles.helperError]\n .filter(Boolean)\n .join(' ');\n\n const wrapperClasses = [styles.wrapper, className].filter(Boolean).join(' ');\n const labelClasses = [styles.label, size === 'sm' && styles.labelSm].filter(Boolean).join(' ');\n\n const inputElement = (\n <Field.Control\n ref={mergedRef}\n type={type}\n value={value}\n defaultValue={defaultValue}\n placeholder={placeholder}\n name={name}\n id={id}\n onChange={(e: React.ChangeEvent<HTMLInputElement>) =>\n onChange?.(e.target.value)\n }\n onBlur={onBlur}\n onFocus={onFocus}\n onKeyDown={onKeyDown}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy}\n aria-describedby={mergeAriaIds(ariaDescribedBy, helperId)}\n className={inputClasses}\n style={inputStyle}\n render={<input />}\n />\n );\n\n return (\n <Field.Root {...htmlProps} disabled={disabled} invalid={error} className={wrapperClasses} style={style}>\n {label && <Field.Label className={labelClasses}>{label}</Field.Label>}\n {shortcut ? (\n <div className={styles.inputContainer}>\n {inputElement}\n <kbd className={styles.shortcut}>{shortcut}</kbd>\n </div>\n ) : (\n inputElement\n )}\n {helperText && (\n <Field.Description id={helperId} className={helperClasses}>\n {helperText}\n </Field.Description>\n )}\n </Field.Root>\n );\n }\n);\n\nexport const Input = Object.assign(InputRoot, {\n Root: InputRoot,\n});\n"],"names":["Input"],"mappings":";;;;AA4CA,SAAS,gBAAgB,KAAoD;AAC3E,QAAM,SAAS,IAAI,OAAO,OAAO,EAAE,KAAK,GAAG,EAAE,KAAA;AAC7C,SAAO,OAAO,SAAS,IAAI,SAAS;AACtC;AAEA,SAAS,cAAc,UAAuF;AAC5G,MAAI,OAAO,OAAO,QAAQ,OAAO,MAAM;AACvC,MAAI,YAAY;AAEhB,MAAI,UAAU,SAAS,GAAG,GAAG;AAAE,WAAO;AAAM,gBAAY,UAAU,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gBAAgB,OACvF,UAAA;AAAA,MAAA,6BAAU,MAAM,OAAN,EAAY,WAAW,cAAe,UAAA,OAAM;AAAA,MACtD,WACC,qBAAC,OAAA,EAAI,WAAW,OAAO,gBACpB,UAAA;AAAA,QAAA;AAAA,QACD,oBAAC,OAAA,EAAI,WAAW,OAAO,UAAW,UAAA,SAAA,CAAS;AAAA,MAAA,EAAA,CAC7C,IAEA;AAAA,MAED,kCACE,MAAM,aAAN,EAAkB,IAAI,UAAU,WAAW,eACzC,UAAA,WAAA,CACH;AAAA,IAAA,GAEJ;AAAA,EAEJ;AACF;AAEO,MAAM,QAAQ,OAAO,OAAO,WAAW;AAAA,EAC5C,MAAM;AACR,CAAC;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/components/Input/index.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { Field } from '@base-ui/react/field';\nimport styles from './Input.module.scss';\n\n/**\n * Text input field with label, helper text, and validation.\n * @see https://usefragments.com/components/input\n */\nexport interface InputProps extends Omit<\n React.InputHTMLAttributes<HTMLInputElement>,\n 'size' | 'onChange' | 'onBlur' | 'onFocus' | 'onKeyDown' | 'className' | 'style'\n> {\n /** Controlled input value */\n value?: string;\n /** Default value for uncontrolled usage */\n defaultValue?: string;\n /** Placeholder text shown when empty */\n placeholder?: string;\n /** HTML input type */\n type?: 'text' | 'email' | 'password' | 'number' | 'tel' | 'url';\n /** Input size.\n * @default \"md\"\n * @see https://usefragments.com/components/input#sizes */\n size?: 'sm' | 'md' | 'lg';\n /** Whether the input is non-interactive */\n disabled?: boolean;\n /** Show error styling */\n error?: boolean;\n /** Visible label text */\n label?: string;\n /** Helper text shown below the input */\n helperText?: string;\n /** Keyboard shortcut hint displayed inside the input (e.g., \"⌘K\"). */\n shortcut?: string;\n /** Whether the shortcut should also register a global focus hotkey.\n * @default \"display-only\" */\n shortcutBehavior?: 'display-only' | 'focus-input';\n /** Called when value changes (string value) */\n onChange?: (value: string) => void;\n /** Alias for onChange (value-first callback) */\n onValueChange?: (value: string) => void;\n onBlur?: () => void;\n onFocus?: () => void;\n onKeyDown?: (e: React.KeyboardEvent<HTMLInputElement>) => void;\n /** Props applied to the wrapper element */\n rootProps?: React.HTMLAttributes<HTMLDivElement>;\n /** Styles applied directly to the input element */\n inputStyle?: React.CSSProperties;\n /** Class applied directly to the input element */\n inputClassName?: string;\n /** Whether to render the Base UI Field wrapper (label/description/invalid wiring)\n * @default true */\n withFieldWrapper?: boolean;\n /** Wrapper class name */\n className?: string;\n /** Wrapper styles */\n style?: React.CSSProperties;\n}\n\nfunction mergeAriaIds(...ids: Array<string | undefined>): string | undefined {\n const merged = ids.filter(Boolean).join(' ').trim();\n return merged.length > 0 ? merged : undefined;\n}\n\nfunction parseShortcut(shortcut: string): { meta: boolean; shift: boolean; alt: boolean; key: string } | null {\n let meta = false, shift = false, alt = false;\n let remaining = shortcut;\n\n if (remaining.includes('⌘')) { meta = true; remaining = remaining.replace('⌘', ''); }\n if (remaining.includes('⇧')) { shift = true; remaining = remaining.replace('⇧', ''); }\n if (remaining.includes('⌥')) { alt = true; remaining = remaining.replace('⌥', ''); }\n\n remaining = remaining.trim();\n if (!remaining) return null;\n\n return { meta, shift, alt, key: remaining };\n}\n\nconst InputRoot = React.forwardRef<HTMLInputElement, InputProps>(\n function Input(\n {\n value,\n defaultValue,\n placeholder,\n type = 'text',\n size = 'md',\n disabled = false,\n error = false,\n label,\n helperText,\n shortcut,\n shortcutBehavior = 'display-only',\n onChange,\n onValueChange,\n onBlur,\n onFocus,\n onKeyDown,\n rootProps,\n className,\n style,\n inputStyle,\n inputClassName,\n withFieldWrapper = true,\n ...inputProps\n },\n ref\n ) {\n const generatedId = React.useId();\n const helperId = helperText ? `input-helper-${generatedId}` : undefined;\n const {\n id,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n 'aria-describedby': ariaDescribedBy,\n ...nativeInputProps\n } = inputProps;\n const resolvedInputId = id ?? `input-${generatedId}`;\n\n const internalRef = React.useRef<HTMLInputElement>(null);\n const mergedRef = React.useCallback(\n (node: HTMLInputElement | null) => {\n internalRef.current = node;\n if (typeof ref === 'function') {\n ref(node);\n } else if (ref) {\n (ref as React.MutableRefObject<HTMLInputElement | null>).current = node;\n }\n },\n [ref]\n );\n\n // Register global keydown handler when shortcut is provided\n React.useEffect(() => {\n if (!shortcut) return;\n if (shortcutBehavior !== 'focus-input') return;\n const parsed = parseShortcut(shortcut);\n if (!parsed) return;\n\n const handler = (e: KeyboardEvent) => {\n if (parsed.meta && !(e.metaKey || e.ctrlKey)) return;\n if (parsed.shift && !e.shiftKey) return;\n if (parsed.alt && !e.altKey) return;\n if (e.key.toLowerCase() !== parsed.key.toLowerCase()) return;\n e.preventDefault();\n internalRef.current?.focus();\n };\n document.addEventListener('keydown', handler);\n return () => document.removeEventListener('keydown', handler);\n }, [shortcut, shortcutBehavior]);\n\n const inputClasses = [\n styles.input,\n styles[size],\n error && styles.error,\n shortcut && styles.hasShortcut,\n inputClassName,\n ]\n .filter(Boolean)\n .join(' ');\n\n const helperClasses = [styles.helper, error && styles.helperError]\n .filter(Boolean)\n .join(' ');\n\n const wrapperClasses = [styles.wrapper, className].filter(Boolean).join(' ');\n const labelClasses = [styles.label, size === 'sm' && styles.labelSm].filter(Boolean).join(' ');\n\n const sharedInputProps = {\n ...nativeInputProps,\n ref: mergedRef,\n id: resolvedInputId,\n type,\n value,\n defaultValue,\n placeholder,\n disabled,\n onChange: (e: React.ChangeEvent<HTMLInputElement>) => {\n onChange?.(e.target.value);\n onValueChange?.(e.target.value);\n },\n onBlur: () => onBlur?.(),\n onFocus: () => onFocus?.(),\n onKeyDown: (e: React.KeyboardEvent<HTMLInputElement>) => onKeyDown?.(e),\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n 'aria-describedby': mergeAriaIds(ariaDescribedBy, helperId),\n className: inputClasses,\n style: inputStyle,\n } satisfies React.InputHTMLAttributes<HTMLInputElement> & {\n ref: React.Ref<HTMLInputElement>;\n };\n\n const inputElement = (\n <Field.Control\n {...sharedInputProps}\n render={<input />}\n />\n );\n\n const fieldlessInputElement = (\n <input\n {...sharedInputProps}\n aria-invalid={error || undefined}\n />\n );\n\n const content = shortcut ? (\n <div className={styles.inputContainer}>\n {withFieldWrapper ? inputElement : fieldlessInputElement}\n <kbd className={styles.shortcut}>{shortcut}</kbd>\n </div>\n ) : (\n withFieldWrapper ? inputElement : fieldlessInputElement\n );\n\n if (!withFieldWrapper) {\n return (\n <div\n {...rootProps}\n className={[styles.wrapper, rootProps?.className, className].filter(Boolean).join(' ')}\n style={{ ...(rootProps?.style ?? {}), ...(style ?? {}) }}\n >\n {label && <label htmlFor={resolvedInputId} className={labelClasses}>{label}</label>}\n {content}\n {helperText && (\n <div id={helperId} className={helperClasses}>\n {helperText}\n </div>\n )}\n </div>\n );\n }\n\n return (\n <Field.Root\n {...rootProps}\n disabled={disabled}\n invalid={error}\n className={[wrapperClasses, rootProps?.className].filter(Boolean).join(' ')}\n style={{ ...(rootProps?.style ?? {}), ...(style ?? {}) }}\n >\n {label && <Field.Label className={labelClasses}>{label}</Field.Label>}\n {content}\n {helperText && (\n <Field.Description id={helperId} className={helperClasses}>\n {helperText}\n </Field.Description>\n )}\n </Field.Root>\n );\n }\n);\n\nexport const Input = Object.assign(InputRoot, {\n Root: InputRoot,\n});\n"],"names":["Input"],"mappings":";;;;AA6DA,SAAS,gBAAgB,KAAoD;AAC3E,QAAM,SAAS,IAAI,OAAO,OAAO,EAAE,KAAK,GAAG,EAAE,KAAA;AAC7C,SAAO,OAAO,SAAS,IAAI,SAAS;AACtC;AAEA,SAAS,cAAc,UAAuF;AAC5G,MAAI,OAAO,OAAO,QAAQ,OAAO,MAAM;AACvC,MAAI,YAAY;AAEhB,MAAI,UAAU,SAAS,GAAG,GAAG;AAAE,WAAO;AAAM,gBAAY,UAAU,QAAQ,KAAK,EAAE;AAAA,EAAG;AACpF,MAAI,UAAU,SAAS,GAAG,GAAG;AAAE,Y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EnD,UAAA;AAAA,UAAA,6BAAU,MAAM,OAAN,EAAY,WAAW,cAAe,UAAA,OAAM;AAAA,UACtD;AAAA,UACA,kCACE,MAAM,aAAN,EAAkB,IAAI,UAAU,WAAW,eACzC,UAAA,WAAA,CACH;AAAA,QAAA;AAAA,MAAA;AAAA,IAAA;AAAA,EAIR;AACF;AAEO,MAAM,QAAQ,OAAO,OAAO,WAAW;AAAA,EAC5C,MAAM;AACR,CAAC;"}
|
|
@@ -20,6 +20,14 @@ function _interopNamespaceDefault(e) {
|
|
|
20
20
|
return Object.freeze(n);
|
|
21
21
|
}
|
|
22
22
|
const React__namespace = /* @__PURE__ */ _interopNamespaceDefault(React);
|
|
23
|
+
function composeEventHandlers(childHandler, parentHandler) {
|
|
24
|
+
if (!childHandler) return parentHandler;
|
|
25
|
+
if (!parentHandler) return childHandler;
|
|
26
|
+
return ((...args) => {
|
|
27
|
+
childHandler(...args);
|
|
28
|
+
parentHandler(...args);
|
|
29
|
+
});
|
|
30
|
+
}
|
|
23
31
|
const LinkRoot = React__namespace.forwardRef(
|
|
24
32
|
function Link2({
|
|
25
33
|
children,
|
|
@@ -52,6 +60,15 @@ const LinkRoot = React__namespace.forwardRef(
|
|
|
52
60
|
...externalProps,
|
|
53
61
|
...props
|
|
54
62
|
};
|
|
63
|
+
for (const [key, parentValue] of Object.entries({ ...externalProps, ...props })) {
|
|
64
|
+
if (!key.startsWith("on") || typeof parentValue !== "function") continue;
|
|
65
|
+
const childValue = childProps[key];
|
|
66
|
+
if (typeof childValue !== "function") continue;
|
|
67
|
+
mergedProps[key] = composeEventHandlers(
|
|
68
|
+
childValue,
|
|
69
|
+
parentValue
|
|
70
|
+
);
|
|
71
|
+
}
|
|
55
72
|
return React__namespace.cloneElement(children, mergedProps);
|
|
56
73
|
}
|
|
57
74
|
return /* @__PURE__ */ jsxRuntime.jsx("a", { ref, className: classes, style, ...externalProps, ...props, children });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../../../src/components/Link/index.tsx"],"sourcesContent":["import * as React from 'react';\nimport styles from './Link.module.scss';\n\nexport interface LinkProps extends React.AnchorHTMLAttributes<HTMLAnchorElement> {\n children: React.ReactNode;\n /** Visual variant */\n variant?: 'default' | 'subtle' | 'muted';\n /** Underline style */\n underline?: 'always' | 'hover' | 'none';\n /** Open in new tab (adds rel=\"noopener noreferrer\") */\n external?: boolean;\n /**\n * Render as child element (polymorphic). When true, clones the single child\n * and merges link props onto it. Useful for rendering as Next.js Link, etc.\n */\n asChild?: boolean;\n /** Additional class name */\n className?: string;\n /** Inline styles */\n style?: React.CSSProperties;\n}\n\nconst LinkRoot = React.forwardRef<HTMLAnchorElement, LinkProps>(\n function Link(\n {\n children,\n variant = 'default',\n underline = 'hover',\n external = false,\n asChild = false,\n className,\n style,\n target,\n rel,\n ...props\n },\n ref\n ) {\n const classes = [\n styles.link,\n styles[variant],\n styles[`underline-${underline}`],\n className,\n ]\n .filter(Boolean)\n .join(' ');\n\n // Handle external links\n const externalProps = external\n ? {\n target: target || '_blank',\n rel: rel || 'noopener noreferrer',\n }\n : { target, rel };\n\n if (asChild && React.isValidElement(children)) {\n const childProps = children.props as Record<string, unknown>;\n const mergedProps: Record<string, unknown> = {\n ref,\n className: childProps.className\n ? `${classes} ${childProps.className}`\n : classes,\n style: { ...style, ...(childProps.style as React.CSSProperties | undefined) },\n ...externalProps,\n ...props,\n };\n return React.cloneElement(children, mergedProps);\n }\n\n return (\n <a ref={ref} className={classes} style={style} {...externalProps} {...props}>\n {children}\n </a>\n );\n }\n);\n\nexport const Link = Object.assign(LinkRoot, {\n Root: LinkRoot,\n});\n"],"names":["React","Link","styles","jsx"],"mappings":";;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../../src/components/Link/index.tsx"],"sourcesContent":["import * as React from 'react';\nimport styles from './Link.module.scss';\n\nfunction composeEventHandlers<T extends (...args: any[]) => void>(\n childHandler: T | undefined,\n parentHandler: T | undefined\n) {\n if (!childHandler) return parentHandler;\n if (!parentHandler) return childHandler;\n return ((...args: Parameters<T>) => {\n childHandler(...args);\n parentHandler(...args);\n }) as T;\n}\n\nexport interface LinkProps extends React.AnchorHTMLAttributes<HTMLAnchorElement> {\n children: React.ReactNode;\n /** Visual variant */\n variant?: 'default' | 'subtle' | 'muted';\n /** Underline style */\n underline?: 'always' | 'hover' | 'none';\n /** Open in new tab (adds rel=\"noopener noreferrer\") */\n external?: boolean;\n /**\n * Render as child element (polymorphic). When true, clones the single child\n * and merges link props onto it. Useful for rendering as Next.js Link, etc.\n */\n asChild?: boolean;\n /** Additional class name */\n className?: string;\n /** Inline styles */\n style?: React.CSSProperties;\n}\n\nconst LinkRoot = React.forwardRef<HTMLAnchorElement, LinkProps>(\n function Link(\n {\n children,\n variant = 'default',\n underline = 'hover',\n external = false,\n asChild = false,\n className,\n style,\n target,\n rel,\n ...props\n },\n ref\n ) {\n const classes = [\n styles.link,\n styles[variant],\n styles[`underline-${underline}`],\n className,\n ]\n .filter(Boolean)\n .join(' ');\n\n // Handle external links\n const externalProps = external\n ? {\n target: target || '_blank',\n rel: rel || 'noopener noreferrer',\n }\n : { target, rel };\n\n if (asChild && React.isValidElement(children)) {\n const childProps = children.props as Record<string, unknown>;\n const mergedProps: Record<string, unknown> = {\n ref,\n className: childProps.className\n ? `${classes} ${childProps.className}`\n : classes,\n style: { ...style, ...(childProps.style as React.CSSProperties | undefined) },\n ...externalProps,\n ...props,\n };\n\n for (const [key, parentValue] of Object.entries({ ...externalProps, ...props })) {\n if (!key.startsWith('on') || typeof parentValue !== 'function') continue;\n const childValue = childProps[key];\n if (typeof childValue !== 'function') continue;\n mergedProps[key] = composeEventHandlers(\n childValue as (...args: unknown[]) => void,\n parentValue as (...args: unknown[]) => void\n );\n }\n return React.cloneElement(children, mergedProps);\n }\n\n return (\n <a ref={ref} className={classes} style={style} {...externalProps} {...props}>\n {children}\n </a>\n );\n }\n);\n\nexport const Link = Object.assign(Lin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AAI,OAAO,eAAe,WAAY;AACtC,oBAAY,GAAG,IAAI;AAAA,UACjB;AAAA,UACA;AAAA,QAAA;AAAA,MAEJ;AACA,aAAOA,iBAAM,aAAa,UAAU,WAAW;AAAA,IACjD;AAEA,WACEG,+BAAC,KAAA,EAAE,KAAU,WAAW,SAAS,OAAe,GAAG,eAAgB,GAAG,OACnE,SAAA,CACH;AAAA,EAEJ;AACF;AAEO,MAAM,OAAO,OAAO,OAAO,UAAU;AAAA,EAC1C,MAAM;AACR,CAAC;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Link/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Link/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAe/B,MAAM,WAAW,SAAU,SAAQ,KAAK,CAAC,oBAAoB,CAAC,iBAAiB,CAAC;IAC9E,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,qBAAqB;IACrB,OAAO,CAAC,EAAE,SAAS,GAAG,QAAQ,GAAG,OAAO,CAAC;IACzC,sBAAsB;IACtB,SAAS,CAAC,EAAE,QAAQ,GAAG,OAAO,GAAG,MAAM,CAAC;IACxC,uDAAuD;IACvD,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,4BAA4B;IAC5B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,oBAAoB;IACpB,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;CAC7B;AAmED,eAAO,MAAM,IAAI;;CAEf,CAAC"}
|
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import * as React from "react";
|
|
3
3
|
import styles from "./Link.module.scss.js";
|
|
4
|
+
function composeEventHandlers(childHandler, parentHandler) {
|
|
5
|
+
if (!childHandler) return parentHandler;
|
|
6
|
+
if (!parentHandler) return childHandler;
|
|
7
|
+
return ((...args) => {
|
|
8
|
+
childHandler(...args);
|
|
9
|
+
parentHandler(...args);
|
|
10
|
+
});
|
|
11
|
+
}
|
|
4
12
|
const LinkRoot = React.forwardRef(
|
|
5
13
|
function Link2({
|
|
6
14
|
children,
|
|
@@ -33,6 +41,15 @@ const LinkRoot = React.forwardRef(
|
|
|
33
41
|
...externalProps,
|
|
34
42
|
...props
|
|
35
43
|
};
|
|
44
|
+
for (const [key, parentValue] of Object.entries({ ...externalProps, ...props })) {
|
|
45
|
+
if (!key.startsWith("on") || typeof parentValue !== "function") continue;
|
|
46
|
+
const childValue = childProps[key];
|
|
47
|
+
if (typeof childValue !== "function") continue;
|
|
48
|
+
mergedProps[key] = composeEventHandlers(
|
|
49
|
+
childValue,
|
|
50
|
+
parentValue
|
|
51
|
+
);
|
|
52
|
+
}
|
|
36
53
|
return React.cloneElement(children, mergedProps);
|
|
37
54
|
}
|
|
38
55
|
return /* @__PURE__ */ jsx("a", { ref, className: classes, style, ...externalProps, ...props, children });
|