@astryxdesign/core 0.3.0-canary.e0fef44 → 0.3.0-canary.e6af10a

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.
@@ -19,19 +19,23 @@
19
19
  */
20
20
  import React, { type ReactNode } from 'react';
21
21
  import { type ButtonProps } from '../Button';
22
- import type { IconType } from '../Icon';
22
+ import type { DropdownMenuItemProps } from './DropdownMenuItem';
23
23
  import type { LayerAlignment, LayerPlacement } from '../Layer/useLayer';
24
24
  import type { BaseProps } from '../BaseProps';
25
- export interface DropdownMenuItemData {
26
- label: string;
27
- onClick?: () => void;
28
- isDisabled?: boolean;
29
- icon?: ReactNode | IconType;
25
+ /**
26
+ * Data-mode shape for one menu row.
27
+ *
28
+ * The item fields are sourced from `DropdownMenuItemProps` — data mode renders
29
+ * through `DropdownMenuItem`, so the two APIs describe the same thing and must
30
+ * not drift. Only the fields listed here are part of the data API; add a key to
31
+ * the `Pick` to expose more of the item's props to `items`.
32
+ */
33
+ export interface DropdownMenuItemData extends Pick<DropdownMenuItemProps, 'icon' | 'onClick' | 'isDisabled' | 'variant'> {
30
34
  /**
31
- * Visual variant for a leaf item. `'destructive'` renders it in the error
32
- * color for dangerous actions (e.g. Delete). @default 'default'
35
+ * Primary label text. Narrowed to `string` from the item's `ReactNode`:
36
+ * data mode derives each row's React key from the label.
33
37
  */
34
- variant?: 'default' | 'destructive';
38
+ label: string;
35
39
  /**
36
40
  * Nested submenu entries. When present, this row becomes a submenu (a
37
41
  * flyout revealing `items`) instead of a leaf action — no separate item
@@ -1 +1 @@
1
- {"version":3,"file":"DropdownMenu.d.ts","sourceRoot":"","sources":["../../src/DropdownMenu/DropdownMenu.tsx"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,EAAE,EAOZ,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAGf,OAAO,EAAS,KAAK,WAAW,EAAC,MAAM,WAAW,CAAC;A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C5B,YAAY,EACZ,SAAS,EACT,OAAO,EACP,UAAiB,EACjB,SAAmB,EACnB,SAAmB,EACnB,SAAS,EACT,KAAK,EACL,MAAM,EACN,aAAa,EAAE,MAAM,EACrB,GAAG,KAAK,EACT,EAAE,iBAAiB,qBAwRnB;yBAtSe,YAAY"}
@@ -82,6 +82,15 @@ const styles = {
82
82
  // Types
83
83
  // =============================================================================
84
84
 
85
+ /**
86
+ * Data-mode shape for one menu row.
87
+ *
88
+ * The item fields are sourced from `DropdownMenuItemProps` — data mode renders
89
+ * through `DropdownMenuItem`, so the two APIs describe the same thing and must
90
+ * not drift. Only the fields listed here are part of the data API; add a key to
91
+ * the `Pick` to expose more of the item's props to `items`.
92
+ */
93
+
85
94
  // =============================================================================
86
95
  // Props
87
96
  // =============================================================================
@@ -1 +1 @@
1
- {"version":3,"file":"renderDropdownItems.d.ts","sourceRoot":"","sources":["../../src/DropdownMenu/renderDropdownItems.tsx"],"names":[],"mappings":"AAEA;;;;GAIG;AAEH,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,OAAO,CAAC;AAYrC,OAAO,KAAK,EAEV,kBAAkB,EAEnB,MAAM,gBAAgB,CAAC;AAyBxB;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,kBAAkB,EAAE,GAAG,SAAS,CA0E1E"}
1
+ {"version":3,"file":"renderDropdownItems.d.ts","sourceRoot":"","sources":["../../src/DropdownMenu/renderDropdownItems.tsx"],"names":[],"mappings":"AAEA;;;;GAIG;AAEH,OAAO,KAAK,EAAe,SAAS,EAAC,MAAM,OAAO,CAAC;AAYnD,OAAO,KAAK,EAEV,kBAAkB,EAEnB,MAAM,gBAAgB,CAAC;AAuCxB;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,kBAAkB,EAAE,GAAG,SAAS,CAwD1E"}
@@ -27,6 +27,25 @@ function getSectionKey(section, index) {
27
27
  return `section-${section.title ?? index}`;
28
28
  }
29
29
 
30
+ /**
31
+ * Renders one leaf row as a `DropdownMenuItem`.
32
+ *
33
+ * `items` is stripped because it selects the submenu shape rather than being an
34
+ * item prop; every other field of `DropdownMenuItemData` is a
35
+ * `DropdownMenuItem` prop by construction (the type is `Pick`ed from
36
+ * `DropdownMenuItemProps`), so the data path forwards them wholesale and can't
37
+ * silently drop a field the data API advertises.
38
+ */
39
+ function renderLeafItem(item) {
40
+ const {
41
+ items: _submenuItems,
42
+ ...itemProps
43
+ } = item;
44
+ return /*#__PURE__*/_jsx(DropdownMenuItem, {
45
+ ...itemProps
46
+ }, getItemKey(item));
47
+ }
48
+
30
49
  /**
31
50
  * Converts data-driven items into DropdownMenuItem components,
32
51
  * so both modes share the same rendering and keyboard navigation path.
@@ -50,13 +69,7 @@ export function renderDropdownItems(items) {
50
69
  className: "xu0wf1k xf314gf x9ynric x141an7d x1ltkj2j xv1l7n4 x87ps6o"
51
70
  }),
52
71
  children: option.title
53
- }), option.items.map(item => /*#__PURE__*/_jsx(DropdownMenuItem, {
54
- icon: item.icon,
55
- label: item.label,
56
- onClick: item.onClick,
57
- isDisabled: item.isDisabled,
58
- variant: item.variant
59
- }, getItemKey(item)))]
72
+ }), option.items.map(renderLeafItem)]
60
73
  }, getSectionKey(option, i)));
