@boxcustodia/library 2.0.0-alpha.26 → 2.0.0-alpha.27

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@boxcustodia/library",
3
- "version": "2.0.0-alpha.26",
3
+ "version": "2.0.0-alpha.27",
4
4
  "type": "module",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.es.js",
@@ -39,6 +39,34 @@ const meta: Meta<typeof Menu> = {
39
39
  },
40
40
  argTypes: {
41
41
  classNames: { control: false },
42
+ items: {
43
+ control: false,
44
+ description: `Array of \`MenuItemType\`. Each entry is a discriminated union on \`type\`:
45
+
46
+ \`\`\`ts
47
+ // Action item
48
+ { type: "item"; label: ReactNode; shortcut?: string; onClick?: () => void; disabled?: boolean; variant?: "default" | "error" }
49
+
50
+ // Checkbox item
51
+ { type: "checkbox"; label: ReactNode; checked?: boolean; onCheckedChange?: (checked: boolean) => void; disabled?: boolean }
52
+
53
+ // Radio group — wraps radio items; controlled via value/onValueChange on the group
54
+ { type: "radio-group"; value?: string; onValueChange?: (value: string) => void; items: RadioItem[] }
55
+ // RadioItem: { type: "radio"; label: ReactNode; value: string; disabled?: boolean }
56
+
57
+ // Group with optional label
58
+ { type: "group"; label?: ReactNode; items: MenuItemType[] }
59
+
60
+ // Submenu
61
+ { type: "submenu"; label: ReactNode; items: MenuItemType[] }
62
+
63
+ // Label (non-interactive heading)
64
+ { type: "label"; label: ReactNode }
65
+
66
+ // Separator
67
+ { type: "separator" }
68
+ \`\`\``,
69
+ },
42
70
  },
43
71
  };
44
72
 
@@ -50,10 +78,10 @@ export const Default: Story = {
50
78
  <Menu
51
79
  {...args}
52
80
  items={[
53
- { type: "item", label: "Profile", onSelect: action("profile") },
54
- { type: "item", label: "Settings", onSelect: action("settings") },
81
+ { type: "item", label: "Profile", onClick: action("profile") },
82
+ { type: "item", label: "Settings", onClick: action("settings") },
55
83
  { type: "separator" },
56
- { type: "item", label: "Log out", onSelect: action("logout") },
84
+ { type: "item", label: "Log out", onClick: action("logout") },
57
85
  ]}
58
86
  />
59
87
  ),
@@ -69,8 +97,8 @@ export const WithClassNames: Story = {
69
97
  {...args}
70
98
  classNames={{ popup: "w-56" }}
71
99
  items={[
72
- { type: "item", label: "Profile", onSelect: action("profile") },
73
- { type: "item", label: "Settings", onSelect: action("settings") },
100
+ { type: "item", label: "Profile", onClick: action("profile") },
101
+ { type: "item", label: "Settings", onClick: action("settings") },
74
102
  ]}
75
103
  />
76
104
  ),
@@ -88,26 +116,26 @@ export const Shortcuts: Story = {
88
116
  type: "item",
89
117
  label: "New",
90
118
  shortcut: "Ctrl+N",
91
- onSelect: action("new"),
119
+ onClick: action("new"),
92
120
  },
93
121
  {
94
122
  type: "item",
95
123
  label: "Open",
96
124
  shortcut: "Ctrl+O",
97
- onSelect: action("open"),
125
+ onClick: action("open"),
98
126
  },
99
127
  {
100
128
  type: "item",
101
129
  label: "Save",
102
130
  shortcut: "Ctrl+S",
103
- onSelect: action("save"),
131
+ onClick: action("save"),
104
132
  },
105
133
  { type: "separator" },
106
134
  {
107
135
  type: "item",
108
136
  label: "Close",
109
137
  shortcut: "Ctrl+W",
110
- onSelect: action("close"),
138
+ onClick: action("close"),
111
139
  },
112
140
  ]}
113
141
  />
@@ -197,19 +225,19 @@ export const Groups: Story = {
197
225
  type: "item",
198
226
  label: "Cut",
199
227
  shortcut: "Ctrl+X",
200
- onSelect: action("cut"),
228
+ onClick: action("cut"),
201
229
  },
202
230
  {
203
231
  type: "item",
204
232
  label: "Copy",
205
233
  shortcut: "Ctrl+C",
206
- onSelect: action("copy"),
234
+ onClick: action("copy"),
207
235
  },
208
236
  {
209
237
  type: "item",
210
238
  label: "Paste",
211
239
  shortcut: "Ctrl+V",
212
- onSelect: action("paste"),
240
+ onClick: action("paste"),
213
241
  },
