@mirai/ui 1.0.248 → 1.0.249
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/build/components/Button/__tests__/__snapshots__/Button.test.js.snap +3 -1
- package/build/components/Menu/__tests__/__snapshots__/Menu.test.jsx.snap +22 -7
- package/build/components/Table/__tests__/__snapshots__/Table.ColumnFilter.test.js.snap +16 -5
- package/build/components/Table/__tests__/__snapshots__/Table.test.js.snap +66 -22
- package/build/components/Tooltip/__tests__/__snapshots__/Tooltip.test.jsx.snap +11 -2
- package/build/primitives/Layer/Layer.js +1 -0
- package/build/primitives/Layer/Layer.js.map +1 -1
- package/build/primitives/Layer/Layer.module.css +4 -0
- package/build/primitives/Layer/__tests__/__snapshots__/Layer.test.js.snap +28 -9
- package/package.json +1 -1
|
@@ -2,13 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
exports[`component:<Menu> inherit:className 1`] = `
|
|
4
4
|
<DocumentFragment>
|
|
5
|
-
<span
|
|
5
|
+
<span
|
|
6
|
+
class="container"
|
|
7
|
+
/>
|
|
6
8
|
</DocumentFragment>
|
|
7
9
|
`;
|
|
8
10
|
|
|
9
11
|
exports[`component:<Menu> prop:Template 1`] = `
|
|
10
12
|
<DocumentFragment>
|
|
11
|
-
<span
|
|
13
|
+
<span
|
|
14
|
+
class="container"
|
|
15
|
+
>
|
|
12
16
|
<button
|
|
13
17
|
class="pressable button"
|
|
14
18
|
>
|
|
@@ -20,7 +24,9 @@ exports[`component:<Menu> prop:Template 1`] = `
|
|
|
20
24
|
|
|
21
25
|
exports[`component:<Menu> prop:children 1`] = `
|
|
22
26
|
<DocumentFragment>
|
|
23
|
-
<span
|
|
27
|
+
<span
|
|
28
|
+
class="container"
|
|
29
|
+
>
|
|
24
30
|
<button
|
|
25
31
|
class="pressable button"
|
|
26
32
|
>
|
|
@@ -32,7 +38,9 @@ exports[`component:<Menu> prop:children 1`] = `
|
|
|
32
38
|
|
|
33
39
|
exports[`component:<Menu> prop:options & visible 1`] = `
|
|
34
40
|
<DocumentFragment>
|
|
35
|
-
<span
|
|
41
|
+
<span
|
|
42
|
+
class="container"
|
|
43
|
+
>
|
|
36
44
|
<button
|
|
37
45
|
class="pressable button"
|
|
38
46
|
>
|
|
@@ -179,7 +187,9 @@ exports[`component:<Menu> prop:options & visible 1`] = `
|
|
|
179
187
|
|
|
180
188
|
exports[`component:<Menu> prop:options 1`] = `
|
|
181
189
|
<DocumentFragment>
|
|
182
|
-
<span
|
|
190
|
+
<span
|
|
191
|
+
class="container"
|
|
192
|
+
>
|
|
183
193
|
<button
|
|
184
194
|
class="pressable button"
|
|
185
195
|
>
|
|
@@ -191,7 +201,9 @@ exports[`component:<Menu> prop:options 1`] = `
|
|
|
191
201
|
|
|
192
202
|
exports[`component:<Menu> prop:title 1`] = `
|
|
193
203
|
<DocumentFragment>
|
|
194
|
-
<span
|
|
204
|
+
<span
|
|
205
|
+
class="container"
|
|
206
|
+
>
|
|
195
207
|
<button
|
|
196
208
|
class="pressable button"
|
|
197
209
|
>
|
|
@@ -211,13 +223,16 @@ exports[`component:<Menu> prop:title 1`] = `
|
|
|
211
223
|
|
|
212
224
|
exports[`component:<Menu> renders 1`] = `
|
|
213
225
|
<DocumentFragment>
|
|
214
|
-
<span
|
|
226
|
+
<span
|
|
227
|
+
class="container"
|
|
228
|
+
/>
|
|
215
229
|
</DocumentFragment>
|
|
216
230
|
`;
|
|
217
231
|
|
|
218
232
|
exports[`component:<Menu> testId 1`] = `
|
|
219
233
|
<DocumentFragment>
|
|
220
234
|
<span
|
|
235
|
+
class="container"
|
|
221
236
|
data-testid="mirai"
|
|
222
237
|
/>
|
|
223
238
|
</DocumentFragment>
|
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
exports[`component:<Table>:<ColumnFilter> inherit:className 1`] = `
|
|
4
4
|
<DocumentFragment>
|
|
5
|
-
<span
|
|
5
|
+
<span
|
|
6
|
+
class="container"
|
|
7
|
+
>
|
|
6
8
|
<div
|
|
7
9
|
class="pressable"
|
|
8
10
|
style="position: relative;"
|
|
@@ -127,7 +129,9 @@ exports[`component:<Table>:<ColumnFilter> inherit:className 1`] = `
|
|
|
127
129
|
|
|
128
130
|
exports[`component:<Table>:<ColumnFilter> prop:l10n 1`] = `
|
|
129
131
|
<DocumentFragment>
|
|
130
|
-
<span
|
|
132
|
+
<span
|
|
133
|
+
class="container"
|
|
134
|
+
>
|
|
131
135
|
<div
|
|
132
136
|
class="pressable"
|
|
133
137
|
style="position: relative;"
|
|
@@ -252,7 +256,9 @@ exports[`component:<Table>:<ColumnFilter> prop:l10n 1`] = `
|
|
|
252
256
|
|
|
253
257
|
exports[`component:<Table>:<ColumnFilter> prop:schema type:number 1`] = `
|
|
254
258
|
<DocumentFragment>
|
|
255
|
-
<span
|
|
259
|
+
<span
|
|
260
|
+
class="container"
|
|
261
|
+
>
|
|
256
262
|
<div
|
|
257
263
|
class="pressable"
|
|
258
264
|
style="position: relative;"
|
|
@@ -377,7 +383,9 @@ exports[`component:<Table>:<ColumnFilter> prop:schema type:number 1`] = `
|
|
|
377
383
|
|
|
378
384
|
exports[`component:<Table>:<ColumnFilter> prop:schema type:text 1`] = `
|
|
379
385
|
<DocumentFragment>
|
|
380
|
-
<span
|
|
386
|
+
<span
|
|
387
|
+
class="container"
|
|
388
|
+
>
|
|
381
389
|
<div
|
|
382
390
|
class="pressable"
|
|
383
391
|
style="position: relative;"
|
|
@@ -502,7 +510,9 @@ exports[`component:<Table>:<ColumnFilter> prop:schema type:text 1`] = `
|
|
|
502
510
|
|
|
503
511
|
exports[`component:<Table>:<ColumnFilter> renders 1`] = `
|
|
504
512
|
<DocumentFragment>
|
|
505
|
-
<span
|
|
513
|
+
<span
|
|
514
|
+
class="container"
|
|
515
|
+
>
|
|
506
516
|
<div
|
|
507
517
|
class="pressable"
|
|
508
518
|
style="position: relative;"
|
|
@@ -628,6 +638,7 @@ exports[`component:<Table>:<ColumnFilter> renders 1`] = `
|
|
|
628
638
|
exports[`component:<Table>:<ColumnFilter> testId 1`] = `
|
|
629
639
|
<DocumentFragment>
|
|
630
640
|
<span
|
|
641
|
+
class="container"
|
|
631
642
|
data-testid="mirai"
|
|
632
643
|
>
|
|
633
644
|
<div
|
|
@@ -110,7 +110,9 @@ exports[`component:<Table> inherit:className 1`] = `
|
|
|
110
110
|
<span
|
|
111
111
|
class="view forceRow column"
|
|
112
112
|
>
|
|
113
|
-
<span
|
|
113
|
+
<span
|
|
114
|
+
class="container"
|
|
115
|
+
>
|
|
114
116
|
<div
|
|
115
117
|
class="dispatcher tooltip"
|
|
116
118
|
>
|
|
@@ -587,7 +589,9 @@ exports[`component:<Table> prop:filter 1`] = `
|
|
|
587
589
|
/>
|
|
588
590
|
</svg>
|
|
589
591
|
</span>
|
|
590
|
-
<span
|
|
592
|
+
<span
|
|
593
|
+
class="container"
|
|
594
|
+
>
|
|
591
595
|
<div
|
|
592
596
|
class="pressable"
|
|
593
597
|
style="position: relative;"
|
|
@@ -647,7 +651,9 @@ exports[`component:<Table> prop:filter 1`] = `
|
|
|
647
651
|
/>
|
|
648
652
|
</svg>
|
|
649
653
|
</span>
|
|
650
|
-
<span
|
|
654
|
+
<span
|
|
655
|
+
class="container"
|
|
656
|
+
>
|
|
651
657
|
<div
|
|
652
658
|
class="pressable"
|
|
653
659
|
style="position: relative;"
|
|
@@ -707,7 +713,9 @@ exports[`component:<Table> prop:filter 1`] = `
|
|
|
707
713
|
/>
|
|
708
714
|
</svg>
|
|
709
715
|
</span>
|
|
710
|
-
<span
|
|
716
|
+
<span
|
|
717
|
+
class="container"
|
|
718
|
+
>
|
|
711
719
|
<div
|
|
712
720
|
class="pressable"
|
|
713
721
|
style="position: relative;"
|
|
@@ -742,7 +750,9 @@ exports[`component:<Table> prop:filter 1`] = `
|
|
|
742
750
|
<span
|
|
743
751
|
class="view forceRow column"
|
|
744
752
|
>
|
|
745
|
-
<span
|
|
753
|
+
<span
|
|
754
|
+
class="container"
|
|
755
|
+
>
|
|
746
756
|
<div
|
|
747
757
|
class="dispatcher tooltip"
|
|
748
758
|
>
|
|
@@ -773,7 +783,9 @@ exports[`component:<Table> prop:filter 1`] = `
|
|
|
773
783
|
/>
|
|
774
784
|
</svg>
|
|
775
785
|
</span>
|
|
776
|
-
<span
|
|
786
|
+
<span
|
|
787
|
+
class="container"
|
|
788
|
+
>
|
|
777
789
|
<div
|
|
778
790
|
class="pressable"
|
|
779
791
|
style="position: relative;"
|
|
@@ -833,7 +845,9 @@ exports[`component:<Table> prop:filter 1`] = `
|
|
|
833
845
|
/>
|
|
834
846
|
</svg>
|
|
835
847
|
</span>
|
|
836
|
-
<span
|
|
848
|
+
<span
|
|
849
|
+
class="container"
|
|
850
|
+
>
|
|
837
851
|
<div
|
|
838
852
|
class="pressable"
|
|
839
853
|
style="position: relative;"
|
|
@@ -1121,7 +1135,9 @@ exports[`component:<Table> prop:inline (false 1`] = `
|
|
|
1121
1135
|
<span
|
|
1122
1136
|
class="view forceRow column"
|
|
1123
1137
|
>
|
|
1124
|
-
<span
|
|
1138
|
+
<span
|
|
1139
|
+
class="container"
|
|
1140
|
+
>
|
|
1125
1141
|
<div
|
|
1126
1142
|
class="dispatcher tooltip"
|
|
1127
1143
|
>
|
|
@@ -1554,7 +1570,9 @@ exports[`component:<Table> prop:onScroll 1`] = `
|
|
|
1554
1570
|
<span
|
|
1555
1571
|
class="view forceRow column"
|
|
1556
1572
|
>
|
|
1557
|
-
<span
|
|
1573
|
+
<span
|
|
1574
|
+
class="container"
|
|
1575
|
+
>
|
|
1558
1576
|
<div
|
|
1559
1577
|
class="dispatcher tooltip"
|
|
1560
1578
|
>
|
|
@@ -2088,7 +2106,9 @@ exports[`component:<Table> prop:onSelect 1`] = `
|
|
|
2088
2106
|
<span
|
|
2089
2107
|
class="view forceRow column"
|
|
2090
2108
|
>
|
|
2091
|
-
<span
|
|
2109
|
+
<span
|
|
2110
|
+
class="container"
|
|
2111
|
+
>
|
|
2092
2112
|
<div
|
|
2093
2113
|
class="dispatcher tooltip"
|
|
2094
2114
|
>
|
|
@@ -2701,7 +2721,9 @@ exports[`component:<Table> prop:pagination 1`] = `
|
|
|
2701
2721
|
<span
|
|
2702
2722
|
class="view forceRow column"
|
|
2703
2723
|
>
|
|
2704
|
-
<span
|
|
2724
|
+
<span
|
|
2725
|
+
class="container"
|
|
2726
|
+
>
|
|
2705
2727
|
<div
|
|
2706
2728
|
class="dispatcher tooltip"
|
|
2707
2729
|
>
|
|
@@ -3022,7 +3044,9 @@ exports[`component:<Table> prop:search 1`] = `
|
|
|
3022
3044
|
<span
|
|
3023
3045
|
class="view forceRow column"
|
|
3024
3046
|
>
|
|
3025
|
-
<span
|
|
3047
|
+
<span
|
|
3048
|
+
class="container"
|
|
3049
|
+
>
|
|
3026
3050
|
<div
|
|
3027
3051
|
class="dispatcher tooltip"
|
|
3028
3052
|
>
|
|
@@ -3242,7 +3266,9 @@ exports[`component:<Table> prop:selected 1`] = `
|
|
|
3242
3266
|
<span
|
|
3243
3267
|
class="view forceRow column"
|
|
3244
3268
|
>
|
|
3245
|
-
<span
|
|
3269
|
+
<span
|
|
3270
|
+
class="container"
|
|
3271
|
+
>
|
|
3246
3272
|
<div
|
|
3247
3273
|
class="dispatcher tooltip"
|
|
3248
3274
|
>
|
|
@@ -3591,7 +3617,9 @@ exports[`component:<Table> prop:sort 1`] = `
|
|
|
3591
3617
|
<span
|
|
3592
3618
|
class="view forceRow column"
|
|
3593
3619
|
>
|
|
3594
|
-
<span
|
|
3620
|
+
<span
|
|
3621
|
+
class="container"
|
|
3622
|
+
>
|
|
3595
3623
|
<div
|
|
3596
3624
|
class="dispatcher tooltip"
|
|
3597
3625
|
>
|
|
@@ -3940,7 +3968,9 @@ exports[`component:<Table> prop:store 1`] = `
|
|
|
3940
3968
|
/>
|
|
3941
3969
|
</svg>
|
|
3942
3970
|
</span>
|
|
3943
|
-
<span
|
|
3971
|
+
<span
|
|
3972
|
+
class="container"
|
|
3973
|
+
>
|
|
3944
3974
|
<div
|
|
3945
3975
|
class="pressable"
|
|
3946
3976
|
style="position: relative;"
|
|
@@ -4000,7 +4030,9 @@ exports[`component:<Table> prop:store 1`] = `
|
|
|
4000
4030
|
/>
|
|
4001
4031
|
</svg>
|
|
4002
4032
|
</span>
|
|
4003
|
-
<span
|
|
4033
|
+
<span
|
|
4034
|
+
class="container"
|
|
4035
|
+
>
|
|
4004
4036
|
<div
|
|
4005
4037
|
class="pressable"
|
|
4006
4038
|
style="position: relative;"
|
|
@@ -4060,7 +4092,9 @@ exports[`component:<Table> prop:store 1`] = `
|
|
|
4060
4092
|
/>
|
|
4061
4093
|
</svg>
|
|
4062
4094
|
</span>
|
|
4063
|
-
<span
|
|
4095
|
+
<span
|
|
4096
|
+
class="container"
|
|
4097
|
+
>
|
|
4064
4098
|
<div
|
|
4065
4099
|
class="pressable"
|
|
4066
4100
|
style="position: relative;"
|
|
@@ -4095,7 +4129,9 @@ exports[`component:<Table> prop:store 1`] = `
|
|
|
4095
4129
|
<span
|
|
4096
4130
|
class="view forceRow column"
|
|
4097
4131
|
>
|
|
4098
|
-
<span
|
|
4132
|
+
<span
|
|
4133
|
+
class="container"
|
|
4134
|
+
>
|
|
4099
4135
|
<div
|
|
4100
4136
|
class="dispatcher tooltip"
|
|
4101
4137
|
>
|
|
@@ -4126,7 +4162,9 @@ exports[`component:<Table> prop:store 1`] = `
|
|
|
4126
4162
|
/>
|
|
4127
4163
|
</svg>
|
|
4128
4164
|
</span>
|
|
4129
|
-
<span
|
|
4165
|
+
<span
|
|
4166
|
+
class="container"
|
|
4167
|
+
>
|
|
4130
4168
|
<div
|
|
4131
4169
|
class="pressable"
|
|
4132
4170
|
style="position: relative;"
|
|
@@ -4186,7 +4224,9 @@ exports[`component:<Table> prop:store 1`] = `
|
|
|
4186
4224
|
/>
|
|
4187
4225
|
</svg>
|
|
4188
4226
|
</span>
|
|
4189
|
-
<span
|
|
4227
|
+
<span
|
|
4228
|
+
class="container"
|
|
4229
|
+
>
|
|
4190
4230
|
<div
|
|
4191
4231
|
class="pressable"
|
|
4192
4232
|
style="position: relative;"
|
|
@@ -4335,7 +4375,9 @@ exports[`component:<Table> renders 1`] = `
|
|
|
4335
4375
|
<span
|
|
4336
4376
|
class="view forceRow column"
|
|
4337
4377
|
>
|
|
4338
|
-
<span
|
|
4378
|
+
<span
|
|
4379
|
+
class="container"
|
|
4380
|
+
>
|
|
4339
4381
|
<div
|
|
4340
4382
|
class="dispatcher tooltip"
|
|
4341
4383
|
>
|
|
@@ -4768,7 +4810,9 @@ exports[`component:<Table> testId 1`] = `
|
|
|
4768
4810
|
<span
|
|
4769
4811
|
class="view forceRow column"
|
|
4770
4812
|
>
|
|
4771
|
-
<span
|
|
4813
|
+
<span
|
|
4814
|
+
class="container"
|
|
4815
|
+
>
|
|
4772
4816
|
<div
|
|
4773
4817
|
class="dispatcher tooltip"
|
|
4774
4818
|
>
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
exports[` 1`] = `
|
|
4
4
|
<DocumentFragment>
|
|
5
5
|
<span
|
|
6
|
+
class="container"
|
|
6
7
|
data-testid="onEnter"
|
|
7
8
|
>
|
|
8
9
|
<button
|
|
@@ -18,6 +19,7 @@ exports[` 1`] = `
|
|
|
18
19
|
exports[` 2`] = `
|
|
19
20
|
<DocumentFragment>
|
|
20
21
|
<span
|
|
22
|
+
class="container"
|
|
21
23
|
data-testid="onEnter"
|
|
22
24
|
>
|
|
23
25
|
<button
|
|
@@ -33,6 +35,7 @@ exports[` 2`] = `
|
|
|
33
35
|
exports[` 3`] = `
|
|
34
36
|
<DocumentFragment>
|
|
35
37
|
<span
|
|
38
|
+
class="container"
|
|
36
39
|
data-testid="onPress"
|
|
37
40
|
>
|
|
38
41
|
<div
|
|
@@ -52,6 +55,7 @@ exports[` 3`] = `
|
|
|
52
55
|
exports[` 4`] = `
|
|
53
56
|
<DocumentFragment>
|
|
54
57
|
<span
|
|
58
|
+
class="container"
|
|
55
59
|
data-testid="onPress"
|
|
56
60
|
>
|
|
57
61
|
<div
|
|
@@ -80,7 +84,9 @@ exports[`component:<Tooltip> inherit:className 1`] = `
|
|
|
80
84
|
|
|
81
85
|
exports[`component:<Tooltip> prop:Template 1`] = `
|
|
82
86
|
<DocumentFragment>
|
|
83
|
-
<span
|
|
87
|
+
<span
|
|
88
|
+
class="container"
|
|
89
|
+
>
|
|
84
90
|
<button
|
|
85
91
|
class="pressable button dispatcher"
|
|
86
92
|
>
|
|
@@ -104,7 +110,9 @@ exports[`component:<Tooltip> prop:Template 1`] = `
|
|
|
104
110
|
|
|
105
111
|
exports[`component:<Tooltip> prop:text 1`] = `
|
|
106
112
|
<DocumentFragment>
|
|
107
|
-
<span
|
|
113
|
+
<span
|
|
114
|
+
class="container"
|
|
115
|
+
>
|
|
108
116
|
<button
|
|
109
117
|
class="pressable button dispatcher"
|
|
110
118
|
>
|
|
@@ -151,6 +159,7 @@ exports[`component:<Tooltip> renders 1`] = `
|
|
|
151
159
|
exports[`component:<Tooltip> testId 1`] = `
|
|
152
160
|
<DocumentFragment>
|
|
153
161
|
<span
|
|
162
|
+
class="container"
|
|
154
163
|
data-testid="mirai"
|
|
155
164
|
>
|
|
156
165
|
<button
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Layer.js","names":["Layer","forceBottom","bottom","centered","propFixed","fixed","forceRender","forceLeft","left","forceRight","right","forceTop","top","timestamp","visible","onPosition","others","device","useDevice","componentRef","useRef","contentRef","useState","setFixed","position","setPosition","useLayoutEffect","content","current","ResizeObserver","observer","calcPosition","observe","unobserve","componentEl","firstChild","contentEl","componentLayout","getElementLayout","scrollTop","getScrollParent","contentLayout","modal","getModalParent","getLayerPosition","orientation","isComponentFixed","children","React","Children","map","child","className","contentStyle","style","createWrapper","role","testId","find","name","type","LayerContent","styles","layer","hidden","createElement","Fragment","undefined","displayName","propTypes","PropTypes","bool","node","number","func"],"sources":["../../../src/primitives/Layer/Layer.jsx"],"sourcesContent":["import PropTypes from 'prop-types';\nimport React, { useLayoutEffect, useRef, useState } from 'react';\n\nimport { styles } from '../../helpers';\nimport { useDevice } from '../../hooks';\nimport { Primitive } from '../Primitive';\nimport { getElementLayout, getLayerPosition, getModalParent, getScrollParent, isComponentFixed } from './helpers';\nimport style from './Layer.module.css';\nimport { LayerContent } from './LayerContent';\n\nconst Layer = ({\n bottom: forceBottom,\n centered,\n fixed: propFixed,\n forceRender = true,\n left: forceLeft,\n right: forceRight,\n top: forceTop,\n timestamp,\n visible,\n onPosition = () => {},\n ...others\n}) => {\n const device = useDevice();\n const componentRef = useRef();\n const contentRef = useRef();\n\n const [fixed, setFixed] = useState();\n const [position, setPosition] = useState();\n\n useLayoutEffect(() => {\n const content = contentRef?.current;\n if (!content || typeof ResizeObserver === 'undefined') return;\n\n const observer = new ResizeObserver(calcPosition);\n observer.observe(content);\n\n return () => observer.unobserve(content);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n useLayoutEffect(\n () => calcPosition(),\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [centered, device, forceBottom, forceLeft, forceRight, forceTop, timestamp, visible],\n );\n\n const calcPosition = () => {\n const { current: { firstChild: componentEl } = {} } = componentRef;\n const { current: contentEl } = contentRef;\n\n if (!componentEl || !contentEl) return setPosition();\n\n const componentLayout = { ...getElementLayout(componentEl), scrollTop: getScrollParent(componentEl)?.scrollTop };\n const contentLayout = getElementLayout(contentEl);\n const modal = getModalParent(componentEl);\n const {\n left = 0,\n top = 0,\n orientation = {},\n } = getLayerPosition(componentLayout, contentLayout, device, modal, {\n centered,\n forceBottom,\n forceLeft,\n forceRight,\n forceTop,\n });\n\n setFixed(propFixed || isComponentFixed(componentEl));\n setPosition({ left: `${left}px`, top: `${top}px` });\n onPosition(orientation);\n };\n\n const children = React.Children.map(others.children || [], (child) => child);\n const { className, style: contentStyle } = others;\n const createWrapper = className || contentStyle;\n\n return (\n <>\n <Primitive
|
|
1
|
+
{"version":3,"file":"Layer.js","names":["Layer","forceBottom","bottom","centered","propFixed","fixed","forceRender","forceLeft","left","forceRight","right","forceTop","top","timestamp","visible","onPosition","others","device","useDevice","componentRef","useRef","contentRef","useState","setFixed","position","setPosition","useLayoutEffect","content","current","ResizeObserver","observer","calcPosition","observe","unobserve","componentEl","firstChild","contentEl","componentLayout","getElementLayout","scrollTop","getScrollParent","contentLayout","modal","getModalParent","getLayerPosition","orientation","isComponentFixed","children","React","Children","map","child","className","contentStyle","style","createWrapper","role","container","testId","find","name","type","LayerContent","styles","layer","hidden","createElement","Fragment","undefined","displayName","propTypes","PropTypes","bool","node","number","func"],"sources":["../../../src/primitives/Layer/Layer.jsx"],"sourcesContent":["import PropTypes from 'prop-types';\nimport React, { useLayoutEffect, useRef, useState } from 'react';\n\nimport { styles } from '../../helpers';\nimport { useDevice } from '../../hooks';\nimport { Primitive } from '../Primitive';\nimport { getElementLayout, getLayerPosition, getModalParent, getScrollParent, isComponentFixed } from './helpers';\nimport style from './Layer.module.css';\nimport { LayerContent } from './LayerContent';\n\nconst Layer = ({\n bottom: forceBottom,\n centered,\n fixed: propFixed,\n forceRender = true,\n left: forceLeft,\n right: forceRight,\n top: forceTop,\n timestamp,\n visible,\n onPosition = () => {},\n ...others\n}) => {\n const device = useDevice();\n const componentRef = useRef();\n const contentRef = useRef();\n\n const [fixed, setFixed] = useState();\n const [position, setPosition] = useState();\n\n useLayoutEffect(() => {\n const content = contentRef?.current;\n if (!content || typeof ResizeObserver === 'undefined') return;\n\n const observer = new ResizeObserver(calcPosition);\n observer.observe(content);\n\n return () => observer.unobserve(content);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n useLayoutEffect(\n () => calcPosition(),\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [centered, device, forceBottom, forceLeft, forceRight, forceTop, timestamp, visible],\n );\n\n const calcPosition = () => {\n const { current: { firstChild: componentEl } = {} } = componentRef;\n const { current: contentEl } = contentRef;\n\n if (!componentEl || !contentEl) return setPosition();\n\n const componentLayout = { ...getElementLayout(componentEl), scrollTop: getScrollParent(componentEl)?.scrollTop };\n const contentLayout = getElementLayout(contentEl);\n const modal = getModalParent(componentEl);\n const {\n left = 0,\n top = 0,\n orientation = {},\n } = getLayerPosition(componentLayout, contentLayout, device, modal, {\n centered,\n forceBottom,\n forceLeft,\n forceRight,\n forceTop,\n });\n\n setFixed(propFixed || isComponentFixed(componentEl));\n setPosition({ left: `${left}px`, top: `${top}px` });\n onPosition(orientation);\n };\n\n const children = React.Children.map(others.children || [], (child) => child);\n const { className, style: contentStyle } = others;\n const createWrapper = className || contentStyle;\n\n return (\n <>\n <Primitive\n ref={componentRef}\n role={others.role || 'layer'}\n tag=\"span\"\n className={style.container}\n testId={others.testId}\n >\n {children.find(({ type: { name } }) => name !== LayerContent.name)}\n </Primitive>\n\n {(forceRender || visible) && (\n <Primitive\n ref={contentRef}\n role={others.role ? `${others.role}-content` : 'layer-content'}\n className={styles(style.layer, fixed && style.fixed, !visible && style.hidden)}\n style={{ ...position }}\n >\n {React.createElement(\n createWrapper ? 'div' : React.Fragment,\n createWrapper ? { className, style: contentStyle } : undefined,\n children?.find(({ type: { name } }) => name === LayerContent.name),\n )}\n </Primitive>\n )}\n </>\n );\n};\n\nLayer.displayName = 'Primitive:Layer';\n\nLayer.propTypes = {\n bottom: PropTypes.bool,\n centered: PropTypes.bool,\n children: PropTypes.node,\n fixed: PropTypes.bool,\n forceRender: PropTypes.bool,\n left: PropTypes.bool,\n right: PropTypes.bool,\n timestamp: PropTypes.number,\n top: PropTypes.bool,\n visible: PropTypes.bool,\n onPosition: PropTypes.func,\n};\n\nexport { Layer };\n"],"mappings":";;;;;;;AAAA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AAA8C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAE9C,IAAMA,KAAK,GAAG,SAARA,KAAK,OAYL;EAAA,IAXIC,WAAW,QAAnBC,MAAM;IACNC,QAAQ,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,MAAM,EAAEqE,kBAAS,CAACC,IAAI;EACtBrE,QAAQ,EAAEoE,kBAAS,CAACC,IAAI;EACxBzB,QAAQ,EAAEwB,kBAAS,CAACE,IAAI;EACxBpE,KAAK,EAAEkE,kBAAS,CAACC,IAAI;EACrBlE,WAAW,EAAEiE,kBAAS,CAACC,IAAI;EAC3BhE,IAAI,EAAE+D,kBAAS,CAACC,IAAI;EACpB9D,KAAK,EAAE6D,kBAAS,CAACC,IAAI;EACrB3D,SAAS,EAAE0D,kBAAS,CAACG,MAAM;EAC3B9D,GAAG,EAAE2D,kBAAS,CAACC,IAAI;EACnB1D,OAAO,EAAEyD,kBAAS,CAACC,IAAI;EACvBzD,UAAU,EAAEwD,kBAAS,CAACI;AACxB,CAAC"}
|
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
exports[`primitive:<Layer> inherit:className 1`] = `
|
|
4
4
|
<DocumentFragment>
|
|
5
|
-
<span
|
|
5
|
+
<span
|
|
6
|
+
class="container"
|
|
7
|
+
/>
|
|
6
8
|
<div
|
|
7
9
|
class="layer hidden"
|
|
8
10
|
>
|
|
@@ -15,7 +17,9 @@ exports[`primitive:<Layer> inherit:className 1`] = `
|
|
|
15
17
|
|
|
16
18
|
exports[`primitive:<Layer> renders 1`] = `
|
|
17
19
|
<DocumentFragment>
|
|
18
|
-
<span
|
|
20
|
+
<span
|
|
21
|
+
class="container"
|
|
22
|
+
/>
|
|
19
23
|
<div
|
|
20
24
|
class="layer hidden"
|
|
21
25
|
/>
|
|
@@ -25,6 +29,7 @@ exports[`primitive:<Layer> renders 1`] = `
|
|
|
25
29
|
exports[`primitive:<Layer> testId 1`] = `
|
|
26
30
|
<DocumentFragment>
|
|
27
31
|
<span
|
|
32
|
+
class="container"
|
|
28
33
|
data-testid="mirai"
|
|
29
34
|
/>
|
|
30
35
|
<div
|
|
@@ -35,7 +40,9 @@ exports[`primitive:<Layer> testId 1`] = `
|
|
|
35
40
|
|
|
36
41
|
exports[`primitive:<Layer> w/ centered && visible 1`] = `
|
|
37
42
|
<DocumentFragment>
|
|
38
|
-
<span
|
|
43
|
+
<span
|
|
44
|
+
class="container"
|
|
45
|
+
>
|
|
39
46
|
<button
|
|
40
47
|
class="pressable button"
|
|
41
48
|
>
|
|
@@ -57,7 +64,9 @@ exports[`primitive:<Layer> w/ centered && visible 1`] = `
|
|
|
57
64
|
|
|
58
65
|
exports[`primitive:<Layer> w/ child fixed 1`] = `
|
|
59
66
|
<DocumentFragment>
|
|
60
|
-
<span
|
|
67
|
+
<span
|
|
68
|
+
class="container"
|
|
69
|
+
>
|
|
61
70
|
<button
|
|
62
71
|
class="pressable button"
|
|
63
72
|
style="position: fixed;"
|
|
@@ -80,7 +89,9 @@ exports[`primitive:<Layer> w/ child fixed 1`] = `
|
|
|
80
89
|
|
|
81
90
|
exports[`primitive:<Layer> w/ component & <LayerContent> 1`] = `
|
|
82
91
|
<DocumentFragment>
|
|
83
|
-
<span
|
|
92
|
+
<span
|
|
93
|
+
class="container"
|
|
94
|
+
>
|
|
84
95
|
<button
|
|
85
96
|
class="pressable button"
|
|
86
97
|
>
|
|
@@ -102,7 +113,9 @@ exports[`primitive:<Layer> w/ component & <LayerContent> 1`] = `
|
|
|
102
113
|
|
|
103
114
|
exports[`primitive:<Layer> w/ component 1`] = `
|
|
104
115
|
<DocumentFragment>
|
|
105
|
-
<span
|
|
116
|
+
<span
|
|
117
|
+
class="container"
|
|
118
|
+
>
|
|
106
119
|
<button
|
|
107
120
|
class="pressable button"
|
|
108
121
|
>
|
|
@@ -118,7 +131,9 @@ exports[`primitive:<Layer> w/ component 1`] = `
|
|
|
118
131
|
|
|
119
132
|
exports[`primitive:<Layer> w/ fixed 1`] = `
|
|
120
133
|
<DocumentFragment>
|
|
121
|
-
<span
|
|
134
|
+
<span
|
|
135
|
+
class="container"
|
|
136
|
+
>
|
|
122
137
|
<button
|
|
123
138
|
class="pressable button"
|
|
124
139
|
>
|
|
@@ -140,7 +155,9 @@ exports[`primitive:<Layer> w/ fixed 1`] = `
|
|
|
140
155
|
|
|
141
156
|
exports[`primitive:<Layer> w/ forceRender={false} & <LayerContent> 1`] = `
|
|
142
157
|
<DocumentFragment>
|
|
143
|
-
<span
|
|
158
|
+
<span
|
|
159
|
+
class="container"
|
|
160
|
+
>
|
|
144
161
|
<button
|
|
145
162
|
class="pressable button"
|
|
146
163
|
>
|
|
@@ -152,7 +169,9 @@ exports[`primitive:<Layer> w/ forceRender={false} & <LayerContent> 1`] = `
|
|
|
152
169
|
|
|
153
170
|
exports[`primitive:<Layer> w/ visible 1`] = `
|
|
154
171
|
<DocumentFragment>
|
|
155
|
-
<span
|
|
172
|
+
<span
|
|
173
|
+
class="container"
|
|
174
|
+
>
|
|
156
175
|
<button
|
|
157
176
|
class="pressable button"
|
|
158
177
|
>
|