Skip to content

Commit c15e08f

Browse files
authored
Merge branch 'main' into test/update-tab-nav-test
2 parents b5d093e + a20faba commit c15e08f

File tree

76 files changed

+3820
-2686
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+3820
-2686
lines changed

.changeset/breezy-cars-hear.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@primer/react': patch
3+
---
4+
5+
UnderlineNav2: Prevent item width calculation when they are null

.changeset/cyan-bananas-live.md

Lines changed: 0 additions & 5 deletions
This file was deleted.

.changeset/fast-shoes-enjoy.md

Lines changed: 0 additions & 5 deletions
This file was deleted.

.changeset/flat-cars-type.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@primer/react': patch
3+
---
4+
5+
UnderlineNav2: Only run overflow layout function when nav item has a width

.changeset/moody-islands-impress.md

Lines changed: 0 additions & 5 deletions
This file was deleted.

.changeset/violet-plants-sip.md

Lines changed: 0 additions & 5 deletions
This file was deleted.

.changeset/wise-dogs-play.md

Lines changed: 0 additions & 5 deletions
This file was deleted.

.storybook/preview.js

Lines changed: 117 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,123 @@ export const parameters = {
1818
removeEmptyComments: true
1919
},
2020
options: {
21-
storySort: {
22-
order: ['Components', 'Behaviors', 'Hooks', 'Private components', 'Deprecated components', '*'],
23-
method: 'alphabetical'
21+
storySort: (a, b) => {
22+
const defaultOrder = [
23+
[
24+
// Match on any story that leads with "Components"
25+
'Components',
26+
// This is the ordering of stories under "Components", by default
27+
// we'll sort alphabetically
28+
[
29+
[
30+
'*',
31+
// Within a set of stories, set the order to the following
32+
['*', 'Playground', /Playground$/, 'Features', 'Examples']
33+
]
34+
]
35+
],
36+
'Behaviors',
37+
'Hooks',
38+
'Private components',
39+
'Deprecated components',
40+
'*'
41+
]
42+
43+
/**
44+
* Get the position of an item within a given order. This will return the
45+
* index if the item is defined in the given array, or the wildcard index
46+
* if it is not explicitlyd efined
47+
*/
48+
function getPosition(order, item) {
49+
const position = order.findIndex(value => {
50+
if (Array.isArray(value)) {
51+
if (typeof value[0] === 'string') {
52+
return value[0] === item
53+
}
54+
return value[0].exec(item)
55+
}
56+
57+
if (typeof value === 'string') {
58+
return value === item
59+
}
60+
61+
return value.exec(item)
62+
})
63+
64+
if (position === -1) {
65+
return order.indexOf('*')
66+
}
67+
68+
return position
69+
}
70+
71+
/**
72+
* Compare two separate stories at the given level for the given order.
73+
* The order will be relative at each level and is resolved based on the
74+
* current order and values of the stories
75+
*/
76+
function compare(a, b, level = 0, order = defaultOrder) {
77+
const valueA = a[level]
78+
const valueB = b[level]
79+
80+
// If the stories match at the same point in the hierarchy, we'll want
81+
// to compare them using a relative ordering for the scheme
82+
if (valueA === valueB) {
83+
// Find the "nested order" for the hierarchy, if one exists. This
84+
// will correspond with the ordering of the stories within this
85+
// hierarchy
86+
const nestedOrder = order.find(value => {
87+
if (Array.isArray(value)) {
88+
return value[0] === valueA
89+
}
90+
return value === valueA
91+
})
92+
93+
if (nestedOrder && Array.isArray(nestedOrder)) {
94+
return compare(a, b, level + 1, nestedOrder[1])
95+
}
96+
97+
// If there is no nested order that we can find, look for wildcard
98+
// patterns
99+
const wildcard = order.find(value => {
100+
if (Array.isArray(value)) {
101+
return value[0] === '*'
102+
}
103+
return value === '*'
104+
})
105+
106+
// If we have a wildcard pattern with sub-patterns to include for
107+
// ordering, pass them along
108+
if (wildcard && Array.isArray(wildcard)) {
109+
return compare(a, b, level + 1, wildcard[1])
110+
}
111+
112+
// Otherwise, everything is a wildcard pattern and should be sorted
113+
// alphabetically at this level
114+
return compare(a, b, level + 1, ['*'])
115+
}
116+
117+
// If the stories do not currently match in the same hierarchy, get the
118+
// position of each and compare them.
119+
const positionA = getPosition(order, valueA)
120+
const positionB = getPosition(order, valueB)
121+
122+
// If the positions are the same, sort them alphabetically
123+
if (positionA === positionB) {
124+
return valueA.localeCompare(valueB)
125+
}
126+
127+
// Otherwise, compare by position in the given order
128+
return positionA - positionB
129+
}
130+
131+
function getHierarchy(story) {
132+
const hierarchy = story.title.split('/')
133+
hierarchy.push(story.name)
134+
return hierarchy
135+
}
136+
137+
return compare(getHierarchy(a), getHierarchy(b))
24138
}
25139
}
26140
}

