@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.
- package/dist/DropdownMenu/DropdownMenu.d.ts +13 -9
- package/dist/DropdownMenu/DropdownMenu.d.ts.map +1 -1
- package/dist/DropdownMenu/DropdownMenu.js +9 -0
- package/dist/DropdownMenu/renderDropdownItems.d.ts.map +1 -1
- package/dist/DropdownMenu/renderDropdownItems.js +21 -14
- package/dist/NumberInput/NumberInput.js +1 -1
- package/dist/TextArea/TextArea.js +1 -1
- package/dist/TextInput/TextInput.js +1 -1
- package/dist/astryx.umd.js +39 -39
- package/dist/astryx.umd.js.map +3 -3
- package/package.json +2 -2
- package/src/Carousel/Carousel.doc.mjs +3 -0
- package/src/DropdownMenu/DropdownMenu.tsx +16 -9
- package/src/DropdownMenu/renderDropdownItems.tsx +17 -21
- package/src/Icon/Icon.doc.mjs +2 -1
- package/src/Item/Item.doc.mjs +1 -1
- package/src/NumberInput/NumberInput.test.tsx +55 -0
- package/src/NumberInput/NumberInput.tsx +1 -1
- package/src/Pagination/Pagination.doc.mjs +1 -1
- package/src/ProgressBar/ProgressBar.doc.mjs +1 -1
- package/src/TextArea/TextArea.test.tsx +55 -0
- package/src/TextArea/TextArea.tsx +1 -1
- package/src/TextInput/TextInput.test.tsx +55 -0
- package/src/TextInput/TextInput.tsx +1 -1
|
@@ -19,19 +19,23 @@
|
|
|
19
19
|
*/
|
|
20
20
|
import React, { type ReactNode } from 'react';
|
|
21
21
|
import { type ButtonProps } from '../Button';
|
|
22
|
-
import type {
|
|
22
|
+
import type { DropdownMenuItemProps } from './DropdownMenuItem';
|
|
23
23
|
import type { LayerAlignment, LayerPlacement } from '../Layer/useLayer';
|
|
24
24
|
import type { BaseProps } from '../BaseProps';
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
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
|
-
*
|
|
32
|
-
*
|
|
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
|
-
|
|
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;
|
|
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;AAInD,OAAO,KAAK,EAAC,qBAAqB,EAAC,MAAM,oBAAoB,CAAC;AAa9D,OAAO,KAAK,EAAC,cAAc,EAAE,cAAc,EAAC,MAAM,mBAAmB,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0B,SAAQ,qBAAqB;IAC/D,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,QAAQ,EAAE,SAAS,CAAC;CACrB;AAED,MAAM,MAAM,iBAAiB,GAC3B,qBAAqB,GAAG,yBAAyB,CAAC;AA+BpD,wBAAgB,YAAY,CAAC,EAC3B,MAAM,EAAE,eAAe,EACvB,UAAU,EAAE,gBAAgB,EAC5B,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,
|
|
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(
|
|
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(
|
|
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
|
}
|