@astryxdesign/core 0.1.7-canary.eb8e07b → 0.1.7
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/ContextMenu/ContextMenu.d.ts.map +1 -1
- package/dist/ContextMenu/ContextMenu.js +3 -4
- package/dist/ContextMenu/index.d.ts +0 -3
- package/dist/ContextMenu/index.d.ts.map +1 -1
- package/dist/ContextMenu/index.js +1 -7
- package/dist/DropdownMenu/DropdownMenu.d.ts.map +1 -1
- package/dist/DropdownMenu/DropdownMenu.js +4 -8
- package/dist/DropdownMenu/DropdownMenuContext.d.ts +1 -17
- package/dist/DropdownMenu/DropdownMenuContext.d.ts.map +1 -1
- package/dist/DropdownMenu/DropdownMenuContext.js +0 -18
- package/dist/DropdownMenu/index.d.ts +1 -5
- package/dist/DropdownMenu/index.d.ts.map +1 -1
- package/dist/DropdownMenu/index.js +1 -10
- package/dist/Icon/Icon.d.ts +12 -17
- package/dist/Icon/Icon.d.ts.map +1 -1
- package/dist/Icon/Icon.js +20 -28
- package/dist/astryx.css +1 -15
- package/dist/astryx.umd.js +46 -46
- package/dist/astryx.umd.js.map +4 -4
- package/package.json +1 -1
- package/src/ContextMenu/ContextMenu.test.tsx +1 -75
- package/src/ContextMenu/ContextMenu.tsx +5 -10
- package/src/ContextMenu/index.ts +0 -15
- package/src/DropdownMenu/DropdownMenu.doc.mjs +0 -10
- package/src/DropdownMenu/DropdownMenu.tsx +6 -11
- package/src/DropdownMenu/DropdownMenuContext.tsx +1 -29
- package/src/DropdownMenu/index.ts +3 -23
- package/src/Icon/Icon.test.tsx +0 -46
- package/src/Icon/Icon.tsx +24 -37
- package/dist/DropdownMenu/DropdownMenuCheckboxItem.d.ts +0 -89
- package/dist/DropdownMenu/DropdownMenuCheckboxItem.d.ts.map +0 -1
- package/dist/DropdownMenu/DropdownMenuCheckboxItem.js +0 -170
- package/dist/DropdownMenu/DropdownMenuRadioGroup.d.ts +0 -69
- package/dist/DropdownMenu/DropdownMenuRadioGroup.d.ts.map +0 -1
- package/dist/DropdownMenu/DropdownMenuRadioGroup.js +0 -70
- package/dist/DropdownMenu/DropdownMenuRadioItem.d.ts +0 -69
- package/dist/DropdownMenu/DropdownMenuRadioItem.d.ts.map +0 -1
- package/dist/DropdownMenu/DropdownMenuRadioItem.js +0 -178
- package/dist/DropdownMenu/menuItemRoles.d.ts +0 -13
- package/dist/DropdownMenu/menuItemRoles.d.ts.map +0 -1
- package/dist/DropdownMenu/menuItemRoles.js +0 -15
- package/src/DropdownMenu/DropdownMenuCheckboxItem.doc.mjs +0 -95
- package/src/DropdownMenu/DropdownMenuCheckboxItem.tsx +0 -237
- package/src/DropdownMenu/DropdownMenuRadioGroup.doc.mjs +0 -80
- package/src/DropdownMenu/DropdownMenuRadioGroup.tsx +0 -119
- package/src/DropdownMenu/DropdownMenuRadioItem.doc.mjs +0 -80
- package/src/DropdownMenu/DropdownMenuRadioItem.tsx +0 -232
- package/src/DropdownMenu/DropdownMenuSelectable.test.tsx +0 -163
- package/src/DropdownMenu/menuItemRoles.ts +0 -22
|
@@ -1,170 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
-
|
|
3
|
-
'use client';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* @file DropdownMenuCheckboxItem.tsx
|
|
7
|
-
* @input React, stylex, Item + Icon + DropdownMenu context + tokens from core
|
|
8
|
-
* @output DropdownMenuCheckboxItem — a standalone checkable menu item.
|
|
9
|
-
* @position Sub-component; used inside DropdownMenu.
|
|
10
|
-
*
|
|
11
|
-
* A menu item that toggles an independent boolean (role="menuitemcheckbox").
|
|
12
|
-
* Unlike CheckboxInput, there is no nested native <input>: the row itself owns
|
|
13
|
-
* the role and aria-checked, per the WAI-ARIA menuitemcheckbox pattern.
|
|
14
|
-
* Keyboard navigation (arrows/typeahead) and Enter/Space activation come from
|
|
15
|
-
* the parent DropdownMenu's useListFocus + activation path, which matches
|
|
16
|
-
* menuitemcheckbox alongside plain menuitem rows.
|
|
17
|
-
*
|
|
18
|
-
* The square checkbox visual is decorative (aria-hidden) — the row owns the
|
|
19
|
-
* checked state. Its size is derived from the menu's item size (a `sm` menu
|
|
20
|
-
* gets the compact control; `md`/`lg` get the standard one) and it swaps to the
|
|
21
|
-
* inline-end of the row on coarse-pointer (touch) devices via CSS `order`, so
|
|
22
|
-
* it lands where selection toggles are conventionally placed on mobile. The
|
|
23
|
-
* checkmark uses the `check` icon from the active theme's icon registry.
|
|
24
|
-
*/
|
|
25
|
-
import { useCallback } from 'react';
|
|
26
|
-
import * as stylex from '@stylexjs/stylex';
|
|
27
|
-
import { Icon, renderIconSlot } from "../Icon/index.js";
|
|
28
|
-
import { Item } from "../Item/index.js";
|
|
29
|
-
import { useDropdownMenuContext } from "./DropdownMenuContext.js";
|
|
30
|
-
import "../theme/tokens.stylex.js";
|
|
31
|
-
import { colorVars, spacingVars, radiusVars, durationVars, easeVars, borderVars } from "../theme/tokens.stylex.js";
|
|
32
|
-
import { mergeProps, themeProps } from "../utils/index.js";
|
|
33
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
34
|
-
const styles = {
|
|
35
|
-
root: {
|
|
36
|
-
kzqmXN: "xh8yej3",
|
|
37
|
-
kaIpWk: "x1ws5lxm",
|
|
38
|
-
kMwMTN: "x1tgivj0",
|
|
39
|
-
kWkggS: "xjbqb8w x1c52tdz x1uwx2nv",
|
|
40
|
-
kkrTdU: "x1ypdohk",
|
|
41
|
-
kI3sdo: "x1a2a7pz",
|
|
42
|
-
$$css: true
|
|
43
|
-
},
|
|
44
|
-
disabled: {
|
|
45
|
-
kSiTet: "xbyyjgo",
|
|
46
|
-
kkrTdU: "x1h6gzvc",
|
|
47
|
-
$$css: true
|
|
48
|
-
},
|
|
49
|
-
box: {
|
|
50
|
-
k1xSpc: "x78zum5",
|
|
51
|
-
kGNEyG: "x6s0dn4",
|
|
52
|
-
kjj79g: "xl56j7k",
|
|
53
|
-
kmuXW: "x2lah0s",
|
|
54
|
-
kB7OPa: "x9f619",
|
|
55
|
-
kMzoRj: "x1litavf",
|
|
56
|
-
ksu8eU: "x1y0btm7",
|
|
57
|
-
kaIpWk: "xx3sua9",
|
|
58
|
-
kMwMTN: "x17wrial",
|
|
59
|
-
k1ekBW: "xts7igz",
|
|
60
|
-
kIyJzY: "xuedmi6 x12w9bfk",
|
|
61
|
-
kAMwcw: "xlr8y92",
|
|
62
|
-
kayTVb: "x1g77sc7 xozvky",
|
|
63
|
-
keTefX: "x1lziwak x1jymrmb",
|
|
64
|
-
$$css: true
|
|
65
|
-
},
|
|
66
|
-
unchecked: {
|
|
67
|
-
kVAM5u: "xvy26l8",
|
|
68
|
-
kWkggS: "x10xzikg",
|
|
69
|
-
$$css: true
|
|
70
|
-
},
|
|
71
|
-
checked: {
|
|
72
|
-
kVAM5u: "xad5do",
|
|
73
|
-
kWkggS: "x1ewilqj",
|
|
74
|
-
$$css: true
|
|
75
|
-
}
|
|
76
|
-
};
|
|
77
|
-
const boxSizeStyles = {
|
|
78
|
-
sm: {
|
|
79
|
-
kzqmXN: "x1xp8n7a",
|
|
80
|
-
kZKoxP: "xmix8c7",
|
|
81
|
-
$$css: true
|
|
82
|
-
},
|
|
83
|
-
md: {
|
|
84
|
-
kzqmXN: "x17z2i9w",
|
|
85
|
-
kZKoxP: "x17rw0jw",
|
|
86
|
-
$$css: true
|
|
87
|
-
}
|
|
88
|
-
};
|
|
89
|
-
/**
|
|
90
|
-
* A checkable dropdown menu item (role="menuitemcheckbox").
|
|
91
|
-
*
|
|
92
|
-
* Must be used inside a DropdownMenu. Toggles an independent boolean; for a
|
|
93
|
-
* one-of-N choice use DropdownMenuRadioGroup + DropdownMenuRadioItem instead.
|
|
94
|
-
*
|
|
95
|
-
* @example
|
|
96
|
-
* ```
|
|
97
|
-
* * import {DropdownMenuCheckboxItem} from '@astryxdesign/core/DropdownMenu';
|
|
98
|
-
*
|
|
99
|
-
* <DropdownMenu button={{label: 'View'}}>
|
|
100
|
-
* <DropdownMenuCheckboxItem
|
|
101
|
-
* label="Show archived"
|
|
102
|
-
* value={showArchived}
|
|
103
|
-
* onChange={setShowArchived}
|
|
104
|
-
* />
|
|
105
|
-
* </DropdownMenu>
|
|
106
|
-
* ```
|
|
107
|
-
*/
|
|
108
|
-
export function DropdownMenuCheckboxItem({
|
|
109
|
-
label,
|
|
110
|
-
description,
|
|
111
|
-
icon,
|
|
112
|
-
value,
|
|
113
|
-
onChange,
|
|
114
|
-
isDisabled = false,
|
|
115
|
-
hasCloseOnSelect = false,
|
|
116
|
-
endContent,
|
|
117
|
-
xstyle,
|
|
118
|
-
className,
|
|
119
|
-
style,
|
|
120
|
-
...rest
|
|
121
|
-
}) {
|
|
122
|
-
const ctx = useDropdownMenuContext();
|
|
123
|
-
const menuSize = ctx?.menuSize ?? 'md';
|
|
124
|
-
const controlSize = menuSize === 'sm' ? 'sm' : 'md';
|
|
125
|
-
const handleClick = useCallback(() => {
|
|
126
|
-
if (isDisabled) {
|
|
127
|
-
return;
|
|
128
|
-
}
|
|
129
|
-
onChange?.(!value);
|
|
130
|
-
if (hasCloseOnSelect) {
|
|
131
|
-
ctx?.closeMenu();
|
|
132
|
-
}
|
|
133
|
-
}, [isDisabled, onChange, value, hasCloseOnSelect, ctx]);
|
|
134
|
-
return /*#__PURE__*/_jsx(Item, {
|
|
135
|
-
...rest,
|
|
136
|
-
role: "menuitemcheckbox",
|
|
137
|
-
"aria-checked": value,
|
|
138
|
-
tabIndex: isDisabled ? undefined : -1,
|
|
139
|
-
marker: /*#__PURE__*/_jsx("span", {
|
|
140
|
-
"aria-hidden": "true",
|
|
141
|
-
...mergeProps(themeProps('dropdown-menu-checkbox', {
|
|
142
|
-
size: controlSize,
|
|
143
|
-
checked: value ? 'checked' : null,
|
|
144
|
-
disabled: isDisabled ? 'disabled' : null
|
|
145
|
-
}), stylex.props(styles.box, boxSizeStyles[controlSize], value ? styles.checked : styles.unchecked)),
|
|
146
|
-
children: value && /*#__PURE__*/_jsx(Icon, {
|
|
147
|
-
icon: "check",
|
|
148
|
-
size: "sm",
|
|
149
|
-
color: "inherit"
|
|
150
|
-
})
|
|
151
|
-
}),
|
|
152
|
-
startContent: icon ? renderIconSlot(icon, {
|
|
153
|
-
size: 'sm',
|
|
154
|
-
color: 'secondary'
|
|
155
|
-
}) : undefined,
|
|
156
|
-
label: label,
|
|
157
|
-
description: description,
|
|
158
|
-
endContent: endContent,
|
|
159
|
-
onClick: handleClick,
|
|
160
|
-
isDisabled: isDisabled,
|
|
161
|
-
xstyle: [styles.root, isDisabled && styles.disabled, xstyle],
|
|
162
|
-
...mergeProps(themeProps('dropdown-menu-item', {
|
|
163
|
-
size: menuSize
|
|
164
|
-
}), {
|
|
165
|
-
className,
|
|
166
|
-
style
|
|
167
|
-
})
|
|
168
|
-
});
|
|
169
|
-
}
|
|
170
|
-
DropdownMenuCheckboxItem.displayName = 'DropdownMenuCheckboxItem';
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file DropdownMenuRadioGroup.tsx
|
|
3
|
-
* @output DropdownMenuRadioGroup — a single-select group of menu items.
|
|
4
|
-
* @position Sub-component; wraps DropdownMenuRadioItem inside a DropdownMenu.
|
|
5
|
-
*
|
|
6
|
-
* Owns single-selection state (value/onChange) for its child
|
|
7
|
-
* DropdownMenuRadioItems and exposes it via context. Renders role="group" with
|
|
8
|
-
* an accessible name so the radios are announced as a set. Keyboard navigation
|
|
9
|
-
* comes from the parent DropdownMenu's useListFocus, which matches
|
|
10
|
-
* menuitemradio rows.
|
|
11
|
-
*/
|
|
12
|
-
import { type ReactNode } from 'react';
|
|
13
|
-
import type { BaseProps } from '../BaseProps';
|
|
14
|
-
export interface DropdownMenuRadioGroupProps extends Omit<BaseProps, 'onChange'> {
|
|
15
|
-
/**
|
|
16
|
-
* The currently selected value in the group. Pass `undefined` when nothing
|
|
17
|
-
* is selected yet.
|
|
18
|
-
*/
|
|
19
|
-
value: string | undefined;
|
|
20
|
-
/**
|
|
21
|
-
* Callback fired when the selected value changes.
|
|
22
|
-
*/
|
|
23
|
-
onChange: (value: string) => void;
|
|
24
|
-
/**
|
|
25
|
-
* Accessible label for the group. Required (together with `aria-labelledby`,
|
|
26
|
-
* one of the two) so screen readers announce the radios as a named set,
|
|
27
|
-
* e.g. "Sort by".
|
|
28
|
-
*/
|
|
29
|
-
'aria-label'?: string;
|
|
30
|
-
/**
|
|
31
|
-
* The id of an element that labels the group, as an alternative to
|
|
32
|
-
* `aria-label`.
|
|
33
|
-
*/
|
|
34
|
-
'aria-labelledby'?: string;
|
|
35
|
-
/**
|
|
36
|
-
* Whether selecting a value closes the menu. Radio items default to closing
|
|
37
|
-
* on selection (a single-choice commit), unlike checkbox items which stay
|
|
38
|
-
* open.
|
|
39
|
-
* @default true
|
|
40
|
-
*/
|
|
41
|
-
hasCloseOnSelect?: boolean;
|
|
42
|
-
/**
|
|
43
|
-
* The `DropdownMenuRadioItem`s that make up the group.
|
|
44
|
-
*/
|
|
45
|
-
children: ReactNode;
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* A single-select group of radio menu items (role="group" of menuitemradio).
|
|
49
|
-
*
|
|
50
|
-
* @example
|
|
51
|
-
* ```
|
|
52
|
-
* * import {
|
|
53
|
-
* DropdownMenuRadioGroup,
|
|
54
|
-
* DropdownMenuRadioItem,
|
|
55
|
-
* } from '@astryxdesign/core/DropdownMenu';
|
|
56
|
-
*
|
|
57
|
-
* <DropdownMenu button={{label: 'Sort'}}>
|
|
58
|
-
* <DropdownMenuRadioGroup value={sort} onChange={setSort} aria-label="Sort by">
|
|
59
|
-
* <DropdownMenuRadioItem value="newest" label="Newest" />
|
|
60
|
-
* <DropdownMenuRadioItem value="oldest" label="Oldest" />
|
|
61
|
-
* </DropdownMenuRadioGroup>
|
|
62
|
-
* </DropdownMenu>
|
|
63
|
-
* ```
|
|
64
|
-
*/
|
|
65
|
-
export declare function DropdownMenuRadioGroup({ value, onChange, hasCloseOnSelect, children, className, style, ...rest }: DropdownMenuRadioGroupProps): import("react").JSX.Element;
|
|
66
|
-
export declare namespace DropdownMenuRadioGroup {
|
|
67
|
-
var displayName: string;
|
|
68
|
-
}
|
|
69
|
-
//# sourceMappingURL=DropdownMenuRadioGroup.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"DropdownMenuRadioGroup.d.ts","sourceRoot":"","sources":["../../src/DropdownMenu/DropdownMenuRadioGroup.tsx"],"names":[],"mappings":"AAIA;;;;;;;;;;GAUG;AAEH,OAAO,EAAU,KAAK,SAAS,EAAC,MAAM,OAAO,CAAC;AAI9C,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,cAAc,CAAC;AAiB5C,MAAM,WAAW,2BAA4B,SAAQ,IAAI,CACvD,SAAS,EACT,UAAU,CACX;IACC;;;OAGG;IACH,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B;;OAEG;IACH,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC;;;;OAIG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;OAGG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B;;;;;OAKG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B;;OAEG;IACH,QAAQ,EAAE,SAAS,CAAC;CACrB;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,sBAAsB,CAAC,EACrC,KAAK,EACL,QAAQ,EACR,gBAAuB,EACvB,QAAQ,EACR,SAAS,EACT,KAAK,EACL,GAAG,IAAI,EACR,EAAE,2BAA2B,+BAgB7B;yBAxBe,sBAAsB"}
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
-
|
|
3
|
-
'use client';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* @file DropdownMenuRadioGroup.tsx
|
|
7
|
-
* @output DropdownMenuRadioGroup — a single-select group of menu items.
|
|
8
|
-
* @position Sub-component; wraps DropdownMenuRadioItem inside a DropdownMenu.
|
|
9
|
-
*
|
|
10
|
-
* Owns single-selection state (value/onChange) for its child
|
|
11
|
-
* DropdownMenuRadioItems and exposes it via context. Renders role="group" with
|
|
12
|
-
* an accessible name so the radios are announced as a set. Keyboard navigation
|
|
13
|
-
* comes from the parent DropdownMenu's useListFocus, which matches
|
|
14
|
-
* menuitemradio rows.
|
|
15
|
-
*/
|
|
16
|
-
import { useMemo } from 'react';
|
|
17
|
-
import * as stylex from '@stylexjs/stylex';
|
|
18
|
-
import "../theme/tokens.stylex.js";
|
|
19
|
-
import { spacingVars } from "../theme/tokens.stylex.js";
|
|
20
|
-
import { mergeProps } from "../utils/index.js";
|
|
21
|
-
import { DropdownMenuRadioGroupContext } from "./DropdownMenuContext.js";
|
|
22
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
23
|
-
/**
|
|
24
|
-
* A single-select group of radio menu items (role="group" of menuitemradio).
|
|
25
|
-
*
|
|
26
|
-
* @example
|
|
27
|
-
* ```
|
|
28
|
-
* * import {
|
|
29
|
-
* DropdownMenuRadioGroup,
|
|
30
|
-
* DropdownMenuRadioItem,
|
|
31
|
-
* } from '@astryxdesign/core/DropdownMenu';
|
|
32
|
-
*
|
|
33
|
-
* <DropdownMenu button={{label: 'Sort'}}>
|
|
34
|
-
* <DropdownMenuRadioGroup value={sort} onChange={setSort} aria-label="Sort by">
|
|
35
|
-
* <DropdownMenuRadioItem value="newest" label="Newest" />
|
|
36
|
-
* <DropdownMenuRadioItem value="oldest" label="Oldest" />
|
|
37
|
-
* </DropdownMenuRadioGroup>
|
|
38
|
-
* </DropdownMenu>
|
|
39
|
-
* ```
|
|
40
|
-
*/
|
|
41
|
-
export function DropdownMenuRadioGroup({
|
|
42
|
-
value,
|
|
43
|
-
onChange,
|
|
44
|
-
hasCloseOnSelect = true,
|
|
45
|
-
children,
|
|
46
|
-
className,
|
|
47
|
-
style,
|
|
48
|
-
...rest
|
|
49
|
-
}) {
|
|
50
|
-
const contextValue = useMemo(() => ({
|
|
51
|
-
value,
|
|
52
|
-
onChange,
|
|
53
|
-
hasCloseOnSelect
|
|
54
|
-
}), [value, onChange, hasCloseOnSelect]);
|
|
55
|
-
return /*#__PURE__*/_jsx("div", {
|
|
56
|
-
...rest,
|
|
57
|
-
role: "group",
|
|
58
|
-
...mergeProps({
|
|
59
|
-
className: "x78zum5 xdt5ytf x1lsbc85"
|
|
60
|
-
}, {
|
|
61
|
-
className,
|
|
62
|
-
style
|
|
63
|
-
}),
|
|
64
|
-
children: /*#__PURE__*/_jsx(DropdownMenuRadioGroupContext, {
|
|
65
|
-
value: contextValue,
|
|
66
|
-
children: children
|
|
67
|
-
})
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
DropdownMenuRadioGroup.displayName = 'DropdownMenuRadioGroup';
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file DropdownMenuRadioItem.tsx
|
|
3
|
-
* @input React, stylex, Item + Icon + DropdownMenu context + tokens from core
|
|
4
|
-
* @output DropdownMenuRadioItem — a single option in a radio group.
|
|
5
|
-
* @position Sub-component; must be used inside a DropdownMenuRadioGroup.
|
|
6
|
-
*
|
|
7
|
-
* A menu item representing one option in a single-select group
|
|
8
|
-
* (role="menuitemradio"). The row owns the role and aria-checked; there is no
|
|
9
|
-
* nested native <input> (per the WAI-ARIA menuitemradio pattern). Selection
|
|
10
|
-
* state + onChange come from DropdownMenuRadioGroupContext. Keyboard nav +
|
|
11
|
-
* Enter/Space activation come from the parent DropdownMenu.
|
|
12
|
-
*
|
|
13
|
-
* The round radio visual (circle + center dot) is decorative (aria-hidden) —
|
|
14
|
-
* the row owns the checked state. Its size is derived from the menu's item size
|
|
15
|
-
* and it swaps to the inline-end of the row on coarse-pointer (touch) devices
|
|
16
|
-
* via CSS `order`. The dot is a shaped element, not an icon (a filled circle
|
|
17
|
-
* has no registry glyph).
|
|
18
|
-
*/
|
|
19
|
-
import { type ReactNode } from 'react';
|
|
20
|
-
import { type IconType } from '../Icon';
|
|
21
|
-
import type { BaseProps } from '../BaseProps';
|
|
22
|
-
export interface DropdownMenuRadioItemProps extends Omit<BaseProps, 'role' | 'aria-checked' | 'tabIndex'> {
|
|
23
|
-
/**
|
|
24
|
-
* The value this item represents within its group. The group's `value`
|
|
25
|
-
* matches against this to determine the checked state.
|
|
26
|
-
*/
|
|
27
|
-
value: string;
|
|
28
|
-
/**
|
|
29
|
-
* Primary label text identifying the option.
|
|
30
|
-
*/
|
|
31
|
-
label: ReactNode;
|
|
32
|
-
/**
|
|
33
|
-
* Secondary description text displayed below the label.
|
|
34
|
-
*/
|
|
35
|
-
description?: ReactNode;
|
|
36
|
-
/**
|
|
37
|
-
* Icon to display before the label. Accepts a semantic icon name (see
|
|
38
|
-
* `npx astryx docs icons`) or a rendered node.
|
|
39
|
-
*/
|
|
40
|
-
icon?: ReactNode | IconType;
|
|
41
|
-
/**
|
|
42
|
-
* Whether this individual radio item is disabled. Disabled items stay
|
|
43
|
-
* focusable (via `aria-disabled`) so they remain discoverable by keyboard
|
|
44
|
-
* and assistive technology, but selection is blocked.
|
|
45
|
-
* @default false
|
|
46
|
-
*/
|
|
47
|
-
isDisabled?: boolean;
|
|
48
|
-
/**
|
|
49
|
-
* Content to render after the label and description, such as a badge or
|
|
50
|
-
* metadata.
|
|
51
|
-
*/
|
|
52
|
-
endContent?: ReactNode;
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* A single option in a DropdownMenuRadioGroup (role="menuitemradio").
|
|
56
|
-
*
|
|
57
|
-
* @example
|
|
58
|
-
* ```
|
|
59
|
-
* <DropdownMenuRadioGroup value={sort} onChange={setSort} aria-label="Sort by">
|
|
60
|
-
* <DropdownMenuRadioItem value="newest" label="Newest" />
|
|
61
|
-
* <DropdownMenuRadioItem value="oldest" label="Oldest" icon="clock" />
|
|
62
|
-
* </DropdownMenuRadioGroup>
|
|
63
|
-
* ```
|
|
64
|
-
*/
|
|
65
|
-
export declare function DropdownMenuRadioItem({ value, label, description, icon, isDisabled, endContent, xstyle, className, style, ...rest }: DropdownMenuRadioItemProps): import("react").JSX.Element;
|
|
66
|
-
export declare namespace DropdownMenuRadioItem {
|
|
67
|
-
var displayName: string;
|
|
68
|
-
}
|
|
69
|
-
//# sourceMappingURL=DropdownMenuRadioItem.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"DropdownMenuRadioItem.d.ts","sourceRoot":"","sources":["../../src/DropdownMenu/DropdownMenuRadioItem.tsx"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAc,KAAK,SAAS,EAAC,MAAM,OAAO,CAAC;AAElD,OAAO,EAAiB,KAAK,QAAQ,EAAC,MAAM,SAAS,CAAC;AAWtD,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,cAAc,CAAC;AAsE5C,MAAM,WAAW,0BAA2B,SAAQ,IAAI,CACtD,SAAS,EACT,MAAM,GAAG,cAAc,GAAG,UAAU,CACrC;IACC;;;OAGG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,KAAK,EAAE,SAAS,CAAC;IACjB;;OAEG;IACH,WAAW,CAAC,EAAE,SAAS,CAAC;IACxB;;;OAGG;IACH,IAAI,CAAC,EAAE,SAAS,GAAG,QAAQ,CAAC;IAC5B;;;;;OAKG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;OAGG;IACH,UAAU,CAAC,EAAE,SAAS,CAAC;CACxB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,qBAAqB,CAAC,EACpC,KAAK,EACL,KAAK,EACL,WAAW,EACX,IAAI,EACJ,UAAkB,EAClB,UAAU,EACV,MAAM,EACN,SAAS,EACT,KAAK,EACL,GAAG,IAAI,EACR,EAAE,0BAA0B,+BAiE5B;yBA5Ee,qBAAqB"}
|
|
@@ -1,178 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
-
|
|
3
|
-
'use client';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* @file DropdownMenuRadioItem.tsx
|
|
7
|
-
* @input React, stylex, Item + Icon + DropdownMenu context + tokens from core
|
|
8
|
-
* @output DropdownMenuRadioItem — a single option in a radio group.
|
|
9
|
-
* @position Sub-component; must be used inside a DropdownMenuRadioGroup.
|
|
10
|
-
*
|
|
11
|
-
* A menu item representing one option in a single-select group
|
|
12
|
-
* (role="menuitemradio"). The row owns the role and aria-checked; there is no
|
|
13
|
-
* nested native <input> (per the WAI-ARIA menuitemradio pattern). Selection
|
|
14
|
-
* state + onChange come from DropdownMenuRadioGroupContext. Keyboard nav +
|
|
15
|
-
* Enter/Space activation come from the parent DropdownMenu.
|
|
16
|
-
*
|
|
17
|
-
* The round radio visual (circle + center dot) is decorative (aria-hidden) —
|
|
18
|
-
* the row owns the checked state. Its size is derived from the menu's item size
|
|
19
|
-
* and it swaps to the inline-end of the row on coarse-pointer (touch) devices
|
|
20
|
-
* via CSS `order`. The dot is a shaped element, not an icon (a filled circle
|
|
21
|
-
* has no registry glyph).
|
|
22
|
-
*/
|
|
23
|
-
import { useCallback } from 'react';
|
|
24
|
-
import * as stylex from '@stylexjs/stylex';
|
|
25
|
-
import { renderIconSlot } from "../Icon/index.js";
|
|
26
|
-
import { Item } from "../Item/index.js";
|
|
27
|
-
import { useDropdownMenuContext } from "./DropdownMenuContext.js";
|
|
28
|
-
import "../theme/tokens.stylex.js";
|
|
29
|
-
import { colorVars, spacingVars, durationVars, easeVars, borderVars } from "../theme/tokens.stylex.js";
|
|
30
|
-
import { mergeProps, themeProps } from "../utils/index.js";
|
|
31
|
-
import { useDropdownMenuRadioGroupContext } from "./DropdownMenuContext.js";
|
|
32
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
33
|
-
const styles = {
|
|
34
|
-
root: {
|
|
35
|
-
kzqmXN: "xh8yej3",
|
|
36
|
-
kaIpWk: "x1ws5lxm",
|
|
37
|
-
kMwMTN: "x1tgivj0",
|
|
38
|
-
kWkggS: "xjbqb8w x1c52tdz x1uwx2nv",
|
|
39
|
-
kkrTdU: "x1ypdohk",
|
|
40
|
-
kI3sdo: "x1a2a7pz",
|
|
41
|
-
$$css: true
|
|
42
|
-
},
|
|
43
|
-
disabled: {
|
|
44
|
-
kSiTet: "xbyyjgo",
|
|
45
|
-
kkrTdU: "x1h6gzvc",
|
|
46
|
-
$$css: true
|
|
47
|
-
},
|
|
48
|
-
circle: {
|
|
49
|
-
k1xSpc: "x78zum5",
|
|
50
|
-
kGNEyG: "x6s0dn4",
|
|
51
|
-
kjj79g: "xl56j7k",
|
|
52
|
-
kmuXW: "x2lah0s",
|
|
53
|
-
kB7OPa: "x9f619",
|
|
54
|
-
kMzoRj: "x1litavf",
|
|
55
|
-
ksu8eU: "x1y0btm7",
|
|
56
|
-
kaIpWk: "x16rqkct",
|
|
57
|
-
k1ekBW: "xts7igz",
|
|
58
|
-
kIyJzY: "xuedmi6 x12w9bfk",
|
|
59
|
-
kAMwcw: "xlr8y92",
|
|
60
|
-
kayTVb: "x1g77sc7 xozvky",
|
|
61
|
-
keTefX: "x1lziwak x1jymrmb",
|
|
62
|
-
$$css: true
|
|
63
|
-
},
|
|
64
|
-
unchecked: {
|
|
65
|
-
kVAM5u: "xvy26l8",
|
|
66
|
-
kWkggS: "x10xzikg",
|
|
67
|
-
$$css: true
|
|
68
|
-
},
|
|
69
|
-
checked: {
|
|
70
|
-
kVAM5u: "xad5do",
|
|
71
|
-
kWkggS: "x1ewilqj",
|
|
72
|
-
$$css: true
|
|
73
|
-
},
|
|
74
|
-
dot: {
|
|
75
|
-
kaIpWk: "x16rqkct",
|
|
76
|
-
kWkggS: "x1azo05",
|
|
77
|
-
$$css: true
|
|
78
|
-
}
|
|
79
|
-
};
|
|
80
|
-
const circleSizeStyles = {
|
|
81
|
-
sm: {
|
|
82
|
-
kzqmXN: "x1xp8n7a",
|
|
83
|
-
kZKoxP: "xmix8c7",
|
|
84
|
-
$$css: true
|
|
85
|
-
},
|
|
86
|
-
md: {
|
|
87
|
-
kzqmXN: "x17z2i9w",
|
|
88
|
-
kZKoxP: "x17rw0jw",
|
|
89
|
-
$$css: true
|
|
90
|
-
}
|
|
91
|
-
};
|
|
92
|
-
const dotSizeStyles = {
|
|
93
|
-
sm: {
|
|
94
|
-
kzqmXN: "x1v4s8kt",
|
|
95
|
-
kZKoxP: "xols6we",
|
|
96
|
-
$$css: true
|
|
97
|
-
},
|
|
98
|
-
md: {
|
|
99
|
-
kzqmXN: "x1xc55vz",
|
|
100
|
-
kZKoxP: "xdk7pt",
|
|
101
|
-
$$css: true
|
|
102
|
-
}
|
|
103
|
-
};
|
|
104
|
-
/**
|
|
105
|
-
* A single option in a DropdownMenuRadioGroup (role="menuitemradio").
|
|
106
|
-
*
|
|
107
|
-
* @example
|
|
108
|
-
* ```
|
|
109
|
-
* <DropdownMenuRadioGroup value={sort} onChange={setSort} aria-label="Sort by">
|
|
110
|
-
* <DropdownMenuRadioItem value="newest" label="Newest" />
|
|
111
|
-
* <DropdownMenuRadioItem value="oldest" label="Oldest" icon="clock" />
|
|
112
|
-
* </DropdownMenuRadioGroup>
|
|
113
|
-
* ```
|
|
114
|
-
*/
|
|
115
|
-
export function DropdownMenuRadioItem({
|
|
116
|
-
value,
|
|
117
|
-
label,
|
|
118
|
-
description,
|
|
119
|
-
icon,
|
|
120
|
-
isDisabled = false,
|
|
121
|
-
endContent,
|
|
122
|
-
xstyle,
|
|
123
|
-
className,
|
|
124
|
-
style,
|
|
125
|
-
...rest
|
|
126
|
-
}) {
|
|
127
|
-
const menuCtx = useDropdownMenuContext();
|
|
128
|
-
const groupCtx = useDropdownMenuRadioGroupContext();
|
|
129
|
-
if (!groupCtx) {
|
|
130
|
-
throw new Error('DropdownMenuRadioItem must be used within a DropdownMenuRadioGroup');
|
|
131
|
-
}
|
|
132
|
-
const menuSize = menuCtx?.menuSize ?? 'md';
|
|
133
|
-
const controlSize = menuSize === 'sm' ? 'sm' : 'md';
|
|
134
|
-
const isChecked = groupCtx.value === value;
|
|
135
|
-
const handleClick = useCallback(() => {
|
|
136
|
-
if (isDisabled) {
|
|
137
|
-
return;
|
|
138
|
-
}
|
|
139
|
-
groupCtx.onChange(value);
|
|
140
|
-
if (groupCtx.hasCloseOnSelect) {
|
|
141
|
-
menuCtx?.closeMenu();
|
|
142
|
-
}
|
|
143
|
-
}, [isDisabled, groupCtx, value, menuCtx]);
|
|
144
|
-
return /*#__PURE__*/_jsx(Item, {
|
|
145
|
-
...rest,
|
|
146
|
-
role: "menuitemradio",
|
|
147
|
-
"aria-checked": isChecked,
|
|
148
|
-
tabIndex: isDisabled ? undefined : -1,
|
|
149
|
-
marker: /*#__PURE__*/_jsx("span", {
|
|
150
|
-
"aria-hidden": "true",
|
|
151
|
-
...mergeProps(themeProps('dropdown-menu-radio', {
|
|
152
|
-
size: controlSize,
|
|
153
|
-
checked: isChecked ? 'checked' : null,
|
|
154
|
-
disabled: isDisabled ? 'disabled' : null
|
|
155
|
-
}), stylex.props(styles.circle, circleSizeStyles[controlSize], isChecked ? styles.checked : styles.unchecked)),
|
|
156
|
-
children: isChecked && /*#__PURE__*/_jsx("span", {
|
|
157
|
-
...stylex.props(styles.dot, dotSizeStyles[controlSize])
|
|
158
|
-
})
|
|
159
|
-
}),
|
|
160
|
-
startContent: icon ? renderIconSlot(icon, {
|
|
161
|
-
size: 'sm',
|
|
162
|
-
color: 'secondary'
|
|
163
|
-
}) : undefined,
|
|
164
|
-
label: label,
|
|
165
|
-
description: description,
|
|
166
|
-
endContent: endContent,
|
|
167
|
-
onClick: handleClick,
|
|
168
|
-
isDisabled: isDisabled,
|
|
169
|
-
xstyle: [styles.root, isDisabled && styles.disabled, xstyle],
|
|
170
|
-
...mergeProps(themeProps('dropdown-menu-item', {
|
|
171
|
-
size: menuSize
|
|
172
|
-
}), {
|
|
173
|
-
className,
|
|
174
|
-
style
|
|
175
|
-
})
|
|
176
|
-
});
|
|
177
|
-
}
|
|
178
|
-
DropdownMenuRadioItem.displayName = 'DropdownMenuRadioItem';
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file menuItemRoles.ts
|
|
3
|
-
* @output Shared menu-item role set + focus selector.
|
|
4
|
-
* @position Internal; used by DropdownMenu and ContextMenu so their
|
|
5
|
-
* roving-focus, typeahead, and Enter/Space activation stay in sync.
|
|
6
|
-
*
|
|
7
|
-
* Includes the selectable items (menuitemradio/menuitemcheckbox) alongside
|
|
8
|
-
* plain menuitem so checkbox/radio rows are reachable by arrow keys, typeahead,
|
|
9
|
-
* and Enter/Space — not just role="menuitem".
|
|
10
|
-
*/
|
|
11
|
-
export declare const MENU_ITEM_ROLES: ReadonlySet<string>;
|
|
12
|
-
export declare const MENU_ITEM_SELECTOR: string;
|
|
13
|
-
//# sourceMappingURL=menuItemRoles.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"menuItemRoles.d.ts","sourceRoot":"","sources":["../../src/DropdownMenu/menuItemRoles.ts"],"names":[],"mappings":"AAEA;;;;;;;;;GASG;AAEH,eAAO,MAAM,eAAe,EAAE,WAAW,CAAC,MAAM,CAI9C,CAAC;AAEH,eAAO,MAAM,kBAAkB,EAAE,MAErB,CAAC"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @file menuItemRoles.ts
|
|
5
|
-
* @output Shared menu-item role set + focus selector.
|
|
6
|
-
* @position Internal; used by DropdownMenu and ContextMenu so their
|
|
7
|
-
* roving-focus, typeahead, and Enter/Space activation stay in sync.
|
|
8
|
-
*
|
|
9
|
-
* Includes the selectable items (menuitemradio/menuitemcheckbox) alongside
|
|
10
|
-
* plain menuitem so checkbox/radio rows are reachable by arrow keys, typeahead,
|
|
11
|
-
* and Enter/Space — not just role="menuitem".
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
export const MENU_ITEM_ROLES = new Set(['menuitem', 'menuitemradio', 'menuitemcheckbox']);
|
|
15
|
-
export const MENU_ITEM_SELECTOR = [...MENU_ITEM_ROLES].map(role => `[role="${role}"]:not([aria-disabled="true"])`).join(',');
|