214
242
  ],
215
243
  },
@@ -222,9 +250,9 @@ export const Groups: Story = {
222
250
  type: "item",
223
251
  label: "Select All",
224
252
  shortcut: "Ctrl+A",
225
- onSelect: action("select-all"),
253
+ onClick: action("select-all"),
226
254
  },
227
- { type: "item", label: "Deselect", onSelect: action("deselect") },
255
+ { type: "item", label: "Deselect", onClick: action("deselect") },
228
256
  ],
229
257
  },
230
258
  ]}
@@ -237,14 +265,14 @@ export const Submenu: Story = {
237
265
  <Menu
238
266
  {...args}
239
267
  items={[
240
- { type: "item", label: "Copy link", onSelect: action("copy-link") },
268
+ { type: "item", label: "Copy link", onClick: action("copy-link") },
241
269
  {
242
270
  type: "submenu",
243
271
  label: "Export as",
244
272
  items: [
245
- { type: "item", label: "PDF", onSelect: action("export-pdf") },
246
- { type: "item", label: "CSV", onSelect: action("export-csv") },
247
- { type: "item", label: "JSON", onSelect: action("export-json") },
273
+ { type: "item", label: "PDF", onClick: action("export-pdf") },
274
+ { type: "item", label: "CSV", onClick: action("export-csv") },
275
+ { type: "item", label: "JSON", onClick: action("export-json") },
248
276
  ],
249
277
  },
250
278
  ]}
@@ -260,14 +288,14 @@ export const Error: Story = {
260
288
  <Menu
261
289
  {...args}
262
290
  items={[
263
- { type: "item", label: "Profile", onSelect: action("profile") },
264
- { type: "item", label: "Billing", onSelect: action("billing") },
291
+ { type: "item", label: "Profile", onClick: action("profile") },
292
+ { type: "item", label: "Billing", onClick: action("billing") },
265
293
  { type: "separator" },
266
294
  {
267
295
  type: "item",
268
296
  label: "Delete account",
269
297
  variant: "error",
270
- onSelect: action("delete"),
298
+ onClick: action("delete"),
271
299
  },
272
300
  ]}
273
301
  />
@@ -283,7 +311,7 @@ export const Error: Story = {
283
311
  * <MenuPopup>
284
312
  * <MenuGroup>
285
313
  * <MenuLabel>Section</MenuLabel>
286
- * <MenuItem onSelect={() => {}}>Item</MenuItem>
314
+ * <MenuItem onClick={() => {}}>Item</MenuItem>
287
315
  * </MenuGroup>
288
316
  * </MenuPopup>
289
317
  * </MenuRoot>
@@ -305,25 +333,25 @@ export const Primitive: Story = {
305
333
  </MenuGroup>
306
334
  <MenuSeparator />
307
335
  <MenuGroup>
308
- <MenuItem onSelect={action("tasks")}>All Tasks</MenuItem>
309
- <MenuItem onSelect={action("completed")}>Completed</MenuItem>
310
- <MenuItem onSelect={action("upcoming")}>Upcoming</MenuItem>
336
+ <MenuItem onClick={action("tasks")}>All Tasks</MenuItem>
337
+ <MenuItem onClick={action("completed")}>Completed</MenuItem>
338
+ <MenuItem onClick={action("upcoming")}>Upcoming</MenuItem>
311
339
  </MenuGroup>
312
340
  <MenuSeparator />
313
341
  <MenuSub>
314
342
  <MenuSubTrigger>Categories</MenuSubTrigger>
315
343
  <MenuSubContent>
316
- <MenuItem onSelect={action("work")}>Work</MenuItem>
317
- <MenuItem onSelect={action("personal")}>Personal</MenuItem>
318
- <MenuItem onSelect={action("shopping")}>Shopping</MenuItem>
344
+ <MenuItem onClick={action("work")}>Work</MenuItem>
345
+ <MenuItem onClick={action("personal")}>Personal</MenuItem>
346
+ <MenuItem onClick={action("shopping")}>Shopping</MenuItem>
319
347
  </MenuSubContent>
320
348
  </MenuSub>
321
349
  <MenuSeparator />
322
- <MenuItem onSelect={action("settings")}>
350
+ <MenuItem onClick={action("settings")}>
323
351
  Settings
324
352
  <MenuShortcut>Ctrl+,</MenuShortcut>
325
353
  </MenuItem>
326
- <MenuItem disabled onSelect={action("archived")}>
354
+ <MenuItem disabled onClick={action("archived")}>
327
355
  Archived
328
356
  </MenuItem>
329
357
  </MenuPopup>