@startupjs-ui/dropdown 0.2.0 → 0.3.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/CHANGELOG.md +11 -0
- package/components/Item/index.tsx +8 -0
- package/index.d.ts +10 -0
- package/index.tsx +37 -1
- package/package.json +12 -11
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [0.3.0](https://github.com/startupjs/startupjs-ui/compare/v0.2.3...v0.3.0) (2026-05-27)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* [BREAKING] [0.3] improve accessibility props for E2E tests. Support testID everywhere ([#31](https://github.com/startupjs/startupjs-ui/issues/31)) ([882588c](https://github.com/startupjs/startupjs-ui/commit/882588ca37d5e1fd14b5717b5697cf9ed47042e4))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
# [0.2.0](https://github.com/startupjs/startupjs-ui/compare/v0.1.23...v0.2.0) (2026-05-04)
|
|
7
18
|
|
|
8
19
|
|
|
@@ -25,6 +25,8 @@ export interface DropdownItemProps {
|
|
|
25
25
|
onPress?: () => void
|
|
26
26
|
/** Custom content when used as a pure/custom item */
|
|
27
27
|
children?: ReactNode
|
|
28
|
+
/** Test id forwarded to the interactive root (menu row or touchable wrapper) */
|
|
29
|
+
testID?: string
|
|
28
30
|
/** @private Active value injected by Dropdown */
|
|
29
31
|
_activeValue?: any
|
|
30
32
|
/** @private Selected index for keyboard navigation */
|
|
@@ -52,6 +54,7 @@ function DropdownItem ({
|
|
|
52
54
|
disabled,
|
|
53
55
|
onPress,
|
|
54
56
|
children,
|
|
57
|
+
testID,
|
|
55
58
|
_activeValue,
|
|
56
59
|
_selectIndexValue,
|
|
57
60
|
_variant,
|
|
@@ -84,6 +87,10 @@ function DropdownItem ({
|
|
|
84
87
|
styleName={ selectMenu: _selectIndexValue === _index }
|
|
85
88
|
onPress=handlePress
|
|
86
89
|
icon=icon
|
|
90
|
+
testID=testID
|
|
91
|
+
role='option'
|
|
92
|
+
aria-selected=(_activeValue === value)
|
|
93
|
+
aria-label=label
|
|
87
94
|
)= label
|
|
88
95
|
`
|
|
89
96
|
}
|
|
@@ -94,6 +101,7 @@ function DropdownItem ({
|
|
|
94
101
|
to=to
|
|
95
102
|
style=style
|
|
96
103
|
onPress=handlePress
|
|
104
|
+
testID=testID
|
|
97
105
|
)
|
|
98
106
|
View.item(
|
|
99
107
|
style=(!isPure && _activeValue === value) ? _styleActiveItem : undefined
|
package/index.d.ts
CHANGED
|
@@ -31,6 +31,12 @@ export interface DropdownProps {
|
|
|
31
31
|
drawerCancelLabel?: string;
|
|
32
32
|
/** Disable caption press */
|
|
33
33
|
disabled?: boolean;
|
|
34
|
+
/** Accessible name for the dropdown trigger */
|
|
35
|
+
'aria-label'?: string;
|
|
36
|
+
/** Element id that labels the dropdown trigger */
|
|
37
|
+
'aria-labelledby'?: string;
|
|
38
|
+
/** Element id that describes the dropdown trigger */
|
|
39
|
+
'aria-describedby'?: string;
|
|
34
40
|
/** Enable drawer behavior on small screens @default true */
|
|
35
41
|
hasDrawer?: boolean;
|
|
36
42
|
/** Show swipe responder zone in drawer */
|
|
@@ -39,6 +45,10 @@ export interface DropdownProps {
|
|
|
39
45
|
onChange?: (value: string | number | undefined) => void;
|
|
40
46
|
/** Called when dropdown is dismissed via overlay/cancel */
|
|
41
47
|
onDismiss?: () => void;
|
|
48
|
+
/** Test identifier for the dropdown trigger */
|
|
49
|
+
testID?: string;
|
|
50
|
+
/** Test id for the desktop/tablet popover surface (passed to `AbstractPopover`) */
|
|
51
|
+
popoverTestID?: string;
|
|
42
52
|
}
|
|
43
53
|
export interface DropdownRef {
|
|
44
54
|
/** Open dropdown programmatically */
|
package/index.tsx
CHANGED
|
@@ -2,7 +2,6 @@ import React, { useState, useRef, useImperativeHandle, useEffect, type ReactNode
|
|
|
2
2
|
import {
|
|
3
3
|
Dimensions,
|
|
4
4
|
UIManager,
|
|
5
|
-
ScrollView,
|
|
6
5
|
StyleSheet,
|
|
7
6
|
Text,
|
|
8
7
|
TouchableOpacity,
|
|
@@ -14,6 +13,7 @@ import { pug, observer, $ } from 'startupjs'
|
|
|
14
13
|
import { themed } from '@startupjs-ui/core'
|
|
15
14
|
import Drawer from '@startupjs-ui/drawer'
|
|
16
15
|
import Popover, { type PopoverRef } from '@startupjs-ui/popover'
|
|
16
|
+
import ScrollView from '@startupjs-ui/scroll-view'
|
|
17
17
|
import DropdownCaption from './components/Caption'
|
|
18
18
|
import DropdownItem from './components/Item'
|
|
19
19
|
import { useKeyboard } from './helpers'
|
|
@@ -48,6 +48,12 @@ export interface DropdownProps {
|
|
|
48
48
|
drawerCancelLabel?: string
|
|
49
49
|
/** Disable caption press */
|
|
50
50
|
disabled?: boolean
|
|
51
|
+
/** Accessible name for the dropdown trigger */
|
|
52
|
+
'aria-label'?: string
|
|
53
|
+
/** Element id that labels the dropdown trigger */
|
|
54
|
+
'aria-labelledby'?: string
|
|
55
|
+
/** Element id that describes the dropdown trigger */
|
|
56
|
+
'aria-describedby'?: string
|
|
51
57
|
/** Enable drawer behavior on small screens @default true */
|
|
52
58
|
hasDrawer?: boolean
|
|
53
59
|
/** Show swipe responder zone in drawer */
|
|
@@ -56,6 +62,10 @@ export interface DropdownProps {
|
|
|
56
62
|
onChange?: (value: string | number | undefined) => void
|
|
57
63
|
/** Called when dropdown is dismissed via overlay/cancel */
|
|
58
64
|
onDismiss?: () => void
|
|
65
|
+
/** Test identifier for the dropdown trigger */
|
|
66
|
+
testID?: string
|
|
67
|
+
/** Test id for the desktop/tablet popover surface (passed to `AbstractPopover`) */
|
|
68
|
+
popoverTestID?: string
|
|
59
69
|
}
|
|
60
70
|
|
|
61
71
|
export interface DropdownRef {
|
|
@@ -79,10 +89,15 @@ function Dropdown ({
|
|
|
79
89
|
drawerListTitle = '',
|
|
80
90
|
drawerCancelLabel = 'Cancel',
|
|
81
91
|
disabled,
|
|
92
|
+
'aria-label': ariaLabel,
|
|
93
|
+
'aria-labelledby': ariaLabelledBy,
|
|
94
|
+
'aria-describedby': ariaDescribedBy,
|
|
82
95
|
hasDrawer = true,
|
|
83
96
|
showDrawerResponder,
|
|
84
97
|
onChange,
|
|
85
98
|
onDismiss,
|
|
99
|
+
testID,
|
|
100
|
+
popoverTestID,
|
|
86
101
|
ref
|
|
87
102
|
}: DropdownProps): ReactNode {
|
|
88
103
|
const popoverRef = useRef<PopoverRef>(null)
|
|
@@ -234,12 +249,16 @@ function Dropdown ({
|
|
|
234
249
|
}
|
|
235
250
|
|
|
236
251
|
const matchAnchorWidth = !(_popoverStyle as any)?.width && !(_popoverStyle as any)?.minWidth
|
|
252
|
+
const captionProps = (caption as any).props ?? {}
|
|
253
|
+
const inferredCaptionLabel = captionProps['aria-label'] ?? captionProps.placeholder ?? activeLabel
|
|
254
|
+
const captionLabel = (ariaLabel ?? (ariaLabelledBy ? undefined : inferredCaptionLabel)) || undefined
|
|
237
255
|
|
|
238
256
|
if (isPopover) {
|
|
239
257
|
const renderPopoverContent = (): ReactNode => pug`
|
|
240
258
|
ScrollView(
|
|
241
259
|
ref=refScroll
|
|
242
260
|
showsVerticalScrollIndicator=false
|
|
261
|
+
role='listbox'
|
|
243
262
|
)= renderContent.current
|
|
244
263
|
`
|
|
245
264
|
|
|
@@ -263,9 +282,18 @@ function Dropdown ({
|
|
|
263
282
|
onOpenComplete=onRequestOpen
|
|
264
283
|
onCloseComplete=handlePopoverCloseComplete
|
|
265
284
|
renderContent=renderPopoverContent
|
|
285
|
+
testID=popoverTestID
|
|
266
286
|
)
|
|
267
287
|
TouchableOpacity(
|
|
288
|
+
testID=testID
|
|
268
289
|
disabled=disabled
|
|
290
|
+
role='button'
|
|
291
|
+
aria-label=captionLabel
|
|
292
|
+
aria-labelledby=ariaLabelledBy
|
|
293
|
+
aria-describedby=ariaDescribedBy
|
|
294
|
+
aria-haspopup='listbox'
|
|
295
|
+
aria-expanded=$isShow.get()
|
|
296
|
+
aria-disabled=disabled
|
|
269
297
|
onPress=() => handleVisibleChange(!$isShow.get(), { reason: !$isShow.get() ? null : 'toggle' })
|
|
270
298
|
)
|
|
271
299
|
= caption
|
|
@@ -275,7 +303,15 @@ function Dropdown ({
|
|
|
275
303
|
return pug`
|
|
276
304
|
if caption
|
|
277
305
|
TouchableOpacity.caption(
|
|
306
|
+
testID=testID
|
|
278
307
|
disabled=disabled
|
|
308
|
+
role='button'
|
|
309
|
+
aria-label=captionLabel
|
|
310
|
+
aria-labelledby=ariaLabelledBy
|
|
311
|
+
aria-describedby=ariaDescribedBy
|
|
312
|
+
aria-haspopup='listbox'
|
|
313
|
+
aria-expanded=$isShow.get()
|
|
314
|
+
aria-disabled=disabled
|
|
279
315
|
onPress=() => handleVisibleChange(!$isShow.get())
|
|
280
316
|
)
|
|
281
317
|
= caption
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@startupjs-ui/dropdown",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -8,20 +8,21 @@
|
|
|
8
8
|
"types": "index.d.ts",
|
|
9
9
|
"type": "module",
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"@startupjs-ui/button": "^0.
|
|
12
|
-
"@startupjs-ui/core": "^0.
|
|
13
|
-
"@startupjs-ui/div": "^0.
|
|
14
|
-
"@startupjs-ui/drawer": "^0.
|
|
15
|
-
"@startupjs-ui/icon": "^0.
|
|
16
|
-
"@startupjs-ui/link": "^0.
|
|
17
|
-
"@startupjs-ui/menu": "^0.
|
|
18
|
-
"@startupjs-ui/popover": "^0.
|
|
19
|
-
"@startupjs-ui/
|
|
11
|
+
"@startupjs-ui/button": "^0.3.0",
|
|
12
|
+
"@startupjs-ui/core": "^0.3.0",
|
|
13
|
+
"@startupjs-ui/div": "^0.3.0",
|
|
14
|
+
"@startupjs-ui/drawer": "^0.3.0",
|
|
15
|
+
"@startupjs-ui/icon": "^0.3.0",
|
|
16
|
+
"@startupjs-ui/link": "^0.3.0",
|
|
17
|
+
"@startupjs-ui/menu": "^0.3.0",
|
|
18
|
+
"@startupjs-ui/popover": "^0.3.0",
|
|
19
|
+
"@startupjs-ui/scroll-view": "^0.3.0",
|
|
20
|
+
"@startupjs-ui/span": "^0.3.0"
|
|
20
21
|
},
|
|
21
22
|
"peerDependencies": {
|
|
22
23
|
"react": "*",
|
|
23
24
|
"react-native": "*",
|
|
24
25
|
"startupjs": "*"
|
|
25
26
|
},
|
|
26
|
-
"gitHead": "
|
|
27
|
+
"gitHead": "8d212b47680af1dfe582f9759b38724b46488e25"
|
|
27
28
|
}
|