@instructure/ui-drilldown 8.28.1-snapshot-2 → 8.28.1-snapshot-4
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 +5 -2
- package/es/Drilldown/index.js +17 -6
- package/lib/Drilldown/index.js +17 -6
- package/package.json +20 -20
- package/src/Drilldown/index.tsx +21 -9
- package/tsconfig.build.tsbuildinfo +1 -1
- package/types/Drilldown/index.d.ts +1 -0
- package/types/Drilldown/index.d.ts.map +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,9 +3,12 @@
|
|
|
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
|
-
## [8.28.1-snapshot-
|
|
6
|
+
## [8.28.1-snapshot-4](https://github.com/instructure/instructure-ui/compare/v8.28.0...v8.28.1-snapshot-4) (2022-09-12)
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* support react 18 ([972bb93](https://github.com/instructure/instructure-ui/commit/972bb93d2835fcca3548d624b1ba2497661b4243))
|
|
9
12
|
|
|
10
13
|
|
|
11
14
|
|
package/es/Drilldown/index.js
CHANGED
|
@@ -652,6 +652,22 @@ let Drilldown = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle,
|
|
|
652
652
|
return this.props.trigger ? this.state.isShowingPopover : true;
|
|
653
653
|
}
|
|
654
654
|
|
|
655
|
+
containsDuplicateChild(children) {
|
|
656
|
+
let containsDuplicate = false;
|
|
657
|
+
const childMap = new Map();
|
|
658
|
+
|
|
659
|
+
for (const child of children) {
|
|
660
|
+
if (!childMap.has(child.props.id)) {
|
|
661
|
+
childMap.set(child.props.id, true);
|
|
662
|
+
} else {
|
|
663
|
+
warn(false, `Duplicate id: "${child.props.id}"! Make sure all options have unique ids, otherwise they won't be rendered.`);
|
|
664
|
+
return containsDuplicate = true;
|
|
665
|
+
}
|
|
666
|
+
}
|
|
667
|
+
|
|
668
|
+
return containsDuplicate;
|
|
669
|
+
}
|
|
670
|
+
|
|
655
671
|
reset() {
|
|
656
672
|
this._activeOptionsMap = {};
|
|
657
673
|
this.setState({
|
|
@@ -746,7 +762,7 @@ let Drilldown = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle,
|
|
|
746
762
|
const currentPage = this.currentPage,
|
|
747
763
|
headerChildren = this.headerChildren;
|
|
748
764
|
|
|
749
|
-
if (!currentPage) {
|
|
765
|
+
if (!currentPage || this.containsDuplicateChild(currentPage.children)) {
|
|
750
766
|
return null;
|
|
751
767
|
}
|
|
752
768
|
|
|
@@ -830,11 +846,6 @@ let Drilldown = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle,
|
|
|
830
846
|
if (!id) {
|
|
831
847
|
warn(false, `Drilldown.Option without id won't be rendered. It is needed to internally track the options.`);
|
|
832
848
|
return null;
|
|
833
|
-
}
|
|
834
|
-
|
|
835
|
-
if (this.getPageChildById(id)) {
|
|
836
|
-
warn(false, `Duplicate id: "${id}"! Make sure all options have unique ids, otherwise they won't be rendered.`);
|
|
837
|
-
return null;
|
|
838
849
|
} // Props passed to the Option.Item
|
|
839
850
|
|
|
840
851
|
|
package/lib/Drilldown/index.js
CHANGED
|
@@ -666,6 +666,22 @@ let Drilldown = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 =
|
|
|
666
666
|
return this.props.trigger ? this.state.isShowingPopover : true;
|
|
667
667
|
}
|
|
668
668
|
|
|
669
|
+
containsDuplicateChild(children) {
|
|
670
|
+
let containsDuplicate = false;
|
|
671
|
+
const childMap = new Map();
|
|
672
|
+
|
|
673
|
+
for (const child of children) {
|
|
674
|
+
if (!childMap.has(child.props.id)) {
|
|
675
|
+
childMap.set(child.props.id, true);
|
|
676
|
+
} else {
|
|
677
|
+
(0, _console.warn)(false, `Duplicate id: "${child.props.id}"! Make sure all options have unique ids, otherwise they won't be rendered.`);
|
|
678
|
+
return containsDuplicate = true;
|
|
679
|
+
}
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
return containsDuplicate;
|
|
683
|
+
}
|
|
684
|
+
|
|
669
685
|
reset() {
|
|
670
686
|
this._activeOptionsMap = {};
|
|
671
687
|
this.setState({
|
|
@@ -758,7 +774,7 @@ let Drilldown = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 =
|
|
|
758
774
|
const currentPage = this.currentPage,
|
|
759
775
|
headerChildren = this.headerChildren;
|
|
760
776
|
|
|
761
|
-
if (!currentPage) {
|
|
777
|
+
if (!currentPage || this.containsDuplicateChild(currentPage.children)) {
|
|
762
778
|
return null;
|
|
763
779
|
}
|
|
764
780
|
|
|
@@ -841,11 +857,6 @@ let Drilldown = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 =
|
|
|
841
857
|
if (!id) {
|
|
842
858
|
(0, _console.warn)(false, `Drilldown.Option without id won't be rendered. It is needed to internally track the options.`);
|
|
843
859
|
return null;
|
|
844
|
-
}
|
|
845
|
-
|
|
846
|
-
if (this.getPageChildById(id)) {
|
|
847
|
-
(0, _console.warn)(false, `Duplicate id: "${id}"! Make sure all options have unique ids, otherwise they won't be rendered.`);
|
|
848
|
-
return null;
|
|
849
860
|
} // Props passed to the Option.Item
|
|
850
861
|
|
|
851
862
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@instructure/ui-drilldown",
|
|
3
|
-
"version": "8.28.1-snapshot-
|
|
3
|
+
"version": "8.28.1-snapshot-4",
|
|
4
4
|
"description": "A drilldown menu component",
|
|
5
5
|
"author": "Instructure, Inc. Engineering and Product Design",
|
|
6
6
|
"module": "./es/index.js",
|
|
@@ -24,28 +24,28 @@
|
|
|
24
24
|
"license": "MIT",
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"@babel/runtime": "^7.13.10",
|
|
27
|
-
"@instructure/console": "8.28.1-snapshot-
|
|
28
|
-
"@instructure/emotion": "8.28.1-snapshot-
|
|
29
|
-
"@instructure/shared-types": "8.28.1-snapshot-
|
|
30
|
-
"@instructure/ui-dom-utils": "8.28.1-snapshot-
|
|
31
|
-
"@instructure/ui-icons": "8.28.1-snapshot-
|
|
32
|
-
"@instructure/ui-options": "8.28.1-snapshot-
|
|
33
|
-
"@instructure/ui-popover": "8.28.1-snapshot-
|
|
34
|
-
"@instructure/ui-position": "8.28.1-snapshot-
|
|
35
|
-
"@instructure/ui-prop-types": "8.28.1-snapshot-
|
|
36
|
-
"@instructure/ui-react-utils": "8.28.1-snapshot-
|
|
37
|
-
"@instructure/ui-selectable": "8.28.1-snapshot-
|
|
38
|
-
"@instructure/ui-testable": "8.28.1-snapshot-
|
|
39
|
-
"@instructure/ui-utils": "8.28.1-snapshot-
|
|
40
|
-
"@instructure/ui-view": "8.28.1-snapshot-
|
|
27
|
+
"@instructure/console": "8.28.1-snapshot-4",
|
|
28
|
+
"@instructure/emotion": "8.28.1-snapshot-4",
|
|
29
|
+
"@instructure/shared-types": "8.28.1-snapshot-4",
|
|
30
|
+
"@instructure/ui-dom-utils": "8.28.1-snapshot-4",
|
|
31
|
+
"@instructure/ui-icons": "8.28.1-snapshot-4",
|
|
32
|
+
"@instructure/ui-options": "8.28.1-snapshot-4",
|
|
33
|
+
"@instructure/ui-popover": "8.28.1-snapshot-4",
|
|
34
|
+
"@instructure/ui-position": "8.28.1-snapshot-4",
|
|
35
|
+
"@instructure/ui-prop-types": "8.28.1-snapshot-4",
|
|
36
|
+
"@instructure/ui-react-utils": "8.28.1-snapshot-4",
|
|
37
|
+
"@instructure/ui-selectable": "8.28.1-snapshot-4",
|
|
38
|
+
"@instructure/ui-testable": "8.28.1-snapshot-4",
|
|
39
|
+
"@instructure/ui-utils": "8.28.1-snapshot-4",
|
|
40
|
+
"@instructure/ui-view": "8.28.1-snapshot-4",
|
|
41
41
|
"prop-types": "^15"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
|
-
"@instructure/ui-babel-preset": "8.28.1-snapshot-
|
|
45
|
-
"@instructure/ui-color-utils": "8.28.1-snapshot-
|
|
46
|
-
"@instructure/ui-test-locator": "8.28.1-snapshot-
|
|
47
|
-
"@instructure/ui-test-utils": "8.28.1-snapshot-
|
|
48
|
-
"@instructure/ui-themes": "8.28.1-snapshot-
|
|
44
|
+
"@instructure/ui-babel-preset": "8.28.1-snapshot-4",
|
|
45
|
+
"@instructure/ui-color-utils": "8.28.1-snapshot-4",
|
|
46
|
+
"@instructure/ui-test-locator": "8.28.1-snapshot-4",
|
|
47
|
+
"@instructure/ui-test-utils": "8.28.1-snapshot-4",
|
|
48
|
+
"@instructure/ui-themes": "8.28.1-snapshot-4"
|
|
49
49
|
},
|
|
50
50
|
"peerDependencies": {
|
|
51
51
|
"react": ">=16.8 <=18"
|
package/src/Drilldown/index.tsx
CHANGED
|
@@ -527,6 +527,26 @@ class Drilldown extends Component<DrilldownProps, DrilldownState> {
|
|
|
527
527
|
return this.props.trigger ? this.state.isShowingPopover : true
|
|
528
528
|
}
|
|
529
529
|
|
|
530
|
+
containsDuplicateChild(children: PageChildren[]) {
|
|
531
|
+
let containsDuplicate = false
|
|
532
|
+
const childMap = new Map<string, boolean>()
|
|
533
|
+
|
|
534
|
+
for (const child of children) {
|
|
535
|
+
if (!childMap.has(child.props.id)) {
|
|
536
|
+
childMap.set(child.props.id, true)
|
|
537
|
+
} else {
|
|
538
|
+
warn(
|
|
539
|
+
false,
|
|
540
|
+
`Duplicate id: "${child.props.id}"! Make sure all options have unique ids, otherwise they won't be rendered.`
|
|
541
|
+
)
|
|
542
|
+
|
|
543
|
+
return (containsDuplicate = true)
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
return containsDuplicate
|
|
548
|
+
}
|
|
549
|
+
|
|
530
550
|
show = (event: React.SyntheticEvent) => {
|
|
531
551
|
if (this._popover) {
|
|
532
552
|
this._popover.show(event as React.UIEvent | React.FocusEvent)
|
|
@@ -878,7 +898,7 @@ class Drilldown extends Component<DrilldownProps, DrilldownState> {
|
|
|
878
898
|
) {
|
|
879
899
|
const { currentPage, headerChildren } = this
|
|
880
900
|
|
|
881
|
-
if (!currentPage) {
|
|
901
|
+
if (!currentPage || this.containsDuplicateChild(currentPage.children)) {
|
|
882
902
|
return null
|
|
883
903
|
}
|
|
884
904
|
|
|
@@ -990,14 +1010,6 @@ class Drilldown extends Component<DrilldownProps, DrilldownState> {
|
|
|
990
1010
|
return null
|
|
991
1011
|
}
|
|
992
1012
|
|
|
993
|
-
if (this.getPageChildById(id)) {
|
|
994
|
-
warn(
|
|
995
|
-
false,
|
|
996
|
-
`Duplicate id: "${id}"! Make sure all options have unique ids, otherwise they won't be rendered.`
|
|
997
|
-
)
|
|
998
|
-
return null
|
|
999
|
-
}
|
|
1000
|
-
|
|
1001
1013
|
// Props passed to the Option.Item
|
|
1002
1014
|
let optionProps: Partial<OptionsItemProps> = {
|
|
1003
1015
|
// passthrough props
|