61
74
  } else if (!('type' in option)) {
62
75
  // A plain item that declares nested `items` becomes a submenu (data-mode
@@ -72,13 +85,7 @@ export function renderDropdownItems(items) {
72
85
  children: renderDropdownItems(option.items)
73
86
  }, getItemKey(option)));
74
87
  } else {
75
- elements.push(/*#__PURE__*/_jsx(DropdownMenuItem, {
76
- icon: option.icon,
77
- label: option.label,
78
- onClick: option.onClick,
79
- isDisabled: option.isDisabled,
80
- variant: option.variant
81
- }, getItemKey(option)));
88
+ elements.push(renderLeafItem(option));
82
89
  }
83
90
  }
84
91
  }
@@ -342,7 +342,7 @@ export function NumberInput({
342
342
  ...rest,
343
343
  ref: mergeRefs(ref, inputRef),
344
344
  id: id,
345
- name: htmlName,
345
+ name: isDisabled ? undefined : htmlName,
346
346
  type: "number",
347
347
  autoComplete: autoComplete,
348
348
  value: displayValue,
@@ -270,7 +270,7 @@ export function TextArea({
270
270
  ...rest,
271
271
  ref: mergeRefs(ref, textareaRef),
272
272
  id: id,
273
- name: htmlName,
273
+ name: isDisabled ? undefined : htmlName,
274
274
  value: optimisticValue,
275
275
  onChange: handleChange,
276
276
  onPaste: onPaste,
@@ -192,7 +192,7 @@ export function TextInput({
192
192
  ...rest,
193
193
  ref: mergeRefs(ref, inputRef),
194
194
  id: id,
195
- name: htmlName,
195
+ name: isDisabled ? undefined : htmlName,
196
196
  type: type,
197
197
  value: optimisticValue,
198
198
  onChange: handleChange,