@oxyhq/bloom 0.17.0 → 0.18.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/lib/commonjs/admonition/index.js +24 -23
- package/lib/commonjs/admonition/index.js.map +1 -1
- package/lib/commonjs/combobox/Combobox.js +7 -7
- package/lib/commonjs/combobox/Combobox.js.map +1 -1
- package/lib/commonjs/context-menu/context.js +2 -2
- package/lib/commonjs/context-menu/context.js.map +1 -1
- package/lib/commonjs/context-menu/index.js +25 -25
- package/lib/commonjs/context-menu/index.js.map +1 -1
- package/lib/commonjs/context-menu/index.web.js +27 -27
- package/lib/commonjs/context-menu/index.web.js.map +1 -1
- package/lib/commonjs/dialog/SheetShell.js +1 -1
- package/lib/commonjs/index.js +134 -38
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/index.web.js +134 -38
- package/lib/commonjs/index.web.js.map +1 -1
- package/lib/commonjs/input-group/InputGroup.js +1 -1
- package/lib/commonjs/menu/context.js +2 -2
- package/lib/commonjs/menu/context.js.map +1 -1
- package/lib/commonjs/menu/index.js +17 -17
- package/lib/commonjs/menu/index.js.map +1 -1
- package/lib/commonjs/menu/index.web.js +16 -16
- package/lib/commonjs/menu/index.web.js.map +1 -1
- package/lib/commonjs/popover/context.js +1 -1
- package/lib/commonjs/popover/context.js.map +1 -1
- package/lib/commonjs/popover/index.js +6 -6
- package/lib/commonjs/popover/index.js.map +1 -1
- package/lib/commonjs/popover/index.web.js +6 -6
- package/lib/commonjs/popover/index.web.js.map +1 -1
- package/lib/commonjs/search-input/index.js +4 -5
- package/lib/commonjs/search-input/index.js.map +1 -1
- package/lib/commonjs/segmented-control/index.js +18 -18
- package/lib/commonjs/segmented-control/index.js.map +1 -1
- package/lib/commonjs/select/common.js +2 -2
- package/lib/commonjs/select/common.js.map +1 -1
- package/lib/commonjs/select/index.js +34 -38
- package/lib/commonjs/select/index.js.map +1 -1
- package/lib/commonjs/select/index.web.js +31 -35
- package/lib/commonjs/select/index.web.js.map +1 -1
- package/lib/commonjs/tabs/Tabs.js +7 -7
- package/lib/commonjs/tabs/Tabs.js.map +1 -1
- package/lib/commonjs/tabs/index.js +6 -6
- package/lib/commonjs/text-field/index.js +14 -14
- package/lib/commonjs/text-field/index.js.map +1 -1
- package/lib/commonjs/theme/color-scope/style-builder.js +6 -6
- package/lib/commonjs/tooltip/index.js +11 -11
- package/lib/commonjs/tooltip/index.js.map +1 -1
- package/lib/commonjs/tooltip/index.web.js +11 -11
- package/lib/commonjs/tooltip/index.web.js.map +1 -1
- package/lib/module/admonition/index.js +18 -17
- package/lib/module/admonition/index.js.map +1 -1
- package/lib/module/combobox/Combobox.js +7 -7
- package/lib/module/combobox/Combobox.js.map +1 -1
- package/lib/module/context-menu/context.js +2 -2
- package/lib/module/context-menu/context.js.map +1 -1
- package/lib/module/context-menu/index.js +17 -17
- package/lib/module/context-menu/index.js.map +1 -1
- package/lib/module/context-menu/index.web.js +19 -19
- package/lib/module/context-menu/index.web.js.map +1 -1
- package/lib/module/dialog/SheetShell.js +1 -1
- package/lib/module/index.js +11 -11
- package/lib/module/index.js.map +1 -1
- package/lib/module/index.web.js +11 -11
- package/lib/module/index.web.js.map +1 -1
- package/lib/module/input-group/InputGroup.js +1 -1
- package/lib/module/menu/context.js +2 -2
- package/lib/module/menu/context.js.map +1 -1
- package/lib/module/menu/index.js +9 -9
- package/lib/module/menu/index.js.map +1 -1
- package/lib/module/menu/index.web.js +8 -8
- package/lib/module/menu/index.web.js.map +1 -1
- package/lib/module/popover/context.js +1 -1
- package/lib/module/popover/context.js.map +1 -1
- package/lib/module/popover/index.js +3 -3
- package/lib/module/popover/index.js.map +1 -1
- package/lib/module/popover/index.web.js +3 -3
- package/lib/module/popover/index.web.js.map +1 -1
- package/lib/module/search-input/index.js +4 -4
- package/lib/module/search-input/index.js.map +1 -1
- package/lib/module/segmented-control/index.js +15 -15
- package/lib/module/segmented-control/index.js.map +1 -1
- package/lib/module/select/common.js +1 -1
- package/lib/module/select/common.js.map +1 -1
- package/lib/module/select/index.js +25 -29
- package/lib/module/select/index.js.map +1 -1
- package/lib/module/select/index.web.js +22 -26
- package/lib/module/select/index.web.js.map +1 -1
- package/lib/module/tabs/Tabs.js +6 -6
- package/lib/module/tabs/Tabs.js.map +1 -1
- package/lib/module/tabs/index.js +1 -1
- package/lib/module/tabs/index.js.map +1 -1
- package/lib/module/text-field/index.js +8 -8
- package/lib/module/text-field/index.js.map +1 -1
- package/lib/module/theme/color-scope/style-builder.js +6 -6
- package/lib/module/tooltip/index.js +6 -6
- package/lib/module/tooltip/index.js.map +1 -1
- package/lib/module/tooltip/index.web.js +6 -6
- package/lib/module/tooltip/index.web.js.map +1 -1
- package/lib/typescript/commonjs/admonition/index.d.ts +14 -13
- package/lib/typescript/commonjs/admonition/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/combobox/Combobox.d.ts +7 -7
- package/lib/typescript/commonjs/combobox/Combobox.d.ts.map +1 -1
- package/lib/typescript/commonjs/context-menu/index.d.ts +9 -9
- package/lib/typescript/commonjs/context-menu/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/context-menu/index.web.d.ts +9 -9
- package/lib/typescript/commonjs/context-menu/index.web.d.ts.map +1 -1
- package/lib/typescript/commonjs/context-menu/types.d.ts +6 -6
- package/lib/typescript/commonjs/context-menu/types.d.ts.map +1 -1
- package/lib/typescript/commonjs/dialog/SheetShell.d.ts +1 -1
- package/lib/typescript/commonjs/index.d.ts +11 -11
- package/lib/typescript/commonjs/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/index.web.d.ts +11 -11
- package/lib/typescript/commonjs/index.web.d.ts.map +1 -1
- package/lib/typescript/commonjs/input-group/types.d.ts +1 -1
- package/lib/typescript/commonjs/menu/index.d.ts +9 -9
- package/lib/typescript/commonjs/menu/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/menu/index.web.d.ts +9 -9
- package/lib/typescript/commonjs/menu/index.web.d.ts.map +1 -1
- package/lib/typescript/commonjs/menu/types.d.ts +5 -5
- package/lib/typescript/commonjs/menu/types.d.ts.map +1 -1
- package/lib/typescript/commonjs/popover/index.d.ts +5 -5
- package/lib/typescript/commonjs/popover/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/popover/index.web.d.ts +5 -5
- package/lib/typescript/commonjs/popover/index.web.d.ts.map +1 -1
- package/lib/typescript/commonjs/popover/types.d.ts +1 -1
- package/lib/typescript/commonjs/popover/types.d.ts.map +1 -1
- package/lib/typescript/commonjs/search-input/index.d.ts +3 -3
- package/lib/typescript/commonjs/search-input/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/segmented-control/index.d.ts +13 -13
- package/lib/typescript/commonjs/segmented-control/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/select/common.d.ts +1 -1
- package/lib/typescript/commonjs/select/common.d.ts.map +1 -1
- package/lib/typescript/commonjs/select/index.d.ts +12 -12
- package/lib/typescript/commonjs/select/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/select/index.web.d.ts +12 -12
- package/lib/typescript/commonjs/select/index.web.d.ts.map +1 -1
- package/lib/typescript/commonjs/select/types.d.ts +10 -10
- package/lib/typescript/commonjs/select/types.d.ts.map +1 -1
- package/lib/typescript/commonjs/tabs/Tabs.d.ts +4 -4
- package/lib/typescript/commonjs/tabs/Tabs.d.ts.map +1 -1
- package/lib/typescript/commonjs/tabs/index.d.ts +2 -2
- package/lib/typescript/commonjs/tabs/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/tabs/types.d.ts +3 -3
- package/lib/typescript/commonjs/tabs/types.d.ts.map +1 -1
- package/lib/typescript/commonjs/text-field/index.d.ts +8 -8
- package/lib/typescript/commonjs/text-field/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/theme/color-scope/style-builder.d.ts +6 -6
- package/lib/typescript/commonjs/tooltip/index.d.ts +6 -6
- package/lib/typescript/commonjs/tooltip/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/tooltip/index.web.d.ts +6 -6
- package/lib/typescript/commonjs/tooltip/index.web.d.ts.map +1 -1
- package/lib/typescript/module/admonition/index.d.ts +14 -13
- package/lib/typescript/module/admonition/index.d.ts.map +1 -1
- package/lib/typescript/module/combobox/Combobox.d.ts +7 -7
- package/lib/typescript/module/combobox/Combobox.d.ts.map +1 -1
- package/lib/typescript/module/context-menu/index.d.ts +9 -9
- package/lib/typescript/module/context-menu/index.d.ts.map +1 -1
- package/lib/typescript/module/context-menu/index.web.d.ts +9 -9
- package/lib/typescript/module/context-menu/index.web.d.ts.map +1 -1
- package/lib/typescript/module/context-menu/types.d.ts +6 -6
- package/lib/typescript/module/context-menu/types.d.ts.map +1 -1
- package/lib/typescript/module/dialog/SheetShell.d.ts +1 -1
- package/lib/typescript/module/index.d.ts +11 -11
- package/lib/typescript/module/index.d.ts.map +1 -1
- package/lib/typescript/module/index.web.d.ts +11 -11
- package/lib/typescript/module/index.web.d.ts.map +1 -1
- package/lib/typescript/module/input-group/types.d.ts +1 -1
- package/lib/typescript/module/menu/index.d.ts +9 -9
- package/lib/typescript/module/menu/index.d.ts.map +1 -1
- package/lib/typescript/module/menu/index.web.d.ts +9 -9
- package/lib/typescript/module/menu/index.web.d.ts.map +1 -1
- package/lib/typescript/module/menu/types.d.ts +5 -5
- package/lib/typescript/module/menu/types.d.ts.map +1 -1
- package/lib/typescript/module/popover/index.d.ts +5 -5
- package/lib/typescript/module/popover/index.d.ts.map +1 -1
- package/lib/typescript/module/popover/index.web.d.ts +5 -5
- package/lib/typescript/module/popover/index.web.d.ts.map +1 -1
- package/lib/typescript/module/popover/types.d.ts +1 -1
- package/lib/typescript/module/popover/types.d.ts.map +1 -1
- package/lib/typescript/module/search-input/index.d.ts +3 -3
- package/lib/typescript/module/search-input/index.d.ts.map +1 -1
- package/lib/typescript/module/segmented-control/index.d.ts +13 -13
- package/lib/typescript/module/segmented-control/index.d.ts.map +1 -1
- package/lib/typescript/module/select/common.d.ts +1 -1
- package/lib/typescript/module/select/common.d.ts.map +1 -1
- package/lib/typescript/module/select/index.d.ts +12 -12
- package/lib/typescript/module/select/index.d.ts.map +1 -1
- package/lib/typescript/module/select/index.web.d.ts +12 -12
- package/lib/typescript/module/select/index.web.d.ts.map +1 -1
- package/lib/typescript/module/select/types.d.ts +10 -10
- package/lib/typescript/module/select/types.d.ts.map +1 -1
- package/lib/typescript/module/tabs/Tabs.d.ts +4 -4
- package/lib/typescript/module/tabs/Tabs.d.ts.map +1 -1
- package/lib/typescript/module/tabs/index.d.ts +2 -2
- package/lib/typescript/module/tabs/index.d.ts.map +1 -1
- package/lib/typescript/module/tabs/types.d.ts +3 -3
- package/lib/typescript/module/tabs/types.d.ts.map +1 -1
- package/lib/typescript/module/text-field/index.d.ts +8 -8
- package/lib/typescript/module/text-field/index.d.ts.map +1 -1
- package/lib/typescript/module/theme/color-scope/style-builder.d.ts +6 -6
- package/lib/typescript/module/tooltip/index.d.ts +6 -6
- package/lib/typescript/module/tooltip/index.d.ts.map +1 -1
- package/lib/typescript/module/tooltip/index.web.d.ts +6 -6
- package/lib/typescript/module/tooltip/index.web.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/__tests__/public-api-contract.test.ts +19 -7
- package/src/__tests__/useNavigationTheme.test.tsx +227 -0
- package/src/admonition/index.tsx +22 -21
- package/src/combobox/Combobox.tsx +14 -14
- package/src/context-menu/ContextMenu.stories.tsx +26 -18
- package/src/context-menu/context.ts +2 -2
- package/src/context-menu/index.tsx +24 -24
- package/src/context-menu/index.web.tsx +26 -26
- package/src/context-menu/types.ts +6 -6
- package/src/dialog/SheetShell.tsx +1 -1
- package/src/field/Field.stories.tsx +3 -3
- package/src/index.ts +11 -11
- package/src/index.web.ts +11 -11
- package/src/input-group/InputGroup.stories.tsx +4 -4
- package/src/input-group/InputGroup.tsx +1 -1
- package/src/input-group/types.ts +1 -1
- package/src/menu/Menu.stories.tsx +35 -35
- package/src/menu/context.ts +2 -2
- package/src/menu/index.tsx +15 -15
- package/src/menu/index.web.tsx +14 -14
- package/src/menu/types.ts +5 -5
- package/src/popover/Popover.stories.tsx +13 -13
- package/src/popover/context.ts +1 -1
- package/src/popover/index.tsx +5 -5
- package/src/popover/index.web.tsx +5 -5
- package/src/popover/types.ts +1 -1
- package/src/search-input/index.tsx +7 -7
- package/src/segmented-control/index.tsx +15 -15
- package/src/select/Select.stories.tsx +32 -23
- package/src/select/common.ts +1 -1
- package/src/select/index.tsx +39 -43
- package/src/select/index.web.tsx +33 -37
- package/src/select/types.ts +10 -10
- package/src/tabs/Tabs.tsx +9 -9
- package/src/tabs/index.ts +2 -2
- package/src/tabs/types.ts +3 -3
- package/src/text-field/TextField.stories.tsx +5 -5
- package/src/text-field/index.tsx +12 -12
- package/src/theme/color-scope/style-builder.ts +6 -6
- package/src/tooltip/index.tsx +6 -6
- package/src/tooltip/index.web.tsx +6 -6
package/src/menu/index.tsx
CHANGED
|
@@ -15,18 +15,18 @@ import {
|
|
|
15
15
|
} from './context';
|
|
16
16
|
import type {
|
|
17
17
|
MenuContextType,
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
18
|
+
MenuGroupProps,
|
|
19
|
+
MenuItemIconProps,
|
|
20
|
+
MenuItemProps,
|
|
21
|
+
MenuItemTextProps,
|
|
22
|
+
MenuTriggerProps,
|
|
23
23
|
} from './types';
|
|
24
24
|
|
|
25
25
|
export type { DialogControlProps as MenuControlProps } from '../dialog/types';
|
|
26
26
|
export { useDialogControl as useMenuControl } from '../dialog/context';
|
|
27
27
|
export { useMenuContext };
|
|
28
28
|
|
|
29
|
-
export function
|
|
29
|
+
export function Menu({
|
|
30
30
|
children,
|
|
31
31
|
control,
|
|
32
32
|
}: React.PropsWithChildren<{
|
|
@@ -47,12 +47,12 @@ export function Root({
|
|
|
47
47
|
);
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
export function
|
|
50
|
+
export function MenuTrigger({
|
|
51
51
|
children,
|
|
52
52
|
label,
|
|
53
53
|
role = 'button',
|
|
54
54
|
hint,
|
|
55
|
-
}:
|
|
55
|
+
}: MenuTriggerProps) {
|
|
56
56
|
const context = useMenuContext();
|
|
57
57
|
const [focused, setFocused] = useState(false);
|
|
58
58
|
const [pressed, setPressed] = useState(false);
|
|
@@ -75,7 +75,7 @@ export function Trigger({
|
|
|
75
75
|
});
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
-
export function
|
|
78
|
+
export function MenuContent({
|
|
79
79
|
children,
|
|
80
80
|
showCancel,
|
|
81
81
|
}: React.PropsWithChildren<{
|
|
@@ -96,7 +96,7 @@ export function Outer({
|
|
|
96
96
|
);
|
|
97
97
|
}
|
|
98
98
|
|
|
99
|
-
export function
|
|
99
|
+
export function MenuItem({ children, label, style, onPress, ...rest }: MenuItemProps) {
|
|
100
100
|
const theme = useTheme();
|
|
101
101
|
const context = useMenuContext();
|
|
102
102
|
const [focused, setFocused] = useState(false);
|
|
@@ -148,7 +148,7 @@ export function Item({ children, label, style, onPress, ...rest }: ItemProps) {
|
|
|
148
148
|
);
|
|
149
149
|
}
|
|
150
150
|
|
|
151
|
-
export function
|
|
151
|
+
export function MenuItemText({ children, style }: MenuItemTextProps) {
|
|
152
152
|
const theme = useTheme();
|
|
153
153
|
const { disabled } = useMenuItemContext();
|
|
154
154
|
|
|
@@ -167,7 +167,7 @@ export function ItemText({ children, style }: ItemTextProps) {
|
|
|
167
167
|
);
|
|
168
168
|
}
|
|
169
169
|
|
|
170
|
-
export function
|
|
170
|
+
export function MenuItemIcon({ icon: Comp, fill }: MenuItemIconProps) {
|
|
171
171
|
const theme = useTheme();
|
|
172
172
|
const { disabled } = useMenuItemContext();
|
|
173
173
|
|
|
@@ -185,7 +185,7 @@ export function ItemIcon({ icon: Comp, fill }: ItemIconProps) {
|
|
|
185
185
|
);
|
|
186
186
|
}
|
|
187
187
|
|
|
188
|
-
export function
|
|
188
|
+
export function MenuGroup({ children, style }: MenuGroupProps) {
|
|
189
189
|
const theme = useTheme();
|
|
190
190
|
|
|
191
191
|
const childArray = React.Children.toArray(children).filter(isValidElement);
|
|
@@ -199,7 +199,7 @@ export function Group({ children, style }: GroupProps) {
|
|
|
199
199
|
]}
|
|
200
200
|
>
|
|
201
201
|
{childArray.map((child, i) => {
|
|
202
|
-
if (child.type ===
|
|
202
|
+
if (child.type === MenuItem) {
|
|
203
203
|
return (
|
|
204
204
|
<Fragment key={i}>
|
|
205
205
|
{i > 0 && (
|
|
@@ -225,7 +225,7 @@ export function Group({ children, style }: GroupProps) {
|
|
|
225
225
|
);
|
|
226
226
|
}
|
|
227
227
|
|
|
228
|
-
export function
|
|
228
|
+
export function MenuDivider() {
|
|
229
229
|
return null;
|
|
230
230
|
}
|
|
231
231
|
|
package/src/menu/index.web.tsx
CHANGED
|
@@ -25,11 +25,11 @@ import {
|
|
|
25
25
|
} from './context';
|
|
26
26
|
import type {
|
|
27
27
|
MenuContextType,
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
28
|
+
MenuGroupProps,
|
|
29
|
+
MenuItemIconProps,
|
|
30
|
+
MenuItemProps,
|
|
31
|
+
MenuItemTextProps,
|
|
32
|
+
MenuTriggerProps,
|
|
33
33
|
} from './types';
|
|
34
34
|
|
|
35
35
|
export { useMenuContext };
|
|
@@ -92,7 +92,7 @@ function useMenuControlAsDialogControl(
|
|
|
92
92
|
}, [menuControl]);
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
-
export function
|
|
95
|
+
export function Menu({
|
|
96
96
|
children,
|
|
97
97
|
control,
|
|
98
98
|
}: React.PropsWithChildren<{
|
|
@@ -157,12 +157,12 @@ export function Root({
|
|
|
157
157
|
);
|
|
158
158
|
}
|
|
159
159
|
|
|
160
|
-
export function
|
|
160
|
+
export function MenuTrigger({
|
|
161
161
|
children,
|
|
162
162
|
label,
|
|
163
163
|
role = 'button',
|
|
164
164
|
hint,
|
|
165
|
-
}:
|
|
165
|
+
}: MenuTriggerProps) {
|
|
166
166
|
const { control, triggerRef } = useMenuContext();
|
|
167
167
|
const [hovered, setHovered] = useState(false);
|
|
168
168
|
const [focused, setFocused] = useState(false);
|
|
@@ -186,7 +186,7 @@ export function Trigger({
|
|
|
186
186
|
});
|
|
187
187
|
}
|
|
188
188
|
|
|
189
|
-
export function
|
|
189
|
+
export function MenuContent({
|
|
190
190
|
children,
|
|
191
191
|
style,
|
|
192
192
|
}: React.PropsWithChildren<{
|
|
@@ -268,7 +268,7 @@ export function Outer({
|
|
|
268
268
|
);
|
|
269
269
|
}
|
|
270
270
|
|
|
271
|
-
export function
|
|
271
|
+
export function MenuItem({ children, label, onPress, style, ...rest }: MenuItemProps) {
|
|
272
272
|
const theme = useTheme();
|
|
273
273
|
const { control } = useMenuContext();
|
|
274
274
|
const [hovered, setHovered] = useState(false);
|
|
@@ -321,7 +321,7 @@ export function Item({ children, label, onPress, style, ...rest }: ItemProps) {
|
|
|
321
321
|
);
|
|
322
322
|
}
|
|
323
323
|
|
|
324
|
-
export function
|
|
324
|
+
export function MenuItemText({ children, style }: MenuItemTextProps) {
|
|
325
325
|
const theme = useTheme();
|
|
326
326
|
const { disabled } = useMenuItemContext();
|
|
327
327
|
|
|
@@ -338,7 +338,7 @@ export function ItemText({ children, style }: ItemTextProps) {
|
|
|
338
338
|
);
|
|
339
339
|
}
|
|
340
340
|
|
|
341
|
-
export function
|
|
341
|
+
export function MenuItemIcon({ icon: Comp, position = 'left', fill }: MenuItemIconProps) {
|
|
342
342
|
const theme = useTheme();
|
|
343
343
|
const { disabled } = useMenuItemContext();
|
|
344
344
|
|
|
@@ -363,11 +363,11 @@ export function ItemIcon({ icon: Comp, position = 'left', fill }: ItemIconProps)
|
|
|
363
363
|
);
|
|
364
364
|
}
|
|
365
365
|
|
|
366
|
-
export function
|
|
366
|
+
export function MenuGroup({ children }: MenuGroupProps) {
|
|
367
367
|
return <>{children}</>;
|
|
368
368
|
}
|
|
369
369
|
|
|
370
|
-
export function
|
|
370
|
+
export function MenuDivider() {
|
|
371
371
|
const theme = useTheme();
|
|
372
372
|
|
|
373
373
|
return (
|
package/src/menu/types.ts
CHANGED
|
@@ -48,14 +48,14 @@ export type TriggerChildProps = {
|
|
|
48
48
|
};
|
|
49
49
|
};
|
|
50
50
|
|
|
51
|
-
export type
|
|
51
|
+
export type MenuTriggerProps = {
|
|
52
52
|
children: (props: TriggerChildProps) => React.ReactNode;
|
|
53
53
|
label: string;
|
|
54
54
|
hint?: string;
|
|
55
55
|
role?: AccessibilityRole;
|
|
56
56
|
};
|
|
57
57
|
|
|
58
|
-
export type
|
|
58
|
+
export type MenuItemProps = React.PropsWithChildren<
|
|
59
59
|
Omit<PressableProps, 'style'> & {
|
|
60
60
|
label: string;
|
|
61
61
|
onPress: (e: GestureResponderEvent) => void;
|
|
@@ -63,16 +63,16 @@ export type ItemProps = React.PropsWithChildren<
|
|
|
63
63
|
}
|
|
64
64
|
>;
|
|
65
65
|
|
|
66
|
-
export type
|
|
66
|
+
export type MenuItemTextProps = React.PropsWithChildren<{
|
|
67
67
|
style?: TextStyle;
|
|
68
68
|
}>;
|
|
69
69
|
|
|
70
|
-
export type
|
|
70
|
+
export type MenuItemIconProps = {
|
|
71
71
|
icon: React.ComponentType<SVGIconProps>;
|
|
72
72
|
position?: 'left' | 'right';
|
|
73
73
|
fill?: (props: { disabled: boolean }) => string;
|
|
74
74
|
};
|
|
75
75
|
|
|
76
|
-
export type
|
|
76
|
+
export type MenuGroupProps = React.PropsWithChildren<{
|
|
77
77
|
style?: StyleProp<ViewStyle>;
|
|
78
78
|
}>;
|
|
@@ -2,7 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import { View } from 'react-native';
|
|
3
3
|
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import { Popover, PopoverTrigger, PopoverContent } from './index';
|
|
6
6
|
import { Button } from '../button';
|
|
7
7
|
import { Item } from '../item';
|
|
8
8
|
import { Text } from '../typography';
|
|
@@ -18,22 +18,22 @@ type Story = StoryObj;
|
|
|
18
18
|
export const Basic: Story = {
|
|
19
19
|
render: () => (
|
|
20
20
|
<View style={{ padding: 80 }}>
|
|
21
|
-
<Popover
|
|
22
|
-
<
|
|
21
|
+
<Popover>
|
|
22
|
+
<PopoverTrigger label="Open popover">
|
|
23
23
|
{({ props }) => (
|
|
24
24
|
<Button {...props} onPress={props.onPress}>
|
|
25
25
|
Open popover
|
|
26
26
|
</Button>
|
|
27
27
|
)}
|
|
28
|
-
</
|
|
29
|
-
<
|
|
28
|
+
</PopoverTrigger>
|
|
29
|
+
<PopoverContent label="Account actions" placement="bottom-start">
|
|
30
30
|
<View style={{ minWidth: 200 }}>
|
|
31
31
|
<Item title="Edit profile" density="compact" onPress={() => {}} />
|
|
32
32
|
<Item title="Settings" density="compact" onPress={() => {}} />
|
|
33
33
|
<Item title="Sign out" density="compact" destructive onPress={() => {}} />
|
|
34
34
|
</View>
|
|
35
|
-
</
|
|
36
|
-
</Popover
|
|
35
|
+
</PopoverContent>
|
|
36
|
+
</Popover>
|
|
37
37
|
</View>
|
|
38
38
|
),
|
|
39
39
|
};
|
|
@@ -41,21 +41,21 @@ export const Basic: Story = {
|
|
|
41
41
|
export const RichContent: Story = {
|
|
42
42
|
render: () => (
|
|
43
43
|
<View style={{ padding: 80 }}>
|
|
44
|
-
<Popover
|
|
45
|
-
<
|
|
44
|
+
<Popover>
|
|
45
|
+
<PopoverTrigger label="Details">
|
|
46
46
|
{({ props }) => (
|
|
47
47
|
<Button {...props} variant="secondary" onPress={props.onPress}>
|
|
48
48
|
Details
|
|
49
49
|
</Button>
|
|
50
50
|
)}
|
|
51
|
-
</
|
|
52
|
-
<
|
|
51
|
+
</PopoverTrigger>
|
|
52
|
+
<PopoverContent label="Details" placement="bottom" maxWidth={280}>
|
|
53
53
|
<View style={{ padding: 12, gap: 6 }}>
|
|
54
54
|
<Text style={{ fontWeight: '600' }}>Storage</Text>
|
|
55
55
|
<Text>4.2 GB of 10 GB used.</Text>
|
|
56
56
|
</View>
|
|
57
|
-
</
|
|
58
|
-
</Popover
|
|
57
|
+
</PopoverContent>
|
|
58
|
+
</Popover>
|
|
59
59
|
</View>
|
|
60
60
|
),
|
|
61
61
|
};
|
package/src/popover/context.ts
CHANGED
|
@@ -20,7 +20,7 @@ PopoverContext.displayName = 'PopoverContext';
|
|
|
20
20
|
export function usePopoverContext(): PopoverContextValue {
|
|
21
21
|
const ctx = useContext(PopoverContext);
|
|
22
22
|
if (!ctx) {
|
|
23
|
-
throw new Error('Popover components must be used within a <Popover
|
|
23
|
+
throw new Error('Popover components must be used within a <Popover>');
|
|
24
24
|
}
|
|
25
25
|
return ctx;
|
|
26
26
|
}
|
package/src/popover/index.tsx
CHANGED
|
@@ -7,7 +7,7 @@ import { PopoverContext, usePopoverContext } from './context';
|
|
|
7
7
|
import type {
|
|
8
8
|
PopoverContentProps,
|
|
9
9
|
PopoverControlProps,
|
|
10
|
-
|
|
10
|
+
PopoverProps,
|
|
11
11
|
PopoverTriggerProps,
|
|
12
12
|
} from './types';
|
|
13
13
|
|
|
@@ -15,7 +15,7 @@ export type {
|
|
|
15
15
|
PopoverControlProps,
|
|
16
16
|
PopoverContentProps,
|
|
17
17
|
PopoverTriggerProps,
|
|
18
|
-
|
|
18
|
+
PopoverProps,
|
|
19
19
|
PopoverPlacement,
|
|
20
20
|
PopoverTriggerRenderProps,
|
|
21
21
|
PopoverTriggerState,
|
|
@@ -29,7 +29,7 @@ export { usePopoverContext };
|
|
|
29
29
|
* established native-overlay convention, shared with `Menu`/`Select`). The
|
|
30
30
|
* web fork (`index.web.tsx`) anchors a floating panel to the trigger.
|
|
31
31
|
*/
|
|
32
|
-
export function
|
|
32
|
+
export function Popover({ children, control }: PopoverProps) {
|
|
33
33
|
const defaultControl = useDialogControl();
|
|
34
34
|
const triggerRef = useRef<View | null>(null);
|
|
35
35
|
const [isOpen, setIsOpen] = useState(false);
|
|
@@ -64,7 +64,7 @@ export function Root({ children, control }: PopoverRootProps) {
|
|
|
64
64
|
);
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
-
export function
|
|
67
|
+
export function PopoverTrigger({ children, label }: PopoverTriggerProps) {
|
|
68
68
|
const { control, triggerRef } = usePopoverContext();
|
|
69
69
|
const [focused, setFocused] = useState(false);
|
|
70
70
|
const [pressed, setPressed] = useState(false);
|
|
@@ -89,7 +89,7 @@ export function Trigger({ children, label }: PopoverTriggerProps) {
|
|
|
89
89
|
);
|
|
90
90
|
}
|
|
91
91
|
|
|
92
|
-
export function
|
|
92
|
+
export function PopoverContent({
|
|
93
93
|
children,
|
|
94
94
|
label = 'Popover',
|
|
95
95
|
style,
|
|
@@ -17,7 +17,7 @@ import type {
|
|
|
17
17
|
PopoverContentProps,
|
|
18
18
|
PopoverControlProps,
|
|
19
19
|
PopoverPlacement,
|
|
20
|
-
|
|
20
|
+
PopoverProps,
|
|
21
21
|
PopoverTriggerProps,
|
|
22
22
|
} from './types';
|
|
23
23
|
|
|
@@ -25,7 +25,7 @@ export type {
|
|
|
25
25
|
PopoverControlProps,
|
|
26
26
|
PopoverContentProps,
|
|
27
27
|
PopoverTriggerProps,
|
|
28
|
-
|
|
28
|
+
PopoverProps,
|
|
29
29
|
PopoverPlacement,
|
|
30
30
|
PopoverTriggerRenderProps,
|
|
31
31
|
PopoverTriggerState,
|
|
@@ -69,7 +69,7 @@ interface Rect {
|
|
|
69
69
|
height: number;
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
-
export function
|
|
72
|
+
export function Popover({ children, control }: PopoverProps) {
|
|
73
73
|
const id = useId();
|
|
74
74
|
const [isOpen, setIsOpen] = useState(false);
|
|
75
75
|
const triggerRef = useRef<View | null>(null);
|
|
@@ -121,7 +121,7 @@ export function Root({ children, control }: PopoverRootProps) {
|
|
|
121
121
|
);
|
|
122
122
|
}
|
|
123
123
|
|
|
124
|
-
export function
|
|
124
|
+
export function PopoverTrigger({ children, label }: PopoverTriggerProps) {
|
|
125
125
|
const { control, triggerRef, isOpen } = usePopoverContext();
|
|
126
126
|
const [hovered, setHovered] = useState(false);
|
|
127
127
|
const [focused, setFocused] = useState(false);
|
|
@@ -191,7 +191,7 @@ function resolvePosition(
|
|
|
191
191
|
return { left, top };
|
|
192
192
|
}
|
|
193
193
|
|
|
194
|
-
export function
|
|
194
|
+
export function PopoverContent({
|
|
195
195
|
children,
|
|
196
196
|
label = 'Popover',
|
|
197
197
|
placement = 'bottom-start',
|
package/src/popover/types.ts
CHANGED
|
@@ -53,7 +53,7 @@ export interface PopoverContentProps {
|
|
|
53
53
|
testID?: string;
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
export interface
|
|
56
|
+
export interface PopoverProps {
|
|
57
57
|
children: React.ReactNode;
|
|
58
58
|
/** Optionally supply your own control (from `usePopoverControl`). */
|
|
59
59
|
control?: PopoverControlProps;
|
|
@@ -4,12 +4,12 @@ import { Platform, type TextInput, View } from 'react-native';
|
|
|
4
4
|
import { useTheme } from '../theme/use-theme';
|
|
5
5
|
import { atoms as a } from '../styles';
|
|
6
6
|
import { Button } from '../button';
|
|
7
|
-
import
|
|
7
|
+
import { TextField, TextFieldIcon, TextFieldInput, type TextFieldInputProps } from '../text-field';
|
|
8
8
|
import { MagnifyingGlass_Stroke2_Corner0_Rounded as MagnifyingGlassIcon } from '../icons/MagnifyingGlass';
|
|
9
9
|
import { TimesLarge_Stroke2_Corner0_Rounded as X } from '../icons/Times';
|
|
10
10
|
|
|
11
|
-
type SearchInputProps = Omit<
|
|
12
|
-
label?:
|
|
11
|
+
type SearchInputProps = Omit<TextFieldInputProps, 'label'> & {
|
|
12
|
+
label?: TextFieldInputProps['label'];
|
|
13
13
|
/**
|
|
14
14
|
* Called when the user presses the clear (X) button.
|
|
15
15
|
*/
|
|
@@ -23,9 +23,9 @@ export const SearchInput = forwardRef<TextInput, SearchInputProps>(
|
|
|
23
23
|
|
|
24
24
|
return (
|
|
25
25
|
<View style={[a.w_full, a.relative]}>
|
|
26
|
-
<TextField
|
|
27
|
-
<
|
|
28
|
-
<
|
|
26
|
+
<TextField>
|
|
27
|
+
<TextFieldIcon icon={MagnifyingGlassIcon} />
|
|
28
|
+
<TextFieldInput
|
|
29
29
|
inputRef={ref}
|
|
30
30
|
label={label}
|
|
31
31
|
value={value}
|
|
@@ -41,7 +41,7 @@ export const SearchInput = forwardRef<TextInput, SearchInputProps>(
|
|
|
41
41
|
style={showClear ? { paddingRight: 24 } : undefined}
|
|
42
42
|
{...rest}
|
|
43
43
|
/>
|
|
44
|
-
</TextField
|
|
44
|
+
</TextField>
|
|
45
45
|
|
|
46
46
|
{showClear && (
|
|
47
47
|
<View
|
|
@@ -40,21 +40,21 @@ const InternalContext = createContext<{
|
|
|
40
40
|
*
|
|
41
41
|
* @example
|
|
42
42
|
* ```tsx
|
|
43
|
-
* <SegmentedControl
|
|
44
|
-
* <
|
|
45
|
-
* <
|
|
43
|
+
* <SegmentedControl value={value} onChange={setValue}>
|
|
44
|
+
* <SegmentedControlItem value="one">
|
|
45
|
+
* <SegmentedControlItemText value="one">
|
|
46
46
|
* One
|
|
47
|
-
* </
|
|
48
|
-
* </
|
|
49
|
-
* <
|
|
50
|
-
* <
|
|
47
|
+
* </SegmentedControlItemText>
|
|
48
|
+
* </SegmentedControlItem>
|
|
49
|
+
* <SegmentedControlItem value="two">
|
|
50
|
+
* <SegmentedControlItemText value="two">
|
|
51
51
|
* Two
|
|
52
|
-
* </
|
|
53
|
-
* </
|
|
54
|
-
* </SegmentedControl
|
|
52
|
+
* </SegmentedControlItemText>
|
|
53
|
+
* </SegmentedControlItem>
|
|
54
|
+
* </SegmentedControl>
|
|
55
55
|
* ```
|
|
56
56
|
*/
|
|
57
|
-
export function
|
|
57
|
+
export function SegmentedControl<T extends string>({
|
|
58
58
|
label,
|
|
59
59
|
type = 'radio',
|
|
60
60
|
size = 'large',
|
|
@@ -146,7 +146,7 @@ const InternalItemContext = createContext<{
|
|
|
146
146
|
active: boolean;
|
|
147
147
|
} | null>(null);
|
|
148
148
|
|
|
149
|
-
export function
|
|
149
|
+
export function SegmentedControlItem({
|
|
150
150
|
value,
|
|
151
151
|
style,
|
|
152
152
|
children,
|
|
@@ -177,7 +177,7 @@ export function Item({
|
|
|
177
177
|
const ctx = useContext(InternalContext);
|
|
178
178
|
if (!ctx) {
|
|
179
179
|
throw new Error(
|
|
180
|
-
'
|
|
180
|
+
'SegmentedControlItem must be used within a SegmentedControl',
|
|
181
181
|
);
|
|
182
182
|
}
|
|
183
183
|
|
|
@@ -264,7 +264,7 @@ export function Item({
|
|
|
264
264
|
);
|
|
265
265
|
}
|
|
266
266
|
|
|
267
|
-
export function
|
|
267
|
+
export function SegmentedControlItemText({
|
|
268
268
|
style,
|
|
269
269
|
children,
|
|
270
270
|
...props
|
|
@@ -276,7 +276,7 @@ export function ItemText({
|
|
|
276
276
|
const ctx = useContext(InternalItemContext);
|
|
277
277
|
if (!ctx) {
|
|
278
278
|
throw new Error(
|
|
279
|
-
'
|
|
279
|
+
'SegmentedControlItemText must be used within a SegmentedControlItem',
|
|
280
280
|
);
|
|
281
281
|
}
|
|
282
282
|
|
|
@@ -2,7 +2,16 @@ import React, { useState } from 'react';
|
|
|
2
2
|
import { View } from 'react-native';
|
|
3
3
|
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import {
|
|
6
|
+
Select,
|
|
7
|
+
SelectTrigger,
|
|
8
|
+
SelectValue,
|
|
9
|
+
SelectIcon,
|
|
10
|
+
SelectContent,
|
|
11
|
+
SelectItem,
|
|
12
|
+
SelectItemIndicator,
|
|
13
|
+
SelectItemText,
|
|
14
|
+
} from './index';
|
|
6
15
|
|
|
7
16
|
const meta: Meta = {
|
|
8
17
|
title: 'Components/Select',
|
|
@@ -25,44 +34,44 @@ const FRUITS: Option[] = [
|
|
|
25
34
|
function BasicSelect() {
|
|
26
35
|
const [value, setValue] = useState<string>('apple');
|
|
27
36
|
return (
|
|
28
|
-
<Select
|
|
29
|
-
<
|
|
30
|
-
<
|
|
31
|
-
<
|
|
32
|
-
</
|
|
33
|
-
<
|
|
37
|
+
<Select value={value} onValueChange={setValue}>
|
|
38
|
+
<SelectTrigger label="Pick a fruit">
|
|
39
|
+
<SelectValue placeholder="Pick a fruit" />
|
|
40
|
+
<SelectIcon />
|
|
41
|
+
</SelectTrigger>
|
|
42
|
+
<SelectContent
|
|
34
43
|
label="Pick a fruit"
|
|
35
44
|
items={FRUITS}
|
|
36
45
|
renderItem={(item) => (
|
|
37
|
-
<
|
|
38
|
-
<
|
|
39
|
-
<
|
|
40
|
-
</
|
|
46
|
+
<SelectItem value={item.value} label={item.label}>
|
|
47
|
+
<SelectItemIndicator />
|
|
48
|
+
<SelectItemText>{item.label}</SelectItemText>
|
|
49
|
+
</SelectItem>
|
|
41
50
|
)}
|
|
42
51
|
/>
|
|
43
|
-
</Select
|
|
52
|
+
</Select>
|
|
44
53
|
);
|
|
45
54
|
}
|
|
46
55
|
|
|
47
56
|
function UncontrolledSelect() {
|
|
48
57
|
const [value, setValue] = useState<string | undefined>(undefined);
|
|
49
58
|
return (
|
|
50
|
-
<Select
|
|
51
|
-
<
|
|
52
|
-
<
|
|
53
|
-
<
|
|
54
|
-
</
|
|
55
|
-
<
|
|
59
|
+
<Select value={value} onValueChange={setValue}>
|
|
60
|
+
<SelectTrigger label="Pick a fruit">
|
|
61
|
+
<SelectValue placeholder="No fruit selected" />
|
|
62
|
+
<SelectIcon />
|
|
63
|
+
</SelectTrigger>
|
|
64
|
+
<SelectContent
|
|
56
65
|
label="Pick a fruit"
|
|
57
66
|
items={FRUITS}
|
|
58
67
|
renderItem={(item) => (
|
|
59
|
-
<
|
|
60
|
-
<
|
|
61
|
-
<
|
|
62
|
-
</
|
|
68
|
+
<SelectItem value={item.value} label={item.label}>
|
|
69
|
+
<SelectItemIndicator />
|
|
70
|
+
<SelectItemText>{item.label}</SelectItemText>
|
|
71
|
+
</SelectItem>
|
|
63
72
|
)}
|
|
64
73
|
/>
|
|
65
|
-
</Select
|
|
74
|
+
</Select>
|
|
66
75
|
);
|
|
67
76
|
}
|
|
68
77
|
|
package/src/select/common.ts
CHANGED
|
@@ -28,6 +28,6 @@ export const ItemContext = createContext<SelectItemContextValue>({
|
|
|
28
28
|
});
|
|
29
29
|
ItemContext.displayName = 'SelectItemContext';
|
|
30
30
|
|
|
31
|
-
export function
|
|
31
|
+
export function useSelectItemContext(): SelectItemContextValue {
|
|
32
32
|
return useContext(ItemContext);
|
|
33
33
|
}
|