@commercetools/nimbus-mcp 3.2.0 → 3.3.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/README.md +9 -1
- package/data/docs/route-manifest.json +806 -41
- package/data/docs/routes/components-buttons-button.json +25 -2
- package/data/docs/routes/components-chat-chat-message-list.json +448 -0
- package/data/docs/routes/components-chat-chat-message.json +580 -0
- package/data/docs/routes/components-content-markdown.json +548 -0
- package/data/docs/routes/components-feedback-activity-indicator.json +396 -0
- package/data/docs/routes/components-feedback-tooltip.json +23 -1
- package/data/docs/routes/components-inputs-drop-zone.json +562 -0
- package/data/docs/routes/components-inputs-file-trigger.json +421 -0
- package/data/docs/routes/components-layout-splitter.json +3 -3
- package/data/docs/routes/components-media-avatar.json +16 -5
- package/data/docs/routes/components-navigation-menu.json +1 -1
- package/data/docs/routes/components-navigation-tabnav.json +80 -14
- package/data/docs/routes/components-navigation-tabs.json +44 -11
- package/data/docs/routes/components-navigation-tree.json +445 -0
- package/data/docs/routes/home-getting-started-mcp-server-overview.json +2 -2
- package/data/docs/routes/home-getting-started-mcp-server-setup.json +2 -2
- package/data/docs/routes/patterns-buttons-floating-action-button.json +392 -0
- package/data/docs/routes/patterns-buttons.json +58 -0
- package/data/docs/search-index.json +1 -1
- package/data/docs/types/AccordionContent.json +24 -24
- package/data/docs/types/AccordionHeader.json +88 -88
- package/data/docs/types/AccordionItem.json +20 -20
- package/data/docs/types/AccordionRoot.json +14 -14
- package/data/docs/types/ActivityIndicator.json +202 -0
- package/data/docs/types/AlertDescription.json +8 -8
- package/data/docs/types/AlertDismissButton.json +98 -81
- package/data/docs/types/AlertTitle.json +8 -8
- package/data/docs/types/Avatar.json +19 -2
- package/data/docs/types/Badge.json +2 -2
- package/data/docs/types/Body.json +6 -6
- package/data/docs/types/Box.json +6 -6
- package/data/docs/types/Button.json +106 -89
- package/data/docs/types/Calendar.json +56 -56
- package/data/docs/types/Caption.json +6 -6
- package/data/docs/types/CardRoot.json +2 -2
- package/data/docs/types/Cell.json +6 -6
- package/data/docs/types/ChatMessage.json +12 -0
- package/data/docs/types/ChatMessageActions.json +42 -0
- package/data/docs/types/ChatMessageAvatar.json +140 -0
- package/data/docs/types/ChatMessageBody.json +42 -0
- package/data/docs/types/ChatMessageList.json +12 -0
- package/data/docs/types/ChatMessageListItem.json +42 -0
- package/data/docs/types/ChatMessageListRoot.json +78 -0
- package/data/docs/types/ChatMessageMeta.json +42 -0
- package/data/docs/types/ChatMessageRoot.json +119 -0
- package/data/docs/types/ChatMessageTyping.json +42 -0
- package/data/docs/types/Checkbox.json +86 -86
- package/data/docs/types/Code.json +11 -11
- package/data/docs/types/Column.json +6 -6
- package/data/docs/types/ColumnGroup.json +6 -6
- package/data/docs/types/ColumnHeader.json +6 -6
- package/data/docs/types/ComboBoxListBox.json +70 -70
- package/data/docs/types/ComboBoxOption.json +64 -64
- package/data/docs/types/ComboBoxPopover.json +91 -70
- package/data/docs/types/ComboBoxRoot.json +8 -8
- package/data/docs/types/ComboBoxSection.json +24 -24
- package/data/docs/types/ComboBoxTrigger.json +6 -6
- package/data/docs/types/DataTable.json +2 -2
- package/data/docs/types/DataTableBody.json +20 -20
- package/data/docs/types/DataTableHeader.json +25 -25
- package/data/docs/types/DataTableRoot.json +2 -2
- package/data/docs/types/DataTableTable.json +6 -6
- package/data/docs/types/DateInput.json +73 -73
- package/data/docs/types/DatePicker.json +58 -58
- package/data/docs/types/DateRangePicker.json +86 -86
- package/data/docs/types/DateRangePickerField.json +86 -86
- package/data/docs/types/DefaultPageRoot.json +2 -2
- package/data/docs/types/DialogCloseTrigger.json +96 -79
- package/data/docs/types/DraggableListField.json +88 -60
- package/data/docs/types/DraggableListItem.json +52 -52
- package/data/docs/types/DraggableListRoot.json +88 -60
- package/data/docs/types/DrawerCloseTrigger.json +96 -79
- package/data/docs/types/DropZone.json +161 -0
- package/data/docs/types/FieldErrors.json +2 -2
- package/data/docs/types/FileTrigger.json +130 -0
- package/data/docs/types/Flex.json +22 -22
- package/data/docs/types/FloatingActionButton.json +1036 -0
- package/data/docs/types/Footer.json +6 -6
- package/data/docs/types/FormActionBar.json +1 -1
- package/data/docs/types/FormFieldRoot.json +2 -2
- package/data/docs/types/Grid.json +24 -24
- package/data/docs/types/Group.json +12 -12
- package/data/docs/types/Header.json +6 -6
- package/data/docs/types/Heading.json +8 -8
- package/data/docs/types/Icon.json +4 -4
- package/data/docs/types/IconButton.json +106 -89
- package/data/docs/types/IconToggleButton.json +71 -71
- package/data/docs/types/Image.json +43 -43
- package/data/docs/types/Indicator.json +6 -6
- package/data/docs/types/InlineSvg.json +2 -2
- package/data/docs/types/Item.json +6 -6
- package/data/docs/types/Kbd.json +8 -8
- package/data/docs/types/Link.json +14 -14
- package/data/docs/types/ListIndicator.json +6 -6
- package/data/docs/types/ListItem.json +6 -6
- package/data/docs/types/ListRoot.json +11 -11
- package/data/docs/types/LoadingSpinner.json +2 -2
- package/data/docs/types/MakeElementFocusable.json +18 -18
- package/data/docs/types/Markdown.json +183 -0
- package/data/docs/types/MenuItem.json +62 -62
- package/data/docs/types/MenuRoot.json +55 -55
- package/data/docs/types/MenuSection.json +30 -30
- package/data/docs/types/MenuSubmenuTrigger.json +4 -4
- package/data/docs/types/MenuTrigger.json +88 -88
- package/data/docs/types/MultilineTextInput.json +104 -104
- package/data/docs/types/MultilineTextInputField.json +102 -102
- package/data/docs/types/NumberInput.json +86 -86
- package/data/docs/types/NumberInputField.json +82 -82
- package/data/docs/types/PageContentColumn.json +6 -6
- package/data/docs/types/PageContentRoot.json +6 -6
- package/data/docs/types/PasswordInput.json +100 -100
- package/data/docs/types/PasswordInputField.json +100 -100
- package/data/docs/types/ProgressBar.json +13 -13
- package/data/docs/types/RadioInputOption.json +56 -56
- package/data/docs/types/RadioInputRoot.json +48 -48
- package/data/docs/types/RangeCalendar.json +58 -58
- package/data/docs/types/Region.json +6 -6
- package/data/docs/types/RegionTarget.json +6 -6
- package/data/docs/types/RichTextInput.json +2 -2
- package/data/docs/types/Root.json +11 -11
- package/data/docs/types/Row.json +6 -6
- package/data/docs/types/ScrollArea.json +2 -2
- package/data/docs/types/SearchInput.json +106 -106
- package/data/docs/types/SearchInputField.json +102 -102
- package/data/docs/types/SelectOption.json +54 -54
- package/data/docs/types/SelectOptionGroup.json +18 -18
- package/data/docs/types/SelectOptions.json +64 -64
- package/data/docs/types/SelectRoot.json +92 -92
- package/data/docs/types/Separator.json +4 -4
- package/data/docs/types/SimpleGrid.json +28 -28
- package/data/docs/types/SlidingIndicatorGeometry.json +9 -0
- package/data/docs/types/SlidingIndicatorRects.json +9 -0
- package/data/docs/types/SplitButton.json +16 -20
- package/data/docs/types/Stack.json +2 -2
- package/data/docs/types/StepsRoot.json +2 -2
- package/data/docs/types/Switch.json +34 -34
- package/data/docs/types/TabNavItem.json +5 -5
- package/data/docs/types/TabNavRoot.json +5 -5
- package/data/docs/types/TableBody.json +6 -6
- package/data/docs/types/TableCaption.json +6 -6
- package/data/docs/types/TableCell.json +6 -6
- package/data/docs/types/TableColumn.json +6 -6
- package/data/docs/types/TableColumnGroup.json +6 -6
- package/data/docs/types/TableColumnHeader.json +6 -6
- package/data/docs/types/TableFooter.json +6 -6
- package/data/docs/types/TableHeader.json +6 -6
- package/data/docs/types/TableRoot.json +19 -19
- package/data/docs/types/TableRow.json +6 -6
- package/data/docs/types/TableScrollArea.json +6 -6
- package/data/docs/types/TabsList.json +2 -2
- package/data/docs/types/TabsPanel.json +2 -2
- package/data/docs/types/TabsPanels.json +2 -2
- package/data/docs/types/TabsRoot.json +3 -3
- package/data/docs/types/TabsTab.json +2 -2
- package/data/docs/types/TagGroupRoot.json +24 -24
- package/data/docs/types/TagGroupTag.json +56 -56
- package/data/docs/types/TagGroupTagList.json +14 -14
- package/data/docs/types/Text.json +8 -8
- package/data/docs/types/TextInput.json +102 -102
- package/data/docs/types/TextInputField.json +100 -100
- package/data/docs/types/TimeInput.json +68 -68
- package/data/docs/types/ToggleButton.json +73 -73
- package/data/docs/types/ToggleButtonGroupButton.json +30 -30
- package/data/docs/types/ToggleButtonGroupRoot.json +20 -20
- package/data/docs/types/Toolbar.json +9 -9
- package/data/docs/types/TooltipContent.json +28 -28
- package/data/docs/types/TooltipRoot.json +16 -16
- package/data/docs/types/Tree.json +12 -0
- package/data/docs/types/TreeIndicator.json +828 -0
- package/data/docs/types/TreeItem.json +559 -0
- package/data/docs/types/TreeItemContent.json +27 -0
- package/data/docs/types/TreeRoot.json +636 -0
- package/data/docs/types/TreeSubTree.json +40 -0
- package/data/docs/types/VisuallyHidden.json +6 -6
- package/data/docs/types/createItemsFromCsvDrop.json +4 -4
- package/data/docs/types/createItemsFromDirectoryDrop.json +4 -4
- package/data/docs/types/createItemsFromFileDrop.json +4 -4
- package/data/docs/types/createItemsFromImageDrop.json +4 -4
- package/data/docs/types/createItemsFromJsonDrop.json +4 -4
- package/data/docs/types/manifest.json +25 -0
- package/data/docs/types/useRegion.json +2 -2
- package/data/docs/types/useSlidingIndicator.json +145 -0
- package/data/docs/types/useTree.json +267 -0
- package/data/tokens.json +21 -0
- package/data/uikit-tokens.json +894 -0
- package/dist/index.js +3298 -109
- package/package.json +8 -6
|
@@ -0,0 +1,421 @@
|
|
|
1
|
+
{
|
|
2
|
+
"meta": {
|
|
3
|
+
"id": "Components-FileTrigger",
|
|
4
|
+
"title": "File trigger",
|
|
5
|
+
"exportName": "FileTrigger",
|
|
6
|
+
"description": "Connects a pressable element such as a button to the native file picker, letting users select files without any custom styling of its own.",
|
|
7
|
+
"lifecycleState": "Experimental",
|
|
8
|
+
"order": 999,
|
|
9
|
+
"repoPath": "packages/nimbus/src/components/file-trigger/file-trigger.mdx",
|
|
10
|
+
"menu": [
|
|
11
|
+
"Components",
|
|
12
|
+
"Inputs",
|
|
13
|
+
"File trigger"
|
|
14
|
+
],
|
|
15
|
+
"route": "components/inputs/file-trigger",
|
|
16
|
+
"tags": [
|
|
17
|
+
"component",
|
|
18
|
+
"inputs",
|
|
19
|
+
"file",
|
|
20
|
+
"upload",
|
|
21
|
+
"chat"
|
|
22
|
+
],
|
|
23
|
+
"toc": [
|
|
24
|
+
{
|
|
25
|
+
"value": "Overview",
|
|
26
|
+
"href": "#overview",
|
|
27
|
+
"depth": 2,
|
|
28
|
+
"numbering": [
|
|
29
|
+
1,
|
|
30
|
+
1
|
|
31
|
+
],
|
|
32
|
+
"parent": "root"
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"value": "Resources",
|
|
36
|
+
"href": "#resources",
|
|
37
|
+
"depth": 3,
|
|
38
|
+
"numbering": [
|
|
39
|
+
1,
|
|
40
|
+
1,
|
|
41
|
+
1
|
|
42
|
+
],
|
|
43
|
+
"parent": "root"
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
"value": "Basic usage",
|
|
47
|
+
"href": "#basic-usage",
|
|
48
|
+
"depth": 2,
|
|
49
|
+
"numbering": [
|
|
50
|
+
1,
|
|
51
|
+
2
|
|
52
|
+
],
|
|
53
|
+
"parent": "root"
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
"value": "Variables",
|
|
57
|
+
"href": "#variables",
|
|
58
|
+
"depth": 2,
|
|
59
|
+
"numbering": [
|
|
60
|
+
1,
|
|
61
|
+
3
|
|
62
|
+
],
|
|
63
|
+
"parent": "root"
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
"value": "Accepted file types",
|
|
67
|
+
"href": "#accepted-file-types",
|
|
68
|
+
"depth": 3,
|
|
69
|
+
"numbering": [
|
|
70
|
+
1,
|
|
71
|
+
3,
|
|
72
|
+
1
|
|
73
|
+
],
|
|
74
|
+
"parent": "root"
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
"value": "Multiple files",
|
|
78
|
+
"href": "#multiple-files",
|
|
79
|
+
"depth": 3,
|
|
80
|
+
"numbering": [
|
|
81
|
+
1,
|
|
82
|
+
3,
|
|
83
|
+
2
|
|
84
|
+
],
|
|
85
|
+
"parent": "root"
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
"value": "Choose with any trigger",
|
|
89
|
+
"href": "#choose-with-any-trigger",
|
|
90
|
+
"depth": 3,
|
|
91
|
+
"numbering": [
|
|
92
|
+
1,
|
|
93
|
+
3,
|
|
94
|
+
3
|
|
95
|
+
],
|
|
96
|
+
"parent": "root"
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
"value": "Guidelines",
|
|
100
|
+
"href": "#guidelines",
|
|
101
|
+
"depth": 2,
|
|
102
|
+
"numbering": [
|
|
103
|
+
1,
|
|
104
|
+
4
|
|
105
|
+
],
|
|
106
|
+
"parent": "root"
|
|
107
|
+
}
|
|
108
|
+
],
|
|
109
|
+
"layout": "app-frame",
|
|
110
|
+
"tabs": [
|
|
111
|
+
{
|
|
112
|
+
"key": "overview",
|
|
113
|
+
"title": "Overview",
|
|
114
|
+
"order": 0
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
"key": "dev",
|
|
118
|
+
"title": "Implementation",
|
|
119
|
+
"order": 3
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
"key": "a11y",
|
|
123
|
+
"title": "Accessibility",
|
|
124
|
+
"order": 4
|
|
125
|
+
}
|
|
126
|
+
]
|
|
127
|
+
},
|
|
128
|
+
"mdx": "\n## Overview\n\n`FileTrigger` is a behavior-only building block: it wraps a pressable child —\nusually a `Button` — and opens the operating system's file picker when that\nchild is activated. It contributes no visual styling, so the appearance is\nentirely determined by the child you provide. This keeps file selection\nconsistent with the rest of the system while leaving the trigger's look up to\nyou.\n\nIt is the foundational piece for file-selection flows (for example, attaching\nfiles in chat) and pairs with richer surfaces such as drop zones.\n\n### Resources\n\nDeep dive into implementation details and access the Nimbus design library.\n\n[React Aria FileTrigger](https://react-aria.adobe.com/FileTrigger)\n\n## Basic usage\n\nWrap any pressable Nimbus component. The button below opens the file picker; the\nselection is reported to your `onSelect` handler.\n\n```jsx live\nconst App = () => {\n const [name, setName] = React.useState(\"\");\n return (\n <Stack direction=\"row\" gap=\"400\" alignItems=\"center\">\n <FileTrigger\n onSelect={(files) => {\n const list = files ? Array.from(files) : [];\n setName(list[0]?.name ?? \"\");\n }}\n >\n <Button>Upload file</Button>\n </FileTrigger>\n <Text>{name || \"No file selected\"}</Text>\n </Stack>\n );\n};\n```\n\n## Variables\n\nGet familiar with the features.\n\n### Accepted file types\n\nLimit selectable files by MIME type or extension.\n\n```jsx live\nconst App = () => (\n <FileTrigger acceptedFileTypes={[\"image/png\", \"image/jpeg\", \".pdf\"]}>\n <Button>Upload image or PDF</Button>\n </FileTrigger>\n);\n```\n\n### Multiple files\n\nAllow selecting more than one file at a time.\n\n```jsx live\nconst App = () => (\n <FileTrigger allowsMultiple>\n <Button>Upload files</Button>\n </FileTrigger>\n);\n```\n\n### Choose with any trigger\n\nBecause the child defines the look, you can use any pressable component — for\nexample an `IconButton`.\n\n```jsx live\nconst App = () => (\n <FileTrigger>\n <IconButton aria-label=\"Attach file\" variant=\"ghost\">\n <Icons.AttachFile />\n </IconButton>\n </FileTrigger>\n);\n```\n\n## Guidelines\n\n- Always give the child a clear, descriptive label — the trigger's accessible\n name comes entirely from the child.\n- Use a concrete verb such as \"Upload\" or \"Attach\" rather than a generic\n \"Choose\".\n- When you only need an icon, pair an `IconButton` with an `aria-label` (or a\n tooltip) so the action stays understandable.\n- Communicate accepted file types and size limits near the trigger so users know\n what to expect before opening the picker.\n",
|
|
129
|
+
"views": {
|
|
130
|
+
"overview": {
|
|
131
|
+
"mdx": "\n## Overview\n\n`FileTrigger` is a behavior-only building block: it wraps a pressable child —\nusually a `Button` — and opens the operating system's file picker when that\nchild is activated. It contributes no visual styling, so the appearance is\nentirely determined by the child you provide. This keeps file selection\nconsistent with the rest of the system while leaving the trigger's look up to\nyou.\n\nIt is the foundational piece for file-selection flows (for example, attaching\nfiles in chat) and pairs with richer surfaces such as drop zones.\n\n### Resources\n\nDeep dive into implementation details and access the Nimbus design library.\n\n[React Aria FileTrigger](https://react-aria.adobe.com/FileTrigger)\n\n## Basic usage\n\nWrap any pressable Nimbus component. The button below opens the file picker; the\nselection is reported to your `onSelect` handler.\n\n```jsx live\nconst App = () => {\n const [name, setName] = React.useState(\"\");\n return (\n <Stack direction=\"row\" gap=\"400\" alignItems=\"center\">\n <FileTrigger\n onSelect={(files) => {\n const list = files ? Array.from(files) : [];\n setName(list[0]?.name ?? \"\");\n }}\n >\n <Button>Upload file</Button>\n </FileTrigger>\n <Text>{name || \"No file selected\"}</Text>\n </Stack>\n );\n};\n```\n\n## Variables\n\nGet familiar with the features.\n\n### Accepted file types\n\nLimit selectable files by MIME type or extension.\n\n```jsx live\nconst App = () => (\n <FileTrigger acceptedFileTypes={[\"image/png\", \"image/jpeg\", \".pdf\"]}>\n <Button>Upload image or PDF</Button>\n </FileTrigger>\n);\n```\n\n### Multiple files\n\nAllow selecting more than one file at a time.\n\n```jsx live\nconst App = () => (\n <FileTrigger allowsMultiple>\n <Button>Upload files</Button>\n </FileTrigger>\n);\n```\n\n### Choose with any trigger\n\nBecause the child defines the look, you can use any pressable component — for\nexample an `IconButton`.\n\n```jsx live\nconst App = () => (\n <FileTrigger>\n <IconButton aria-label=\"Attach file\" variant=\"ghost\">\n <Icons.AttachFile />\n </IconButton>\n </FileTrigger>\n);\n```\n\n## Guidelines\n\n- Always give the child a clear, descriptive label — the trigger's accessible\n name comes entirely from the child.\n- Use a concrete verb such as \"Upload\" or \"Attach\" rather than a generic\n \"Choose\".\n- When you only need an icon, pair an `IconButton` with an `aria-label` (or a\n tooltip) so the action stays understandable.\n- Communicate accepted file types and size limits near the trigger so users know\n what to expect before opening the picker.\n",
|
|
132
|
+
"toc": [
|
|
133
|
+
{
|
|
134
|
+
"value": "Overview",
|
|
135
|
+
"href": "#overview",
|
|
136
|
+
"depth": 2,
|
|
137
|
+
"numbering": [
|
|
138
|
+
1,
|
|
139
|
+
1
|
|
140
|
+
],
|
|
141
|
+
"parent": "root"
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
"value": "Resources",
|
|
145
|
+
"href": "#resources",
|
|
146
|
+
"depth": 3,
|
|
147
|
+
"numbering": [
|
|
148
|
+
1,
|
|
149
|
+
1,
|
|
150
|
+
1
|
|
151
|
+
],
|
|
152
|
+
"parent": "root"
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
"value": "Basic usage",
|
|
156
|
+
"href": "#basic-usage",
|
|
157
|
+
"depth": 2,
|
|
158
|
+
"numbering": [
|
|
159
|
+
1,
|
|
160
|
+
2
|
|
161
|
+
],
|
|
162
|
+
"parent": "root"
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
"value": "Variables",
|
|
166
|
+
"href": "#variables",
|
|
167
|
+
"depth": 2,
|
|
168
|
+
"numbering": [
|
|
169
|
+
1,
|
|
170
|
+
3
|
|
171
|
+
],
|
|
172
|
+
"parent": "root"
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
"value": "Accepted file types",
|
|
176
|
+
"href": "#accepted-file-types",
|
|
177
|
+
"depth": 3,
|
|
178
|
+
"numbering": [
|
|
179
|
+
1,
|
|
180
|
+
3,
|
|
181
|
+
1
|
|
182
|
+
],
|
|
183
|
+
"parent": "root"
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
"value": "Multiple files",
|
|
187
|
+
"href": "#multiple-files",
|
|
188
|
+
"depth": 3,
|
|
189
|
+
"numbering": [
|
|
190
|
+
1,
|
|
191
|
+
3,
|
|
192
|
+
2
|
|
193
|
+
],
|
|
194
|
+
"parent": "root"
|
|
195
|
+
},
|
|
196
|
+
{
|
|
197
|
+
"value": "Choose with any trigger",
|
|
198
|
+
"href": "#choose-with-any-trigger",
|
|
199
|
+
"depth": 3,
|
|
200
|
+
"numbering": [
|
|
201
|
+
1,
|
|
202
|
+
3,
|
|
203
|
+
3
|
|
204
|
+
],
|
|
205
|
+
"parent": "root"
|
|
206
|
+
},
|
|
207
|
+
{
|
|
208
|
+
"value": "Guidelines",
|
|
209
|
+
"href": "#guidelines",
|
|
210
|
+
"depth": 2,
|
|
211
|
+
"numbering": [
|
|
212
|
+
1,
|
|
213
|
+
4
|
|
214
|
+
],
|
|
215
|
+
"parent": "root"
|
|
216
|
+
}
|
|
217
|
+
]
|
|
218
|
+
},
|
|
219
|
+
"a11y": {
|
|
220
|
+
"mdx": "\n## Accessibility\n\n`FileTrigger` delegates all interaction semantics to React Aria. The visible,\nfocusable child you provide is the only interactive element: it receives focus,\nis operable with mouse, touch, and keyboard (Enter / Space), and is announced to\nassistive technology. The underlying `<input type=\"file\">` is hidden with\n`display: none` and is clicked programmatically when the child is pressed, so it\nis not a separate tab stop and never competes with the child for focus.\n\n```jsx live\nconst App = () => (\n <FileTrigger onSelect={(files) => alert(`${files?.length ?? 0} file(s)`)}>\n <Button>Upload file</Button>\n </FileTrigger>\n);\n```\n\n### Accessibility standards\n\n- **Accessible name comes from the child:** `FileTrigger` adds no label of its\n own. Provide visible text, an `aria-label`, or a tooltip on the child so the\n action is clearly announced (e.g. \"Upload file\", \"Attach image\").\n- **Keyboard operability:** The trigger must be reachable with the Tab key and\n activatable with Enter or Space. Using a Nimbus `Button` or `IconButton` as\n the child satisfies this automatically.\n- **Focus indicator:** Ensure the child shows a clear focus ring; Nimbus\n buttons provide this by default.\n- **Icon-only triggers:** When the child is an `IconButton`, always supply an\n `aria-label` or a tooltip so the purpose is conveyed to screen reader users.\n- **Disabled state:** Disable the child (not `FileTrigger`) to prevent\n activation; the disabled state is then communicated to assistive technology by\n the child.\n- **Set expectations:** Communicate accepted file types, count, and size limits\n in nearby visible text, not only through the picker, so users understand\n constraints before opening the dialog.\n- **Target size:** Keep the trigger large enough to activate comfortably; follow\n the minimum target-size guidance for the chosen button size.\n",
|
|
221
|
+
"toc": [
|
|
222
|
+
{
|
|
223
|
+
"value": "Accessibility",
|
|
224
|
+
"href": "#accessibility",
|
|
225
|
+
"depth": 2,
|
|
226
|
+
"numbering": [
|
|
227
|
+
1,
|
|
228
|
+
1
|
|
229
|
+
],
|
|
230
|
+
"parent": "root"
|
|
231
|
+
},
|
|
232
|
+
{
|
|
233
|
+
"value": "Accessibility standards",
|
|
234
|
+
"href": "#accessibility-standards",
|
|
235
|
+
"depth": 3,
|
|
236
|
+
"numbering": [
|
|
237
|
+
1,
|
|
238
|
+
1,
|
|
239
|
+
1
|
|
240
|
+
],
|
|
241
|
+
"parent": "root"
|
|
242
|
+
}
|
|
243
|
+
]
|
|
244
|
+
},
|
|
245
|
+
"dev": {
|
|
246
|
+
"mdx": "\n## Getting started\n\n### Import\n\n```tsx\nimport { FileTrigger, type FileTriggerProps } from \"@commercetools/nimbus\";\n```\n\n### Basic usage\n\n`FileTrigger` wraps a pressable child (typically a `Button`) and opens the\nnative file picker when the child is activated. It renders no styling of its own\n— the child provides the visual treatment. The `onSelect` handler receives the\nnative `FileList` (or `null`).\n\n```jsx live-dev\nconst App = () => {\n const [name, setName] = React.useState(\"\");\n return (\n <Stack direction=\"row\" gap=\"400\" alignItems=\"center\">\n <FileTrigger\n onSelect={(files) => {\n const list = files ? Array.from(files) : [];\n setName(list[0]?.name ?? \"\");\n }}\n >\n <Button>Upload file</Button>\n </FileTrigger>\n <Text>{name || \"No file selected\"}</Text>\n </Stack>\n );\n};\n```\n\n## Usage examples\n\n### Restrict accepted file types\n\nPass `acceptedFileTypes` (MIME types or extensions) to limit what the picker\noffers. It maps to the input's `accept` attribute.\n\n```jsx live-dev\nconst App = () => (\n <FileTrigger acceptedFileTypes={[\"image/png\", \"image/jpeg\", \".pdf\"]}>\n <Button>Upload image or PDF</Button>\n </FileTrigger>\n);\n```\n\n### Select multiple files\n\nSet `allowsMultiple` to let the user pick more than one file at a time.\n\n```jsx live-dev\nconst App = () => {\n const [count, setCount] = React.useState(0);\n return (\n <Stack direction=\"row\" gap=\"400\" alignItems=\"center\">\n <FileTrigger\n allowsMultiple\n onSelect={(files) => setCount(files ? files.length : 0)}\n >\n <Button>Upload files</Button>\n </FileTrigger>\n <Text>{count} file(s) selected</Text>\n </Stack>\n );\n};\n```\n\n### Select a directory\n\nSet `acceptDirectory` to let the user choose a whole folder instead of\nindividual files.\n\n```jsx live-dev\nconst App = () => (\n <FileTrigger acceptDirectory>\n <Button>Select folder</Button>\n </FileTrigger>\n);\n```\n\n### Capture from the camera (mobile)\n\n`defaultCamera` hints which camera a mobile device should use (`\"user\"` or\n`\"environment\"`). It maps to the `capture` attribute and is ignored on desktop.\n\n```jsx live-dev\nconst App = () => (\n <FileTrigger defaultCamera=\"environment\" acceptedFileTypes={[\"image/*\"]}>\n <Button>Take photo</Button>\n </FileTrigger>\n);\n```\n\n### Disabling the trigger\n\n`FileTrigger` has no `isDisabled` prop of its own — disable the child instead. A\ndisabled child cannot open the picker.\n\n```jsx live-dev\nconst App = () => (\n <FileTrigger>\n <Button isDisabled>Upload file</Button>\n </FileTrigger>\n);\n```\n\n## Notes and limitations\n\n- **`onSelect` receives a `FileList`, not an array.** Use `Array.from(files)` to\n map over the selection. `files` is `null` if the selection was cleared.\n- **Re-selecting the same file.** Browsers do not fire a change event when the\n user picks the identical file again. `FileTrigger` does not expose a reset\n API; if you need to allow re-selecting the same file, remount the component\n with a changing `key` prop after handling a selection.\n- **No native form (`name`) integration.** `FileTrigger` does not submit a file\n via a native `<form>`. Lift the selection into state via `onSelect` and submit\n it yourself.\n- **Combining `acceptDirectory` and `allowsMultiple`.** How these interact is\n defined by the browser, not by `FileTrigger` — some browsers honor only the\n directory selection and ignore `allowsMultiple`. Don't rely on a consistent\n result across browsers.\n\n## API reference\n\n<PropsTable id=\"FileTrigger\" />\n\n## Testing your implementation\n\nThese examples demonstrate how to test your implementation when using\n`FileTrigger` within your application. As the component's internal functionality\nis already tested by Nimbus, these patterns help you verify your integration and\napplication-specific logic.\n\n### Basic Rendering Tests\n\nVerify the FileTrigger renders a pressable child plus a hidden file input\n\n```tsx\nimport { describe, it, expect, vi } from \"vitest\";\nimport { render, screen } from \"@testing-library/react\";\nimport userEvent from \"@testing-library/user-event\";\nimport { FileTrigger, Button, NimbusProvider } from \"@commercetools/nimbus\";\n\ndescribe(\"FileTrigger - Basic rendering\", () => {\n it(\"renders the child trigger and a hidden file input\", () => {\n const { container } = render(\n <NimbusProvider>\n <FileTrigger>\n <Button aria-label=\"Upload file\">Upload file</Button>\n </FileTrigger>\n </NimbusProvider>\n );\n\n expect(\n screen.getByRole(\"button\", { name: /upload file/i })\n ).toBeInTheDocument();\n expect(getFileInput(container)).toHaveAttribute(\"type\", \"file\");\n });\n\n it(\"forwards acceptedFileTypes to the input's accept attribute\", () => {\n const { container } = render(\n <NimbusProvider>\n <FileTrigger acceptedFileTypes={[\"image/png\", \".pdf\"]}>\n <Button aria-label=\"Upload\">Upload</Button>\n </FileTrigger>\n </NimbusProvider>\n );\n\n expect(getFileInput(container)).toHaveAttribute(\"accept\", \"image/png,.pdf\");\n });\n\n it(\"forwards allowsMultiple to the input's multiple attribute\", () => {\n const { container } = render(\n <NimbusProvider>\n <FileTrigger allowsMultiple>\n <Button aria-label=\"Upload\">Upload</Button>\n </FileTrigger>\n </NimbusProvider>\n );\n\n expect(getFileInput(container)).toHaveAttribute(\"multiple\");\n });\n});\n```\n\n### Interaction Tests\n\nTest selecting files through the FileTrigger\n\n```tsx\nimport { describe, it, expect, vi } from \"vitest\";\nimport { render, screen } from \"@testing-library/react\";\nimport userEvent from \"@testing-library/user-event\";\nimport { FileTrigger, Button, NimbusProvider } from \"@commercetools/nimbus\";\n\ndescribe(\"FileTrigger - Interactions\", () => {\n it(\"calls onSelect with a FileList when a file is selected\", async () => {\n const user = userEvent.setup();\n const handleSelect = vi.fn();\n\n const { container } = render(\n <NimbusProvider>\n <FileTrigger onSelect={handleSelect}>\n <Button aria-label=\"Upload file\">Upload file</Button>\n </FileTrigger>\n </NimbusProvider>\n );\n\n const file = new File([\"hello\"], \"report.txt\", { type: \"text/plain\" });\n await user.upload(getFileInput(container), file);\n\n expect(handleSelect).toHaveBeenCalledTimes(1);\n const files = handleSelect.mock.calls[0][0] as FileList;\n expect(files.length).toBe(1);\n expect(files[0].name).toBe(\"report.txt\");\n });\n\n it(\"reports every file when allowsMultiple is set\", async () => {\n const user = userEvent.setup();\n const handleSelect = vi.fn();\n\n const { container } = render(\n <NimbusProvider>\n <FileTrigger allowsMultiple onSelect={handleSelect}>\n <Button aria-label=\"Upload files\">Upload files</Button>\n </FileTrigger>\n </NimbusProvider>\n );\n\n await user.upload(getFileInput(container), [\n new File([\"a\"], \"a.txt\", { type: \"text/plain\" }),\n new File([\"b\"], \"b.txt\", { type: \"text/plain\" }),\n ]);\n\n expect(handleSelect).toHaveBeenCalledTimes(1);\n expect((handleSelect.mock.calls[0][0] as FileList).length).toBe(2);\n });\n});\n```\n\n### State Tests\n\nDisabling is delegated to the child trigger\n\n```tsx\nimport { describe, it, expect, vi } from \"vitest\";\nimport { render, screen } from \"@testing-library/react\";\nimport userEvent from \"@testing-library/user-event\";\nimport { FileTrigger, Button, NimbusProvider } from \"@commercetools/nimbus\";\n\ndescribe(\"FileTrigger - States\", () => {\n it(\"does not select when the child button is disabled\", async () => {\n const user = userEvent.setup();\n const handleSelect = vi.fn();\n\n render(\n <NimbusProvider>\n <FileTrigger onSelect={handleSelect}>\n <Button aria-label=\"Upload file\" isDisabled>\n Upload file\n </Button>\n </FileTrigger>\n </NimbusProvider>\n );\n\n const button = screen.getByRole(\"button\", { name: /upload file/i });\n expect(button).toBeDisabled();\n\n await user.click(button);\n expect(handleSelect).not.toHaveBeenCalled();\n });\n});\n```\n\n\n## Resources\n\n- [Storybook](https://nimbus-storybook.vercel.app/?path=/docs/components-filetrigger--docs)\n- [React Aria FileTrigger](https://react-aria.adobe.com/FileTrigger)\n",
|
|
247
|
+
"toc": [
|
|
248
|
+
{
|
|
249
|
+
"value": "Getting started",
|
|
250
|
+
"href": "#getting-started",
|
|
251
|
+
"depth": 2,
|
|
252
|
+
"numbering": [
|
|
253
|
+
1,
|
|
254
|
+
1
|
|
255
|
+
],
|
|
256
|
+
"parent": "root"
|
|
257
|
+
},
|
|
258
|
+
{
|
|
259
|
+
"value": "Import",
|
|
260
|
+
"href": "#import",
|
|
261
|
+
"depth": 3,
|
|
262
|
+
"numbering": [
|
|
263
|
+
1,
|
|
264
|
+
1,
|
|
265
|
+
1
|
|
266
|
+
],
|
|
267
|
+
"parent": "root"
|
|
268
|
+
},
|
|
269
|
+
{
|
|
270
|
+
"value": "Basic usage",
|
|
271
|
+
"href": "#basic-usage",
|
|
272
|
+
"depth": 3,
|
|
273
|
+
"numbering": [
|
|
274
|
+
1,
|
|
275
|
+
1,
|
|
276
|
+
2
|
|
277
|
+
],
|
|
278
|
+
"parent": "root"
|
|
279
|
+
},
|
|
280
|
+
{
|
|
281
|
+
"value": "Usage examples",
|
|
282
|
+
"href": "#usage-examples",
|
|
283
|
+
"depth": 2,
|
|
284
|
+
"numbering": [
|
|
285
|
+
1,
|
|
286
|
+
2
|
|
287
|
+
],
|
|
288
|
+
"parent": "root"
|
|
289
|
+
},
|
|
290
|
+
{
|
|
291
|
+
"value": "Restrict accepted file types",
|
|
292
|
+
"href": "#restrict-accepted-file-types",
|
|
293
|
+
"depth": 3,
|
|
294
|
+
"numbering": [
|
|
295
|
+
1,
|
|
296
|
+
2,
|
|
297
|
+
1
|
|
298
|
+
],
|
|
299
|
+
"parent": "root"
|
|
300
|
+
},
|
|
301
|
+
{
|
|
302
|
+
"value": "Select multiple files",
|
|
303
|
+
"href": "#select-multiple-files",
|
|
304
|
+
"depth": 3,
|
|
305
|
+
"numbering": [
|
|
306
|
+
1,
|
|
307
|
+
2,
|
|
308
|
+
2
|
|
309
|
+
],
|
|
310
|
+
"parent": "root"
|
|
311
|
+
},
|
|
312
|
+
{
|
|
313
|
+
"value": "Select a directory",
|
|
314
|
+
"href": "#select-a-directory",
|
|
315
|
+
"depth": 3,
|
|
316
|
+
"numbering": [
|
|
317
|
+
1,
|
|
318
|
+
2,
|
|
319
|
+
3
|
|
320
|
+
],
|
|
321
|
+
"parent": "root"
|
|
322
|
+
},
|
|
323
|
+
{
|
|
324
|
+
"value": "Capture from the camera (mobile)",
|
|
325
|
+
"href": "#capture-from-the-camera-mobile",
|
|
326
|
+
"depth": 3,
|
|
327
|
+
"numbering": [
|
|
328
|
+
1,
|
|
329
|
+
2,
|
|
330
|
+
4
|
|
331
|
+
],
|
|
332
|
+
"parent": "root"
|
|
333
|
+
},
|
|
334
|
+
{
|
|
335
|
+
"value": "Disabling the trigger",
|
|
336
|
+
"href": "#disabling-the-trigger",
|
|
337
|
+
"depth": 3,
|
|
338
|
+
"numbering": [
|
|
339
|
+
1,
|
|
340
|
+
2,
|
|
341
|
+
5
|
|
342
|
+
],
|
|
343
|
+
"parent": "root"
|
|
344
|
+
},
|
|
345
|
+
{
|
|
346
|
+
"value": "Notes and limitations",
|
|
347
|
+
"href": "#notes-and-limitations",
|
|
348
|
+
"depth": 2,
|
|
349
|
+
"numbering": [
|
|
350
|
+
1,
|
|
351
|
+
3
|
|
352
|
+
],
|
|
353
|
+
"parent": "root"
|
|
354
|
+
},
|
|
355
|
+
{
|
|
356
|
+
"value": "API reference",
|
|
357
|
+
"href": "#api-reference",
|
|
358
|
+
"depth": 2,
|
|
359
|
+
"numbering": [
|
|
360
|
+
1,
|
|
361
|
+
4
|
|
362
|
+
],
|
|
363
|
+
"parent": "root"
|
|
364
|
+
},
|
|
365
|
+
{
|
|
366
|
+
"value": "Testing your implementation",
|
|
367
|
+
"href": "#testing-your-implementation",
|
|
368
|
+
"depth": 2,
|
|
369
|
+
"numbering": [
|
|
370
|
+
1,
|
|
371
|
+
5
|
|
372
|
+
],
|
|
373
|
+
"parent": "root"
|
|
374
|
+
},
|
|
375
|
+
{
|
|
376
|
+
"value": "Basic Rendering Tests",
|
|
377
|
+
"href": "#basic-rendering-tests",
|
|
378
|
+
"depth": 3,
|
|
379
|
+
"numbering": [
|
|
380
|
+
1,
|
|
381
|
+
5,
|
|
382
|
+
1
|
|
383
|
+
],
|
|
384
|
+
"parent": "root"
|
|
385
|
+
},
|
|
386
|
+
{
|
|
387
|
+
"value": "Interaction Tests",
|
|
388
|
+
"href": "#interaction-tests",
|
|
389
|
+
"depth": 3,
|
|
390
|
+
"numbering": [
|
|
391
|
+
1,
|
|
392
|
+
5,
|
|
393
|
+
2
|
|
394
|
+
],
|
|
395
|
+
"parent": "root"
|
|
396
|
+
},
|
|
397
|
+
{
|
|
398
|
+
"value": "State Tests",
|
|
399
|
+
"href": "#state-tests",
|
|
400
|
+
"depth": 3,
|
|
401
|
+
"numbering": [
|
|
402
|
+
1,
|
|
403
|
+
5,
|
|
404
|
+
3
|
|
405
|
+
],
|
|
406
|
+
"parent": "root"
|
|
407
|
+
},
|
|
408
|
+
{
|
|
409
|
+
"value": "Resources",
|
|
410
|
+
"href": "#resources",
|
|
411
|
+
"depth": 2,
|
|
412
|
+
"numbering": [
|
|
413
|
+
1,
|
|
414
|
+
6
|
|
415
|
+
],
|
|
416
|
+
"parent": "root"
|
|
417
|
+
}
|
|
418
|
+
]
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
}
|