@pie-element/placement-ordering 14.3.0-beta.0 → 14.3.1
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 +75 -8
- package/configure/CHANGELOG.md +64 -8
- package/configure/package.json +5 -5
- package/controller/CHANGELOG.md +10 -2
- package/controller/package.json +1 -1
- package/lib/keyboard-coordinates.js +124 -0
- package/lib/keyboard-coordinates.js.map +1 -0
- package/lib/placement-ordering.js +138 -8
- package/lib/placement-ordering.js.map +1 -1
- package/lib/tile.js +93 -22
- package/lib/tile.js.map +1 -1
- package/lib/tiler.js +7 -1
- package/lib/tiler.js.map +1 -1
- package/package.json +6 -5
- package/configure/lib/__tests__/choice-editor.test.js +0 -376
- package/configure/lib/__tests__/choice-tile.test.js +0 -283
- package/configure/lib/__tests__/design.test.js +0 -268
- package/configure/lib/__tests__/help.test.js +0 -64
- package/configure/lib/__tests__/index.test.js +0 -77
- package/configure/lib/__tests__/utils.test.js +0 -493
- package/controller/lib/__tests__/index.test.js +0 -401
- package/controller/lib/__tests__/scoring.test.js +0 -165
- package/docs/demo/pie.manifest.json +0 -11
- package/lib/__tests__/index-test.js +0 -90
- package/lib/__tests__/ordering.test.js +0 -133
- package/lib/__tests__/placement-ordering.test.js +0 -445
package/CHANGELOG.md
CHANGED
|
@@ -3,24 +3,91 @@
|
|
|
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
|
-
|
|
6
|
+
## [14.3.1](https://github.com/pie-framework/pie-elements/compare/@pie-element/placement-ordering@14.3.0...@pie-element/placement-ordering@14.3.1) (2026-08-26)
|
|
7
7
|
|
|
8
8
|
**Note:** Version bump only for package @pie-element/placement-ordering
|
|
9
9
|
|
|
10
|
-
# [14.
|
|
10
|
+
# [14.3.0](https://github.com/pie-framework/pie-elements/compare/@pie-element/placement-ordering@14.2.1...@pie-element/placement-ordering@14.3.0) (2026-08-21)
|
|
11
|
+
|
|
12
|
+
### Bug Fixes
|
|
13
|
+
|
|
14
|
+
- move [@pie-lib](https://github.com/pie-lib) deps back to latest, off next prereleases PIE-927 ([a53e012](https://github.com/pie-framework/pie-elements/commit/a53e0127eb4ac95ece54e1e2bd669ae4974f4251))
|
|
15
|
+
- **theming:** move the grey palette reads onto --pie-\* tokens PIE-856 ([d7d005b](https://github.com/pie-framework/pie-elements/commit/d7d005bf081843335b4b0377852f2ecd075cb62d)), closes [#000000](https://github.com/pie-framework/pie-elements/issues/000000) [#E0E1E6](https://github.com/pie-framework/pie-elements/issues/E0E1E6) [#646464](https://github.com/pie-framework/pie-elements/issues/646464) [#616161](https://github.com/pie-framework/pie-elements/issues/616161) [#E0E1E6](https://github.com/pie-framework/pie-elements/issues/E0E1E6) [#C0C3](https://github.com/pie-framework/pie-elements/issues/C0C3)
|
|
16
|
+
|
|
17
|
+
### Features
|
|
18
|
+
|
|
19
|
+
- bump libs PIE-856, PIE-681, PIE-927 ([cb26d7a](https://github.com/pie-framework/pie-elements/commit/cb26d7afa6c99522533c321d5ff8ce3148a66e9e))
|
|
20
|
+
|
|
21
|
+
## [14.2.1](https://github.com/pie-framework/pie-elements/compare/@pie-element/placement-ordering@14.2.0...@pie-element/placement-ordering@14.2.1) (2026-08-19)
|
|
22
|
+
|
|
23
|
+
### Bug Fixes
|
|
24
|
+
|
|
25
|
+
- bump libs and shared modules PIE-681, PIE-708 ([08af8b5](https://github.com/pie-framework/pie-elements/commit/08af8b5802aecc8ee5454a1b6d60277d7ec94204))
|
|
26
|
+
|
|
27
|
+
# [14.2.0](https://github.com/pie-framework/pie-elements/compare/@pie-element/placement-ordering@14.1.8...@pie-element/placement-ordering@14.2.0) (2026-08-13)
|
|
28
|
+
|
|
29
|
+
### Bug Fixes
|
|
30
|
+
|
|
31
|
+
- **match-list/placement-ordering:** scroll the interactive region horizontally when it does not fit PIE-766 & PIE-768 ([f0395a9](https://github.com/pie-framework/pie-elements/commit/f0395a91b16a803c5609d5ece6d3f87208dee1b2))
|
|
32
|
+
|
|
33
|
+
### Features
|
|
34
|
+
|
|
35
|
+
- **placement-ordering:** add Tab/Shift+Tab keyboard accessibility support PIE-767 ([6199e0e](https://github.com/pie-framework/pie-elements/commit/6199e0ef2689304d33d2fe576f4ab3f2788703b5))
|
|
36
|
+
|
|
37
|
+
## [14.1.9](https://github.com/pie-framework/pie-elements/compare/@pie-element/placement-ordering@14.1.7...@pie-element/placement-ordering@14.1.9) (2026-08-11)
|
|
38
|
+
|
|
39
|
+
### Bug Fixes
|
|
40
|
+
|
|
41
|
+
- **placement-ordering:** adjust choice grid row height and center choices PIE-787 ([ad3e41e](https://github.com/pie-framework/pie-elements/commit/ad3e41e606a1e80b2c6ba2c37e18367cbb9ccda1))
|
|
42
|
+
|
|
43
|
+
## [14.1.8](https://github.com/pie-framework/pie-elements/compare/@pie-element/placement-ordering@14.1.7...@pie-element/placement-ordering@14.1.8) (2026-07-31)
|
|
44
|
+
|
|
45
|
+
### Bug Fixes
|
|
46
|
+
|
|
47
|
+
- **placement-ordering:** adjust choice grid row height and center choices PIE-787 ([ad3e41e](https://github.com/pie-framework/pie-elements/commit/ad3e41e606a1e80b2c6ba2c37e18367cbb9ccda1))
|
|
48
|
+
|
|
49
|
+
## [14.1.7](https://github.com/pie-framework/pie-elements/compare/@pie-element/placement-ordering@14.1.6...@pie-element/placement-ordering@14.1.7) (2026-07-08)
|
|
11
50
|
|
|
12
51
|
### Bug Fixes
|
|
13
52
|
|
|
14
53
|
- bump libs & shared modules PIE-706, PIE-702, PIE-679, PIE-698 ([5b1a8c4](https://github.com/pie-framework/pie-elements/commit/5b1a8c4c3eba2126fc43d78fd0187e7cd11d5424))
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
54
|
+
|
|
55
|
+
## [14.1.6](https://github.com/pie-framework/pie-elements/compare/@pie-element/placement-ordering@14.1.5...@pie-element/placement-ordering@14.1.6) (2026-07-02)
|
|
56
|
+
|
|
57
|
+
### Bug Fixes
|
|
58
|
+
|
|
18
59
|
- bump shared modules and libs PIE-695, PIE-697, PIE-699, PIE-680, PIE-714, PIE-665, PIE-656 ([4b76ae7](https://github.com/pie-framework/pie-elements/commit/4b76ae75d1c5ea6d55f7c6fb53f299dfcbda2b1f))
|
|
19
|
-
- bump shared modules and libsPIE-603, PIE-604, PIE-663, PIE-662, PIE-678 ([e61c7a7](https://github.com/pie-framework/pie-elements/commit/e61c7a7d23744586337dfbb17a18ebfc656c202f))
|
|
20
|
-
- handle webcomponent lifecycle on every element that misses it PIE-703 ([9d5923f](https://github.com/pie-framework/pie-elements/commit/9d5923f973f0471e1e8f69ad4309cfc63d980d93))
|
|
21
|
-
- **placement-ordering:** adjust choice grid row height and center choices PIE-787 ([ad3e41e](https://github.com/pie-framework/pie-elements/commit/ad3e41e606a1e80b2c6ba2c37e18367cbb9ccda1))
|
|
22
60
|
- sync libs versions ([48b5be9](https://github.com/pie-framework/pie-elements/commit/48b5be9559eb5b5235ca05f51c5f0161032a7041))
|
|
23
61
|
|
|
62
|
+
## [14.1.5](https://github.com/pie-framework/pie-elements/compare/@pie-element/placement-ordering@14.1.4...@pie-element/placement-ordering@14.1.5) (2026-06-22)
|
|
63
|
+
|
|
64
|
+
### Bug Fixes
|
|
65
|
+
|
|
66
|
+
- bump shared modules and libs PIE-674, PIE-662, PIE-705, PIE-674, PIE-963 ([78a3f64](https://github.com/pie-framework/pie-elements/commit/78a3f64652c9581c61bd4159f3210fc1e32d8bcf))
|
|
67
|
+
- handle webcomponent lifecycle on every element that misses it PIE-703 ([9d5923f](https://github.com/pie-framework/pie-elements/commit/9d5923f973f0471e1e8f69ad4309cfc63d980d93))
|
|
68
|
+
|
|
69
|
+
## [14.1.4](https://github.com/pie-framework/pie-elements/compare/@pie-element/placement-ordering@14.1.3...@pie-element/placement-ordering@14.1.4) (2026-06-17)
|
|
70
|
+
|
|
71
|
+
### Bug Fixes
|
|
72
|
+
|
|
73
|
+
- bump shared modules and libs PIE-661 PIE-664 PIE-683 PIE-666 PIE-656 PIE-657 PIE-658 PIE-659 PIE-670 ([ebd6be4](https://github.com/pie-framework/pie-elements/commit/ebd6be4fd48fca41ad4c4908f606b25334731aed))
|
|
74
|
+
|
|
75
|
+
## [14.1.3](https://github.com/pie-framework/pie-elements/compare/@pie-element/placement-ordering@14.1.2...@pie-element/placement-ordering@14.1.3) (2026-06-12)
|
|
76
|
+
|
|
77
|
+
### Bug Fixes
|
|
78
|
+
|
|
79
|
+
- bump shared modules and libsPIE-603, PIE-604, PIE-663, PIE-662, PIE-678 ([e61c7a7](https://github.com/pie-framework/pie-elements/commit/e61c7a7d23744586337dfbb17a18ebfc656c202f))
|
|
80
|
+
|
|
81
|
+
## [14.1.2](https://github.com/pie-framework/pie-elements/compare/@pie-element/placement-ordering@14.1.1...@pie-element/placement-ordering@14.1.2) (2026-06-04)
|
|
82
|
+
|
|
83
|
+
### Bug Fixes
|
|
84
|
+
|
|
85
|
+
- bump shared modules and libs PIE-600, PIE-602 ([ce99f6a](https://github.com/pie-framework/pie-elements/commit/ce99f6af50cb855b666a6df9340f9f5445fde4c4))
|
|
86
|
+
|
|
87
|
+
## [14.1.1](https://github.com/pie-framework/pie-elements/compare/@pie-element/placement-ordering@14.1.0...@pie-element/placement-ordering@14.1.1) (2026-05-21)
|
|
88
|
+
|
|
89
|
+
**Note:** Version bump only for package @pie-element/placement-ordering
|
|
90
|
+
|
|
24
91
|
# [14.1.0](https://github.com/pie-framework/pie-elements/compare/@pie-element/placement-ordering@14.1.0-next.1...@pie-element/placement-ordering@14.1.0) (2026-05-21)
|
|
25
92
|
|
|
26
93
|
### Bug Fixes
|
package/configure/CHANGELOG.md
CHANGED
|
@@ -3,24 +3,80 @@
|
|
|
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
|
-
|
|
6
|
+
## [11.2.1](https://github.com/pie-framework/pie-elements/compare/@pie-element/placement-ordering-configure@11.2.0...@pie-element/placement-ordering-configure@11.2.1) (2026-08-26)
|
|
7
7
|
|
|
8
8
|
**Note:** Version bump only for package @pie-element/placement-ordering-configure
|
|
9
9
|
|
|
10
|
-
# [11.2.0
|
|
10
|
+
# [11.2.0](https://github.com/pie-framework/pie-elements/compare/@pie-element/placement-ordering-configure@11.1.11...@pie-element/placement-ordering-configure@11.2.0) (2026-08-21)
|
|
11
|
+
|
|
12
|
+
### Features
|
|
13
|
+
|
|
14
|
+
- bump libs PIE-856, PIE-681, PIE-927 ([cb26d7a](https://github.com/pie-framework/pie-elements/commit/cb26d7afa6c99522533c321d5ff8ce3148a66e9e))
|
|
15
|
+
|
|
16
|
+
## [11.1.11](https://github.com/pie-framework/pie-elements/compare/@pie-element/placement-ordering-configure@11.1.10...@pie-element/placement-ordering-configure@11.1.11) (2026-08-19)
|
|
17
|
+
|
|
18
|
+
### Bug Fixes
|
|
19
|
+
|
|
20
|
+
- bump libs and shared modules PIE-681, PIE-708 ([08af8b5](https://github.com/pie-framework/pie-elements/commit/08af8b5802aecc8ee5454a1b6d60277d7ec94204))
|
|
21
|
+
|
|
22
|
+
## [11.1.10](https://github.com/pie-framework/pie-elements/compare/@pie-element/placement-ordering-configure@11.1.8...@pie-element/placement-ordering-configure@11.1.10) (2026-08-13)
|
|
23
|
+
|
|
24
|
+
**Note:** Version bump only for package @pie-element/placement-ordering-configure
|
|
25
|
+
|
|
26
|
+
## [11.1.9](https://github.com/pie-framework/pie-elements/compare/@pie-element/placement-ordering-configure@11.1.7...@pie-element/placement-ordering-configure@11.1.9) (2026-08-11)
|
|
27
|
+
|
|
28
|
+
### Bug Fixes
|
|
29
|
+
|
|
30
|
+
- **placement-ordering:** adjust choice grid row height and center choices PIE-787 ([ad3e41e](https://github.com/pie-framework/pie-elements/commit/ad3e41e606a1e80b2c6ba2c37e18367cbb9ccda1))
|
|
31
|
+
|
|
32
|
+
## [11.1.8](https://github.com/pie-framework/pie-elements/compare/@pie-element/placement-ordering-configure@11.1.7...@pie-element/placement-ordering-configure@11.1.8) (2026-07-31)
|
|
33
|
+
|
|
34
|
+
### Bug Fixes
|
|
35
|
+
|
|
36
|
+
- **placement-ordering:** adjust choice grid row height and center choices PIE-787 ([ad3e41e](https://github.com/pie-framework/pie-elements/commit/ad3e41e606a1e80b2c6ba2c37e18367cbb9ccda1))
|
|
37
|
+
|
|
38
|
+
## [11.1.7](https://github.com/pie-framework/pie-elements/compare/@pie-element/placement-ordering-configure@11.1.6...@pie-element/placement-ordering-configure@11.1.7) (2026-07-08)
|
|
11
39
|
|
|
12
40
|
### Bug Fixes
|
|
13
41
|
|
|
14
42
|
- bump libs & shared modules PIE-706, PIE-702, PIE-679, PIE-698 ([5b1a8c4](https://github.com/pie-framework/pie-elements/commit/5b1a8c4c3eba2126fc43d78fd0187e7cd11d5424))
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
43
|
+
|
|
44
|
+
## [11.1.6](https://github.com/pie-framework/pie-elements/compare/@pie-element/placement-ordering-configure@11.1.5...@pie-element/placement-ordering-configure@11.1.6) (2026-07-02)
|
|
45
|
+
|
|
46
|
+
### Bug Fixes
|
|
47
|
+
|
|
18
48
|
- bump shared modules and libs PIE-695, PIE-697, PIE-699, PIE-680, PIE-714, PIE-665, PIE-656 ([4b76ae7](https://github.com/pie-framework/pie-elements/commit/4b76ae75d1c5ea6d55f7c6fb53f299dfcbda2b1f))
|
|
19
|
-
- bump shared modules and libsPIE-603, PIE-604, PIE-663, PIE-662, PIE-678 ([e61c7a7](https://github.com/pie-framework/pie-elements/commit/e61c7a7d23744586337dfbb17a18ebfc656c202f))
|
|
20
|
-
- handle webcomponent lifecycle on every element that misses it PIE-703 ([9d5923f](https://github.com/pie-framework/pie-elements/commit/9d5923f973f0471e1e8f69ad4309cfc63d980d93))
|
|
21
|
-
- **placement-ordering:** adjust choice grid row height and center choices PIE-787 ([ad3e41e](https://github.com/pie-framework/pie-elements/commit/ad3e41e606a1e80b2c6ba2c37e18367cbb9ccda1))
|
|
22
49
|
- sync libs versions ([48b5be9](https://github.com/pie-framework/pie-elements/commit/48b5be9559eb5b5235ca05f51c5f0161032a7041))
|
|
23
50
|
|
|
51
|
+
## [11.1.5](https://github.com/pie-framework/pie-elements/compare/@pie-element/placement-ordering-configure@11.1.4...@pie-element/placement-ordering-configure@11.1.5) (2026-06-22)
|
|
52
|
+
|
|
53
|
+
### Bug Fixes
|
|
54
|
+
|
|
55
|
+
- bump shared modules and libs PIE-674, PIE-662, PIE-705, PIE-674, PIE-963 ([78a3f64](https://github.com/pie-framework/pie-elements/commit/78a3f64652c9581c61bd4159f3210fc1e32d8bcf))
|
|
56
|
+
- handle webcomponent lifecycle on every element that misses it PIE-703 ([9d5923f](https://github.com/pie-framework/pie-elements/commit/9d5923f973f0471e1e8f69ad4309cfc63d980d93))
|
|
57
|
+
|
|
58
|
+
## [11.1.4](https://github.com/pie-framework/pie-elements/compare/@pie-element/placement-ordering-configure@11.1.3...@pie-element/placement-ordering-configure@11.1.4) (2026-06-17)
|
|
59
|
+
|
|
60
|
+
### Bug Fixes
|
|
61
|
+
|
|
62
|
+
- bump shared modules and libs PIE-661 PIE-664 PIE-683 PIE-666 PIE-656 PIE-657 PIE-658 PIE-659 PIE-670 ([ebd6be4](https://github.com/pie-framework/pie-elements/commit/ebd6be4fd48fca41ad4c4908f606b25334731aed))
|
|
63
|
+
|
|
64
|
+
## [11.1.3](https://github.com/pie-framework/pie-elements/compare/@pie-element/placement-ordering-configure@11.1.2...@pie-element/placement-ordering-configure@11.1.3) (2026-06-12)
|
|
65
|
+
|
|
66
|
+
### Bug Fixes
|
|
67
|
+
|
|
68
|
+
- bump shared modules and libsPIE-603, PIE-604, PIE-663, PIE-662, PIE-678 ([e61c7a7](https://github.com/pie-framework/pie-elements/commit/e61c7a7d23744586337dfbb17a18ebfc656c202f))
|
|
69
|
+
|
|
70
|
+
## [11.1.2](https://github.com/pie-framework/pie-elements/compare/@pie-element/placement-ordering-configure@11.1.1...@pie-element/placement-ordering-configure@11.1.2) (2026-06-04)
|
|
71
|
+
|
|
72
|
+
### Bug Fixes
|
|
73
|
+
|
|
74
|
+
- bump shared modules and libs PIE-600, PIE-602 ([ce99f6a](https://github.com/pie-framework/pie-elements/commit/ce99f6af50cb855b666a6df9340f9f5445fde4c4))
|
|
75
|
+
|
|
76
|
+
## [11.1.1](https://github.com/pie-framework/pie-elements/compare/@pie-element/placement-ordering-configure@11.1.0...@pie-element/placement-ordering-configure@11.1.1) (2026-05-21)
|
|
77
|
+
|
|
78
|
+
**Note:** Version bump only for package @pie-element/placement-ordering-configure
|
|
79
|
+
|
|
24
80
|
# [11.1.0](https://github.com/pie-framework/pie-elements/compare/@pie-element/placement-ordering-configure@11.1.0-next.1...@pie-element/placement-ordering-configure@11.1.0) (2026-05-21)
|
|
25
81
|
|
|
26
82
|
### Bug Fixes
|
package/configure/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pie-element/placement-ordering-configure",
|
|
3
|
-
"version": "11.
|
|
3
|
+
"version": "11.2.1",
|
|
4
4
|
"private": true,
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "src/index.js",
|
|
@@ -11,10 +11,10 @@
|
|
|
11
11
|
"@mui/icons-material": "^7.3.4",
|
|
12
12
|
"@mui/material": "^7.3.4",
|
|
13
13
|
"@pie-framework/pie-configure-events": "^1.3.0",
|
|
14
|
-
"@pie-lib/config-ui": "13.
|
|
15
|
-
"@pie-lib/drag": "4.
|
|
16
|
-
"@pie-lib/editable-html-tip-tap": "2.
|
|
17
|
-
"@pie-lib/render-ui": "
|
|
14
|
+
"@pie-lib/config-ui": "13.0.17",
|
|
15
|
+
"@pie-lib/drag": "4.1.2",
|
|
16
|
+
"@pie-lib/editable-html-tip-tap": "2.1.15",
|
|
17
|
+
"@pie-lib/render-ui": "7.0.1",
|
|
18
18
|
"debug": "^4.1.1",
|
|
19
19
|
"lodash-es": "^4.17.23",
|
|
20
20
|
"nested-property": "^0.0.7",
|
package/controller/CHANGELOG.md
CHANGED
|
@@ -3,16 +3,24 @@
|
|
|
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
|
-
|
|
6
|
+
## [11.1.4](https://github.com/pie-framework/pie-elements/compare/@pie-element/placement-ordering-controller@11.1.2...@pie-element/placement-ordering-controller@11.1.4) (2026-08-13)
|
|
7
7
|
|
|
8
8
|
**Note:** Version bump only for package @pie-element/placement-ordering-controller
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
## [11.1.3](https://github.com/pie-framework/pie-elements/compare/@pie-element/placement-ordering-controller@11.1.2...@pie-element/placement-ordering-controller@11.1.3) (2026-08-11)
|
|
11
|
+
|
|
12
|
+
**Note:** Version bump only for package @pie-element/placement-ordering-controller
|
|
13
|
+
|
|
14
|
+
## [11.1.2](https://github.com/pie-framework/pie-elements/compare/@pie-element/placement-ordering-controller@11.1.1...@pie-element/placement-ordering-controller@11.1.2) (2026-07-02)
|
|
11
15
|
|
|
12
16
|
### Bug Fixes
|
|
13
17
|
|
|
14
18
|
- bump shared modules and libs PIE-695, PIE-697, PIE-699, PIE-680, PIE-714, PIE-665, PIE-656 ([4b76ae7](https://github.com/pie-framework/pie-elements/commit/4b76ae75d1c5ea6d55f7c6fb53f299dfcbda2b1f))
|
|
15
19
|
|
|
20
|
+
## [11.1.1](https://github.com/pie-framework/pie-elements/compare/@pie-element/placement-ordering-controller@11.1.0...@pie-element/placement-ordering-controller@11.1.1) (2026-05-21)
|
|
21
|
+
|
|
22
|
+
**Note:** Version bump only for package @pie-element/placement-ordering-controller
|
|
23
|
+
|
|
16
24
|
# [11.1.0](https://github.com/pie-framework/pie-elements/compare/@pie-element/placement-ordering-controller@11.1.0-next.1...@pie-element/placement-ordering-controller@11.1.0) (2026-05-21)
|
|
17
25
|
|
|
18
26
|
### Bug Fixes
|
package/controller/package.json
CHANGED
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.closestDroppableKeyboardCoordinates = void 0;
|
|
7
|
+
var _core = require("@dnd-kit/core");
|
|
8
|
+
/**
|
|
9
|
+
* Custom keyboard coordinate getter for placement-ordering's Tab-based placement mode
|
|
10
|
+
* (enabled only when the item is configured with `placementArea` / `includeTargets`).
|
|
11
|
+
*
|
|
12
|
+
* Tab/Shift+Tab cycle the dragged choice directly onto the next/previous enabled
|
|
13
|
+
* droppable (a placement/target tile, or an empty gap left behind in the choices row),
|
|
14
|
+
* in real on-screen position order, placing the dragged item's own top-left corner at
|
|
15
|
+
* the target's center-left point.
|
|
16
|
+
*
|
|
17
|
+
* Arrow keys are delegated to dnd-kit's own `defaultKeyboardCoordinateGetter` so the
|
|
18
|
+
* pre-existing free-form arrow-key dragging behavior is left completely unchanged.
|
|
19
|
+
*
|
|
20
|
+
* The tile currently being dragged already disables its own droppable
|
|
21
|
+
* (see `useDroppable({ disabled: isDragging })` in tile.jsx), so it's naturally
|
|
22
|
+
* excluded from the candidate list here without any extra bookkeeping.
|
|
23
|
+
*
|
|
24
|
+
* When picking up a choice from the choices row, the other not-yet-placed choice
|
|
25
|
+
* tiles are also registered droppables (tile.jsx disables a droppable only while it's
|
|
26
|
+
* the one being dragged), but dropping a choice onto another choice is a no-op in the
|
|
27
|
+
* reducer (ordering.js's updateResponse has no `choice -> choice` case) — so they're
|
|
28
|
+
* excluded from the Tab/Shift+Tab cycle, leaving only the real placement targets.
|
|
29
|
+
*/
|
|
30
|
+
const closestDroppableKeyboardCoordinates = (event, {
|
|
31
|
+
active,
|
|
32
|
+
context,
|
|
33
|
+
currentCoordinates
|
|
34
|
+
}) => {
|
|
35
|
+
const {
|
|
36
|
+
code
|
|
37
|
+
} = event;
|
|
38
|
+
const isTab = code === 'Tab';
|
|
39
|
+
const isArrow = code === _core.KeyboardCode.Down || code === _core.KeyboardCode.Up || code === _core.KeyboardCode.Left || code === _core.KeyboardCode.Right;
|
|
40
|
+
if (!isTab && !isArrow) {
|
|
41
|
+
return undefined;
|
|
42
|
+
}
|
|
43
|
+
if (isArrow) {
|
|
44
|
+
return (0, _core.defaultKeyboardCoordinateGetter)(event, {
|
|
45
|
+
context,
|
|
46
|
+
currentCoordinates
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
event.preventDefault();
|
|
50
|
+
const {
|
|
51
|
+
droppableRects,
|
|
52
|
+
droppableContainers,
|
|
53
|
+
collisionRect
|
|
54
|
+
} = context;
|
|
55
|
+
if (!droppableRects || droppableRects.size === 0) {
|
|
56
|
+
return currentCoordinates;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// `currentCoordinates` is the top-left of the dragged item's collision rect (not its
|
|
60
|
+
// center), so derive the dragged item's center in the same frame before comparing it
|
|
61
|
+
// against droppable centers below.
|
|
62
|
+
const draggedHalfSize = {
|
|
63
|
+
x: (collisionRect?.width || 0) / 2,
|
|
64
|
+
y: (collisionRect?.height || 0) / 2
|
|
65
|
+
};
|
|
66
|
+
const currentCenter = {
|
|
67
|
+
x: currentCoordinates.x + draggedHalfSize.x,
|
|
68
|
+
y: currentCoordinates.y + draggedHalfSize.y
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
// Only exclude other choice tiles while dragging a choice; dragging a placed target
|
|
72
|
+
// back onto a choice-row gap is still a valid "return to pool" destination.
|
|
73
|
+
const activeType = active?.data?.current?.type;
|
|
74
|
+
const excludeChoiceDroppables = activeType === 'choice';
|
|
75
|
+
const targets = [];
|
|
76
|
+
for (const [id, container] of droppableContainers) {
|
|
77
|
+
if (container?.disabled) continue;
|
|
78
|
+
if (excludeChoiceDroppables && container?.data?.current?.type === 'choice') continue;
|
|
79
|
+
const rect = droppableRects.get(id);
|
|
80
|
+
if (!rect) continue;
|
|
81
|
+
const center = {
|
|
82
|
+
x: rect.left + rect.width / 2,
|
|
83
|
+
y: rect.top + rect.height / 2
|
|
84
|
+
};
|
|
85
|
+
// Land the dragged item's own top-left corner at the target's center-left point,
|
|
86
|
+
// rather than at the target's own top-left corner.
|
|
87
|
+
const dropPosition = {
|
|
88
|
+
x: rect.left,
|
|
89
|
+
y: rect.top + rect.height / 2
|
|
90
|
+
};
|
|
91
|
+
targets.push({
|
|
92
|
+
id,
|
|
93
|
+
dropPosition,
|
|
94
|
+
center
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
if (targets.length === 0) {
|
|
98
|
+
return currentCoordinates;
|
|
99
|
+
}
|
|
100
|
+
const reverse = event.shiftKey;
|
|
101
|
+
|
|
102
|
+
// Sort targets by real on-screen position (top to bottom, then left to right), so
|
|
103
|
+
// this works the same whether the tiler is laid out vertically or horizontally.
|
|
104
|
+
targets.sort((a, b) => {
|
|
105
|
+
if (Math.abs(a.center.y - b.center.y) > 10) return a.center.y - b.center.y;
|
|
106
|
+
return a.center.x - b.center.x;
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
// Find the current target (closest to current coordinates)
|
|
110
|
+
let currentIndex = 0;
|
|
111
|
+
let minDist = Infinity;
|
|
112
|
+
for (let i = 0; i < targets.length; i++) {
|
|
113
|
+
const dist = distance(currentCenter, targets[i].center);
|
|
114
|
+
if (dist < minDist) {
|
|
115
|
+
minDist = dist;
|
|
116
|
+
currentIndex = i;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
const nextIndex = reverse ? (currentIndex - 1 + targets.length) % targets.length : (currentIndex + 1) % targets.length;
|
|
120
|
+
return targets[nextIndex].dropPosition;
|
|
121
|
+
};
|
|
122
|
+
exports.closestDroppableKeyboardCoordinates = closestDroppableKeyboardCoordinates;
|
|
123
|
+
const distance = (a, b) => Math.sqrt((a.x - b.x) ** 2 + (a.y - b.y) ** 2);
|
|
124
|
+
//# sourceMappingURL=keyboard-coordinates.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keyboard-coordinates.js","names":["_core","require","closestDroppableKeyboardCoordinates","event","active","context","currentCoordinates","code","isTab","isArrow","KeyboardCode","Down","Up","Left","Right","undefined","defaultKeyboardCoordinateGetter","preventDefault","droppableRects","droppableContainers","collisionRect","size","draggedHalfSize","x","width","y","height","currentCenter","activeType","data","current","type","excludeChoiceDroppables","targets","id","container","disabled","rect","get","center","left","top","dropPosition","push","length","reverse","shiftKey","sort","a","b","Math","abs","currentIndex","minDist","Infinity","i","dist","distance","nextIndex","exports","sqrt"],"sources":["../src/keyboard-coordinates.js"],"sourcesContent":["import { defaultKeyboardCoordinateGetter, KeyboardCode } from '@dnd-kit/core';\n\n/**\n * Custom keyboard coordinate getter for placement-ordering's Tab-based placement mode\n * (enabled only when the item is configured with `placementArea` / `includeTargets`).\n *\n * Tab/Shift+Tab cycle the dragged choice directly onto the next/previous enabled\n * droppable (a placement/target tile, or an empty gap left behind in the choices row),\n * in real on-screen position order, placing the dragged item's own top-left corner at\n * the target's center-left point.\n *\n * Arrow keys are delegated to dnd-kit's own `defaultKeyboardCoordinateGetter` so the\n * pre-existing free-form arrow-key dragging behavior is left completely unchanged.\n *\n * The tile currently being dragged already disables its own droppable\n * (see `useDroppable({ disabled: isDragging })` in tile.jsx), so it's naturally\n * excluded from the candidate list here without any extra bookkeeping.\n *\n * When picking up a choice from the choices row, the other not-yet-placed choice\n * tiles are also registered droppables (tile.jsx disables a droppable only while it's\n * the one being dragged), but dropping a choice onto another choice is a no-op in the\n * reducer (ordering.js's updateResponse has no `choice -> choice` case) — so they're\n * excluded from the Tab/Shift+Tab cycle, leaving only the real placement targets.\n */\nexport const closestDroppableKeyboardCoordinates = (event, { active, context, currentCoordinates }) => {\n const { code } = event;\n const isTab = code === 'Tab';\n const isArrow =\n code === KeyboardCode.Down || code === KeyboardCode.Up || code === KeyboardCode.Left || code === KeyboardCode.Right;\n\n if (!isTab && !isArrow) {\n return undefined;\n }\n\n if (isArrow) {\n return defaultKeyboardCoordinateGetter(event, { context, currentCoordinates });\n }\n\n event.preventDefault();\n\n const { droppableRects, droppableContainers, collisionRect } = context;\n\n if (!droppableRects || droppableRects.size === 0) {\n return currentCoordinates;\n }\n\n // `currentCoordinates` is the top-left of the dragged item's collision rect (not its\n // center), so derive the dragged item's center in the same frame before comparing it\n // against droppable centers below.\n const draggedHalfSize = {\n x: (collisionRect?.width || 0) / 2,\n y: (collisionRect?.height || 0) / 2,\n };\n const currentCenter = {\n x: currentCoordinates.x + draggedHalfSize.x,\n y: currentCoordinates.y + draggedHalfSize.y,\n };\n\n // Only exclude other choice tiles while dragging a choice; dragging a placed target\n // back onto a choice-row gap is still a valid \"return to pool\" destination.\n const activeType = active?.data?.current?.type;\n const excludeChoiceDroppables = activeType === 'choice';\n\n const targets = [];\n\n for (const [id, container] of droppableContainers) {\n if (container?.disabled) continue;\n\n if (excludeChoiceDroppables && container?.data?.current?.type === 'choice') continue;\n\n const rect = droppableRects.get(id);\n\n if (!rect) continue;\n\n const center = {\n x: rect.left + rect.width / 2,\n y: rect.top + rect.height / 2,\n };\n // Land the dragged item's own top-left corner at the target's center-left point,\n // rather than at the target's own top-left corner.\n const dropPosition = {\n x: rect.left,\n y: rect.top + rect.height / 2,\n };\n\n targets.push({ id, dropPosition, center });\n }\n\n if (targets.length === 0) {\n return currentCoordinates;\n }\n\n const reverse = event.shiftKey;\n\n // Sort targets by real on-screen position (top to bottom, then left to right), so\n // this works the same whether the tiler is laid out vertically or horizontally.\n targets.sort((a, b) => {\n if (Math.abs(a.center.y - b.center.y) > 10) return a.center.y - b.center.y;\n return a.center.x - b.center.x;\n });\n\n // Find the current target (closest to current coordinates)\n let currentIndex = 0;\n let minDist = Infinity;\n\n for (let i = 0; i < targets.length; i++) {\n const dist = distance(currentCenter, targets[i].center);\n\n if (dist < minDist) {\n minDist = dist;\n currentIndex = i;\n }\n }\n\n const nextIndex = reverse\n ? (currentIndex - 1 + targets.length) % targets.length\n : (currentIndex + 1) % targets.length;\n\n return targets[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,6 +14,7 @@ var _debug = _interopRequireDefault(require("debug"));
|
|
|
14
14
|
var _lodashEs = require("lodash-es");
|
|
15
15
|
var _styles = require("@mui/material/styles");
|
|
16
16
|
var _core = require("@dnd-kit/core");
|
|
17
|
+
var _modifiers = require("@dnd-kit/modifiers");
|
|
17
18
|
var _renderUi = require("@pie-lib/render-ui");
|
|
18
19
|
var _mathRendering = require("@pie-lib/math-rendering");
|
|
19
20
|
var _translator = _interopRequireDefault(require("@pie-lib/translator"));
|
|
@@ -22,6 +23,24 @@ var _drag = require("@pie-lib/drag");
|
|
|
22
23
|
var _tiler = require("./tiler");
|
|
23
24
|
var _ordering = require("./ordering");
|
|
24
25
|
var _utils = require("./utils");
|
|
26
|
+
var _keyboardCoordinates = require("./keyboard-coordinates");
|
|
27
|
+
// A click that lands right after a real drag gesture ends must be ignored by the
|
|
28
|
+
// click-to-select/click-to-place handlers below, or it would immediately reopen or
|
|
29
|
+
// re-trigger a selection for a drag that just completed.
|
|
30
|
+
const CLICK_AFTER_DRAG_GUARD_MS = 250;
|
|
31
|
+
const getKeyboardDragOptions = includeTargets => includeTargets ? {
|
|
32
|
+
keyboardCoordinateGetter: _keyboardCoordinates.closestDroppableKeyboardCoordinates,
|
|
33
|
+
keyboardCodes: {
|
|
34
|
+
start: ['Space', 'Enter'],
|
|
35
|
+
cancel: ['Escape'],
|
|
36
|
+
end: ['Space', 'Enter']
|
|
37
|
+
},
|
|
38
|
+
accessibility: {
|
|
39
|
+
screenReaderInstructions: {
|
|
40
|
+
draggable: 'Press Space or Enter to pick up this answer choice. Once picked up, use Tab or Shift+Tab to cycle through response areas, or use arrow keys to move it freely. Press Space or Enter to drop, or Escape to cancel.'
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
} : {};
|
|
25
44
|
const {
|
|
26
45
|
translator
|
|
27
46
|
} = _translator.default;
|
|
@@ -34,6 +53,26 @@ const PlacementOrderingContainer = (0, _styles.styled)('div')({
|
|
|
34
53
|
alignItems: 'center',
|
|
35
54
|
boxSizing: 'border-box'
|
|
36
55
|
});
|
|
56
|
+
|
|
57
|
+
// The interactive region - the choices and answers columns for a vertical item, or the choices and
|
|
58
|
+
// answers rows for a horizontal one - scrolls horizontally when it does not fit the available width.
|
|
59
|
+
const InteractiveRegion = (0, _styles.styled)('div')({
|
|
60
|
+
// the ancestors centre their children, which shrink-wraps this box to its content. without a
|
|
61
|
+
// definite width it grows with the tiler and the overflow escapes outwards instead of scrolling.
|
|
62
|
+
alignSelf: 'stretch',
|
|
63
|
+
maxWidth: '100%',
|
|
64
|
+
overflowX: 'auto',
|
|
65
|
+
// tiles are dragged by transform, which counts towards scrollable overflow, so leaving this axis
|
|
66
|
+
// scrollable would pop a vertical scrollbar mid-drag
|
|
67
|
+
overflowY: 'hidden'
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
// keeps the tiler at its natural width, and centred while it still fits
|
|
71
|
+
const InteractiveRegionContent = (0, _styles.styled)('div')({
|
|
72
|
+
display: 'flex',
|
|
73
|
+
justifyContent: 'center',
|
|
74
|
+
minWidth: 'min-content'
|
|
75
|
+
});
|
|
37
76
|
const StyledPrompt = (0, _styles.styled)('div')(({
|
|
38
77
|
theme
|
|
39
78
|
}) => ({
|
|
@@ -202,6 +241,12 @@ class PlacementOrdering extends _react.default.Component {
|
|
|
202
241
|
active
|
|
203
242
|
} = event;
|
|
204
243
|
const ordering = this.createOrdering();
|
|
244
|
+
|
|
245
|
+
// A real drag (pointer or keyboard) just ended — whatever mirrored selection it
|
|
246
|
+
// set on start is now resolved, and any click landing immediately after this must
|
|
247
|
+
// not be misread as a fresh selection/placement
|
|
248
|
+
this.cancelSelection();
|
|
249
|
+
this.lastDragEndAt = Date.now();
|
|
205
250
|
if (over && active) {
|
|
206
251
|
const draggedItem = active.data.current;
|
|
207
252
|
const droppedOnItem = over.data.current;
|
|
@@ -219,14 +264,91 @@ class PlacementOrdering extends _react.default.Component {
|
|
|
219
264
|
}
|
|
220
265
|
}
|
|
221
266
|
});
|
|
267
|
+
(0, _defineProperty2.default)(this, "onDragStart", event => {
|
|
268
|
+
const {
|
|
269
|
+
active
|
|
270
|
+
} = event;
|
|
271
|
+
if (active?.data?.current) {
|
|
272
|
+
// A real drag (pointer or keyboard) is itself a selection — mirror it into the
|
|
273
|
+
// same selectedChoice state that click-to-select uses, so the two interaction
|
|
274
|
+
// models can be freely intermixed
|
|
275
|
+
this.selectChoice(active.data.current);
|
|
276
|
+
}
|
|
277
|
+
});
|
|
278
|
+
(0, _defineProperty2.default)(this, "onDragCancel", () => {
|
|
279
|
+
this.cancelSelection();
|
|
280
|
+
this.lastDragEndAt = Date.now();
|
|
281
|
+
});
|
|
282
|
+
(0, _defineProperty2.default)(this, "isSameChoice", (a, b) => !!a && !!b && a.type === b.type && a.id === b.id && a.index === b.index);
|
|
283
|
+
(0, _defineProperty2.default)(this, "selectChoice", data => {
|
|
284
|
+
this.setState({
|
|
285
|
+
selectedChoice: data
|
|
286
|
+
});
|
|
287
|
+
});
|
|
288
|
+
// Click-to-select semantics: selecting the currently-selected choice again clears
|
|
289
|
+
// the selection instead of re-selecting it.
|
|
290
|
+
(0, _defineProperty2.default)(this, "toggleChoiceSelection", data => {
|
|
291
|
+
this.setState(state => ({
|
|
292
|
+
selectedChoice: this.isSameChoice(state.selectedChoice, data) ? null : data
|
|
293
|
+
}));
|
|
294
|
+
});
|
|
295
|
+
(0, _defineProperty2.default)(this, "cancelSelection", () => {
|
|
296
|
+
this.setState({
|
|
297
|
+
selectedChoice: null
|
|
298
|
+
});
|
|
299
|
+
});
|
|
300
|
+
// If a real dnd-kit drag (started via keyboard Space/Enter) is still live when a
|
|
301
|
+
// click completes the placement below, it needs to be cleanly ended — otherwise
|
|
302
|
+
// dnd-kit would still think a drag is in progress. Escape is already configured as
|
|
303
|
+
// this sensor's cancel key (see getKeyboardDragOptions), and dispatching it as a real
|
|
304
|
+
// DOM KeyboardEvent is how dnd-kit's own document-level listener is reached from
|
|
305
|
+
// outside its sensor. onDragCancel only resets local UI state, not the session, so
|
|
306
|
+
// this is safe to call unconditionally, including when no drag is actually live
|
|
307
|
+
// (dnd-kit simply has no listener attached in that case, and the dispatch is a
|
|
308
|
+
// no-op).
|
|
309
|
+
(0, _defineProperty2.default)(this, "endAnyLiveKeyboardDrag", () => {
|
|
310
|
+
document.dispatchEvent(new KeyboardEvent('keydown', {
|
|
311
|
+
code: 'Escape',
|
|
312
|
+
bubbles: true,
|
|
313
|
+
cancelable: true
|
|
314
|
+
}));
|
|
315
|
+
});
|
|
316
|
+
(0, _defineProperty2.default)(this, "placeSelectedChoice", targetTileData => {
|
|
317
|
+
const {
|
|
318
|
+
selectedChoice
|
|
319
|
+
} = this.state;
|
|
320
|
+
if (!selectedChoice) {
|
|
321
|
+
return;
|
|
322
|
+
}
|
|
323
|
+
const ordering = this.createOrdering();
|
|
324
|
+
this.onDropChoice(targetTileData, selectedChoice, ordering);
|
|
325
|
+
this.cancelSelection();
|
|
326
|
+
this.endAnyLiveKeyboardDrag();
|
|
327
|
+
this.lastDragEndAt = Date.now();
|
|
328
|
+
});
|
|
329
|
+
(0, _defineProperty2.default)(this, "isClickSoonAfterDragEnd", () => Date.now() - this.lastDragEndAt < CLICK_AFTER_DRAG_GUARD_MS);
|
|
330
|
+
(0, _defineProperty2.default)(this, "onChoiceClick", data => {
|
|
331
|
+
if (this.isClickSoonAfterDragEnd()) {
|
|
332
|
+
return;
|
|
333
|
+
}
|
|
334
|
+
this.toggleChoiceSelection(data);
|
|
335
|
+
});
|
|
336
|
+
(0, _defineProperty2.default)(this, "onPlacementClick", targetTileData => {
|
|
337
|
+
if (this.isClickSoonAfterDragEnd()) {
|
|
338
|
+
return;
|
|
339
|
+
}
|
|
340
|
+
this.placeSelectedChoice(targetTileData);
|
|
341
|
+
});
|
|
222
342
|
this.instanceId = (0, _lodashEs.uniqueId)();
|
|
223
343
|
const {
|
|
224
344
|
value: _value,
|
|
225
345
|
needsReset: _needsReset
|
|
226
346
|
} = this.validateSession(props);
|
|
227
347
|
this.state = {
|
|
228
|
-
showingCorrect: false
|
|
348
|
+
showingCorrect: false,
|
|
349
|
+
selectedChoice: null
|
|
229
350
|
};
|
|
351
|
+
this.lastDragEndAt = 0;
|
|
230
352
|
const {
|
|
231
353
|
model: _model
|
|
232
354
|
} = props || {};
|
|
@@ -356,13 +478,21 @@ class PlacementOrdering extends _react.default.Component {
|
|
|
356
478
|
display: 'flex',
|
|
357
479
|
flexDirection: 'column',
|
|
358
480
|
alignItems: 'center',
|
|
359
|
-
boxSizing: 'border-box'
|
|
481
|
+
boxSizing: 'border-box',
|
|
482
|
+
width: '100%'
|
|
360
483
|
};
|
|
361
|
-
|
|
362
|
-
|
|
484
|
+
const clickPlacementProps = includeTargets ? {
|
|
485
|
+
selectedChoice: this.state.selectedChoice,
|
|
486
|
+
onChoiceClick: this.onChoiceClick,
|
|
487
|
+
onPlacementClick: this.onPlacementClick
|
|
488
|
+
} : {};
|
|
489
|
+
return /*#__PURE__*/_react.default.createElement(_drag.DragProvider, (0, _extends2.default)({
|
|
490
|
+
onDragStart: this.onDragStart,
|
|
363
491
|
onDragEnd: this.onDragEnd,
|
|
364
|
-
|
|
365
|
-
|
|
492
|
+
onDragCancel: this.onDragCancel,
|
|
493
|
+
collisionDetection: _core.rectIntersection,
|
|
494
|
+
modifiers: [_modifiers.restrictToParentElement]
|
|
495
|
+
}, getKeyboardDragOptions(includeTargets)), /*#__PURE__*/_react.default.createElement(PlacementOrderingContainer, null, /*#__PURE__*/_react.default.createElement(_renderUi.UiLayout, {
|
|
366
496
|
extraCSSRules: extraCSSRules,
|
|
367
497
|
style: containerStyle
|
|
368
498
|
}, showTeacherInstructions && /*#__PURE__*/_react.default.createElement(StyledCollapsible, {
|
|
@@ -380,7 +510,7 @@ class PlacementOrdering extends _react.default.Component {
|
|
|
380
510
|
toggled: showingCorrect,
|
|
381
511
|
onToggle: this.toggleCorrect,
|
|
382
512
|
language: language
|
|
383
|
-
}), /*#__PURE__*/_react.default.createElement(OrderingTiler, {
|
|
513
|
+
}), /*#__PURE__*/_react.default.createElement(InteractiveRegion, null, /*#__PURE__*/_react.default.createElement(InteractiveRegionContent, null, /*#__PURE__*/_react.default.createElement(OrderingTiler, (0, _extends2.default)({
|
|
384
514
|
instanceId: this.instanceId,
|
|
385
515
|
choiceLabel: config.choiceLabel,
|
|
386
516
|
targetLabel: config.targetLabel,
|
|
@@ -391,7 +521,7 @@ class PlacementOrdering extends _react.default.Component {
|
|
|
391
521
|
tileSize: config.tileSize,
|
|
392
522
|
includeTargets: includeTargets,
|
|
393
523
|
choiceLabelEnabled: model.config && model.config.choiceLabelEnabled
|
|
394
|
-
}), displayNote && /*#__PURE__*/_react.default.createElement(StyledNote, {
|
|
524
|
+
}, clickPlacementProps)))), displayNote && /*#__PURE__*/_react.default.createElement(StyledNote, {
|
|
395
525
|
dangerouslySetInnerHTML: {
|
|
396
526
|
__html: note
|
|
397
527
|
}
|