CHANGELOG.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,23 @@
11
# @primer/components
22

3+
## 35.14.1
4+
5+
### Patch Changes
6+
7+
- [#2510](https://github.com/primer/react/pull/2510) [`c326777e`](https://github.com/primer/react/commit/c326777ec0369968e49d9d9ceb21f7f5609f697b) Thanks [@langermank](https://github.com/langermank)! - Remove deprecated focus style primitives
8+
9+
- [#2483](https://github.com/primer/react/pull/2483) [`23647cfc`](https://github.com/primer/react/commit/23647cfce6132bcf16aa2a31c33c20be029124e0) Thanks [@joshblack](https://github.com/joshblack)! - Add unobserve mock for ResizeObserver in test helpers
10+
11+
- [#2504](https://github.com/primer/react/pull/2504) [`ea4a3c2a`](https://github.com/primer/react/commit/ea4a3c2a11d8d9cdc972405495902ac8e7b61e54) Thanks [@joshblack](https://github.com/joshblack)! - TreeView: Add support for Backspace to move focus to parent item
12+
13+
- [#2511](https://github.com/primer/react/pull/2511) [`0a94420e`](https://github.com/primer/react/commit/0a94420e96a1989a0183f36ec7b90954c4ff4c7b) Thanks [@joshblack](https://github.com/joshblack)! - Remove selected from `<option>` and add defaultValue for `<select>` when placeholder is provided
14+
15+
- [#2523](https://github.com/primer/react/pull/2523) [`50ed6441`](https://github.com/primer/react/commit/50ed644180733ab7baa8ee79dc019a9b6f61bf99) Thanks [@colebemis](https://github.com/colebemis)! - TreeView: Performance improvements
16+
17+
- [#2521](https://github.com/primer/react/pull/2521) [`862f93c7`](https://github.com/primer/react/commit/862f93c7438b4c9be753e98a39af98c496d8629f) Thanks [@colebemis](https://github.com/colebemis)! - TreeView: Fix unexpected scrolling when focusing child items
18+
19+
- [#2518](https://github.com/primer/react/pull/2518) [`60c36f58`](https://github.com/primer/react/commit/60c36f5872182047c8242718ae1fdeb5bf1669b8) Thanks [@colebemis](https://github.com/colebemis)! - TreeView: Remove loading indicator delay
20+
321
## 35.14.0
422

523
### Minor Changes

docs/content/ActionList.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ componentId: action_list
33
title: ActionList
44
status: Beta
55
source: https://github.com/primer/react/tree/main/src/ActionList
6-
storybook: '/react/storybook?path=/story/composite-components-actionlist'
6+
storybook: '/react/storybook?path=/story/components-actionlist'
77
description: An ActionList is a list of items that can be activated or selected. ActionList is the base component for many menu-type components, including ActionMenu and SelectPanel.
88
---
99

0 commit comments

Comments
 (0)